OK … time to implement the handling of cmi.core.lesson_status as I discussed in Step 22.
I’ve already covered the initialization of cmi.core.lesson_status in Step 20, so I don’t have to worry about that. So most of my changes will be to the finish.php code that’s used when LMSFinish() is invoked by the SCO (if you don’t know what a SCO is, please see my last post). Just as a reminder, here’s the logic flow that I’m going to follow.

The first part of the process is pretty simple. I find the current value of cmi.core.lesson_status and, if it’s still set to the initial value (‘not attempted’), I change it to ‘completed’.
// find existing value of cmi.core.lesson_status
$result = mysql_query("select varValue from scormvars where (varName='cmi.core.lesson_status')",$link);
list($value) = mysql_fetch_row($result);
// if it's 'not attempted', change it to 'completed'
if ($value == 'not attempted') {
mysql_query("update scormvars set varValue='completed' where (varName='cmi.core.lesson_status')",$link);
}
So far, so good. Now I have to look to see if a mastery score has been set in the IMS manifest file. If I had a functional LMS, the manifest file would have been read by the LMS when the content aggregation package (what many of us would commonly call a course package) was imported and installed. But I don’t have a real LMS right now (I’ll work on that later), so I’m going to assume that it’s been read and stored in my database as an element called ‘adlcp:masteryscore’. To mimic this, I modify my initialize.php code like this (assuming a 90% passing score).
// if not set, adlcp:masteryscore should be set to the value from the IMS manifest file
$result = mysql_query("select varValue from scormvars where (varName='adlcp:masteryscore')",$link);
list($value) = mysql_fetch_row($result);
if (! $value) {
mysql_query("delete from scormvars where (varName='adlcp:masteryscore')",$link);
mysql_query("insert into scormvars (varName,varValue) values ('adlcp:masteryscore','90')",$link);
}
And my new finish.php code looks like this.
// find existing value of cmi.core.lesson_status
$result = mysql_query("select varValue from scormvars where (varName='cmi.core.lesson_status')",$link);
list($value) = mysql_fetch_row($result);
// if it's 'not attempted', change it to 'completed'
if ($value == 'not attempted') {
mysql_query("update scormvars set varValue='completed' where (varName='cmi.core.lesson_status')",$link);
}
// has a mastery score been specified in the IMS manifest file?
$result = mysql_query("select varValue from scormvars where (varName='adlcp:masteryscore')",$link);
list($value) = mysql_fetch_row($result);
$value *= 1;
if ($value) {
// yes - so read the score
$result2 = mysql_query("select varValue from scormvars where (varName='cmi.score.raw')",$link);
list($value2) = mysql_fetch_row($result2);
$value2 *= 1;
// set cmi.core.lesson_status to passed/failed
if ($value2 >= $value) {
mysql_query("update scormvars set varValue='passed' where (varName='cmi.core.lesson_status')",$link);
}
else {
mysql_query("update scormvars set varValue='failed' where (varName='cmi.core.lesson_status')",$link);
}
}
Time to test it out … the SCO runs through to the end and I score 88 – enough to pass according to the SCO itself. This is what the database table looks like at the end of the SCO but before LMSFinish() has been called.
| varName | varValue |
| adlcp:masteryscore | 90 |
| cmi.core.credit | credit |
| cmi.core.entry | ab initio |
| cmi.core.lesson_location | 13 |
| cmi.core.lesson_status | passed |
| cmi.core.score.raw | 88 |
| cmi.core.session_time | 00:02:04 |
| cmi.core.total_time | 0000:00:00 |
| cmi.suspend_data | K01BB000IA%7E%24KS%2AXQov%5F110BBBB1 … |
Then I close the SCO window causing LMSFinish() to be called and here’s what happens.
| varName | varValue |
| adlcp:masteryscore | 90 |
| cmi.core.credit | credit |
| cmi.core.entry | |
| cmi.core.lesson_location | 13 |
| cmi.core.lesson_status | failed |
| cmi.core.score.raw | 88 |
| cmi.core.total_time | 0000:02:04 |
| cmi.suspend_data | K01BB000IA%7E%24KS%2AXQov%5F110BBBB1 … |
The mastery score set by my ‘imaginary’ LMS has caused the SCO to be graded as a fail rather than as the pass that the SCO intended which is – from my reading of the SCORM specification – what is intended.
I am at this stage and I have a question. I have the above output but I can’t seem to have the cmi.core.exit status set to suspend. Doesn’t this particular sample SCO support cmi.core.exit?
Also after completing the SCO once and after reload of the course, it starts and hangs-up in the last location(10) of the Simulation exercise. Problem with SCO or expected behaviour and up to LMS to allow this particular SCO to be allowed only once?
I have the same problem when using the simulation SCO as a test case. But I don’t know how it was designed, so I can’t comment in any great detail. If you’re having problems, you could try the VERY simple test case that I’ve just posted.