Location: PHPKode > projects > Ps and Qs: Processing QTI using PHP > qti-eb/functionsfiles/tolaptlite.inc.php
<?php
$functionsmemory = array(); // Will store key->value pairs for things which want some persistence

$functionsmemory['llexample'] = <<<EOD
S("Questions about Britain");

Q("Britain is in the Northern Hemisphere",T);  


Q("What is the capital of England?");
A("London");
A("Londres","Yes, but the English name is London");


Q(MCQ,"Which is the capital of Scotland?");
M("Glasgow");
M("Edinburgh");
M("Stirling");
A(2);
I(1,"Not the capital, but it is the largest city");

Q("How many separate countries or provinces make up the UK?");
A("4");  // model answer
A("four"); //allows text version
A("{4}  * ");  // bit unnecessary in this case! - but would allow as correct '4.0 countries'  (any format of 4 (+1%) with or without a following word). 


E("They are England, Scotland, Wales and Northern Ireland: The 'United Kingdom of Great Britain and Northern Ireland' . It does not include the Channel Islands or the Isle of Man but for VAT purposes the Isle of Man is treated as part of the UK. ");


Q("British shops sometimes still use the 'pound' as a unit of mass. How many kg is one pound.?");
A("0.454 kg");
A(" {0.45 0.46} * ");  //permissible range,  wild card * allows any or no unit, since the unit was specified.
A(" {450 460}  g* ");  //also accepts if student gives the correct answer, but in grammes
EOD;


// This default filename can/should be replaced by the <assessment> title
$functionsmemory['filetitle'] = ucwords(str_replace('_',' ',reset(explode('.',end(explode('/',$qtifilename)),2))));

$functionsmemory['sections'] = array();

// $showviewsource = false;

// The following two functions are called before the start, and after the end, respectively,
//  of the QTI XML processing. Use them to wrap HTML around the whole output, for example.
function qtiEbVeryStart()
{
  // @header('Content-type: text/plain');
}
function qtiEbVeryEnd()
{
  global $functionsmemory, $qtifilename;
  echo "<pre>";
  $lloutput = '';
  $lloutput .= "/* QTI-to-LAPTlite - experimental version - by Dan Stowell.\n File: $qtifilename */\n\n";
  $lloutput .= "TITLE(\"" . htmlspecialchars($functionsmemory['filetitle']) . "\"); \n\n";
  
  foreach($functionsmemory['sections'] as $sectionnum => $section)
  {
//    echo "// Section data: \n";  print_r($section);  echo "\n";

    $sectionoutput = '';
    if(is_array($section['rubric']))
      foreach($section['rubric'] as $rub)
  	    $sectionoutput .= str_replace('"', '\"', implode('<br />', $rub)) . '<br />';
    if(is_array($section['presentation']))
      foreach($section['presentation'] as $pres)
        $sectionoutput .= str_replace('"', '\"', implode('<br />', $pres));

    $lloutput .=  "\nS(\"" . htmlspecialchars($section['title']) . "\", \"$sectionoutput\");\n";
    if(is_array($section['items']))
	  foreach($section['items'] as $item)
	  {
	    $itemquestion = '';
        if(is_array($item['rubric']))
		  foreach($item['rubric'] as $rub)
  	        $itemquestion .= str_replace('"', '\"', implode('<br />', $rub)) . '<br />';
        if(is_array($item['presentation']))
		  foreach($item['presentation'] as $pres)
	        $itemquestion .= str_replace('"', '\"', implode('<br />', $pres));
		
		$qtype = whatLaptQuestionType($item);
	//	$lloutput .=  "// \$qtype = $qtype \n";
		switch($qtype)
		{
		  case 'Text':
		    $lloutput .=  "Q(\"$itemquestion\");\n";
			// Also need to implement A("answer text", "explanation text") and I("wronganswer text", "explanation text")
			break;
		  case 'TF-T':
		    $lloutput .=  "Q(\"$itemquestion\", T);\n";
			break;
		  case 'TF-F':
		    $lloutput .=  "Q(\"$itemquestion\", F);\n";
			break;
		  case 'Matrix':
		    $lloutput .= "\n/* Warning: Item " . $item['attrs']['ident'] . " is a matrix-type question. Not supported. */\n\n";
			break;
/*		  case 'MCQ': // Simple MCQ - N.B. will not render matrix-type questions
// NO NEED! Translate MCQs as if they were MRQs!?!?
		    $lloutput .=  "Q(MCQ, \"$itemquestion\");\n";
			$feedbacks = is_array($item['itemfeedback']) ? reset($item['itemfeedback']) : array();
		    foreach(reset($item['response_label']) as $k => $v)
		 	  $lloutput .=  "MC(\"" . escapeLaptChars($v) . "\", \"". escapeLaptChars($feedbacks[$k]) ."\");\n";
			break;
*/
		  case 'MRQ':
		  default:
		    $lloutput .=  "\nQ(MRQ, " . intval($item['maxchoices']) . ", \"$itemquestion\");\n";
			$feedbacks = is_array($item['itemfeedback']) ? reset($item['itemfeedback']) : array();
			$feedbacklinks = is_array($item['respconditions']) ? $item['respconditions'] : array();
		    foreach(reset($item['response_label']) as $k => $v)
		 	  $lloutput .=  "MC(\"" . escapeLaptChars($v) . "\");\n";
	//	 	  $lloutput .=  "MC(\"" . escapeLaptChars($v) . "\", \"". escapeLaptChars($feedbacks[$k]) ."\");\n";
			$incrementer = 1;
		    foreach(reset($item['response_label']) as $k => $v)
			  // Write out an A(n, "Feecback") line if correct, or an I(n, "Feedback") line if incorrect
			  if($feedbacklinks[$k]['setvar']['SCORE']>0)
		        $lloutput .=  "A(\"" . $incrementer++ . "\", \"". escapeLaptChars($feedbacks[$feedbacklinks[$k]['feedback']['linkrefid']]) ."\");\n";
			  else
		        $lloutput .=  "I(\"" . $incrementer++ . "\", \"". escapeLaptChars($feedbacks[$feedbacklinks[$k]['feedback']['linkrefid']]) ."\");\n";
        } // END OF QUESTIONTYPE SWITCH
        if(is_array($item['solution']) && is_array(reset($item['solution'])) && strlen(reset(reset($item['solution'])))>0)
		  $lloutput .=  "E(\"" . escapeLaptChars(reset(reset($item['solution']))) . "\");\n";
//	    $lloutput .=  "/*\n   Item " . $item['attrs']['ident'] . "\n";
  //      $lloutput .=  "  (Want to create Q(),A(), etc, here)\n";
	//	$lloutput .=  "\n                  " . str_replace("\n", "\n                  ", print_r($item, true));
      //  $lloutput .=  "*/\n\n";
	  }
  }
  echo htmlspecialchars($lloutput);
  echo "</pre>";
  ?>
  <form method="post" action="laptlitetest.php">
  <input type="hidden" name="llcontent" value="<?php echo htmlspecialchars($lloutput /* $functionsmemory['llexample'] */); ?>" />
  <input type="submit" value="Test in LAPTlite"  />
  
  </form>
  <?php
}

function escapeLaptChars($t)
{
 // return preg_replace('/(?!<\\)\"/', '\\\"', $t);
  return str_replace('"', '\\"', $t);
}

// Function to take QTI data and decide what LAPT question fits it best!
function whatLaptQuestionType($item)
{
/*
  if($item['render_type']=='choice' && sizeof($item['reponse_label'])==2)
    return 'TF-T';
  if($item['render_type']=='choice')
    return 'MCQ';
*/

  if($item['render_type']=='choice' && sizeof($item['response_label'])==1 && sizeof(reset($item['response_label']))>1)
  // If this is a VERY SIMPLE MCQ - matrix-type questions fail this test because the size of response_label > 1
    return ($item['maxchoices']>1) ? 'MRQ' : 'MCQ';
  if($item['render_type']=='choice' && sizeof($item['response_label'])>1 && sizeof(reset($item['response_label']))>1)
    return 'Matrix';

  return 'TF-T';
}

// "and":
function qtiEbStartand($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDataand($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopand($context)
{
  global $functionsmemory;
}
// ...end "and"


// "altmaterial":
function qtiEbStartaltmaterial($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDataaltmaterial($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopaltmaterial($context)
{
  global $functionsmemory;
}
// ...end "altmaterial"


// "assessfeedback":
function qtiEbStartassessfeedback($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDataassessfeedback($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopassessfeedback($context)
{
  global $functionsmemory;
}
// ...end "assessfeedback"


// "assessment":
function qtiEbStartassessment($attrs, $context)
{
  global $functionsmemory;
  if(strlen($attrs['title'])>0)
    $functionsmemory['filetitle'] = $attrs['title'];
}
function qtiEbDataassessment($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopassessment($context)
{
  global $functionsmemory;
}
// ...end "assessment"


// "assessmentcontrol":
function qtiEbStartassessmentcontrol($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDataassessmentcontrol($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopassessmentcontrol($context)
{
  global $functionsmemory;
}
// ...end "assessmentcontrol"


// "assessproc_extension":
function qtiEbStartassessproc_extension($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDataassessproc_extension($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopassessproc_extension($context)
{
  global $functionsmemory;
}
// ...end "assessproc_extension"


// "conditionvar":
function qtiEbStartconditionvar($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDataconditionvar($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopconditionvar($context)
{
  global $functionsmemory;
}
// ...end "conditionvar"


// "decvar":
function qtiEbStartdecvar($attrs, $context)
{
  global $functionsmemory;
  // Take the variable's name (default SCORE)
  $varname = (strlen($attrs['varname'])>0) ? $attrs['varname'] : 'SCORE';
  // Take the variable's initial value (default 0)
  $functionsmemory['resprocessing'][$varname]['value'] = (isset($attrs['defaultval'])) ? $attrs['defaultval'] : 0;
  $functionsmemory['resprocessing'][$varname]['vartype'] = $attrs['vartype'];
  // Store other optional attributes if given
  if(isset($attrs['cutvalue'])) $functionsmemory['resprocessing'][$varname]['cutvalue'] = $attrs['cutvalue'];
  if(isset($attrs['minvalue'])) $functionsmemory['resprocessing'][$varname]['minvalue'] = $attrs['minvalue'];
  if(isset($attrs['maxvalue'])) $functionsmemory['resprocessing'][$varname]['maxvalue'] = $attrs['maxvalue'];
  if(isset($attrs['members'])) $functionsmemory['resprocessing'][$varname]['members'] = $attrs['members'];
}
function qtiEbDatadecvar($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopdecvar($context)
{
  global $functionsmemory;
}
// ...end "decvar"


// "displayfeedback":
function qtiEbStartdisplayfeedback($attrs, $context)
{
  global $functionsmemory;
  $functionsmemory['current']['respcondition']['feedback']['linkrefid'] = $attrs['linkrefid'];
}
function qtiEbDatadisplayfeedback($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopdisplayfeedback($context)
{
  global $functionsmemory;
}
// ...end "displayfeedback"


// "duration":
function qtiEbStartduration($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDataduration($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopduration($context)
{
  global $functionsmemory;
}
// ...end "duration"


// "flow":
function qtiEbStartflow($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDataflow($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopflow($context)
{
  global $functionsmemory;
}
// ...end "flow"


// "fieldentry":
function qtiEbStartfieldentry($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDatafieldentry($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopfieldentry($context)
{
  global $functionsmemory;
}
// ...end "fieldentry"


// "fieldlabel":
function qtiEbStartfieldlabel($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDatafieldlabel($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopfieldlabel($context)
{
  global $functionsmemory;
}
// ...end "fieldlabel"


// "flow_label":
function qtiEbStartflow_label($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDataflow_label($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopflow_label($context)
{
  global $functionsmemory;
}
// ...end "flow_label"


// "flow_mat":
function qtiEbStartflow_mat($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDataflow_mat($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopflow_mat($context)
{
  global $functionsmemory;
}
// ...end "flow_mat"


// "hint":
function qtiEbStarthint($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDatahint($context, $data)
{
  global $functionsmemory;
}
function qtiEbStophint($context)
{
  global $functionsmemory;
}
// ...end "hint"


// "hintmaterial":
function qtiEbStarthintmaterial($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDatahintmaterial($context, $data)
{
  global $functionsmemory;
}
function qtiEbStophintmaterial($context)
{
  global $functionsmemory;
}
// ...end "hintmaterial"


// "interpretvar":
function qtiEbStartinterpretvar($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDatainterpretvar($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopinterpretvar($context)
{
  global $functionsmemory;
}
// ...end "interpretvar"


// "item":
function qtiEbStartitem($attrs, $context)
{
  global $functionsmemory;
  $functionsmemory['current']['item'] = array('attrs'=>$attrs);
}
function qtiEbDataitem($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopitem($context)
{
  global $functionsmemory;
  $functionsmemory['sections'][$functionsmemory['sectionnumber']]['items'][] = $functionsmemory['current']['item'];
  unset($functionsmemory['current']['item']);
  unset($functionsmemory['current']['matcontext']);
  unset($functionsmemory['current']['matcontextid']);
}
// ...end "item"


// "itemcontrol":
function qtiEbStartitemcontrol($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDataitemcontrol($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopitemcontrol($context)
{
  global $functionsmemory;
}
// ...end "itemcontrol"


// "itemfeedback":
function qtiEbStartitemfeedback($attrs, $context)
{
  global $functionsmemory;
  $functionsmemory['current']['matcontext'] = 'itemfeedback';
  $functionsmemory['current']['matcontextid'] = $functionsmemory['current']['item']['attrs']['ident'];
  $functionsmemory['current']['matcontextsubid'] = $attrs['ident'];
 // echo "\n\n<p>SUBID = " . print_r($functionsmemory['current']['item']['attrs']['ident'], true);
}
function qtiEbDataitemfeedback($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopitemfeedback($context)
{
  global $functionsmemory;
  unset($functionsmemory['current']['matcontext']);
  unset($functionsmemory['current']['matcontextid']);
}
// ...end "itemfeedback"


// "itemmetadata":
function qtiEbStartitemmetadata($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDataitemmetadata($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopitemmetadata($context)
{
  global $functionsmemory;
}
// ...end "itemmetadata"


// "itempostcondition":
function qtiEbStartitempostcondition($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDataitempostcondition($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopitempostcondition($context)
{
  global $functionsmemory;
}
// ...end "itempostcondition"


// "itemprecondition":
function qtiEbStartitemprecondition($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDataitemprecondition($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopitemprecondition($context)
{
  global $functionsmemory;
}
// ...end "itemprecondition"


// "itemproc_extension":
function qtiEbStartitemproc_extension($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDataitemproc_extension($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopitemproc_extension($context)
{
  global $functionsmemory;
}
// ...end "itemproc_extension"


// "itemref":
function qtiEbStartitemref($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDataitemref($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopitemref($context)
{
  global $functionsmemory;
}
// ...end "itemref"


// "itemrubric":
function qtiEbStartitemrubric($attrs, $context)
{
  global $functionsmemory;
  $functionsmemory['current']['matcontext'] = 'itemrubric';
  $functionsmemory['current']['matcontextid'] = 0;
}
function qtiEbDataitemrubric($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopitemrubric($context)
{
  global $functionsmemory;
  unset($functionsmemory['current']['matcontext']);
  unset($functionsmemory['current']['matcontextid']);
}
// ...end "itemrubric"


// "mat_extension":
function qtiEbStartmat_extension($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDatamat_extension($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopmat_extension($context)
{
  global $functionsmemory;
}
// ...end "mat_extension"


// "matapplet":
function qtiEbStartmatapplet($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDatamatapplet($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopmatapplet($context)
{
  global $functionsmemory;
}
// ...end "matapplet"


// "matapplication":
function qtiEbStartmatapplication($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDatamatapplication($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopmatapplication($context)
{
  global $functionsmemory;
}
// ...end "matapplication"


// "mataudio":
function qtiEbStartmataudio($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDatamataudio($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopmataudio($context)
{
  global $functionsmemory;
}
// ...end "mataudio"


// "matbreak":
function qtiEbStartmatbreak($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDatamatbreak($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopmatbreak($context)
{
  global $functionsmemory;
}
// ...end "matbreak"



// "matemtext":
function qtiEbStartmatemtext($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDatamatemtext($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopmatemtext($context)
{
  global $functionsmemory;
}
// ...end "matemtext"


// "material":
function qtiEbStartmaterial($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDatamaterial($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopmaterial($context)
{
  global $functionsmemory;
}
// ...end "material"


// "material_ref":
function qtiEbStartmaterial_ref($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDatamaterial_ref($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopmaterial_ref($context)
{
  global $functionsmemory;
}
// ...end "material_ref"


// "matimage":
function qtiEbStartmatimage($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDatamatimage($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopmatimage($context)
{
  global $functionsmemory;
}
// ...end "matimage"


// "matref":
function qtiEbStartmatref($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDatamatref($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopmatref($context)
{
  global $functionsmemory;
}
// ...end "matref"


// "mattext":
function qtiEbStartmattext($attrs, $context)
{
  global $functionsmemory;
  $functionsmemory['current']['mattexttype'] = $attrs['texttype'];
  if(!isset($functionsmemory['current']['matcontext']))
  {
    for($i=sizeof($context)-1; $i>=0; $i--)
      if($context[$i]->name == 'presentation')
	    $functionsmemory['current']['matcontext'] = $context[$i]->name;
  }
  if(!isset($functionsmemory['current']['matcontext']))
  {
    echo "// WARNING! &lt;mattext&gt; element encountered without knowing the material context!\n";
	foreach($context as $el)
	  echo $el->name . '>';
	echo "\n\n";
  }
//  else
  //  echo "// &lt;mattext&gt; element for context \"" . $functionsmemory['current']['matcontext'] . "\" should go here.\n";
}
function qtiEbDatamattext($context, $data)
{
  global $functionsmemory;
  
  $data = preg_replace('/[\r\n]/',' ', $data);
  
  $context = isset($functionsmemory['current']['matcontext']) 
                    ? $functionsmemory['current']['matcontext']
                    : 'unknowncontext';
  
  if(isset($functionsmemory['current']['item']))
    $functionsmemory['current']['item'][$context][$functionsmemory['current']['matcontextid']][$functionsmemory['current']['matcontextsubid']] .= $data;
  else
    $functionsmemory['sections'][$functionsmemory['sectionnumber']][$context][$functionsmemory['current']['matcontextid']][$functionsmemory['current']['matcontextsubid']] .= $data;
}
function qtiEbStopmattext($context)
{
  global $functionsmemory;
  unset($functionsmemory['current']['mattexttype']);
}
// ...end "mattext"


// "matvideo":
function qtiEbStartmatvideo($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDatamatvideo($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopmatvideo($context)
{
  global $functionsmemory;
}
// ...end "matvideo"


// "not":
function qtiEbStartnot($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDatanot($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopnot($context)
{
  global $functionsmemory;
}
// ...end "not"


// "objectbank":
function qtiEbStartobjectbank($attrs, $context)
{
  global $functionsmemory;
  if(strlen($attrs['ident'])>0)
    $functionsmemory['filetitle'] = $attrs['ident'];
}
function qtiEbDataobjectbank($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopobjectbank($context)
{
  global $functionsmemory;
}
// ...end "objectbank"


// "objectives":
function qtiEbStartobjectives($attrs, $context)
{
  global $functionsmemory;
  $functionsmemory['current']['matcontext'] = 'objectives';
  $functionsmemory['current']['matcontextid'] = 0;
}
function qtiEbDataobjectives($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopobjectives($context)
{
  global $functionsmemory;
  unset($functionsmemory['current']['matcontext']);
  unset($functionsmemory['current']['matcontextid']);
}
// ...end "objectives"


// "or":
function qtiEbStartor($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDataor($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopor($context)
{
  global $functionsmemory;
}
// ...end "or"

// "order":
function qtiEbStartorder($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDataorder($context, $data)
{
  global $functionsmemory;
}
function qtiEbStoporder($context)
{
  global $functionsmemory;
}
// ...end "order"


// "other":
function qtiEbStartother($attrs, $context)
{
  global $functionsmemory;
  $functionsmemory['resprocessing']['condition']=='other';
}
function qtiEbDataother($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopother($context)
{
  global $functionsmemory;
}
// ...end "other"


// "outcomes":
function qtiEbStartoutcomes($attrs, $context)
{
  global $functionsmemory;
  $functionsmemory['resprocessing']['SCORE']['value'] = 0;
}
function qtiEbDataoutcomes($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopoutcomes($context)
{
  global $functionsmemory;
}
// ...end "outcomes"


// "outcomes_processing":
function qtiEbStartoutcomes_processing($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDataoutcomes_processing($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopoutcomes_processing($context)
{
  global $functionsmemory;
}
// ...end "outcomes_processing"


// "presentation":
function qtiEbStartpresentation($attrs, $context)
{
  global $functionsmemory;
  $functionsmemory['current']['matcontext'] = 'presentation';
  $functionsmemory['current']['matcontextid'] = 0;
}
function qtiEbDatapresentation($context, $data)
{
  global $functionsmemory;
}
function qtiEbStoppresentation($context)
{
  global $functionsmemory;
  unset($functionsmemory['current']['matcontext']);
  unset($functionsmemory['current']['matcontextid']);
}
// ...end "presentation"


// "presentation_material":
function qtiEbStartpresentation_material($attrs, $context)
{
  global $functionsmemory;
  $functionsmemory['current']['matcontext'] = 'presentation_material';
  $functionsmemory['current']['matcontextid'] = 0;
}
function qtiEbDatapresentation_material($context, $data)
{
  global $functionsmemory;
}
function qtiEbStoppresentation_material($context)
{
  global $functionsmemory;
  unset($functionsmemory['current']['matcontext']);
  unset($functionsmemory['current']['matcontextid']);
}
// ...end "presentation_material"

// "qmd_itemtype":
function qtiEbStartqmd_itemtype($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDataqmd_itemtype($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopqmd_itemtype($context)
{
  global $functionsmemory;
}
// ...end "qmd_itemtype"


// "qmd_levelofdifficulty":
function qtiEbStartqmd_levelofdifficulty($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDataqmd_levelofdifficulty($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopqmd_levelofdifficulty($context)
{
  global $functionsmemory;
}
// ...end "qmd_levelofdifficulty"


// "qmd_maximumscore":
function qtiEbStartqmd_maximumscore($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDataqmd_maximumscore($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopqmd_maximumscore($context)
{
  global $functionsmemory;
}
// ...end "qmd_maximumscore"


// "qmd_minimumscore":
function qtiEbStartqmd_minimumscore($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDataqmd_minimumscore($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopqmd_minimumscore($context)
{
  global $functionsmemory;
}
// ...end "qmd_minimumscore"


// "qmd_status":
function qtiEbStartqmd_status($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDataqmd_status($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopqmd_status($context)
{
  global $functionsmemory;
}
// ...end "qmd_status"


// "qmd_weighting":
function qtiEbStartqmd_weighting($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDataqmd_weighting($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopqmd_weighting($context)
{
  global $functionsmemory;
}
// ...end "qmd_weighting"


// "qmd_toolvendor":
function qtiEbStartqmd_toolvendor($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDataqmd_toolvendor($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopqmd_toolvendor($context)
{
  global $functionsmemory;
}
// ...end "qmd_toolvendor"


// "qmd_topic":
function qtiEbStartqmd_topic($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDataqmd_topic($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopqmd_topic($context)
{
  global $functionsmemory;
}
// ...end "qmd_topic"



// "qticomment":
function qtiEbStartqticomment($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDataqticomment($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopqticomment($context)
{
  global $functionsmemory;
}
// ...end "qticomment"


// "qtimetadata":
function qtiEbStartqtimetadata($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDataqtimetadata($context, $data)
{
  global $functionsmemory;
}

function qtiEbStopqtimetadata($context)
{
  global $functionsmemory;
}
// ...end "qtimetadata"


// "qtimetadatafield":
function qtiEbStartqtimetadatafield($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDataqtimetadatafield($context, $data)
{
  global $functionsmemory;
}

function qtiEbStopqtimetadatafield($context)
{
  global $functionsmemory;
}
// ...end "qtimetadatafield"


// "questestinterop":
function qtiEbStartquestestinterop($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDataquestestinterop($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopquestestinterop($context)
{
  global $functionsmemory;
}
// ...end "questestinterop"


// "reference":
function qtiEbStartreference($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDatareference($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopreference($context)
{
  global $functionsmemory;
}
// ...end "reference"


// "render_choice":
function qtiEbStartrender_choice($attrs, $context)
{
  global $functionsmemory;
  $functionsmemory['current']['item']['render_type'] = 'choice';
  $functionsmemory['current']['item']['maxchoices'] = ($attrs['maxnumber'] > 1) ? $attrs['maxnumber'] : 1;
}
function qtiEbDatarender_choice($context, $data)
{
  global $functionsmemory;
}
function qtiEbStoprender_choice($context)
{
  global $functionsmemory;
}
// ...end "render_choice"


// "render_fib":
function qtiEbStartrender_fib($attrs, $context)
{
  global $functionsmemory;
  $functionsmemory['current']['item']['render_type'] = 'fib';
}
function qtiEbDatarender_fib($context, $data)
{
  global $functionsmemory;
}
function qtiEbStoprender_fib($context)
{
  global $functionsmemory;
}
// ...end "render_fib"


// "render_hotspot":
function qtiEbStartrender_hotspot($attrs, $context)
{
  global $functionsmemory;
  $functionsmemory['current']['item']['render_type'] = 'hotspot';
}
function qtiEbDatarender_hotspot($context, $data)
{
  global $functionsmemory;
}
function qtiEbStoprender_hotspot($context)
{
  global $functionsmemory;
}
// ...end "render_hotspot"


// "render_slider":
function qtiEbStartrender_slider($attrs, $context)
{
  global $functionsmemory;
  $functionsmemory['current']['item']['render_type'] = 'slider';
}
function qtiEbDatarender_slider($context, $data)
{
  global $functionsmemory;
}
function qtiEbStoprender_slider($context)
{
  global $functionsmemory;
}
// ...end "render_slider"


// "respcondition":
function qtiEbStartrespcondition($attrs, $context)
{
  global $functionsmemory;
  $functionsmemory['current']['respcondition'] = array('attrs'=>$attrs);
}
function qtiEbDatarespcondition($context, $data)
{
  global $functionsmemory;
}
function qtiEbStoprespcondition($context)
{
  global $functionsmemory;
  $functionsmemory['current']['item']['respconditions'][$functionsmemory['current']['respcondition']['varequaldata']]
                          = $functionsmemory['current']['respcondition'];
  unset($functionsmemory['current']['respcondition']);
}
// ...end "respcondition"


// "response_extension":
function qtiEbStartresponse_extension($attrs, $context)
{
  global $functionsmemory;
  $functionsmemory['current']['matcontext'] = 'response_extension';
  $functionsmemory['current']['item']['response_type'] = 'extension';
}
function qtiEbDataresponse_extension($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopresponse_extension($context)
{
  global $functionsmemory;
  unset($functionsmemory['current']['matcontext']);
}
// ...end "response_extension"


// "response_grp":
function qtiEbStartresponse_grp($attrs, $context)
{
  global $functionsmemory;
  $functionsmemory['current']['matcontext'] = 'response_grp';
  $functionsmemory['current']['item']['response_type'] = 'group';
}
function qtiEbDataresponse_grp($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopresponse_grp($context)
{
  global $functionsmemory;
  unset($functionsmemory['current']['matcontext']);
}
// ...end "response_grp"


// "response_label":
function qtiEbStartresponse_label($attrs, $context)
{
  global $functionsmemory;
  $functionsmemory['current']['matcontext'] = 'response_label';
  $functionsmemory['current']['matcontextsubid'] = $attrs['ident'];
  $functionsmemory['current']['item']['response_type'] = 'label';
}
function qtiEbDataresponse_label($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopresponse_label($context)
{
  global $functionsmemory;
  unset($functionsmemory['current']['matcontext']);
  unset($functionsmemory['current']['matcontextsubid']);
}
// ...end "response_label"


// "response_lid":
function qtiEbStartresponse_lid($attrs, $context)
{
  global $functionsmemory;
  $functionsmemory['current']['matcontext'] = 'response_lid';
  $functionsmemory['current']['matcontextid'] = $attrs['ident'];
  $functionsmemory['current']['item']['response_type'] = 'lid';
}
function qtiEbDataresponse_lid($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopresponse_lid($context)
{
  global $functionsmemory;
  unset($functionsmemory['current']['matcontext']);
  unset($functionsmemory['current']['matcontextid']);
}
// ...end "response_lid"


// "response_num":
function qtiEbStartresponse_num($attrs, $context)
{
  global $functionsmemory;
  $functionsmemory['current']['matcontext'] = 'response_num';
  $functionsmemory['current']['matcontextid'] = $attrs['ident'];
  $functionsmemory['current']['item']['response_type'] = 'num';
}
function qtiEbDataresponse_num($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopresponse_num($context)
{
  global $functionsmemory;
  unset($functionsmemory['current']['matcontext']);
  unset($functionsmemory['current']['matcontextid']);
}
// ...end "response_num"


// "response_str":
function qtiEbStartresponse_str($attrs, $context)
{
  global $functionsmemory;
  $functionsmemory['current']['matcontext'] = 'response_str';
  $functionsmemory['current']['matcontextid'] = $attrs['ident'];
  $functionsmemory['current']['item']['response_type'] = 'str';
}
function qtiEbDataresponse_str($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopresponse_str($context)
{
  global $functionsmemory;
  unset($functionsmemory['current']['matcontext']);
  unset($functionsmemory['current']['matcontextid']);
}
// ...end "response_str"


// "response_xy":
function qtiEbStartresponse_xy($attrs, $context)
{
  global $functionsmemory;
  $functionsmemory['current']['matcontext'] = 'response_xy';
  $functionsmemory['current']['matcontextid'] = $attrs['ident'];
  $functionsmemory['current']['item']['response_type'] = 'xy';
}
function qtiEbDataresponse_xy($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopresponse_xy($context)
{
  global $functionsmemory;
  unset($functionsmemory['current']['matcontext']);
  unset($functionsmemory['current']['matcontextid']);
}
// ...end "response_xy"


// "resprocessing":
function qtiEbStartresprocessing($attrs, $context)
{
  global $functionsmemory;
  $functionsmemory['resprocessing'] = array();
}
function qtiEbDataresprocessing($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopresprocessing($context)
{
  global $functionsmemory;
  $functionsmemory['current']['item']['resprocessing'] = $functionsmemory['resprocessing'];
  unset($functionsmemory['resprocessing']);
}
// ...end "resprocessing"


// "rubric":
function qtiEbStartrubric($attrs, $context)
{
  global $functionsmemory;
  $functionsmemory['current']['matcontext'] = 'rubric';
}
function qtiEbDatarubric($context, $data)
{
  global $functionsmemory;
}
function qtiEbStoprubric($context)
{
  global $functionsmemory;
  unset($functionsmemory['current']['matcontext']);
}
// ...end "rubric"


// "section":
function qtiEbStartsection($attrs, $context)
{
  global $functionsmemory;
  if(isset($functionsmemory['sectionnumber']))
    $functionsmemory['sectionnumber']++;
  else
    $functionsmemory['sectionnumber']=0;

  $functionsmemory['sections'][$functionsmemory['sectionnumber']] = array(); // Establish new section stuff
  $functionsmemory['sections'][$functionsmemory['sectionnumber']]['title'] = strlen($attrs['title'])>0 ? $attrs['title'] : $attrs['ident'];
}
function qtiEbDatasection($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopsection($context)
{
  global $functionsmemory;
}
// ...end "section"


// "sectioncontrol":
function qtiEbStartsectioncontrol($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDatasectioncontrol($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopsectioncontrol($context)
{
  global $functionsmemory;
}
// ...end "sectioncontrol"


// "sectionfeedback":
function qtiEbStartsectionfeedback($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDatasectionfeedback($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopsectionfeedback($context)
{
  global $functionsmemory;
}
// ...end "sectionfeedback"


// "sectionpostcondition":
function qtiEbStartsectionpostcondition($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDatasectionpostcondition($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopsectionpostcondition($context)
{
  global $functionsmemory;
}
// ...end "sectionpostcondition"


// "sectionprecondition":
function qtiEbStartsectionprecondition($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDatasectionprecondition($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopsectionprecondition($context)
{
  global $functionsmemory;
}
// ...end "sectionprecondition"


// "sectionproc_extension":
function qtiEbStartsectionproc_extension($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDatasectionproc_extension($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopsectionproc_extension($context)
{
  global $functionsmemory;
}
// ...end "sectionproc_extension"


// "sectionref":
function qtiEbStartsectionref($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDatasectionref($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopsectionref($context)
{
  global $functionsmemory;
}
// ...end "sectionref"


// "selection":
function qtiEbStartselection($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDataselection($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopselection($context)
{
  global $functionsmemory;
}
// ...end "selection"


// "selection_ordering":
function qtiEbStartselection_ordering($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDataselection_ordering($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopselection_ordering($context)
{
  global $functionsmemory;
}
// ...end "selection_ordering"


// "sequence_parameter":
function qtiEbStartsequence_parameter($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDatasequence_parameter($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopsequence_parameter($context)
{
  global $functionsmemory;
}
// ...end "sequence_parameter"


// "setvar":
function qtiEbStartsetvar($attrs, $context)
{
  global $functionsmemory;
  $functionsmemory['current']['setvar']['varname'] = strlen($attrs['varname']) ? $attrs['varname'] : 'SCORE';
}
function qtiEbDatasetvar($context, $data)
{
  global $functionsmemory;
  $functionsmemory['current']['respcondition']['setvar'][$functionsmemory['current']['setvar']['varname']] .= $data;
}
function qtiEbStopsetvar($context)
{
  global $functionsmemory;
  unset($functionsmemory['current']['setvar']['varname']);
}
// ...end "setvar"


// "solution":
function qtiEbStartsolution($attrs, $context)
{
  global $functionsmemory;
  $functionsmemory['current']['matcontext'] = 'solution';
}
function qtiEbDatasolution($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopsolution($context)
{
  global $functionsmemory;
  unset($functionsmemory['current']['matcontext']);
}
// ...end "solution"


// "solutionmaterial":
function qtiEbStartsolutionmaterial($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDatasolutionmaterial($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopsolutionmaterial($context)
{
  global $functionsmemory;
}
// ...end "solutionmaterial"

// "unanswered":
function qtiEbStartunanswered($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDataunanswered($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopunanswered($context)
{
  global $functionsmemory;
}
// ...end "unanswered"


// "varequal":
function qtiEbStartvarequal($attrs, $context)
{
  global $functionsmemory;
  $functionsmemory['current']['respcondition']['varequalid'] = $attrs['respident'];
}
function qtiEbDatavarequal($context, $data)
{
  global $functionsmemory;
  $functionsmemory['current']['respcondition']['varequaldata'] .= $data;
}
function qtiEbStopvarequal($context)
{
  global $functionsmemory;
}
// ...end "varequal"

// "varinside":
function qtiEbStartvarinside($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDatavarinside($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopvarinside($context)
{
  global $functionsmemory;
}
// ...end "varinside"




// "varlt":
function qtiEbStartvarlt($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDatavarlt($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopvarlt($context)
{
  global $functionsmemory;
}
// ...end "varlt"


// "varlte":
function qtiEbStartvarlte($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDatavarlte($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopvarlte($context)
{
  global $functionsmemory;
}
// ...end "varlte"


// "vargt":
function qtiEbStartvargt($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDatavargt($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopvargt($context)
{
  global $functionsmemory;
}
// ...end "vargt"


// "vargte":
function qtiEbStartvargte($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDatavargte($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopvargte($context)
{
  global $functionsmemory;
}
// ...end "vargte"


// "varsubset":
function qtiEbStartvarsubset($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDatavarsubset($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopvarsubset($context)
{
  global $functionsmemory;
}
// ...end "varsubset"


// "varsubstring":
function qtiEbStartvarsubstring($attrs, $context)
{
  global $functionsmemory;
}
function qtiEbDatavarsubstring($context, $data)
{
  global $functionsmemory;
}
function qtiEbStopvarsubstring($context)
{
  global $functionsmemory;
}
// ...end "varsubstring"
?>
Return current item: Ps and Qs: Processing QTI using PHP