Step 15 – cmi.core.student_id and cmi.core.student_name

According to the SCORM specification, cmi.core.student_name and cmi.core.student_id are read-only data elements. They simply return the name of the student as stored by the LMS (in lastname, firstname format), and an ID number for the student stored by the LMS.

This is pretty easy to implement in my “imaginary” LMS since I simply modify the getValue.php code like this.



VS SCORM - getValue.php 
Rev 2.1 - Monday, July 06, 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
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);

// read GET variable
$varname = trim($_REQUEST['varname']);

// determine value to be returned
switch ($varname) {

  // no variable name supplied
  case "":
    $varvalue = "";

  // 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";

  // cmi.core.student_name is a read-only element
  // Note: in a real application, read from the main LMS student database
  case "cmi.core.student_name":
    $varvalue = "Addison, Steve";

  // cmi.core.student_id is a read-only element
  // Note: in a real application, read from the main LMS student database
  case "cmi.core.student_id":
    $varvalue = "007";

  // all other variable names

    // 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;


For the purposes of this project, this should work fine. However, in a real application, I’d obviously want to replace lines 52 and 58 with calls to the main LMS database tables where the student information is stored.

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 *