function add($xml = '', $order = '') { if ($xml) { $this->count++; if ($xml->attributes()->objectid) { $this->orderid = $xml->attributes()->objectid; } $chunk = new ST_QTI12_Material_Inner(); $chunk->label = (string) $xml->attributes()->label; foreach ($xml->children() as $child) { $name = $child->getName(); if ($name == 'mattext') { $chunk->data[] = MakeValidHTML($this->ParseImages((string) $child), $this->notrim); if (isset($child->attributes()->label)) { $chunk->label = (string) $child->attributes()->label; } } if ($name == 'matemtext') { $chunk->data[] = "<em>" . MakeValidHTML($this->ParseImages((string) $child)) . "</em>"; } if ($name == 'matbreak') { $chunk->data[] = "<br />"; } if ($name == 'mat_extension') { foreach ($child->children() as $child1) { $name1 = $child1->getName(); if ($name1 == 'webct_localizable_mattext') { $chunk->data[] = MakeValidHTML($this->ParseImages((string) $child1)); } } } } if ($order) { $this->chunks[$order] = $chunk; } else { $this->chunks[] = $chunk; } // load any images here if ($xml->matimage) { $this->addImage((string) $xml->matimage->attributes()->uri, (string) $xml->matimage->attributes()->width, (string) $xml->matimage->attributes()->height, (string) $xml->matimage); } } }
function LoadExtmatch(&$source) { // easy to do, no feedback in Rogo so goes the way of the dinosar $dest = new ST_Question_Extmatch(); $dest->load_id = $source->load_id; $dest->status = $source->qmd_status; $dest->type = "extmatch"; $shuf = 0; foreach ($source->responses as $respeach) { if ($respeach->shuffle == 1) { $shuf = 1; } } if ($shuf == 1) { // if ($source->responses[1]->shuffle == 1) { $dest->q_option_order = 'random'; } $this->GenerateQuestionInfo($dest, $source->material, $source->title); // load option list $optionlist = $this->GetResponseLabelList($source, false, $lablk, $lablkd); $optid = 1; foreach ($optionlist as $id => $option) { $opt = new STQ_Extm_Option(); $opt->option = $option; $opt->id = $id; $dest->optionlist[$optid] = $opt; $optid++; } $optid = 1; // load all stems $stemid = 1; $respcond = $this->GetRespConditions($source, 1); print_p($respcond); $usedfb = array(); $dest->marks = 0; foreach ($source->responses as $rid => $response) { $stem = new STQ_Extm_Scenario(); $stem->stem = MakeValidHTML(RemoveLoneP($response->material->GetHTML())); $stem->base_response_id = $rid; if (!empty($response->material->media)) { $stem->media = $response->material->media; $stem->media_width = $response->material->media_width; $stem->media_height = $response->material->media_height; } $dest->scenarios[$stemid++] = $stem; $correct = array(); foreach ($respcond as $cond) { foreach ($cond->conditions as $condvar) { // 1 mark per correct answer so skip ones that have a diff respident and mark correct rest if ($condvar->respident != $rid) { continue; } if ($condvar->not) { continue; } $correct[] = $condvar->value; } } list($marks_incorrect, $marks_partial, $marks_correct) = $this->getMarksFromRespConditions($source); $dest->marks_correct = $marks_correct; $dest->marks_incorrect = $marks_incorrect; $dest->marks_partial = $marks_partial; // work out correct answers for this stem $correct_mapped = array(); foreach ($correct as $answer) { foreach ($dest->optionlist as $oid => $option) { if ($option->id == $answer) { $stem->correctans[] = $oid; } } foreach ($lablkd as $lablkk => $lablkv) { if ($lablkk != "") { if ($lablk[$rid][$answer] == $lablkk) { $stem->correctans[] = $lablkv; } } } } // get feedback for this stem $fb = $this->GetFeedbacks($source, $rid); $stem->feedback = $this->GetFeedbackFromArray($source, $fb); } return $dest; }