When (if) the course issues the LMSGetValue(‘cmi.core._children’) call, it expects to see a value returned from the LMS. But what is that value?
The SCORM standard says that the cmi.core._children data element should store a list of the other data elements in the cmi.core.* set that are supported by the LMS. Since I’m planning to support the mandatory variables – and only the mandatory elements – that’s simply:
"student_id,student_name,lesson_location,credit,lesson_status,entry,score,total_time,exit,session_time"
The specification also says that this is a read-only data element so the course can’t set it and I don’t have to worry about it changing as we run the course. So I can incorporate this in my code by modifying the getValue.php code like this.
<?php
/*
VS SCORM - getValue.php
Rev 2.0 - Sunday, July 05, 2009
Copyright (C) 2009, Addison Robson LLC
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
// database login information
require "config.php";
// connect to the database
$link = mysql_connect($dbhost,$dbuser,$dbpass);
mysql_select_db($dbname,$link);
// read GET variable
$varname = trim($_REQUEST['varname']);
// determine value to be returned
switch ($varname) {
// no variable name supplied
case "":
$varvalue = "";
break;
// cmi.core._children is always the same
case "cmi.core._children":
$varvalue = "student_id,student_name,lesson_location,credit,lesson_status,entry,score,total_time,exit,session_time";
break;
// all other variable names
default:
// make safe for database
$safevarname = mysql_escape_string($varname);
$varvalue = "";
// read data from the 'scormvars' table
$result = mysql_query("select varValue from scormvars where (varName='$safevarname')",$link);
list($varvalue) = mysql_fetch_row($result);
}
// return variable value to the calling program
print $varvalue;
?>
That was easy. Now onto some slightly more complicated elements.
Pingback: Desarrollando un LMS(con soporte de SCORM)