Update 10/13/2011: I added more comments to the ActionScript code to help explain what each line of code does. I also added a Flash CS4 version of the FLA to the ZIP so more people can access the example.

My “Planets” example (How to Add Basic SCORM Code to a Flash Movie) has proven to be one of the most popular items on pipwerks.com. Unfortunately, it was designed as a quick example and had a bunch of flaws and shortcomings. It’s also about 3 years old and starting to show its age. Since people frequently contact me with questions — many of which were due to the flaws in the example — I decided to update the project.

The new Planets example has a bunch of fixes:

  • Full compliance with SCORM XSD requirements (it includes all those pesky XSD files that really don’t do anything but are required anyway).
  • Upgraded the pipwerks JavaScript wrapper to the latest version
  • Upgraded the pipwerks ActionScript 3 wrapper to the latest version
  • Upgraded SWFObject from 1.5 to 2.2
  • Changed the doctype and markup to HTML5
  • Added an unload handler to the JavaScript to ensure course progress is saved if the learner exits early
  • Added support for tracking progress across attempts using cmi.suspend_data
  • Completely rebuilt the FLA file to remove all timeline-based animation and scripts. Now uses a single ActionScript file, loaded on a single frame. All animations (fade transitions) are handled via ActionScript. This makes the file smaller and hopefully less confusing.
  • The SCORM code is clearly separated from the rest of the movie’s ActionScript; it’s in the same file, but not intermingled with other functions.

I haven’t decided if I’ll create a detailed tutorial to explain the updates; I’ve added a ton of comments to the ActionScript file, and hope it’s clear enough for others to follow.

Download the updated Planets example
The ZIP includes two FLA files: one in CS4 format, and the other in CS5.5. The code, movieclips, and graphic elements inside the FLAs are exactly the same.


Comments

irene wrote on October 10, 2011 at 1:54 am:

<blockquote>I haven’t decided if I’ll create a detailed tutorial to explain the updates</blockquote>

please do πŸ™‚

Craig Grummitt wrote on October 10, 2011 at 10:39 am:

Philip – thanks a lot for your work on this, I had been trying to work out how to build a SCORM compliant system that retained the nice Flash interface and custom menus for a while with no luck, your idea of using suspend_data for maintaing status data does the trick!

I've built a proof of concept using LibScorm and SCORM 2004 Fourth edition. If you're interested you can see it <a href="http://craiggrummitt.wordpress.com/2011/10/10/scorm-with-custom-menu-built-in-flash/" rel="nofollow ugc">here</a>.

philip wrote on October 10, 2011 at 2:52 pm:

@craig

Interesting take, glad to be of help. In response to your blog post:

I chose SCORM 1.2 because it is by far the most widely supported version of SCORM. Many of the people who visit my blog need to create SCORM packages that run in systems like Moodle, which don't have proper SCORM 2004 support yet.

I may not have explained it clearly enough, but the Planets example uses just the basic RTE functionality of SCORM, which is almost identical between 1.2 and 2004. Since it doesn't use SCORM 2004's sequencing and navigation, and doesn't rely on new or heavily changed features, it would only take a few minutes to upgrade the example to SCORM 2004.

(The pipwerks wrapper supports both SCORM 1.2 and 2004 using a single AS file and a single JS file, which means switching from 1.2 to 2004 is a snap. You'd need a new manifest and supporting XSD files, though.)

As far as the pipwerks wrapper versus LibSCORM, I believe the pipwerks wrapper is much simpler. I haven't used LibSCORM so I can't speak to it's functionality, but my understanding is that Joe Nelson put a lot of good work into it, adding a lot of bells and whistles. The pipwerks wrapper was deliberately kept simple; it's a wrapper, not a framework. Choose whichever best suits your needs.

Regarding upkeep and maintenance, LibSCORM was produced by the Academic ADL Co-Lab, which is independent of the ADL proper. Therefore neither the pipwerks wrapper or LibSCORM are ADL products and have no guarantees regarding updates. (FWIW thay're both released open-source and can be modified/updated by anyone.) But it's all a moot point anyway, because SCORM as we know it is finalized — the ADL announced that SCORM development is complete and there will be no new updates.

Lastly, the SCORM wrapper for ActionScript is a pure AS3 class; the Planets example imports <code>com.pipwerks.SCORM</code>. I used an <code>include</code> to externalize the AS code in the example, but the wrapper is a class and follows OOP principles.

Craig Grummitt wrote on October 11, 2011 at 7:30 am:

Ok fair points Philip, thanks for taking the time to reply. Illuminating your reasons on using v1.2 rather than 2004, and the distinction between ADL and ADL Co-Lab had passed me by.

Eric wrote on October 12, 2011 at 8:02 am:

Well, i've been reading your files and using your AS3 scorm class. I installed a moodle on my local box. But no matter what i do i get :
pipwerks.SCORM.connect() called from class file
connection.initialize called.
SCORM.API.find: API found. Version: 1.2
API: [object Object]
SCORM.data.get(cmi.core.lesson_status) failed.
Error code: 0
Error info: n/a

Trying to set : screen3 for parameter cmi.core.lesson_status
Connection active? true
Call result : true
pipwerks.SCORM.set(cmi.core.lesson_status) success.

I can set and save but i get never get !

What do i do wrong ?? Or is it just not working at all ?

philip wrote on October 12, 2011 at 9:01 am:

<code>cmi.core.lesson_status</code> only accepts pre-defined values: "incomplete", "completed", "passed", "failed", "unknown".

If you have further questions about SCORM, I suggest you post your question on the <a href="http://pwrk.us/etd" rel="nofollow ugc">E-Learning Technology and Development Google Group</a>

Eric wrote on October 12, 2011 at 9:31 am:

I tried them all. suspend_data, lesson_location … I always get the same error :

SCORM.data.get(cmi.suspend_data) failed.
Error code: 0
Error info: n/a

Eric wrote on October 12, 2011 at 9:50 am:

this is also what i get when putting "planets.zip" on my moodle :

Initializing SCORM class. Checking dependencies: ExternalInterface.available evaluates true.
SCORM.isAvailable() evaluates true. SCORM class file ready to go! πŸ™‚
pipwerks.SCORM.connect() called from class file
connection.initialize called.
SCORM.API.find: API found. Version: 1.2
API: [object Object]
SCORM.data.get(cmi.core.lesson_status) failed.
Error code: 0
Error info: n/a
SCORM.data.get(cmi.core.lesson_status) value:
__connectionActive: true
SCORM.data.get(cmi.core.lesson_status) failed.
Error code: 0 Error info: n/a
SCORM.data.get(cmi.core.lesson_status) value:
public function get returned:
SCORM.data.get(cmi.suspend_data) failed.
Error code: 0
Error info: n/a
SCORM.data.get(cmi.suspend_data) value:
public function get returned:

get always fails and never returns any value.. Any idea ? thank you

philip wrote on October 12, 2011 at 10:00 am:

@eric

I dont' know how your Moodle environment is configured or the condition of your course ZIP file, so I can't really say much.

I just uploaded the Planets.zip file (as-is, no modifications) into Moodle (1.9) and it worked fine:

<pre>
Initializing SCORM class. Checking dependencies:
ExternalInterface.available evaluates true.
SCORM.isAvailable() evaluates true.
SCORM class file ready to go! πŸ™‚
pipwerks.SCORM.connect() called from class file
connection.initialize called.
SCORM.API.find: API found. Version: 1.2
API: [object Object]
SCORM.data.get(cmi.core.lesson_status) value: incomplete
__connectionActive: true
SCORM.data.get(cmi.core.lesson_status) value: incomplete
public function get returned: incomplete
SCORM.data.get(cmi.suspend_data) value: 0,1,1,0
public function get returned: 0,1,1,0
</pre>

My guess is that you've made a modification of some kind to the Planets example (either the code or the ZIP packaging) or your Moodle installation is wonky. (Yes, that's a highly technical term!)

Eric wrote on October 12, 2011 at 10:02 am:

Also did a test in Cornerstone :

Some SCORM function look better but the swf itself doesn't work at all.
Here's the debug info :

Initializing SCORM class. Checking dependencies: ExternalInterface.available evaluates true. SCORM.isAvailable() evaluates true. SCORM class file ready to go! πŸ™‚
pipwerks.SCORM.connect() called from class file
connection.initialize called.
SCORM.API.find: API found. Version: 1.2
API: [object Object]
SCORM.data.get(cmi.core.lesson_status) value: incomplete
__connectionActive: true
SCORM.data.get(cmi.core.lesson_status) value: incomplete
public function get returned: incomplete
SCORM.data.get(cmi.suspend_data) failed.
Error code: 0
Error info: No Error
SCORM.data.get(cmi.suspend_data) value:
public function get returned:

So, so far in conerstone, lesson_status works but the SWF doesn't work at all, maybe because get(cmi.suspend_data) failed.
In moodle, you already have the debug info and the SWF works.
So, so far, i am not very sure of what to do πŸ™‚

Eric wrote on October 12, 2011 at 10:04 am:

This is a fresh install of moodle with the latest package (just installed it and the install report showed success everywhere).. I don't know really what's going on…

Eric wrote on October 12, 2011 at 10:05 am:

Sorry forgot to add, i uploaded the .zip file without modifications to the two LMS's

Eric wrote on October 12, 2011 at 10:12 am:

Sorry for spamming, Planets! didn't work in Cornetstone because i was using FF and the swfObjects method doesn't work with FF. Cornerstone works ok, so i'm guessing it's my moodle version / install …

philip wrote on October 12, 2011 at 10:14 am:

@eric the ActionScript in the SWF is executing those SCORM calls, so the SWF is working fine. When you say "the SWF doesn't work at all," you need to be more specific. There's a 'next' button that must be clicked from the initial page; do you see it? Does it work? Also, what version of Flash Player do you have?

philip wrote on October 12, 2011 at 10:16 am:

@eric swfobject is cross-browser and works with all versions of Firefox. Perhaps you have an add-on like AdBlock that prevents SWFs from playing correctly?

Eric wrote on October 12, 2011 at 10:26 am:

I ment IE ffffssss πŸ™‚ thanks for replying, i'm reinstalling moodle to see what's going on, planets works ok with Cornerstone. Thank you.

Eric wrote on October 12, 2011 at 10:37 am:

Ok so here's the deal.
FF + moodle + Planets! = BAD
IE + moodle + Planets! = GOOD

philip wrote on October 12, 2011 at 10:51 am:

@eric I'm sorry you're continuing to have problems, but everything has been tested cross-browser: Firefox, SWFObject, SCORM wrappers, etc. I suspect your issues have something to do with your computer's setup.

If you would like to continue this discussion, perhaps you can post at the <a href="http://pwrk.us/etd" rel="nofollow ugc">E-Learning Technology and Development Google Group</a> so we can minimize the comments for this post.

Bob DeFord wrote on October 18, 2011 at 8:25 am:

Is there recommended way to zip the files. When I try uploading your zipped file, it works, but when I unzip it and re-zip (without making any changes), it isn't recognized as SCORM anymore by our LMS, which is SumTotal.

Bob DeFord wrote on October 18, 2011 at 8:46 am:

Oops, I found the answer. Windows built-in zip utility seems to be the problem. I used 7-Zip and it worked fine.

philip wrote on October 18, 2011 at 9:04 am:

Also, be careful not to zip the folder: the imsmanifest.xml file needs to be at the root of the zip. If you zip the <em>folder</em> containing the manifest (as opposed to zipping the contents directly) your manifest will be one-level deep inside the root, and will no longer work in the LMS.

Bob DeFord wrote on October 19, 2011 at 9:32 am:

Thanks — that is what happened. Philip, first of all, thanks for all your work on this! I am having trouble though with modifying my course to work like yours. Your planets course works great on my LMS, which is SumTotal. It tracks completion great. However, my course just needs to track completion when the student gets to the last page, but I can't get that part to work. The LMS recognizes it but it just won't show completion. I can't figure out how to modify your tracking of visiting each planet to going to the last page in my course. I am willing to pay you to look at my files. It is probably something very simple. Thanks again!

Bob DeFord wrote on October 19, 2011 at 1:14 pm:

Philip, I got it to work. I just worked through your How to Add Basic SCORM to a Flash Movie and what do you know it worked. For completion, I put the course completion code on the last page. Thank you so much!

philip wrote on October 19, 2011 at 9:27 pm:

@bob you're welcome, glad you got it working.

Bob DeFord wrote on October 20, 2011 at 2:16 pm:

Well, I thought my course was working. It does record completion. But when you relaunch it and stop before the end, it gives you a status of incomplete.

Here is my code on the first frame of the course (it has about 30 frames on the main timeline but the actionscript here goes across the frames). Can you spot anything that is off?

import flash.external.ExternalInterface;
import fl.controls.Button;
import com.pipwerks.SCORM;

var scorm:SCORM;
var lmsConnected:Boolean;
var lessonStatus:String;
var success:Boolean;

scorm = new SCORM();

lmsConnected = scorm.connect();

if(lmsConnected){
lessonStatus = scorm.get("cmi.core.lesson_status");
if(lessonStatus == "completed" || lessonStatus == "passed"){
scorm.disconnect();
} else {
success = scorm.set("cmi.core.lesson_status", "incomplete");
scorm.save();
}
} else {
trace("Could not connect to LMS.");
}

philip wrote on October 20, 2011 at 3:01 pm:

@bob Any completed course will show a status of incomplete when re-launched. It's the default behavior in SCORM. Some LMSs let you change this setting, but you have to do it within the LMS, not from your course. If you'd like more help with SCORM, I suggest posting on the <a href="http://pwrk.us/etd" rel="nofollow ugc">E-Learning and Technology Google Group.</a>

Craig Grummitt wrote on November 15, 2011 at 4:46 pm:

Hi again Philip, turned out my client only has an LMS with SCORM 1.2 in the end!
I'm testing this zip in the ADL TestSuite for 1.2, and after the suite says "The manifest is well-formed", I'm getting 'ERROR: The manifest is not valid against the controlling documents… eg "ERROR: Element type 'general' must be declared. ERROR: Element type 'langstring' must be declared.. etc etc

Any ideas?

philip wrote on November 15, 2011 at 4:55 pm:

The ADL Test Suite is a strange beast. One of the most common gotchas is that you have to have a copy of the course's XSD support files <em>on your desktop!</em> I have no idea why, but it's a requirement and frequently trips people up. That's why I switched to SCORM Test Track.

Similar Posts

28 Comments

  1. I haven’t decided if I’ll create a detailed tutorial to explain the updates

    please do πŸ™‚

  2. Philip – thanks a lot for your work on this, I had been trying to work out how to build a SCORM compliant system that retained the nice Flash interface and custom menus for a while with no luck, your idea of using suspend_data for maintaing status data does the trick!

    I’ve built a proof of concept using LibScorm and SCORM 2004 Fourth edition. If you’re interested you can see it here.

  3. @craig

    Interesting take, glad to be of help. In response to your blog post:

    I chose SCORM 1.2 because it is by far the most widely supported version of SCORM. Many of the people who visit my blog need to create SCORM packages that run in systems like Moodle, which don’t have proper SCORM 2004 support yet.

    I may not have explained it clearly enough, but the Planets example uses just the basic RTE functionality of SCORM, which is almost identical between 1.2 and 2004. Since it doesn’t use SCORM 2004’s sequencing and navigation, and doesn’t rely on new or heavily changed features, it would only take a few minutes to upgrade the example to SCORM 2004.

    (The pipwerks wrapper supports both SCORM 1.2 and 2004 using a single AS file and a single JS file, which means switching from 1.2 to 2004 is a snap. You’d need a new manifest and supporting XSD files, though.)

    As far as the pipwerks wrapper versus LibSCORM, I believe the pipwerks wrapper is much simpler. I haven’t used LibSCORM so I can’t speak to it’s functionality, but my understanding is that Joe Nelson put a lot of good work into it, adding a lot of bells and whistles. The pipwerks wrapper was deliberately kept simple; it’s a wrapper, not a framework. Choose whichever best suits your needs.

    Regarding upkeep and maintenance, LibSCORM was produced by the Academic ADL Co-Lab, which is independent of the ADL proper. Therefore neither the pipwerks wrapper or LibSCORM are ADL products and have no guarantees regarding updates. (FWIW thay’re both released open-source and can be modified/updated by anyone.) But it’s all a moot point anyway, because SCORM as we know it is finalized — the ADL announced that SCORM development is complete and there will be no new updates.

    Lastly, the SCORM wrapper for ActionScript is a pure AS3 class; the Planets example imports com.pipwerks.SCORM. I used an include to externalize the AS code in the example, but the wrapper is a class and follows OOP principles.

  4. Ok fair points Philip, thanks for taking the time to reply. Illuminating your reasons on using v1.2 rather than 2004, and the distinction between ADL and ADL Co-Lab had passed me by.

  5. Well, i’ve been reading your files and using your AS3 scorm class. I installed a moodle on my local box. But no matter what i do i get :
    pipwerks.SCORM.connect() called from class file
    connection.initialize called.
    SCORM.API.find: API found. Version: 1.2
    API: [object Object]
    SCORM.data.get(cmi.core.lesson_status) failed.
    Error code: 0
    Error info: n/a

    Trying to set : screen3 for parameter cmi.core.lesson_status
    Connection active? true
    Call result : true
    pipwerks.SCORM.set(cmi.core.lesson_status) success.

    I can set and save but i get never get !

    What do i do wrong ?? Or is it just not working at all ?

  6. I tried them all. suspend_data, lesson_location … I always get the same error :

    SCORM.data.get(cmi.suspend_data) failed.
    Error code: 0
    Error info: n/a

  7. this is also what i get when putting “planets.zip” on my moodle :

    Initializing SCORM class. Checking dependencies: ExternalInterface.available evaluates true.
    SCORM.isAvailable() evaluates true. SCORM class file ready to go! πŸ™‚
    pipwerks.SCORM.connect() called from class file
    connection.initialize called.
    SCORM.API.find: API found. Version: 1.2
    API: [object Object]
    SCORM.data.get(cmi.core.lesson_status) failed.
    Error code: 0
    Error info: n/a
    SCORM.data.get(cmi.core.lesson_status) value:
    __connectionActive: true
    SCORM.data.get(cmi.core.lesson_status) failed.
    Error code: 0 Error info: n/a
    SCORM.data.get(cmi.core.lesson_status) value:
    public function get returned:
    SCORM.data.get(cmi.suspend_data) failed.
    Error code: 0
    Error info: n/a
    SCORM.data.get(cmi.suspend_data) value:
    public function get returned:

    get always fails and never returns any value.. Any idea ? thank you

  8. @eric

    I dont’ know how your Moodle environment is configured or the condition of your course ZIP file, so I can’t really say much.

    I just uploaded the Planets.zip file (as-is, no modifications) into Moodle (1.9) and it worked fine:

    Initializing SCORM class. Checking dependencies: 
      ExternalInterface.available evaluates true. 
      SCORM.isAvailable() evaluates true. 
      SCORM class file ready to go!  :) 
    pipwerks.SCORM.connect() called from class file
    connection.initialize called.
    SCORM.API.find: API found. Version: 1.2
    API: [object Object]
    SCORM.data.get(cmi.core.lesson_status) value: incomplete
    __connectionActive: true
    SCORM.data.get(cmi.core.lesson_status) value: incomplete
    public function get returned: incomplete
    SCORM.data.get(cmi.suspend_data) value: 0,1,1,0
    public function get returned: 0,1,1,0
    

    My guess is that you’ve made a modification of some kind to the Planets example (either the code or the ZIP packaging) or your Moodle installation is wonky. (Yes, that’s a highly technical term!)

  9. Also did a test in Cornerstone :

    Some SCORM function look better but the swf itself doesn’t work at all.
    Here’s the debug info :

    Initializing SCORM class. Checking dependencies: ExternalInterface.available evaluates true. SCORM.isAvailable() evaluates true. SCORM class file ready to go! πŸ™‚
    pipwerks.SCORM.connect() called from class file
    connection.initialize called.
    SCORM.API.find: API found. Version: 1.2
    API: [object Object]
    SCORM.data.get(cmi.core.lesson_status) value: incomplete
    __connectionActive: true
    SCORM.data.get(cmi.core.lesson_status) value: incomplete
    public function get returned: incomplete
    SCORM.data.get(cmi.suspend_data) failed.
    Error code: 0
    Error info: No Error
    SCORM.data.get(cmi.suspend_data) value:
    public function get returned:

    So, so far in conerstone, lesson_status works but the SWF doesn’t work at all, maybe because get(cmi.suspend_data) failed.
    In moodle, you already have the debug info and the SWF works.
    So, so far, i am not very sure of what to do πŸ™‚

  10. This is a fresh install of moodle with the latest package (just installed it and the install report showed success everywhere).. I don’t know really what’s going on…

  11. Sorry for spamming, Planets! didn’t work in Cornetstone because i was using FF and the swfObjects method doesn’t work with FF. Cornerstone works ok, so i’m guessing it’s my moodle version / install …

  12. @eric the ActionScript in the SWF is executing those SCORM calls, so the SWF is working fine. When you say “the SWF doesn’t work at all,” you need to be more specific. There’s a ‘next’ button that must be clicked from the initial page; do you see it? Does it work? Also, what version of Flash Player do you have?

  13. @eric swfobject is cross-browser and works with all versions of Firefox. Perhaps you have an add-on like AdBlock that prevents SWFs from playing correctly?

  14. I ment IE ffffssss πŸ™‚ thanks for replying, i’m reinstalling moodle to see what’s going on, planets works ok with Cornerstone. Thank you.

  15. @eric I’m sorry you’re continuing to have problems, but everything has been tested cross-browser: Firefox, SWFObject, SCORM wrappers, etc. I suspect your issues have something to do with your computer’s setup.

    If you would like to continue this discussion, perhaps you can post at the E-Learning Technology and Development Google Group so we can minimize the comments for this post.

  16. Is there recommended way to zip the files. When I try uploading your zipped file, it works, but when I unzip it and re-zip (without making any changes), it isn’t recognized as SCORM anymore by our LMS, which is SumTotal.

  17. Oops, I found the answer. Windows built-in zip utility seems to be the problem. I used 7-Zip and it worked fine.

    1. Also, be careful not to zip the folder: the imsmanifest.xml file needs to be at the root of the zip. If you zip the folder containing the manifest (as opposed to zipping the contents directly) your manifest will be one-level deep inside the root, and will no longer work in the LMS.

  18. Thanks — that is what happened. Philip, first of all, thanks for all your work on this! I am having trouble though with modifying my course to work like yours. Your planets course works great on my LMS, which is SumTotal. It tracks completion great. However, my course just needs to track completion when the student gets to the last page, but I can’t get that part to work. The LMS recognizes it but it just won’t show completion. I can’t figure out how to modify your tracking of visiting each planet to going to the last page in my course. I am willing to pay you to look at my files. It is probably something very simple. Thanks again!

  19. Philip, I got it to work. I just worked through your How to Add Basic SCORM to a Flash Movie and what do you know it worked. For completion, I put the course completion code on the last page. Thank you so much!

  20. Well, I thought my course was working. It does record completion. But when you relaunch it and stop before the end, it gives you a status of incomplete.

    Here is my code on the first frame of the course (it has about 30 frames on the main timeline but the actionscript here goes across the frames). Can you spot anything that is off?

    import flash.external.ExternalInterface;
    import fl.controls.Button;
    import com.pipwerks.SCORM;

    var scorm:SCORM;
    var lmsConnected:Boolean;
    var lessonStatus:String;
    var success:Boolean;

    scorm = new SCORM();

    lmsConnected = scorm.connect();

    if(lmsConnected){
    lessonStatus = scorm.get(“cmi.core.lesson_status”);
    if(lessonStatus == “completed” || lessonStatus == “passed”){
    scorm.disconnect();
    } else {
    success = scorm.set(“cmi.core.lesson_status”, “incomplete”);
    scorm.save();
    }
    } else {
    trace(“Could not connect to LMS.”);
    }

  21. Hi again Philip, turned out my client only has an LMS with SCORM 1.2 in the end!
    I’m testing this zip in the ADL TestSuite for 1.2, and after the suite says “The manifest is well-formed”, I’m getting ‘ERROR: The manifest is not valid against the controlling documents… eg “ERROR: Element type ‘general’ must be declared. ERROR: Element type ‘langstring’ must be declared.. etc etc

    Any ideas?

  22. The ADL Test Suite is a strange beast. One of the most common gotchas is that you have to have a copy of the course’s XSD support files on your desktop! I have no idea why, but it’s a requirement and frequently trips people up. That’s why I switched to SCORM Test Track.

Comments are closed.