Step 35 – Reading the IMS Manifest File – Organizations

Having read the resource information from the manifest file, I’m going to extend the code to read the organization information. As a reminder, the <organizations> section of my manifest file looks like this.


	
		<title>Privacy 101</title> 
		
			<title>Browser Options</title> 
			 
			 
			80 
			exit,message 
		
	

The data elements and attributes that I’ll want to read are:

  • identifierref – links the organization item to a resource
  • <title> – title for my SCO (course) to be displayed to the student
  • <adlcp:datafromlms> – launch data for the SCO
  • <adlcp:masteryscore> – mastery score to override anything set in the SCO itself

And, as I noted before, I’m not (currently) supporting any kind of time limit for the SCO (course) since it’s not mandatory, so I can ignore the <adlcp:maxtimeallowed> and <adlcp:timelimitaction> elements.

So I add the following code to my ‘manifest reader’.

// ------------------------------------------------------------------------------------
// Read the Organizations List
// ------------------------------------------------------------------------------------

// output table header row
$orgListTable  = "<table cellpadding=3 cellspacing=0 border=1>\n";
$orgListTable .= "<tr>\n";
$orgListTable .= "\t<td valign=top align=left><b>Identifier</b></td>\n";
$orgListTable .= "\t<td valign=top align=left><b>Identifier Ref</b></td>\n";
$orgListTable .= "\t<td valign=top align=left><b>Title</b></td>\n";
$orgListTable .= "\t<td valign=top align=left><b>MasteryScore</b></td>\n";
$orgListTable .= "\t<td valign=top align=left><b>LaunchData</b></td>\n";
$orgListTable .= "</tr>\n";

// get the organizations element
$organizationsList = $dom->getElementsByTagName('organizations');

// iterate over each of the organizations
foreach ($organizationsList as $organizationsListRow) {

  $organizationList = $organizationsListRow->getElementsByTagName('organization');

  foreach ($organizationList as $organizationListRow) {

    $itemsList = $organizationListRow->getElementsByTagName('item');

    foreach ($itemsList as $itemsListRow) {

      // decode the attributes
      // e.g. <item identifier="I_A001" identifierref="A001">
      $identifier = $itemsListRow->getAttribute('identifier');
      $identifierref = $itemsListRow->getAttribute('identifierref');

      $titleTag = $itemsListRow->getElementsByTagName('title');
      $title = $titleTag->item(0)->nodeValue;

      $masteryscoreTag = $itemsListRow->getElementsByTagNameNS($adlcp,'masteryscore');
      $masteryscore = $masteryscoreTag->item(0)->nodeValue;

      $launchdataTag = $itemsListRow->getElementsByTagNameNS($adlcp,'datafromlms');
      $launchdata = $launchdataTag->item(0)->nodeValue;

      // make safe for display
      $identifier = cleanVar($identifier);
      $identifierref = cleanVar($identifierref);
      $title = cleanVar($title);
      $masteryscore = cleanVar($masteryscore);
      $launchdata = cleanVar($launchdata);

      // table row
      $orgListTable .= "<tr>\n";
      $orgListTable .= "\t<td valign=top align=left>$identifier</td>\n";
      $orgListTable .= "\t<td valign=top align=left>$identifierref</td>\n";
      $orgListTable .= "\t<td valign=top align=left>$title</td>\n";
      $orgListTable .= "\t<td valign=top align=left>$masteryscore</td>\n";
      $orgListTable .= "\t<td valign=top align=left>$launchdata</td>\n";
      $orgListTable .= "</tr>\n";

    }

  }

}

$orgListTable .= "</table>\n";

It’s pretty much the same as the code that I used to read the resources data except for one thing. Where I want to read the data from the <adlcp:datafromlms> and <adlcp:masteryscore>, I have to use the following code:

$masteryscoreTag = $itemsListRow->getElementsByTagNameNS($adlcp,'masteryscore');
$masteryscore = $masteryscoreTag->item(0)->nodeValue;

which uses the value of $adlcp that I determined from the manifest file <manifest> attributes (see lines 35 to 37 of the code listing in Step 34 for more details).

Finally, I add a little code to display the output.

<html>
<head>
  <title></title>
</head>
<body bgcolor="#ffffff">

<h2>Resources = Assets</h2>
<p><?php print $resListTable; ?>

<h2>Organizations</h2>
<p><?php print $orgListTable; ?>

</body>
</html>

And here’s what I get when I run it:

Identifier Identifier Ref Title MasteryScore LaunchData
P1 P1_RES Browser Options 80  

So far, so good. Next step, link the <organization> and <resource> data together.

This entry was posted in Content Aggregation Model. Bookmark the permalink.

Leave a Reply

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