Beispiel #1
0
 function __construct($xml)
 {
     $this->params['KEYWORD'] = array();
     $this->params['VARIABLE'] = array();
     $this->raw_xml = $xml;
     $this->title = (string) $xml->attributes()->title;
     $this->load_id = (string) $xml->attributes()->ident;
     $this->material = new ST_QTI12_Material();
     // load item meta data
     if ($xml->itemmetadata) {
         foreach ($xml->itemmetadata as $th) {
             foreach ($th as $rg) {
                 foreach ($rg as $ef) {
                     if ($ef->fieldlabel == "wct_questiontype") {
                         $this->wct_questiontype = (string) $ef->fieldentry;
                     }
                 }
             }
         }
         if ($xml->itemmetadata->qmd_itemtype) {
             $this->qmd_itemtype = (string) $xml->itemmetadata->qmd_itemtype;
         }
         if ($xml->itemmetadata->qmd_status) {
             $this->qmd_status = (string) $xml->itemmetadata->qmd_status;
         }
         if ($xml->itemmetadata->qmd_toolvendor) {
             $this->qmd_toolvendor = (string) $xml->itemmetadata->qmd_toolvendor;
         }
         $t = 0;
     }
     $this->LoadComments($xml);
     if ($this->wct_questiontype == "WCT_JumbledSentence") {
         $ttt = $xml->presentation->flow->response_lid->render_extension->ims_render_object;
         $itemid = 1;
         foreach ($xml->presentation->flow->response_lid->render_extension->ims_render_object->children() as $child1) {
             $name = $child1->getName();
             if ($name == "material") {
                 $mat = new ST_QTI12_Material();
                 $mat->notrim = 1;
                 $mat->add($child1);
                 $question[] = $mat->GetText(1);
                 $trtrtr = 1;
                 unset($mat);
             }
             if ($name == "response_label") {
                 $mat = new ST_QTI12_Material();
                 $mat->notrim = 1;
                 $mat->add($child1->material);
                 $string = sprintf("%%BLANK_%d%%", $itemid);
                 $question[] = $string;
                 $optionslk[$itemid] = $mat->GetText(1);
                 $ident1 = (string) $child1->attributes()->ident;
                 $optionslk1[$itemid] = $ident1;
                 $optionslk2[$ident1] = $mat->GetText(1);
                 $trtrtr = 1;
                 unset($mat);
                 $itemid++;
             }
         }
         if ($xml->resprocessing->respcondition->conditionvar->and) {
             foreach ($xml->resprocessing->respcondition->conditionvar->and->children() as $child2) {
                 $ident2 = (string) $child2->attributes()->index;
                 $nm = (string) $child2;
                 $optionslk3[$ident2] = $nm;
                 $optionslk4[$nm] = $ident2;
             }
         }
         if (isset($optionslk3)) {
             foreach ($optionslk1 as $par3 => $child3) {
                 $string = sprintf("%%BLANK_%d%%", $par3);
                 $lk2 = $optionslk3[$par3];
                 $options[$string][] = $optionslk2[$lk2];
                 foreach ($optionslk2 as $par4 => $child4) {
                     if ($par4 != $lk2) {
                         $options[$string][] = $optionslk2[$par4];
                     }
                 }
             }
         }
         $this->optionslk1 = $optionslk1;
         $this->optionslk2 = $optionslk2;
         @($this->optionslk3 = $optionslk3);
         @($this->optionslk4 = $optionslk4);
         @($this->options2 = $options);
         $this->question2 = $question;
         $debpoint = 1;
         $this->LoadPresentation($xml->presentation->flow);
     } else {
         $this->LoadPresentation($xml->presentation);
     }
     if ($xml->resprocessing->respcondition) {
         foreach ($xml->resprocessing as $respch) {
             foreach ($respch->respcondition as $respcondition) {
                 $this->respconditions[] = new ST_QTI12_RespCondition($respcondition);
             }
         }
     }
     // load all the feedback options
     foreach ($xml->itemfeedback as $itemfeedback) {
         $fb = new ST_QTI12_Itemfeedback($itemfeedback);
         $this->itemfeedback[$fb->id] = $fb;
     }
     // QMP FIX:
     // need to validate all id in ST_QTI12_CondVar against the correct ST_QTI12_Response object,
     // if the id isnt found attempt to look it up from the value
     foreach ($this->respconditions as &$respcondition) {
         foreach ($respcondition->conditions as $condition) {
             $value = $condition->value;
             $respid = $condition->respident;
             if (!array_key_exists($respid, $this->responses)) {
                 continue;
             }
             $response = $this->responses[$respid];
             if (!array_key_exists($value, $response->labels)) {
                 foreach ($response->labels as $label) {
                     if (strtolower($label->material->GetText()) == strtolower($value)) {
                         $condition->value = $label->id;
                     }
                 }
             }
         }
     }
 }
Beispiel #2
0
 function BlankDropdowns(&$dest, &$source)
 {
     global $string;
     echo "{$string['loadingblankdrop']}<br>";
     $qtext = array();
     $optionid = 1;
     foreach ($source->presentation->children() as $child) {
         $name = $child->getName();
         if ($name == 'material') {
             if ($child->attributes()->label != "") {
                 continue;
             }
             $material = new ST_QTI12_Material();
             $material->add($child);
             $qtext[] = $material->GetHTML();
         }
         if ($name == 'response_lid') {
             $response = new ST_QTI12_Response('lid', $child);
             $blankid = "%" . sprintf("BLANK_%d", $optionid) . "%";
             $blankoptions = array();
             // get all conditions that are related to this response
             $conds = $this->GetRespConditions($source, 1, $response->id);
             foreach ($response->labels as $id => $label) {
                 $blank = new STQ_Blank_Option();
                 $blank->display = $label->material->GetText();
                 $blank->id = $id;
                 $blankoptions[] = $blank;
                 //echo "Checking for blank " . $id . " - ";
                 // need to work out if this label is correct or not
                 foreach ($conds as $cond) {
                     foreach ($cond->conditions as $condvar) {
                         if ($condvar->value != $blank->id) {
                             continue;
                         }
                         if ($condvar->respident != $response->id) {
                             continue;
                         }
                         if ($condvar->not) {
                             continue;
                         }
                         $blank->correct = 1;
                     }
                 }
             }
             $dest->options[$blankid] = $blankoptions;
             $qtext[] = $blankid;
             $optionid++;
         }
         $dest->question = $qtext;
     }
     $dest->displaymode = "dropdown";
 }