cmi.location and cmi.exit help

532 views
Skip to first unread message

baldTrainer

unread,
Mar 17, 2009, 3:42:59 PM3/17/09
to eLearning Technology and Development
As stated in a previous post, I've got a course that is composed of a
main .swf container that loads 6 external .swfs via XML...and I'm
using pipwerks AS3 class.

I've got 2 issues that I'm trying to work through that go hand in
hand...

1. I need to set up bookmarks throughout the course. From what I've
read in ADL's manual, I've managed to figure out that I need to use
cmi.location; however, I'm at a loss as to what the format of this
code ought to look like.

2. I've got an exit button in the course. When pressed, this button
needs to close out the course window and set the bookmark. Again,
I've figured out that I need to use cmi.exit, but I'm not sure how
this should look.

I'm not looking for specific answers to meet my particular
scenario...just guidelines. If someone can give me a headstart, that
would be a great help!!

Thanks so much!!

Matt Philipps

unread,
Mar 17, 2009, 3:45:31 PM3/17/09
to elearning-technolo...@googlegroups.com
Assuming your XML is pretty simple, like

<course>
   <swf path=""></swf>
   <swf path=""></swf>
   <swf path=""></swf>
   <swf path=""></swf>
   <swf path=""></swf>
   <swf path=""></swf>
</course>

You could just store the number of the slide you are currently on, and when you exit the course, set "suspend", and when you reload the course if "resume" then load the SWF in lesson_location.

Philip Hutchison

unread,
Mar 18, 2009, 1:19:17 AM3/18/09
to elearning-technolo...@googlegroups.com
cmi.location is a string and can contain whatever you want (up to a point).  as Matt pointed out, you could store the number of the slide you're on.  you could also store the URL of the SWF.  it all depends on you and how you write your course code.

whenever you need to close the course, the pipwerks SCORM wrapper and AS classes will handle cmi.exit for you... if the course hasn't been set to completed or passed, it will automatically set cmi.exit to "suspend" for you.

so your code could look like this (assuming you're on SWF 3 when you exit):

var scormsession:SCORM = new SCORM();

//connection stuff goes here...
//... omitting for brevity

var currentSWF:Number = 3;

function exitButtonHandler:void(){
   scormsession.set("cmi.location", String(currentSWF));
   scormsession.save();
}

Then the next time the learner resumes the course you could grab the location data and load the appropriate SWF:

var scormsession:SCORM = new SCORM();

//connection stuff goes here...
//... omitting for brevity

var currentSWF:Number = scormsession.get("cmi.location");

function loadExternalSWF:void(){
    //handle loading
}

loadExternalSWF(currentSWF);


- philip

Ryan Wale

unread,
Mar 18, 2009, 2:04:36 PM3/18/09
to elearning-technolo...@googlegroups.com
Philip,
 
I'm with you during during the first part of what you stated; however, I'm a bit lost once I get to the point where I need to grab the location data.  When you say the 'connecting stuff goes here', are you referring to the XML loader I've got setup?  I've never done anything like this before, so if this is a dumb question, please forgive me...thanks again for all of your help!!

Philip Hutchison

unread,
Mar 18, 2009, 2:35:59 PM3/18/09
to elearning-technolo...@googlegroups.com
i meant the scorm connection initialization code, and whatever course code you use to track progress.

the underlying idea here is that SCORM won't track a SCO's progress for you; you need to do it yourself in your course's code, then just use SCORM to store that data in the LMS.

this means you need to come up with a mechanism to determine which SWFs have been completed and which ones haven't, then store that data in the LMS.

one way to do it is cmi.location, which can store a URL.  if your course follows a strict sequential order, you could use it to track progress.

------------------------

var bookmark:String = scormsession.get("cmi.location");

if(bookmark != ""){


  //a bookmark was found, let's load it
   loadContentSWF(bookmark);

} else {


  //no bookmark found, start from beginning
   loadContentSWF("http://path/to/file/1.swf");

}



function loadContentSWF:void( swfURL ){

   //load the swf using the swfURL variable
   myMovieClipLoader.loadClip(swfURL);

   //bookmark the swf
   scormsession.set("cmi.location", swfURL);

}

----------------------

you could also use suspend_data to store an array indicating which SWFs have been completed

----------------------

var completedSWFs:Array = [0, 0, 0, 0, 0, 0];

//upon completing the first SWF:
completedSWFs[0] = 1;

//completedSWFs now returns [1, 0, 0, 0, 0, 0]

//save this info in the LMS:
scormsession.set("cmi.suspend_data", completedSWFs.ToString());

var suspend_data:String = scormsession.get("cmi.suspend_data");
completedSWFs = suspend_data.split(",");

//completedSWFs now returns [1, 0, 0, 0, 0, 0]

------------------------------

so as you can see, it really depends on how you design your course code.  it's up to you to build a loading/tracking mechanism, and once you've it built you can use SCORM to store important data such as URLs or other strings.  there are a lot of different ways to do it, and you'll need to figure out what works best for you.

the best way to start (in my opinion) is to get it working without SCORM, then add the SCORM code as needed.  some SCORM purists may disagree with this approach, but this is also how most flash-based elearning tools work.

- philip

Ryan Wale

unread,
Mar 20, 2009, 10:46:03 AM3/20/09
to elearning-technolo...@googlegroups.com
Philip,
 
Thanks so much for the information.  It made sense and I was able to use the cmi.location and make it work within my test suite; however, when I loaded it into our LMS, it wouldn't work.  Come to find out, our LMS manufacturer says there is an issue with their system.  The only way to make it work is using cmi.suspend.
 
Thankfully, I get how it should work based on your comments; however, I'm having a lot of difficulty figuring out how to setup the array with XML.  I'm brand-spanking new to this type of setup and have spent the past day trying to figure it out.  I'm at a complete loss.  I've gone through Moock's Essential ActionScript book and the forums and am probably more confused now than I was to begin with. 
 
I'm under the gun with a deadline looming and am hoping you can give me just some guidelines as to how to setup an array with my current code using XML.  I've attached an AS file.  If you could guide me along, I'd really appreciate it!! 
xmlTemplate.as

Philip Hutchison

unread,
Mar 21, 2009, 3:35:36 AM3/21/09
to elearning-technolo...@googlegroups.com
You've previously mentioned you have six SWFs that need loading.  Since the files are specified by an XML file, use AS3 to analyze the XML and count how many SWFs are in the course, then create an array using that number.

Attached is some code I threw together for you.  It's not a complete piece but was written specifically to illustrate how you can create and manage a 'completion' array (an array storing completion data) using AS3, XML and SCORM.  You should be able to copy and paste into your own code and edit as needed.  It has a bunch of comments and is hopefully fairly self-explanatory.

Good luck and good weekend. :)

- philip
example.fla
example.xml

Philip Hutchison

unread,
Mar 21, 2009, 2:07:08 PM3/21/09
to elearning-technolo...@googlegroups.com
The FLA in my previous email was created in CS4 and requires CS4 to open it.

Attached to this email is an AS text file containing all the code from the FLA, so you won't need CS4 to see the code.

- philip
example.as

Philip Hutchison

unread,
Mar 21, 2009, 3:26:24 PM3/21/09
to elearning-technolo...@googlegroups.com
BTW there's a small typo:  the XML file is listed in the AS as "text.xml"... it should be "example.xml". Sorry.

Ryan Wale

unread,
Mar 23, 2009, 1:41:44 PM3/23/09
to elearning-technolo...@googlegroups.com
Thanks so much!! I think I get what needs done now. I really
appreciate you taking the time to help me out!
>>>> the best way to start (in my opinion) is to get it working *without
>>>> SCORM*, then add the SCORM code as needed. some SCORM purists may
Reply all
Reply to author
Forward
0 new messages