Step 60 – Supported Data Elements

One of the things that has caught me out in a couple of recent cases is that the SCORM standard makes SCO developers rely on error codes to determine whether or not certain elements are supported. I describe one specific example in an earlier post – Step 54 – Error Handling.

In a sensible system, the initialization process would provide the SCO with a complete list of supported elements so that it wouldn’t have to go through all this rigmarole. But that’s too much to hope for, so I need a simple way to check whether a data element is supported or not, and I’ll also need to check whether it’s readable and/or writeable.

I’m going to start with my favorite weapon of choice – a JavaScript object (associative array for the perl and PHP fans). Here it is:

var dataElements = new Object();

dataElements['cmi.core._children'] = 'RO';

dataElements['cmi.core.student_id'] = 'RO';
dataElements['cmi.core.student_name'] = 'RO';

dataElements['cmi.core.lesson_location'] = 'RW';
dataElements['cmi.core.credit'] = 'RO';
dataElements['cmi.core.lesson_status'] = 'RW';
dataElements['cmi.core.entry'] = 'RO';
dataElements['cmi.core.exit'] = 'WO';

dataElements['cmi.core.score._children'] = 'RO';
dataElements['cmi.core.score.raw'] = 'RW';
dataElements['cmi.core.score.max'] = 'RW';
dataElements['cmi.core.score.min'] = 'RW';

dataElements['cmi.core.total_time'] = 'RO';
dataElements['cmi.core.session_time'] = 'WO';

dataElements['cmi.suspend_data'] = 'RW';
dataElements['cmi.launch_data'] = 'RO';

dataElements['cmi.comments'] = 'RW';
dataElements['cmi.comments_from_lms'] = 'RO';

This is nothing more than a list of the supported elements with their read/write status.

Then, to make life a little neater when I come to plug this into the actual code, I’m going to define a simple little function:

function isSupported(dataElementName) {

  // flags
  dataElementSupported = false;
  dataElementRead = false;
  dataElementWrite = false;

  // if the data element is in the list of supported elements
  if (dataElementName in dataElements) {

    rights = dataElements[dataElementName];
    dataElementSupported = true;

    if ( (rights == 'RW') || (rights == 'RO') ) { dataElementRead = true; }
    if ( (rights == 'RW') || (rights == 'WO') ) { dataElementWrite = true; }

  }

  return dataElementSupported;

}

This function simply sets three flags that are available to the LMSSetValue and LMSGetValue functions so that they can test the SCO-supplied input, and generate appropriate error codes.

Next, I’m going to add this to the LMSSetValue and LMSGetValue functions.

Be Sociable, Share!
This entry was posted in Run Time Environment. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *