In my last two posts, I figured out how to read resource and organization data from the manifest file that describes the content package. But the code that I wrote really wasn’t that solid, and wouldn’t be particularly easy to integrate with my “imaginary” LMS. So I’m going to take the lessons that I learned there and see if I can create something a little better.
In Step 26 (Getting Data from the LMS), I identified that my RTE needed the following parameters to run – three of which come from the data in the imsmanifest file:
Parameter | Data From | Used In |
the entry point for the SCO | imsmanifest file | rte.php |
cmi.core.student_name | the LMS database | initialize.php |
cmi.core.student_id | the LMS database | initialize.php |
adlcp:masteryscore | imsmanifest file | initialize.php |
cmi.launch_data | imsmanifest file | initialize.php |
And I’m going to add a couple more that will probably be needed by a typical LMS:
- I’m going to extract the SCO title from the manifest file as well, because I’m sure that a real LMS would need to use it in a listing screen.
- The manifest file contains a list of files that constitute the resources. This would (probably) be useful for the LMS to know when importing a package so that it could extract only those files that it needs to run the SCO. This might not be quite as important right now, with disk space being so cheap, but I’ll include it anyway.
So, the data that I want from the manifest file is:
- the SCO title
- the mastery score set in the manifest file
- the launch data for the SCO
- the entry point for the SCO
- a list of files
I’m going to create a function called readIMSManifestFile($manifestfile) which, given the path to the manifest file on disk, will return the data that I require in an array e.g.
$SCOdata = readIMSManifestFile("/data/import/123/imsmanifest.xml");
This should be easier to integrate with LMS code. To test it out, I create a short PHP/HTML program like this:
<?php /* VS SCORM - CAM - index.php Rev 2.0 - Monday, October 12, 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. */ require "subs.php"; $SCOdata = readIMSManifestFile('imsmanifest.xml'); // ------------------------------------------------------------------------------------ // Process the Items List to Find SCOs // ------------------------------------------------------------------------------------ // output table header row $SCOListTable = "<table cellpadding=3 cellspacing=0 border=1>\n"; $SCOListTable .= "<tr>\n"; $SCOListTable .= "\t<td valign=top align=left><b>Identifier</b></td>\n"; $SCOListTable .= "\t<td valign=top align=left><b>Title</b></td>\n"; $SCOListTable .= "\t<td valign=top align=left><b>MasteryScore</b></td>\n"; $SCOListTable .= "\t<td valign=top align=left><b>LaunchData</b></td>\n"; $SCOListTable .= "\t<td valign=top align=left><b>SCO Entry Point</b></td>\n"; $SCOListTable .= "\t<td valign=top align=left><b>Required Files</b></td>\n"; $SCOListTable .= "</tr>\n"; // loop through the list of items foreach ($SCOdata as $identifier => $SCO) { // data that we want $SCOListTable .= "<tr>\n"; $SCOListTable .= "\t<td valign=top align=left>".cleanVar($identifier)."</td>\n"; $SCOListTable .= "\t<td valign=top align=left>".cleanVar($SCO['title'])."</td>\n"; $SCOListTable .= "\t<td valign=top align=left>".cleanVar($SCO['masteryscore'])."</td>\n"; $SCOListTable .= "\t<td valign=top align=left>".cleanVar($SCO['datafromlms'])."</td>\n"; $SCOListTable .= "\t<td valign=top align=left>".cleanVar($SCO['href'])."</td>\n"; $SCOListTable .= "\t<td valign=top align=left>".implode('<br>',$SCO['files'])."</td>\n"; $SCOListTable .= "</tr>\n"; } $SCOListTable .= "</table>\n"; // function to clean data for display function cleanVar($value) { $value = (trim($value) == "") ? " " : htmlentities(trim($value)); return $value; } ?> <html> <head> <title></title> <style type="text/css"> p,td,li,body,input,select,textarea { font-family: verdana, sans-serif; font-size: 10pt; } h1 { font-weight: bold; font-size: 12pt; } </style> </head> <body bgcolor="#ffffff"> <h1>SCO Data</h1> <p><?php print $SCOListTable; ?> <body> </html>
This program simply requires/includes the ‘subs.php’ file that contains the functions that do the actual work, calls the readIMSManifestFile() function, and displays the resulting data in an HTML table.
One further thing to note here — you’ll see from the looping construct on lines 45 through 58 that the code is designed to handle multiple SCOs contained in the same content package. Although I’ve conducted my tests so far using a single SCO package, the SCORM 1.2 CAM specification allows there to be multiple SCOs contained within the same package.
To be quite honest, I’ve never come across a multiple SCO package in a business environment, but I do have to allow for the possibility. So I’ve created a test package consisting of 2 SCOs using the Lectora authoring tool. You can download a copy of the imsmanifest file from [here] if you’d like to follow along with the next stages.
Next post … I’m going to start writing the code for the readIMSManifestFile() function.