📜 ⬆️ ⬇️

Using the pipwerks SCORM API

Hello!

In this post I want to describe an example of working with the library of the pipwerks SCORM API.
What is this library? I think the person who finds this post probably knows about it :) This is a library for communicating with the LMS (Distance Learning System) using the SCORM protocol.


Actually the solution itself consists of two parts: a wrapper on JavaScript - SCORM API Wrapper.js and an Action Script class -SCORM.as
')
We take here: github.com/pipwerks/scorm-api-wrapper
Project Page: pipwerks.com/laboratory/scorm/api-wrapper-javascript

In general, everything is quite simple, so that this post may not bring any practical benefit to anyone, and yet, it is necessary for me to amuse my self-esteem and write something on the habr after such a long lull! ))

So, actually in the case!

We downloaded the SCORM_API_wrapper.js and SCORM.as sources, now js will be included in our index.html, and we will write several lines and indicate the version of SCORM that is supported by your LMS.

<script type="text/javascript"> pipwerks.SCORM.version = "2004"; //  1.2 </script> 


We put SCORM.as in the source code of our flash drive in some kind of package (or by default)

Now we go to the code and first we will check the possibility of connecting to the SCORM API Wrapper.

 if(Capabilities.playerType == 'PlugIn' || Capabilities.playerType == 'ActiveX'){ try{ _SCORM = new SCORM; _SCORMAvailable = _SCORM.connect(); }catch(e: Error){ Log.message("SCORM Error: "+e.message, this); } } 


1. I added a check on the type of player, since it is useless to try to contact JavaScript if the player is not running in the browser.
In this case, 'ActiveX' means that it is running in IE (it is always highlighted), and 'PlugIn' is any other browser.
2. I create an object of the SCORM class, I establish the connection, the result of the connection being established, either true or false, I put the result of the connection in _SCORMAvailable, I close the connection. In this case, I check that the connection attempt was successful and I can open the connection again without any problems later.
3. Log class is my self logger.
4. Try block to avoid errors.

Now you can safely send and receive data from the LMS.

I will give an example of recording arbitrary data that is necessary for the operation of an electronic course.

 // SCORM       if(!_SCORMAvailable ) return //    suspend_data var status:Boolean = _SCORM.set('cmi.suspend_data', '  ,   '); //     SCORM     LMS     false if( !status ) trace('-   ') //            ,   _SCORM.save(); 


Get data from suspend_data, you can

 // SCORM       if(!_SCORMAvailable ) return var str:String = _SCORM.get('cmi.suspend_data'); //   trace(str); 


Naturally, only text data can be stored in suspend_data (but this is not a problem, for which serialization was invented) and the size of the stored data depends on the SCORM version.

I think that's all! Honestly? Very lazy to write, my fingers do not have time for thoughts and it is very tiring))

Thank you, I hope that this post will be useful to someone.

Source: https://habr.com/ru/post/150577/


All Articles