|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 // This file is part of Moodle - http://moodle.org/ 00003 // 00004 // Moodle is free software: you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation, either version 3 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // Moodle is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00022 defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.'); 00023 00024 require_once 'cc_utils.php'; 00025 require_once 'cc_general.php'; 00026 00027 abstract class cc_xml_namespace { 00028 const xml = 'http://www.w3.org/XML/1998/namespace'; 00029 } 00030 00031 abstract class cc_qti_metadata { 00032 //assesment 00033 const qmd_assessmenttype = 'qmd_assessmenttype'; 00034 const qmd_scoretype = 'qmd_scoretype'; 00035 const qmd_feedbackpermitted = 'qmd_feedbackpermitted'; 00036 const qmd_hintspermitted = 'qmd_hintspermitted'; 00037 const qmd_solutionspermitted = 'qmd_solutionspermitted'; 00038 const qmd_timelimit = 'qmd_timelimit'; 00039 const cc_allow_late_submission = 'cc_allow_late_submission'; 00040 const cc_maxattempts = 'cc_maxattempts'; 00041 const cc_profile = 'cc_profile'; 00042 00043 //item 00044 const cc_weighting = 'cc_weighting'; 00045 const qmd_scoringpermitted = 'qmd_scoringpermitted'; 00046 const qmd_computerscored = 'qmd_computerscored'; 00047 const cc_question_category = 'cc_question_category'; 00048 } 00049 00050 abstract class cc_qti_profiletype { 00051 const multiple_choice = 'cc.multiple_choice.v0p1'; 00052 const multiple_response = 'cc.multiple_response.v0p1'; 00053 const true_false = 'cc.true_false.v0p1'; 00054 const field_entry = 'cc.fib.v0p1'; 00055 const pattern_match = 'cc.pattern_match.v0p1'; 00056 const essay = 'cc.essay.v0p1'; 00057 00064 public static function valid($value) { 00065 static $verification_values = array( self::essay, 00066 self::field_entry, 00067 self::multiple_choice, 00068 self::multiple_response, 00069 self::pattern_match, 00070 self::true_false 00071 ); 00072 return in_array($value, $verification_values); 00073 } 00074 00075 } 00076 00077 abstract class cc_qti_values { 00078 const exam_profile = 'cc.exam.v0p1'; 00079 const Yes = 'Yes'; 00080 const No = 'No'; 00081 const Response = 'Response'; 00082 const Solution = 'Solution'; 00083 const Hint = 'Hint'; 00084 const Examination = 'Examination'; 00085 const Percentage = 'Percentage'; 00086 const unlimited = 'unlimited'; 00087 const Single = 'Single'; 00088 const Multiple = 'Multiple'; 00089 const Ordered = 'Ordered'; 00090 const Asterisk = 'Asterisk'; 00091 const Box = 'Box'; 00092 const Dashline = 'Dashline'; 00093 const Underline = 'Underline'; 00094 const Decimal = 'Decimal'; 00095 const Integer = 'Integer'; 00096 const Scientific = 'Scientific'; 00097 const String = 'String'; 00098 const SCORE = 'SCORE'; 00099 const Set = 'Set'; 00100 const Complete = 'Complete'; 00101 const texttype = 'text/plain'; 00102 const htmltype = 'text/html'; 00103 } 00104 00105 abstract class cc_qti_tags { 00106 const questestinterop = 'questestinterop'; 00107 const assessment = 'assessment'; 00108 const qtimetadata = 'qtimetadata'; 00109 const qtimetadatafield = 'qtimetadatafield'; 00110 const fieldlabel = 'fieldlabel'; 00111 const fieldentry = 'fieldentry'; 00112 const section = 'section'; 00113 const ident = 'ident'; 00114 const item = 'item'; 00115 const title = 'title'; 00116 const itemmetadata = 'itemmetadata'; 00117 const presentation = 'presentation'; 00118 const material = 'material'; 00119 const mattext = 'mattext'; 00120 const matref = 'matref'; 00121 const matbreak = 'matbreak'; 00122 const texttype = 'texttype'; 00123 const response_lid = 'response_lid'; 00124 const render_choice = 'render_choice'; 00125 const response_label = 'response_label'; 00126 const resprocessing = 'resprocessing'; 00127 const outcomes = 'outcomes'; 00128 const decvar = 'decvar'; 00129 const respcondition = 'respcondition'; 00130 const conditionvar = 'conditionvar'; 00131 const other = 'other'; 00132 const displayfeedback = 'displayfeedback'; 00133 const maxvalue = 'maxvalue'; 00134 const minvalue = 'minvalue'; 00135 const varname = 'varname'; 00136 const vartype = 'vartype'; 00137 const continue_ = 'continue'; 00138 const feedbacktype = 'feedbacktype'; 00139 const linkrefid = 'linkrefid'; 00140 const varequal = 'varequal'; 00141 const respident = 'respident'; 00142 const itemfeedback = 'itemfeedback'; 00143 const flow_mat = 'flow_mat'; 00144 const rcardinality = 'rcardinality'; 00145 const charset = 'charset'; 00146 const label = 'label'; 00147 const uri = 'uri'; 00148 const width = 'width'; 00149 const height = 'height'; 00150 const x0 = 'x0'; 00151 const y0 = 'y0'; 00152 const xml_lang = 'lang'; 00153 const xml_space = 'space'; 00154 const rubric = 'rubric'; 00155 const altmaterial = 'altmaterial'; 00156 const presentation_material = 'presentation_material'; 00157 const t_class = 'class'; 00158 const material_ref = 'material_ref'; 00159 const rtiming = 'rtiming'; 00160 const render_fib = 'render_fib'; 00161 const shuffle = 'shuffle'; 00162 const minnumber = 'minnumber'; 00163 const maxnumber = 'maxnumber'; 00164 const encoding = 'encoding'; 00165 const maxchars = 'maxchars'; 00166 const prompt = 'prompt'; 00167 const fibtype = 'fibtype'; 00168 const rows = 'rows'; 00169 const columns = 'columns'; 00170 const labelrefid = 'labelrefid'; 00171 const rshuffle = 'rshuffle'; 00172 const match_group = 'match_group'; 00173 const match_max = 'match_max'; 00174 const flow = 'flow'; 00175 const response_str = 'response_str'; 00176 const flow_label = 'flow_label'; 00177 const setvar = 'setvar'; 00178 const action = 'action'; 00179 const and_ = 'and'; 00180 const not_ = 'not'; 00181 const case_ = 'case'; 00182 const varsubstring = 'varsubstring'; 00183 const hint = 'hint'; 00184 const solution = 'solution'; 00185 const feedbackstyle = 'feedbackstyle'; 00186 const solutionmaterial = 'solutionmaterial'; 00187 const hintmaterial = 'hintmaterial'; 00188 } 00189 00190 class cc_question_metadata_base { 00194 protected $metadata = array(); 00195 00200 protected function set_setting($setting, $value = null) { 00201 $this->metadata[$setting] = $value; 00202 } 00203 00208 protected function get_setting($setting) { 00209 $result = null; 00210 if (array_key_exists($setting, $this->metadata)) { 00211 $result = $this->metadata[$setting]; 00212 } 00213 return $result; 00214 } 00215 00221 protected function set_setting_wns($setting, $namespace, $value = null) { 00222 $this->metadata[$setting] = array($namespace => $value); 00223 } 00224 00229 protected function enable_setting_yesno($setting, $value = true) { 00230 $svalue = $value ? cc_qti_values::Yes : cc_qti_values::No; 00231 $this->set_setting($setting, $svalue); 00232 } 00233 00239 public function generate_attributes(XMLGenericDocument &$doc, DOMNode &$item, $namespace) { 00240 foreach ($this->metadata as $attribute => $value) { 00241 if (!is_null($value)) { 00242 if (!is_array($value)) { 00243 $doc->append_new_attribute_ns($item, $namespace, $attribute, $value); 00244 } else { 00245 $ns = key($value); 00246 $nval = current($value); 00247 if (!is_null($nval)) { 00248 $doc->append_new_attribute_ns($item, $ns, $attribute, $nval); 00249 } 00250 } 00251 } 00252 } 00253 } 00254 00260 public function generate(XMLGenericDocument &$doc, DOMNode &$item, $namespace) { 00261 $qtimetadata = $doc->append_new_element_ns($item, $namespace, cc_qti_tags::qtimetadata); 00262 foreach ($this->metadata as $label => $entry) { 00263 if (!is_null($entry)) { 00264 $qtimetadatafield = $doc->append_new_element_ns($qtimetadata, $namespace, cc_qti_tags::qtimetadatafield); 00265 $doc->append_new_element_ns($qtimetadatafield, $namespace, cc_qti_tags::fieldlabel, $label); 00266 $doc->append_new_element_ns($qtimetadatafield, $namespace, cc_qti_tags::fieldentry, $entry); 00267 } 00268 } 00269 } 00270 } 00271 00272 class cc_question_metadata extends cc_question_metadata_base { 00273 00274 public function set_category($value) { 00275 $this->set_setting(cc_qti_metadata::cc_question_category, $value); 00276 } 00277 00278 public function set_weighting($value) { 00279 $this->set_setting(cc_qti_metadata::cc_weighting, $value); 00280 } 00281 00282 public function enable_scoringpermitted($value = true) { 00283 $this->enable_setting_yesno(cc_qti_metadata::qmd_scoringpermitted, $value); 00284 } 00285 00286 public function enable_computerscored($value = true) { 00287 $this->enable_setting_yesno(cc_qti_metadata::qmd_computerscored, $value); 00288 } 00289 00296 public function __construct($profile) { 00297 if (!cc_qti_profiletype::valid($profile)) { 00298 throw new InvalidArgumentException('Invalid profile type!'); 00299 } 00300 $this->set_setting(cc_qti_metadata::cc_profile, $profile); 00301 $this->set_setting(cc_qti_metadata::cc_question_category); 00302 $this->set_setting(cc_qti_metadata::cc_weighting ); 00303 $this->set_setting(cc_qti_metadata::qmd_scoringpermitted); 00304 $this->set_setting(cc_qti_metadata::qmd_computerscored ); 00305 } 00306 } 00307 00308 00309 class cc_assesment_metadata extends cc_question_metadata_base { 00310 00311 public function enable_hints($value = true) { 00312 $this->enable_setting_yesno(cc_qti_metadata::qmd_hintspermitted, $value); 00313 } 00314 00315 public function enable_solutions($value = true) { 00316 $this->enable_setting_yesno(cc_qti_metadata::qmd_solutionspermitted, $value); 00317 } 00318 00319 public function enable_latesubmissions($value = true) { 00320 $this->enable_setting_yesno(cc_qti_metadata::cc_allow_late_submission, $value); 00321 } 00322 00323 public function enable_feedback($value = true) { 00324 $this->enable_setting_yesno(cc_qti_metadata::qmd_feedbackpermitted, $value); 00325 } 00326 00327 public function set_timelimit($value) { 00328 $ivalue = (int)$value; 00329 if (($ivalue < 0) || ($ivalue > 527401)) { 00330 throw new OutOfRangeException('Time limit value out of permitted range!'); 00331 } 00332 00333 $this->set_setting(cc_qti_metadata::qmd_timelimit, $value); 00334 } 00335 00336 public function set_maxattempts($value) { 00337 $valid_values = array(cc_qti_values::Examination, cc_qti_values::unlimited, 1, 2, 3, 4, 5); 00338 if (!in_array($value, $valid_values)) { 00339 throw new OutOfRangeException('Max attempts has invalid value'); 00340 } 00341 00342 $this->set_setting(cc_qti_metadata::cc_maxattempts, $value); 00343 } 00344 00345 public function __construct() { 00346 //prepared default values 00347 $this->set_setting(cc_qti_metadata::cc_profile , cc_qti_values::exam_profile); 00348 $this->set_setting(cc_qti_metadata::qmd_assessmenttype, cc_qti_values::Examination ); 00349 $this->set_setting(cc_qti_metadata::qmd_scoretype , cc_qti_values::Percentage ); 00350 //optional empty values 00351 $this->set_setting(cc_qti_metadata::qmd_feedbackpermitted ); 00352 $this->set_setting(cc_qti_metadata::qmd_hintspermitted ); 00353 $this->set_setting(cc_qti_metadata::qmd_solutionspermitted ); 00354 $this->set_setting(cc_qti_metadata::qmd_timelimit ); 00355 $this->set_setting(cc_qti_metadata::cc_allow_late_submission); 00356 $this->set_setting(cc_qti_metadata::cc_maxattempts ); 00357 } 00358 00359 } 00360 00361 class cc_assesment_mattext extends cc_question_metadata_base { 00362 protected $value = null; 00363 00364 public function __construct($value = null) { 00365 $this->set_setting(cc_qti_tags::texttype, cc_qti_values::texttype); 00366 $this->set_setting(cc_qti_tags::charset);//, 'ascii-us'); 00367 $this->set_setting(cc_qti_tags::label); 00368 $this->set_setting(cc_qti_tags::uri); 00369 $this->set_setting(cc_qti_tags::width); 00370 $this->set_setting(cc_qti_tags::height); 00371 $this->set_setting(cc_qti_tags::x0); 00372 $this->set_setting(cc_qti_tags::y0); 00373 $this->set_setting_wns(cc_qti_tags::xml_lang , cc_xml_namespace::xml); 00374 $this->set_setting_wns(cc_qti_tags::xml_space, cc_xml_namespace::xml);//, 'default'); 00375 $this->value = $value; 00376 } 00377 00378 public function set_label($value) { 00379 $this->set_setting(cc_qti_tags::label, $value); 00380 } 00381 00382 public function set_uri($value) { 00383 $this->set_setting(cc_qti_tags::uri, $value); 00384 } 00385 00386 public function set_width_height($width = null, $height = null) { 00387 $this->set_setting(cc_qti_tags::width, $width); 00388 $this->set_setting(cc_qti_tags::height, $height); 00389 } 00390 00391 public function set_coor($x = null, $y = null) { 00392 $this->set_setting(cc_qti_tags::x0, $x); 00393 $this->set_setting(cc_qti_tags::y0, $y); 00394 } 00395 00396 public function set_lang($lang = null) { 00397 $this->set_setting_wns(cc_qti_tags::xml_lang , cc_xml_namespace::xml, $lang); 00398 } 00399 00400 public function set_content($content, $type = cc_qti_values::texttype, $charset = null) { 00401 $this->value = $content; 00402 $this->set_setting(cc_qti_tags::texttype, $type); 00403 $this->set_setting(cc_qti_tags::charset, $charset); 00404 } 00405 00406 public function generate(XMLGenericDocument &$doc, DOMNode &$item, $namespace) { 00407 $mattext = $doc->append_new_element_ns_cdata($item, $namespace, cc_qti_tags::mattext, $this->value); 00408 $this->generate_attributes($doc, $mattext, $namespace); 00409 } 00410 } 00411 00412 class cc_assesment_matref { 00413 protected $linkref = null; 00414 00415 public function __construct($linkref) { 00416 $this->linkref = $linkref; 00417 } 00418 00419 public function generate(XMLGenericDocument &$doc, DOMNode &$item, $namespace) { 00420 $doc->append_new_element_ns($item, $namespace, cc_qti_tags::matref, $this->linkref); 00421 $doc->append_new_attribute_ns($node, $namespace, cc_qti_tags::linkrefid, $this->linkref); 00422 } 00423 } 00424 00425 class cc_assesment_response_matref extends cc_assesment_matref { 00426 public function generate(XMLGenericDocument &$doc, DOMNode &$item, $namespace) { 00427 $node = $doc->append_new_element_ns($item, $namespace, cc_qti_tags::material_ref); 00428 $doc->append_new_attribute_ns($node, $namespace, cc_qti_tags::linkrefid, $this->linkref); 00429 } 00430 } 00431 00432 class cc_assesment_matbreak { 00433 public function generate(XMLGenericDocument &$doc, DOMNode &$item, $namespace) { 00434 $doc->append_new_element_ns($item, $namespace, cc_qti_tags::matbreak); 00435 } 00436 } 00437 00438 abstract class cc_assesment_material_base extends cc_question_metadata_base { 00442 protected $mattag = null; 00443 protected $tagname = null; 00444 00445 protected function set_tag_value($object) { 00446 $this->mattag = $object; 00447 } 00448 00449 public function set_mattext(cc_assesment_mattext $object) { 00450 $this->set_tag_value($object); 00451 } 00452 00453 public function set_matref(cc_assesment_matref $object) { 00454 $this->set_tag_value($object); 00455 } 00456 00457 public function set_matbreak(cc_assesment_matbreak $object) { 00458 $this->set_tag_value($object); 00459 } 00460 00461 public function set_lang($value) { 00462 $this->set_setting_wns(cc_qti_tags::xml_lang , cc_xml_namespace::xml, $value); 00463 } 00464 00465 public function generate(XMLGenericDocument &$doc, DOMNode &$item, $namespace) { 00466 $material = $doc->append_new_element_ns($item, $namespace, $this->tagname); 00467 $this->generate_attributes($doc, $material, $namespace); 00468 if (!empty($this->mattag)) { 00469 $this->mattag->generate($doc, $material, $namespace); 00470 } 00471 return $material; 00472 } 00473 } 00474 00475 class cc_assesment_altmaterial extends cc_assesment_material_base { 00476 public function __construct($value = null) { 00477 $this->set_setting_wns(cc_qti_tags::xml_lang , cc_xml_namespace::xml); 00478 $this->tagname = cc_qti_tags::altmaterial; 00479 } 00480 } 00481 00482 class cc_assesment_material extends cc_assesment_material_base { 00483 00484 protected $altmaterial = null; 00485 00486 public function __construct($value = null) { 00487 $this->set_setting(cc_qti_tags::label); 00488 $this->set_setting_wns(cc_qti_tags::xml_lang , cc_xml_namespace::xml); 00489 $this->tagname = cc_qti_tags::material; 00490 } 00491 00492 public function set_label($value) { 00493 $this->set_setting(cc_qti_tags::label, $value); 00494 } 00495 00496 public function set_altmaterial(cc_assesment_altmaterial $object) { 00497 $this->altmaterial = $object; 00498 } 00499 00500 public function generate(XMLGenericDocument &$doc, DOMNode &$item, $namespace) { 00501 $material = parent::generate($doc, $item, $namespace); 00502 if (!empty($this->altmaterial)) { 00503 $this->altmaterial->generate($doc, $material, $namespace); 00504 } 00505 } 00506 } 00507 00508 class cc_assesment_rubric_base extends cc_question_metadata_base { 00509 00510 protected $material = null; 00511 00512 public function set_material($object) { 00513 $this->material = $object; 00514 } 00515 00516 public function generate(XMLGenericDocument &$doc, DOMNode &$item, $namespace) { 00517 $rubric = $doc->append_new_element_ns($item, $namespace, cc_qti_tags::rubric); 00518 if (!empty($this->material)) { 00519 $this->material->generate($doc, $rubric, $namespace); 00520 } 00521 } 00522 } 00523 00524 class cc_assesment_presentation_material_base extends cc_question_metadata_base { 00525 protected $flowmats = array(); 00526 00527 public function add_flow_mat($object) { 00528 $this->flowmats[] = $object; 00529 } 00530 00531 public function generate(XMLGenericDocument &$doc, DOMNode &$item, $namespace) { 00532 $node = $doc->append_new_element_ns($item, $namespace, cc_qti_tags::presentation_material); 00533 if (!empty($this->flowmats)) { 00534 foreach ($this->flowmats as $flow_mat) { 00535 $flow_mat->generate($doc, $node, $namespace); 00536 } 00537 } 00538 } 00539 } 00540 00541 class cc_assesment_flow_mat_base extends cc_question_metadata_base { 00542 00543 protected $mattag = null; 00544 00545 protected function set_tag_value($object) { 00546 $this->mattag = $object; 00547 } 00548 00549 public function set_flow_mat(cc_assesment_flow_mat_base $object) { 00550 $this->set_tag_value($object); 00551 } 00552 00553 public function set_material(cc_assesment_material $object) { 00554 $this->set_tag_value($object); 00555 } 00556 00557 public function set_material_ref(cc_assesment_matref $object) { 00558 $this->set_tag_value($object); 00559 } 00560 00561 public function __construct($value = null) { 00562 $this->set_setting(cc_qti_tags::t_class); 00563 } 00564 00565 public function set_class($value) { 00566 $this->set_setting(cc_qti_tags::t_class, $value); 00567 } 00568 00569 public function generate(XMLGenericDocument &$doc, DOMNode &$item, $namespace) { 00570 $node = $doc->append_new_element_ns($item, $namespace, cc_qti_tags::flow_mat); 00571 $this->generate_attributes($doc, $node, $namespace); 00572 if (!empty($this->mattag)) { 00573 $this->mattag->generate($doc, $node, $namespace); 00574 } 00575 } 00576 00577 } 00578 00579 class cc_assesment_section extends cc_question_metadata_base { 00583 protected $items = array(); 00584 00585 public function __construct() { 00586 $this->set_setting(cc_qti_tags::ident, cc_helpers::uuidgen('I_')); 00587 $this->set_setting(cc_qti_tags::title); 00588 $this->set_setting_wns(cc_qti_tags::xml_lang, cc_xml_namespace::xml); 00589 } 00590 00591 public function set_ident($value) { 00592 $this->set_setting(cc_qti_tags::ident, $value); 00593 } 00594 00595 public function set_title($value) { 00596 $this->set_setting(cc_qti_tags::title, $value); 00597 } 00598 00599 public function set_lang($value) { 00600 $this->set_setting_wns(cc_qti_tags::xml_lang, cc_xml_namespace::xml, $value); 00601 } 00602 00603 public function add_item(cc_assesment_section_item $object) { 00604 $this->items[] = $object; 00605 } 00606 00607 public function generate(XMLGenericDocument &$doc, DOMNode &$item, $namespace) { 00608 $node = $doc->append_new_element_ns($item, $namespace, cc_qti_tags::section); 00609 $this->generate_attributes($doc, $node, $namespace); 00610 if (!empty($this->items)) { 00611 foreach ($this->items as $item) { 00612 $item->generate($doc, $node, $namespace); 00613 } 00614 } 00615 } 00616 } 00617 00618 class cc_assesment_itemmetadata extends cc_question_metadata_base { 00619 public function add_metadata($object) { 00620 $this->metadata[] = $object; 00621 } 00622 00623 public function generate(XMLGenericDocument &$doc, DOMNode &$item, $namespace) { 00624 $node = $doc->append_new_element_ns($item, $namespace, cc_qti_tags::itemmetadata); 00625 if (!empty($this->metadata)) { 00626 foreach ($this->metadata as $metaitem) { 00627 $metaitem->generate($doc, $node, $namespace); 00628 } 00629 } 00630 } 00631 } 00632 00633 class cc_assesment_decvartype extends cc_question_metadata_base { 00634 00635 public function __construct() { 00636 $this->set_setting(cc_qti_tags::varname, cc_qti_values::SCORE); 00637 $this->set_setting(cc_qti_tags::vartype, cc_qti_values::Integer); 00638 $this->set_setting(cc_qti_tags::minvalue); 00639 $this->set_setting(cc_qti_tags::maxvalue); 00640 } 00641 00642 public function set_vartype($value) { 00643 $this->set_setting(cc_qti_tags::vartype, $value); 00644 } 00645 00646 public function set_limits($min = null, $max = null) { 00647 $this->set_setting(cc_qti_tags::minvalue, $min); 00648 $this->set_setting(cc_qti_tags::maxvalue, $max); 00649 } 00650 00651 public function generate(XMLGenericDocument &$doc, DOMNode &$item, $namespace) { 00652 $node = $doc->append_new_element_ns($item, $namespace, cc_qti_tags::decvar); 00653 $this->generate_attributes($doc, $node, $namespace); 00654 } 00655 } 00656 00657 00658 class cc_assignment_conditionvar_othertype extends cc_question_metadata_base { 00659 public function generate(XMLGenericDocument &$doc, DOMNode &$item, $namespace) { 00660 $doc->append_new_element_ns($item, $namespace, cc_qti_tags::other); 00661 } 00662 } 00663 00664 class cc_assignment_conditionvar_varequaltype extends cc_question_metadata_base { 00665 protected $tagname = null; 00666 protected $answerid = null; 00667 00668 public function __construct($value = null) { 00669 if (is_null($value)) { 00670 throw new InvalidArgumentException('Must not pass null!'); 00671 } 00672 $this->answerid = $value; 00673 $this->set_setting(cc_qti_tags::respident); 00674 $this->set_setting(cc_qti_tags::case_);//, cc_qti_values::No ); 00675 $this->tagname = cc_qti_tags::varequal; 00676 } 00677 00678 public function set_respident($value) { 00679 $this->set_setting(cc_qti_tags::respident, $value); 00680 } 00681 00682 public function enable_case($value = true) { 00683 $this->enable_setting_yesno(cc_qti_tags::case_, $value); 00684 } 00685 00686 public function generate(XMLGenericDocument &$doc, DOMNode &$item, $namespace) { 00687 $node = $doc->append_new_element_ns($item, $namespace, $this->tagname, $this->answerid); 00688 $this->generate_attributes($doc, $node, $namespace); 00689 } 00690 } 00691 00692 class cc_assignment_conditionvar_varsubstringtype extends cc_assignment_conditionvar_varequaltype { 00693 public function __construct($value) { 00694 parent::__construct($value); 00695 $this->tagname = cc_qti_tags::varsubstring; 00696 } 00697 } 00698 00699 00700 class cc_assignment_conditionvar_andtype extends cc_question_metadata_base { 00701 protected $not = null; 00702 protected $varequal = null; 00703 00704 public function set_not(cc_assignment_conditionvar_varequaltype $object) { 00705 $this->not = $object; 00706 } 00707 00708 public function set_varequal(cc_assignment_conditionvar_varequaltype $object) { 00709 $this->varequal = $object; 00710 } 00711 00712 public function generate(XMLGenericDocument &$doc, DOMNode &$item, $namespace) { 00713 $node = $doc->append_new_element_ns($item, $namespace, cc_qti_tags::and_); 00714 if (!empty($this->not)) { 00715 $not = $doc->append_new_element_ns($node, $namespace, cc_qti_tags::not_); 00716 $this->not->generate($doc, $not, $namespace); 00717 } 00718 00719 if (!empty($this->varequal)) { 00720 $this->varequal->generate($doc, $node, $namespace); 00721 } 00722 } 00723 } 00724 00725 class cc_assignment_conditionvar extends cc_question_metadata_base { 00726 00730 protected $and = null; 00734 protected $other = null; 00738 protected $varequal = null; 00742 protected $varsubstring = null; 00743 00744 public function set_and(cc_assignment_conditionvar_andtype $object) { 00745 $this->and = $object; 00746 } 00747 00748 public function set_other(cc_assignment_conditionvar_othertype $object) { 00749 $this->other = $object; 00750 } 00751 00752 public function set_varequal(cc_assignment_conditionvar_varequaltype $object) { 00753 $this->varequal = $object; 00754 } 00755 00756 public function set_varsubstring(cc_assignment_conditionvar_varsubstringtype $object) { 00757 $this->varsubstring = $object; 00758 } 00759 00760 public function generate(XMLGenericDocument &$doc, DOMNode &$item, $namespace) { 00761 $node = $doc->append_new_element_ns($item, $namespace, cc_qti_tags::conditionvar); 00762 00763 if (!empty($this->and)) { 00764 $this->and->generate($doc, $node, $namespace); 00765 } 00766 00767 if (!empty($this->other)) { 00768 $this->other->generate($doc, $node, $namespace); 00769 } 00770 00771 if (!empty($this->varequal)) { 00772 $this->varequal->generate($doc, $node, $namespace); 00773 } 00774 00775 if (!empty($this->varsubstring)) { 00776 $this->varsubstring->generate($doc, $node, $namespace); 00777 } 00778 } 00779 } 00780 00781 class cc_assignment_displayfeedbacktype extends cc_question_metadata_base { 00782 public function __construct() { 00783 $this->set_setting(cc_qti_tags::feedbacktype); 00784 $this->set_setting(cc_qti_tags::linkrefid); 00785 } 00786 00787 public function set_feedbacktype($value) { 00788 $this->set_setting(cc_qti_tags::feedbacktype, $value); 00789 } 00790 00791 public function set_linkrefid($value) { 00792 $this->set_setting(cc_qti_tags::linkrefid, $value); 00793 } 00794 00795 public function generate(XMLGenericDocument &$doc, DOMNode &$item, $namespace) { 00796 $node = $doc->append_new_element_ns($item, $namespace, cc_qti_tags::displayfeedback); 00797 $this->generate_attributes($doc, $node, $namespace); 00798 } 00799 } 00800 00801 00802 class cc_assignment_setvartype extends cc_question_metadata_base { 00806 protected $tagvalue = null; 00807 00808 public function __construct($tagvalue = 100) { 00809 $this->set_setting(cc_qti_tags::varname, cc_qti_values::SCORE); 00810 $this->set_setting(cc_qti_tags::action , cc_qti_values::Set ); 00811 $this->tagvalue = $tagvalue; 00812 } 00813 00814 public function set_varname($value) { 00815 $this->set_setting(cc_qti_tags::varname, $value); 00816 } 00817 00818 public function generate(XMLGenericDocument &$doc, DOMNode &$item, $namespace) { 00819 $node = $doc->append_new_element_ns($item, $namespace, cc_qti_tags::setvar, $this->tagvalue); 00820 $this->generate_attributes($doc, $node, $namespace); 00821 } 00822 } 00823 00824 class cc_assesment_respconditiontype extends cc_question_metadata_base { 00828 protected $conditionvar = null; 00829 protected $setvar = array(); 00830 protected $displayfeedback = array(); 00831 00832 public function __construct() { 00833 $this->set_setting(cc_qti_tags::title); 00834 $this->set_setting(cc_qti_tags::continue_, cc_qti_values::No); 00835 } 00836 00837 public function set_title($value) { 00838 $this->set_setting(cc_qti_tags::title, $value); 00839 } 00840 00841 public function enable_continue($value = true) { 00842 $this->enable_setting_yesno(cc_qti_tags::continue_, $value); 00843 } 00844 00845 public function set_conditionvar(cc_assignment_conditionvar $object) { 00846 $this->conditionvar = $object; 00847 } 00848 00849 public function add_setvar(cc_assignment_setvartype $object) { 00850 $this->setvar[] = $object; 00851 } 00852 00853 public function add_displayfeedback(cc_assignment_displayfeedbacktype $object) { 00854 $this->displayfeedback[] = $object; 00855 } 00856 00857 public function generate(XMLGenericDocument &$doc, DOMNode &$item, $namespace) { 00858 $node = $doc->append_new_element_ns($item, $namespace, cc_qti_tags::respcondition); 00859 $this->generate_attributes($doc, $node, $namespace); 00860 00861 if (!empty($this->conditionvar)) { 00862 $this->conditionvar->generate($doc, $node, $namespace); 00863 } 00864 00865 if (!empty($this->setvar)) { 00866 foreach ($this->setvar as $setvar) { 00867 $setvar->generate($doc, $node, $namespace); 00868 } 00869 } 00870 00871 if (!empty($this->displayfeedback)) { 00872 foreach ($this->displayfeedback as $displayfeedback) { 00873 $displayfeedback->generate($doc, $node, $namespace); 00874 } 00875 } 00876 } 00877 } 00878 00879 00880 class cc_assesment_resprocessingtype extends cc_question_metadata_base { 00884 protected $decvar = null; 00888 protected $respconditions = array(); 00889 00890 public function set_decvar(cc_assesment_decvartype $object) { 00891 $this->decvar = $object; 00892 } 00893 00894 public function add_respcondition(cc_assesment_respconditiontype $object) { 00895 $this->respconditions[] = $object; 00896 } 00897 00898 public function generate(XMLGenericDocument &$doc, DOMNode &$item, $namespace) { 00899 $node = $doc->append_new_element_ns($item, $namespace, cc_qti_tags::resprocessing); 00900 $outcomes = $doc->append_new_element_ns($node, $namespace, cc_qti_tags::outcomes); 00901 if (!empty($this->decvar)) { 00902 $this->decvar->generate($doc, $outcomes, $namespace); 00903 } 00904 if (!empty($this->respconditions)) { 00905 foreach ($this->respconditions as $rcond) { 00906 $rcond->generate($doc, $node, $namespace); 00907 } 00908 } 00909 } 00910 } 00911 00912 00913 class cc_assesment_itemfeedback_shintmaterial_base extends cc_question_metadata_base { 00917 protected $tagname = null; 00921 protected $flow_mats = array(); 00925 protected $materials = array(); 00926 00930 public function add_flow_mat(cc_assesment_flow_mattype $object) { 00931 $this->flow_mats[] = $object; 00932 } 00933 00937 public function add_material(cc_assesment_material $object) { 00938 $this->materials[] = $object; 00939 } 00940 00941 public function generate(XMLGenericDocument &$doc, DOMNode &$item, $namespace) { 00942 $node = $doc->append_new_element_ns($item, $namespace, $this->tagname); 00943 00944 if (!empty($this->flow_mats)) { 00945 foreach ($this->flow_mats as $flow_mat) { 00946 $flow_mat->generate($doc, $node, $namespace); 00947 } 00948 } 00949 00950 if (!empty($this->materials)) { 00951 foreach ($this->materials as $material) { 00952 $material->generate($doc, $node, $namespace); 00953 } 00954 } 00955 } 00956 } 00957 00958 class cc_assesment_itemfeedback_hintmaterial extends cc_assesment_itemfeedback_shintmaterial_base { 00959 public function __construct() { 00960 $this->tagname = cc_qti_tags::hint; 00961 } 00962 } 00963 00964 class cc_assesment_itemfeedback_solutionmaterial extends cc_assesment_itemfeedback_shintmaterial_base { 00965 public function __construct() { 00966 $this->tagname = cc_qti_tags::solutionmaterial; 00967 } 00968 } 00969 00970 class cc_assesment_itemfeedback_shintype_base extends cc_question_metadata_base { 00974 protected $tagname = null; 00978 protected $items = array(); 00979 00980 public function __construct() { 00981 $this->set_setting(cc_qti_tags::feedbackstyle, cc_qti_values::Complete); 00982 } 00983 00984 public function generate(XMLGenericDocument &$doc, DOMNode &$item, $namespace) { 00985 $node = $doc->append_new_element_ns($item, $namespace, $this->tagname); 00986 $this->generate_attributes($doc, $node, $namespace); 00987 00988 if (!empty($this->items)) { 00989 foreach ($this->items as $telement) { 00990 $telement->generate($doc, $node, $namespace); 00991 } 00992 } 00993 } 00994 } 00995 00996 class cc_assesment_itemfeedback_solutiontype extends cc_assesment_itemfeedback_shintype_base { 00997 public function __construct() { 00998 parent::__construct(); 00999 $this->tagname = cc_qti_tags::solution; 01000 } 01001 01005 public function add_solutionmaterial(cc_assesment_itemfeedback_solutionmaterial $object) { 01006 $this->items[] = $object; 01007 } 01008 } 01009 01010 class cc_assesment_itemfeedbac_hinttype extends cc_assesment_itemfeedback_shintype_base { 01011 public function __construct() { 01012 parent::__construct(); 01013 $this->tagname = cc_qti_tags::hint; 01014 } 01015 01019 public function add_hintmaterial(cc_assesment_itemfeedback_hintmaterial $object) { 01020 $this->items[] = $object; 01021 } 01022 } 01023 01024 class cc_assesment_itemfeedbacktype extends cc_question_metadata_base { 01028 protected $flow_mat = null; 01032 protected $material = null; 01036 protected $solution = null; 01037 protected $hint = null; 01038 01039 public function __construct() { 01040 $this->set_setting(cc_qti_tags::ident, cc_helpers::uuidgen('I_')); 01041 $this->set_setting(cc_qti_tags::title); 01042 } 01043 01047 public function set_ident($value) { 01048 $this->set_setting(cc_qti_tags::ident, $value); 01049 } 01050 01054 public function set_title($value) { 01055 $this->set_setting(cc_qti_tags::title, $value); 01056 } 01057 01061 public function set_flow_mat(cc_assesment_flow_mattype $object) { 01062 $this->flow_mat = $object; 01063 } 01064 01068 public function set_material(cc_assesment_material $object) { 01069 $this->material = $object; 01070 } 01071 01075 public function set_solution(cc_assesment_itemfeedback_solutiontype $object) { 01076 $this->solution = $object; 01077 } 01078 01079 public function set_hint($object) { 01080 $this->hint = $object; 01081 } 01082 01083 public function generate(XMLGenericDocument &$doc, DOMNode &$item, $namespace) { 01084 $node = $doc->append_new_element_ns($item, $namespace, cc_qti_tags::itemfeedback); 01085 $this->generate_attributes($doc, $node, $namespace); 01086 01087 if (!empty($this->flow_mat) && empty($this->material)) { 01088 $this->flow_mat->generate($doc, $node, $namespace); 01089 } 01090 01091 if (!empty($this->material) && empty($this->flow_mat)) { 01092 $this->material->generate($doc, $node, $namespace); 01093 } 01094 01095 if (!empty($this->solution)) { 01096 $this->solution->generate($doc, $node, $namespace); 01097 } 01098 01099 if (!empty($this->itemfeedback)) { 01100 $this->itemfeedback->generate($doc, $node, $namespace); 01101 } 01102 } 01103 } 01104 01105 class cc_assesment_section_item extends cc_assesment_section { 01106 01110 protected $itemmetadata = null; 01114 protected $presentation = null; 01115 protected $resprocessing = array(); 01116 protected $itemfeedback = array(); 01117 01118 public function set_itemmetadata(cc_assesment_itemmetadata $object) { 01119 $this->itemmetadata = $object; 01120 } 01121 01122 public function set_presentation(cc_assesment_presentation $object) { 01123 $this->presentation = $object; 01124 } 01125 01126 public function add_resprocessing(cc_assesment_resprocessingtype $object) { 01127 $this->resprocessing[] = $object; 01128 } 01129 01130 public function add_itemfeedback(cc_assesment_itemfeedbacktype $object) { 01131 $this->itemfeedback[] = $object; 01132 } 01133 01134 public function generate(XMLGenericDocument &$doc, DOMNode &$item, $namespace) { 01135 $node = $doc->append_new_element_ns($item, $namespace, cc_qti_tags::item); 01136 $this->generate_attributes($doc, $node, $namespace); 01137 01138 if (!empty($this->itemmetadata)) { 01139 $this->itemmetadata->generate($doc, $node, $namespace); 01140 } 01141 01142 if (!empty($this->presentation)) { 01143 $this->presentation->generate($doc, $node, $namespace); 01144 } 01145 01146 if (!empty($this->resprocessing)) { 01147 foreach ($this->resprocessing as $resprocessing) { 01148 $resprocessing->generate($doc, $node, $namespace); 01149 } 01150 } 01151 01152 if (!empty($this->itemfeedback)) { 01153 foreach ($this->itemfeedback as $itemfeedback) { 01154 $itemfeedback->generate($doc, $node, $namespace); 01155 } 01156 } 01157 } 01158 } 01159 01160 class cc_assesment_render_choicetype extends cc_question_metadata_base { 01164 protected $materials = array(); 01165 01169 protected $material_refs = array(); 01170 01174 protected $response_labels = array(); 01178 protected $flow_labels = array(); 01179 01180 public function __construct() { 01181 $this->set_setting(cc_qti_tags::shuffle, cc_qti_values::No); 01182 $this->set_setting(cc_qti_tags::minnumber); 01183 $this->set_setting(cc_qti_tags::maxnumber); 01184 } 01185 01186 public function add_material(cc_assesment_material $object) { 01187 $this->materials[] = $object; 01188 } 01189 01190 public function add_material_ref(cc_assesment_response_matref $object) { 01191 $this->material_refs[] = $object; 01192 } 01193 01194 public function add_response_label(cc_assesment_response_labeltype $object) { 01195 $this->response_labels[] = $object; 01196 } 01197 01198 public function add_flow_label($object) { 01199 $this->flow_labels[] = $object; 01200 } 01201 01202 public function enable_shuffle($value = true) { 01203 $this->enable_setting_yesno(cc_qti_tags::shuffle, $value); 01204 } 01205 01206 public function set_limits($min = null, $max = null) { 01207 $this->set_setting(cc_qti_tags::minnumber, $min); 01208 $this->set_setting(cc_qti_tags::maxnumber, $max); 01209 } 01210 01211 public function generate(XMLGenericDocument &$doc, DOMNode &$item, $namespace) { 01212 $node = $doc->append_new_element_ns($item, $namespace, cc_qti_tags::render_choice); 01213 $this->generate_attributes($doc, $node, $namespace); 01214 01215 if (!empty($this->materials)) { 01216 foreach ($this->materials as $mattag) { 01217 $mattag->generate($doc, $node, $namespace); 01218 } 01219 } 01220 01221 if (!empty($this->material_refs)) { 01222 foreach ($this->material_refs as $matreftag) { 01223 $matreftag->generate($doc, $node, $namespace); 01224 } 01225 } 01226 01227 if (!empty($this->response_labels)) { 01228 foreach ($this->response_labels as $resplabtag) { 01229 $resplabtag->generate($doc, $node, $namespace); 01230 } 01231 } 01232 01233 if (!empty($this->flow_labels)) { 01234 foreach ($this->flow_labels as $flowlabtag) { 01235 $flowlabtag->generate($doc, $node, $namespace); 01236 } 01237 } 01238 } 01239 01240 } 01241 01242 class cc_assesment_flow_mattype extends cc_question_metadata_base { 01243 01247 protected $material = null; 01251 protected $material_ref = null; 01255 protected $flow_mat = null; 01256 01257 public function __construct() { 01258 $this->set_setting(cc_qti_tags::t_class); 01259 } 01260 01261 public function set_class($value) { 01262 $this->set_setting(cc_qti_tags::t_class, $value); 01263 } 01264 01265 public function set_material(cc_assesment_material $object) { 01266 $this->material = $object; 01267 } 01268 01269 public function set_material_ref(cc_assesment_response_matref $object) { 01270 $this->material_ref = $object; 01271 } 01272 01273 public function set_flow_mat(cc_assesment_flow_mattype $object) { 01274 $this->flow_mat = $object; 01275 } 01276 01277 public function generate(XMLGenericDocument &$doc, DOMNode &$item, $namespace) { 01278 $node = $doc->append_new_element_ns($item, $namespace, cc_qti_tags::flow_mat); 01279 $this->generate_attributes($doc, $node, $namespace); 01280 01281 if (!empty($this->flow_mat)) { 01282 $this->flow_mat->generate($doc, $node, $namespace); 01283 } 01284 01285 if (!empty($this->material)) { 01286 $this->material->generate($doc, $node, $namespace); 01287 } 01288 01289 if (!empty($this->material_ref)) { 01290 $this->material_ref->generate($doc, $node, $namespace); 01291 } 01292 } 01293 } 01294 01295 class cc_assesment_response_labeltype extends cc_question_metadata_base { 01299 protected $material = null; 01300 01304 protected $material_ref = null; 01305 01309 protected $flow_mat = null; 01310 01311 public function __construct() { 01312 $this->set_setting(cc_qti_tags::ident, cc_helpers::uuidgen('I_')); 01313 $this->set_setting(cc_qti_tags::labelrefid); 01314 $this->set_setting(cc_qti_tags::rshuffle); 01315 $this->set_setting(cc_qti_tags::match_group); 01316 $this->set_setting(cc_qti_tags::match_max); 01317 } 01318 01319 public function set_ident($value) { 01320 $this->set_setting(cc_qti_tags::ident, $value); 01321 } 01322 01323 public function get_ident() { 01324 return $this->get_setting(cc_qti_tags::ident); 01325 } 01326 01327 public function set_labelrefid($value) { 01328 $this->set_setting(cc_qti_tags::labelrefid, $value); 01329 } 01330 01331 public function enable_rshuffle($value = true) { 01332 $this->enable_setting_yesno(cc_qti_tags::rshuffle, $value); 01333 } 01334 01335 public function set_match_group($value) { 01336 $this->set_setting(cc_qti_tags::match_group, $value); 01337 } 01338 01339 public function set_match_max($value) { 01340 $this->set_setting(cc_qti_tags::match_max, $value); 01341 } 01342 01343 public function set_material(cc_assesment_material $object) { 01344 $this->material = $object; 01345 } 01346 01347 public function set_material_ref(cc_assesment_response_matref $object) { 01348 $this->material_ref = $object; 01349 } 01350 01351 public function set_flow_mat(cc_assesment_flow_mattype $object) { 01352 $this->flow_mat = $object; 01353 } 01354 01355 public function generate(XMLGenericDocument &$doc, DOMNode &$item, $namespace) { 01356 $node = $doc->append_new_element_ns($item, $namespace, cc_qti_tags::response_label); 01357 $this->generate_attributes($doc, $node, $namespace); 01358 01359 if (!empty($this->material)) { 01360 $this->material->generate($doc, $node, $namespace); 01361 } 01362 01363 if (!empty($this->material_ref)) { 01364 $this->material_ref->generate($doc, $node, $namespace); 01365 } 01366 01367 if (!empty($this->flow_mat)) { 01368 $this->flow_mat->generate($doc, $node, $namespace); 01369 } 01370 } 01371 } 01372 01373 class cc_assesment_flow_labeltype extends cc_question_metadata_base { 01377 protected $flow_label = null; 01381 protected $response_label = null; 01382 01383 public function __construct() { 01384 $this->set_setting(cc_qti_tags::t_class); 01385 } 01386 01387 public function set_class($value) { 01388 $this->set_setting(cc_qti_tags::t_class, $value); 01389 } 01390 01391 public function set_flow_label(cc_assesment_flow_labeltype $object) { 01392 $this->flow_label = $object; 01393 } 01394 01395 public function set_response_label(cc_assesment_response_labeltype $object) { 01396 $this->response_label = $object; 01397 } 01398 01399 public function generate(XMLGenericDocument &$doc, DOMNode &$item, $namespace) { 01400 $node = $doc->append_new_element_ns($item, $namespace, cc_qti_tags::flow_label); 01401 $this->generate_attributes($doc, $node, $namespace); 01402 01403 if (!empty($this->material)) { 01404 $this->material->generate($doc, $node, $namespace); 01405 } 01406 01407 if (!empty($this->material_ref)) { 01408 $this->material_ref->generate($doc, $node, $namespace); 01409 } 01410 01411 if (!empty($this->response_label)) { 01412 $this->response_label->generate($doc, $node, $namespace); 01413 } 01414 01415 if (!empty($this->flow_label)) { 01416 $this->flow_label->generate($doc, $node, $namespace); 01417 } 01418 } 01419 01420 } 01421 01422 01423 class cc_assesment_render_fibtype extends cc_question_metadata_base { 01427 protected $material = null; 01428 01432 protected $material_ref = null; 01436 protected $response_label = null; 01442 protected $flow_label = null; 01443 01444 01445 public function __construct() { 01446 $this->set_setting(cc_qti_tags::encoding ); 01447 $this->set_setting(cc_qti_tags::charset ); 01448 $this->set_setting(cc_qti_tags::rows ); 01449 $this->set_setting(cc_qti_tags::columns ); 01450 $this->set_setting(cc_qti_tags::maxchars ); 01451 $this->set_setting(cc_qti_tags::minnumber); 01452 $this->set_setting(cc_qti_tags::maxnumber); 01453 $this->set_setting(cc_qti_tags::prompt, cc_qti_values::Box); 01454 $this->set_setting(cc_qti_tags::fibtype, cc_qti_values::String); 01455 } 01456 01457 public function set_encoding($value) { 01458 $this->set_setting(cc_qti_tags::encoding, $value); 01459 } 01460 public function set_charset($value) { 01461 $this->set_setting(cc_qti_tags::charset, $value); 01462 } 01463 01464 public function set_rows($value) { 01465 $this->set_setting(cc_qti_tags::rows, $value); 01466 } 01467 01468 public function set_columns($value) { 01469 $this->set_setting(cc_qti_tags::columns, $value); 01470 } 01471 01472 public function set_maxchars($value) { 01473 $this->set_setting(cc_qti_tags::columns, $value); 01474 } 01475 01476 public function set_limits($min = null, $max = null) { 01477 $this->set_setting(cc_qti_tags::minnumber, $min); 01478 $this->set_setting(cc_qti_tags::maxnumber, $max); 01479 } 01480 01481 public function set_prompt($value) { 01482 $this->set_setting(cc_qti_tags::prompt, $value); 01483 } 01484 01485 public function set_fibtype($value) { 01486 $this->set_setting(cc_qti_tags::fibtype, $value); 01487 } 01488 01489 public function set_material(cc_assesment_material $object) { 01490 $this->material = $object; 01491 } 01492 01493 public function set_material_ref(cc_assesment_response_matref $object) { 01494 $this->material_ref = $object; 01495 } 01496 01497 public function set_response_label(cc_assesment_response_labeltype $object) { 01498 $this->response_label = $object; 01499 } 01500 01501 public function set_flow_label($object) { 01502 $this->flow_label = $object; 01503 } 01504 01505 public function generate(XMLGenericDocument &$doc, DOMNode &$item, $namespace) { 01506 $node = $doc->append_new_element_ns($item, $namespace, cc_qti_tags::render_fib); 01507 $this->generate_attributes($doc, $node, $namespace); 01508 01509 if (!empty($this->material) && empty($this->material_ref)) { 01510 $this->material->generate($doc, $node, $namespace); 01511 } 01512 01513 if (!empty($this->material_ref) && empty($this->material)) { 01514 $this->material_ref->generate($doc, $node, $namespace); 01515 } 01516 01517 if (!empty($this->response_label)) { 01518 $this->response_label->generate($doc, $node, $namespace); 01519 } 01520 01521 if (!empty($this->flow_label)) { 01522 $this->flow_label->generate($doc, $node, $namespace); 01523 } 01524 } 01525 } 01526 01527 class cc_response_lidtype extends cc_question_metadata_base { 01531 protected $tagname = null; 01535 protected $material = null; 01536 01540 protected $material_ref = null; 01541 01545 protected $render_choice = null; 01546 01550 protected $render_fib = null; 01551 01552 public function __construct() { 01553 $this->set_setting(cc_qti_tags::rcardinality, cc_qti_values::Single); 01554 $this->set_setting(cc_qti_tags::rtiming); 01555 $this->set_setting(cc_qti_tags::ident, cc_helpers::uuidgen('I_')); 01556 $this->tagname = cc_qti_tags::response_lid; 01557 } 01558 01559 public function set_rcardinality($value) { 01560 $this->set_setting(cc_qti_tags::rcardinality, $value); 01561 } 01562 01563 public function enable_rtiming($value = true) { 01564 $this->enable_setting_yesno(cc_qti_tags::rtiming, $value); 01565 } 01566 01567 public function set_ident($value) { 01568 $this->set_setting(cc_qti_tags::ident, $value); 01569 } 01570 01571 public function get_ident() { 01572 return $this->get_setting(cc_qti_tags::ident); 01573 } 01574 01575 public function set_material_ref(cc_assesment_response_matref $object) { 01576 $this->material_ref = $object; 01577 } 01578 01579 public function set_material(cc_assesment_material $object) { 01580 $this->material = $object; 01581 } 01582 01583 public function set_render_choice(cc_assesment_render_choicetype $object) { 01584 $this->render_choice = $object; 01585 } 01586 01587 public function set_render_fib(cc_assesment_render_fibtype $object) { 01588 $this->render_fib = $object; 01589 } 01590 01591 public function generate(XMLGenericDocument &$doc, DOMNode &$item, $namespace) { 01592 $node = $doc->append_new_element_ns($item, $namespace, $this->tagname); 01593 $this->generate_attributes($doc, $node, $namespace); 01594 01595 if (!empty($this->material) && empty($this->material_ref)) { 01596 $this->material->generate($doc, $node, $namespace); 01597 } 01598 01599 if (!empty($this->material_ref) && empty($this->material)) { 01600 $this->material_ref->generate($doc, $node, $namespace); 01601 } 01602 01603 if (!empty($this->render_choice) && empty($this->render_fib)) { 01604 $this->render_choice->generate($doc, $node, $namespace); 01605 } 01606 01607 if (!empty($this->render_fib) && empty($this->render_choice)) { 01608 $this->render_fib->generate($doc, $node, $namespace); 01609 } 01610 } 01611 } 01612 01613 class cc_assesment_response_strtype extends cc_response_lidtype { 01614 public function __construct() { 01615 $rtt = parent::__construct(); 01616 $this->tagname = cc_qti_tags::response_str; 01617 } 01618 } 01619 01620 class cc_assesment_flowtype extends cc_question_metadata_base { 01624 protected $flow = null; 01628 protected $material = null; 01632 protected $material_ref = null; 01636 protected $response_lid = null; 01640 protected $response_str = null; 01641 01642 public function __construct() { 01643 $this->set_setting(cc_qti_tags::t_class); 01644 } 01645 01646 public function set_class($value) { 01647 $this->set_setting(cc_qti_tags::t_class, $value); 01648 } 01649 01650 public function set_flow(cc_assesment_flowtype $object) { 01651 $this->flow = $object; 01652 } 01653 01654 public function set_material(cc_assesment_material $object) { 01655 $this->material = $object; 01656 } 01657 01658 public function set_material_ref(cc_assesment_response_matref $object) { 01659 $this->material_ref = $object; 01660 } 01661 01662 public function set_response_lid(cc_response_lidtype $object) { 01663 $this->response_lid = $object; 01664 } 01665 01666 public function set_response_str(cc_assesment_response_strtype $object) { 01667 $this->response_str = $object; 01668 } 01669 01670 public function generate(XMLGenericDocument &$doc, DOMNode &$item, $namespace) { 01671 $node = $doc->append_new_element_ns($item, $namespace, cc_qti_tags::flow); 01672 $this->generate_attributes($doc, $node, $namespace); 01673 01674 if (!empty($this->flow)) { 01675 $this->flow->generate($doc, $node, $namespace); 01676 } 01677 01678 if (!empty($this->material)) { 01679 $this->material->generate($doc, $node, $namespace); 01680 } 01681 01682 if (!empty($this->response_lid)) { 01683 $this->response_lid->generate($doc, $node, $namespace); 01684 } 01685 01686 if (!empty($this->response_str)) { 01687 $this->response_str->generate($doc, $node, $namespace); 01688 } 01689 } 01690 } 01691 01692 class cc_assesment_presentation extends cc_question_metadata_base { 01696 protected $flow = null; 01700 protected $material = null; 01704 protected $response_lid = null; 01708 protected $response_str = null; 01709 01710 public function __construct() { 01711 $this->set_setting(cc_qti_tags::label); 01712 $this->set_setting_wns(cc_qti_tags::xml_lang , cc_xml_namespace::xml); 01713 $this->set_setting(cc_qti_tags::x0); 01714 $this->set_setting(cc_qti_tags::y0); 01715 $this->set_setting(cc_qti_tags::width); 01716 $this->set_setting(cc_qti_tags::height); 01717 } 01718 01719 public function set_label($value) { 01720 $this->set_setting(cc_qti_tags::label, $value); 01721 } 01722 01723 public function set_lang($value) { 01724 $this->set_setting_wns(cc_qti_tags::xml_lang , cc_xml_namespace::xml, $value); 01725 } 01726 01727 public function set_coor($x = null, $y = null) { 01728 $this->set_setting(cc_qti_tags::x0, $x); 01729 $this->set_setting(cc_qti_tags::y0, $y); 01730 } 01731 01732 public function set_size($width = null, $height = null) { 01733 $this->set_setting(cc_qti_tags::width, $width); 01734 $this->set_setting(cc_qti_tags::height, $height); 01735 } 01736 01737 public function set_flow(cc_assesment_flowtype $object) { 01738 $this->flow = $object; 01739 } 01740 01741 public function set_material(cc_assesment_material $object) { 01742 $this->material = $object; 01743 } 01744 01745 public function set_response_lid(cc_response_lidtype $object) { 01746 $this->response_lid = $object; 01747 } 01748 01749 public function set_response_str(cc_assesment_response_strtype $object) { 01750 $this->response_str = $object; 01751 } 01752 01753 public function generate(XMLGenericDocument &$doc, DOMNode &$item, $namespace) { 01754 $node = $doc->append_new_element_ns($item, $namespace, cc_qti_tags::presentation); 01755 $this->generate_attributes($doc, $node, $namespace); 01756 01757 if (!empty($this->flow)) { 01758 $this->flow->generate($doc, $node, $namespace); 01759 } 01760 01761 if (!empty($this->material) && empty($this->flow)) { 01762 $this->material->generate($doc, $node, $namespace); 01763 } 01764 01765 if (!empty($this->response_lid) && empty($this->flow)) { 01766 $this->response_lid->generate($doc, $node, $namespace); 01767 } 01768 01769 if (!empty($this->response_str) && empty($this->flow)) { 01770 $this->response_str->generate($doc, $node, $namespace); 01771 } 01772 } 01773 } 01774 01775 class assesment1_resurce_file extends general_cc_file { 01776 const deafultname = 'assesment.xml'; 01777 01778 protected $rootns = 'xmlns'; 01779 protected $rootname = cc_qti_tags::questestinterop; 01780 protected $ccnamespaces = array('xmlns' => 'http://www.imsglobal.org/xsd/ims_qtiasiv1p2', 01781 'xsi' => 'http://www.w3.org/2001/XMLSchema-instance'); 01782 protected $ccnsnames = array('xmlns' => 'http://www.imsglobal.org/profile/cc/ccv1p0/derived_schema/domainProfile_4/ims_qtiasiv1p2_localised.xsd'); 01783 01787 protected $assessment_title = 'Untitled'; 01791 protected $metadata = null; 01795 protected $rubric = null; 01796 01800 protected $presentation_material = null; 01801 01805 protected $section = null; 01806 01807 public function set_metadata(cc_assesment_metadata $object) { 01808 $this->metadata = $object; 01809 } 01810 01811 public function set_rubric(cc_assesment_rubric_base $object) { 01812 $this->rubric = $object; 01813 } 01814 01815 public function set_presentation_material(cc_assesment_presentation_material_base $object) { 01816 $this->presentation_material = $object; 01817 } 01818 01819 public function set_section(cc_assesment_section $object) { 01820 $this->section = $object; 01821 } 01822 01823 public function set_title($value) { 01824 $this->assessment_title = self::safexml($value); 01825 } 01826 01827 protected function on_save() { 01828 $rns = $this->ccnamespaces[$this->rootns]; 01829 //root assesment element - required 01830 $assessment = $this->append_new_element_ns($this->root, $rns, cc_qti_tags::assessment); 01831 $this->append_new_attribute_ns($assessment, $rns, cc_qti_tags::ident, cc_helpers::uuidgen('QDB_')); 01832 $this->append_new_attribute_ns($assessment, $rns, cc_qti_tags::title, $this->assessment_title); 01833 01834 //metadata - optional 01835 if (!empty($this->metadata)) { 01836 $this->metadata->generate($this, $assessment, $rns); 01837 } 01838 01839 //rubric - optional 01840 if (!empty($this->rubric)) { 01841 $this->rubric->generate($this, $assessment, $rns); 01842 } 01843 01844 //presentation_material - optional 01845 if (!empty($this->presentation_material)) { 01846 $this->presentation_material->generate($this, $assessment, $rns); 01847 } 01848 01849 //section - required 01850 if (!empty($this->section)) { 01851 $this->section->generate($this, $assessment, $rns); 01852 } 01853 01854 return true; 01855 } 01856 } 01857 01858 01859 class assesment11_resurce_file extends assesment1_resurce_file { 01860 protected $ccnsnames = array('xmlns' => 'http://www.imsglobal.org/profile/cc/ccv1p1/ccv1p1_qtiasiv1p2p1_v1p0.xsd'); 01861 } 01862 01863 abstract class cc_assesment_helper { 01864 01865 public static $correct_fb = null; 01866 public static $incorrect_fb = null; 01867 01868 public static function add_feedback($qitem, $content, $content_type, $ident) { 01869 if (empty($content)) { 01870 return false; 01871 } 01872 $qitemfeedback = new cc_assesment_itemfeedbacktype(); 01873 $qitem->add_itemfeedback($qitemfeedback); 01874 if (!empty($ident)) { 01875 $qitemfeedback->set_ident($ident); 01876 } 01877 $qflowmat = new cc_assesment_flow_mattype(); 01878 $qitemfeedback->set_flow_mat($qflowmat); 01879 $qmaterialfb = new cc_assesment_material(); 01880 $qflowmat->set_material($qmaterialfb); 01881 $qmattext = new cc_assesment_mattext(); 01882 $qmaterialfb->set_mattext($qmattext); 01883 $qmattext->set_content($content, $content_type); 01884 return true; 01885 } 01886 01887 public static function add_answer($qresponse_choice, $content, $content_type) { 01888 $qresponse_label = new cc_assesment_response_labeltype(); 01889 $qresponse_choice->add_response_label($qresponse_label); 01890 $qrespmaterial = new cc_assesment_material(); 01891 $qresponse_label->set_material($qrespmaterial); 01892 $qrespmattext = new cc_assesment_mattext(); 01893 $qrespmaterial->set_mattext($qrespmattext); 01894 $qrespmattext->set_content($content, $content_type); 01895 return $qresponse_label; 01896 } 01897 01898 public static function add_response_condition() { 01899 01900 } 01901 01902 public static function add_assesment_description($rt, $content, $contenttype) { 01903 if (empty($rt) || empty($content)) { 01904 return; 01905 } 01906 $activity_rubric = new cc_assesment_rubric_base(); 01907 $rubric_material = new cc_assesment_material(); 01908 $activity_rubric->set_material($rubric_material); 01909 $rubric_mattext = new cc_assesment_mattext(); 01910 $rubric_material->set_label('Summary'); 01911 $rubric_material->set_mattext($rubric_mattext); 01912 $rubric_mattext->set_content($content, $contenttype); 01913 $rt->set_rubric($activity_rubric); 01914 } 01915 01926 public static function process_questions(&$qdoc, &$manifest, cc_assesment_section &$section, $rootpath, $contextid, $outdir) { 01927 $question_file = $rootpath . DIRECTORY_SEPARATOR . 'questions.xml'; 01928 //load questions file 01929 $questions = new XMLGenericDocument(); 01930 if (!$questions->load($question_file)) { 01931 return false; 01932 } 01933 01934 pkg_resource_dependencies::instance()->reset(); 01935 01936 $qids = explode(',', $qdoc->nodeValue('/activity/quiz/questions')); 01937 foreach ($qids as $value) { 01938 if (intval($value) == 0) { 01939 continue; 01940 } 01941 $question_node = $questions->node("//question_category/questions/question[@id='{$value}']"); 01942 if (empty($question_node)) { 01943 continue; 01944 } 01945 //process question 01946 //question type 01947 $qtype = $questions->nodeValue('qtype', $question_node); 01948 $question_processor = null; 01949 switch ($qtype) { 01950 case 'multichoice': 01951 $single_correct_answer = (int)$questions->nodeValue('plugin_qtype_multichoice_question/multichoice/single', $question_node) > 0; 01952 if ($single_correct_answer) { 01953 $question_processor = new cc_assesment_question_multichoice($qdoc, $questions, $manifest, $section, $question_node, $rootpath, $contextid, $outdir); 01954 $question_processor->generate(); 01955 } else { 01956 //TODO: implement 01957 } 01958 ; 01959 break; 01960 01961 default: 01962 ; 01963 break; 01964 } 01965 01966 } 01967 01968 //return dependencies 01969 return pkg_resource_dependencies::instance()->get_deps(); 01970 } 01971 01972 } 01973 01974 class cc_assesment_question_proc_base { 01978 protected $quiz = null; 01979 01983 protected $questions = null; 01984 01988 protected $manifest = null; 01989 01993 protected $section = null; 01994 01998 protected $question_node = null; 01999 02003 protected $rootpath = null; 02004 02008 protected $contextid = null; 02009 02013 protected $outdir = null; 02014 02018 protected $qtype = null; 02019 02023 protected $qmetadata = null; 02024 02028 protected $qitem = null; 02029 02033 protected $qpresentation = null; 02034 02038 protected $qresponse_lid = null; 02039 02040 protected $qresprocessing = null; 02041 02042 protected $correct_grade_value = null; 02043 protected $correct_answer_node_id = null; 02044 protected $correct_answer_ident = null; 02045 02046 protected $total_grade_value = null; 02047 02048 protected $answerlist = null; 02049 02050 protected $general_feedback = null; 02051 protected $correct_feedbacks = array(); 02052 protected $incorrect_feedbacks = array(); 02053 02063 public function __construct(XMLGenericDocument &$quiz, XMLGenericDocument &$questions, cc_manifest &$manifest, cc_assesment_section &$section, &$question_node, $rootpath, $contextid, $outdir) { 02064 $this->quiz = $quiz; 02065 $this->questions = $questions; 02066 $this->manifest = $manifest; 02067 $this->section = $section; 02068 $this->question_node = $question_node; 02069 $this->rootpath = $rootpath; 02070 $this->contextid = $contextid; 02071 $this->outdir = $outdir; 02072 02073 // 02074 $qitem = new cc_assesment_section_item(); 02075 $this->section->add_item($qitem); 02076 $qitem->set_title($this->questions->nodeValue('name', $this->question_node)); 02077 $this->qitem = $qitem; 02078 } 02079 02080 public function on_generate_metadata() { 02081 if (empty($this->qmetadata)) { 02082 $this->qmetadata = new cc_question_metadata($this->qtype); 02083 //Get weighting value 02084 $weighting_value = (int)$this->questions->nodeValue('defaultmark', $this->question_node); 02085 if ($weighting_value > 1) { 02086 $this->qmetadata->set_weighting($weighting_value); 02087 } 02088 $rts = new cc_assesment_itemmetadata(); 02089 $rts->add_metadata($this->qmetadata); 02090 $this->qitem->set_itemmetadata($rts); 02091 } 02092 } 02093 02094 public function on_generate_presentation() { 02095 if (empty($this->qpresentation)) { 02096 $qpresentation = new cc_assesment_presentation(); 02097 $this->qitem->set_presentation($qpresentation); 02098 //add question text 02099 $qmaterial = new cc_assesment_material(); 02100 $qmattext = new cc_assesment_mattext(); 02101 $question_text = $this->questions->nodeValue('questiontext', $this->question_node); 02102 $result = cc_helpers::process_linked_files( $question_text, 02103 $this->manifest, 02104 $this->rootpath, 02105 $this->contextid, 02106 $this->outdir); 02107 $qmattext->set_content($result[0], cc_qti_values::htmltype); 02108 $qmaterial->set_mattext($qmattext); 02109 $qpresentation->set_material($qmaterial); 02110 $this->qpresentation = $qpresentation; 02111 pkg_resource_dependencies::instance()->add($result[1]); 02112 } 02113 } 02114 02115 public function on_generate_answers() {} 02116 public function on_generate_feedbacks() { 02117 $general_question_feedback = $this->questions->nodeValue('generalfeedback', $this->question_node); 02118 if (empty($general_question_feedback)) { 02119 return; 02120 } 02121 $name = 'general_fb'; 02122 //Add question general feedback - the one that should be always displayed 02123 $result = cc_helpers::process_linked_files( $general_question_feedback, 02124 $this->manifest, 02125 $this->rootpath, 02126 $this->contextid, 02127 $this->outdir); 02128 02129 cc_assesment_helper::add_feedback($this->qitem, 02130 $result[0], 02131 cc_qti_values::htmltype, 02132 $name); 02133 pkg_resource_dependencies::instance()->add($result[1]); 02134 $this->general_feedback = $name; 02135 } 02136 02137 public function on_generate_response_processing() { 02138 02139 $qresprocessing = new cc_assesment_resprocessingtype(); 02140 $this->qitem->add_resprocessing($qresprocessing); 02141 $qdecvar = new cc_assesment_decvartype(); 02142 $qresprocessing->set_decvar($qdecvar); 02143 //according to the Common Cartridge 1.1 Profile: Implementation document 02144 //this should always be set to 0, 100 in case of question type that is not essay 02145 $qdecvar->set_limits(0,100); 02146 $qdecvar->set_vartype(cc_qti_values::Decimal); 02147 02148 $this->qresprocessing = $qresprocessing; 02149 02150 } 02151 02152 public function generate() { 02153 $this->on_generate_metadata(); 02154 02155 $this->on_generate_presentation(); 02156 02157 $this->on_generate_answers(); 02158 02159 $this->on_generate_feedbacks(); 02160 02161 $this->on_generate_response_processing(); 02162 } 02163 02164 } 02165 02166 class cc_assesment_question_multichoice extends cc_assesment_question_proc_base { 02167 public function __construct($quiz, $questions, $manifest, $section, $question_node, $rootpath, $contextid, $outdir) { 02168 parent::__construct($quiz, $questions, $manifest, $section, $question_node, $rootpath, $contextid, $outdir); 02169 $this->qtype = cc_qti_profiletype::multiple_choice; 02170 02179 $correct_answer_node = $this->questions->node("plugin_qtype_multichoice_question/answers/answer[fraction!=0.0000000]", $this->question_node); 02180 if (empty($correct_answer_node)) { 02181 throw new RuntimeException('No correct answer!'); 02182 } 02183 $this->correct_answer_node_id = $this->questions->nodeValue('@id', $correct_answer_node); 02184 $maximum_quiz_grade = (int)$this->quiz->nodeValue('/activity/quiz/grade'); 02185 $this->total_grade_value = ($maximum_quiz_grade + 1).'.0000000'; 02186 } 02187 02188 public function on_generate_answers() { 02189 //add responses holder 02190 $qresponse_lid = new cc_response_lidtype(); 02191 $this->qresponse_lid = $qresponse_lid; 02192 $this->qpresentation->set_response_lid($qresponse_lid); 02193 $qresponse_choice = new cc_assesment_render_choicetype(); 02194 $qresponse_lid->set_render_choice($qresponse_choice); 02195 //Mark that question has only one correct answer - 02196 //which applies for multiple choice and yes/no questions 02197 $qresponse_lid->set_rcardinality(cc_qti_values::Single); 02198 //are we to shuffle the responses? 02199 $shuffle_answers = (int)$this->quiz->nodeValue('/activity/quiz/shuffleanswers') > 0; 02200 $qresponse_choice->enable_shuffle($shuffle_answers); 02201 $answerlist = array(); 02202 $qa_responses = $this->questions->nodeList('plugin_qtype_multichoice_question/answers/answer', $this->question_node); 02203 foreach ($qa_responses as $node) { 02204 $answer_content = $this->questions->nodeValue('answertext', $node); 02205 $id = ((int)$this->questions->nodeValue('@id', $node) == $this->correct_answer_node_id); 02206 $result = cc_helpers::process_linked_files( $answer_content, 02207 $this->manifest, 02208 $this->rootpath, 02209 $this->contextid, 02210 $this->outdir); 02211 $qresponse_label = cc_assesment_helper::add_answer( $qresponse_choice, 02212 $result[0], 02213 cc_qti_values::htmltype); 02214 pkg_resource_dependencies::instance()->add($result[1]); 02215 $answer_ident = $qresponse_label->get_ident(); 02216 $feedback_ident = $answer_ident.'_fb'; 02217 if (empty($this->correct_answer_ident) && $id) { 02218 $this->correct_answer_ident = $answer_ident; 02219 } 02220 //add answer specific feedbacks if not empty 02221 $content = $this->questions->nodeValue('feedback', $node); 02222 if (!empty($content)) { 02223 $result = cc_helpers::process_linked_files( $content, 02224 $this->manifest, 02225 $this->rootpath, 02226 $this->contextid, 02227 $this->outdir); 02228 02229 02230 cc_assesment_helper::add_feedback( $this->qitem, 02231 $result[0], 02232 cc_qti_values::htmltype, 02233 $feedback_ident); 02234 02235 pkg_resource_dependencies::instance()->add($result[1]); 02236 02237 $answerlist[$answer_ident] = $feedback_ident; 02238 } 02239 } 02240 02241 $this->answerlist = $answerlist; 02242 02243 } 02244 02245 public function on_generate_feedbacks() { 02246 parent::on_generate_feedbacks(); 02247 //Question combined feedbacks 02248 $correct_question_fb = $this->questions->nodeValue('plugin_qtype_multichoice_question/multichoice/correctfeedback', $this->question_node); 02249 $incorrect_question_fb = $this->questions->nodeValue('plugin_qtype_multichoice_question/multichoice/incorrectfeedback', $this->question_node); 02250 $proc = array('correct_fb' => $correct_question_fb, 'general_incorrect_fb' => $incorrect_question_fb); 02251 foreach ($proc as $ident => $content) { 02252 if (empty($content)) { 02253 continue; 02254 } 02255 $result = cc_helpers::process_linked_files( $content, 02256 $this->manifest, 02257 $this->rootpath, 02258 $this->contextid, 02259 $this->outdir); 02260 02261 cc_assesment_helper::add_feedback( $this->qitem, 02262 $result[0], 02263 cc_qti_values::htmltype, 02264 $ident); 02265 02266 pkg_resource_dependencies::instance()->add($result[1]); 02267 if ($ident == 'correct_fb') { 02268 $this->correct_feedbacks[] = $ident; 02269 } else { 02270 $this->incorrect_feedbacks[] = $ident; 02271 } 02272 } 02273 02274 } 02275 02276 public function on_generate_response_processing() { 02277 parent::on_generate_response_processing(); 02278 02279 //respconditions 02284 if (!empty($this->general_feedback)) { 02285 $qrespcondition = new cc_assesment_respconditiontype(); 02286 $qrespcondition->set_title('General feedback'); 02287 $this->qresprocessing->add_respcondition($qrespcondition); 02288 $qrespcondition->enable_continue(); 02289 //define the condition for success 02290 $qconditionvar = new cc_assignment_conditionvar(); 02291 $qrespcondition->set_conditionvar($qconditionvar); 02292 $qother = new cc_assignment_conditionvar_othertype(); 02293 $qconditionvar->set_other($qother); 02294 $qdisplayfeedback = new cc_assignment_displayfeedbacktype(); 02295 $qrespcondition->add_displayfeedback($qdisplayfeedback); 02296 $qdisplayfeedback->set_feedbacktype(cc_qti_values::Response); 02297 $qdisplayfeedback->set_linkrefid('general_fb'); 02298 } 02299 02300 //success condition 02307 $qrespcondition = new cc_assesment_respconditiontype(); 02308 $qrespcondition->set_title('Correct'); 02309 $this->qresprocessing->add_respcondition($qrespcondition); 02310 $qrespcondition->enable_continue(false); 02311 $qsetvar = new cc_assignment_setvartype(100); 02312 $qrespcondition->add_setvar($qsetvar); 02313 //define the condition for success 02314 $qconditionvar = new cc_assignment_conditionvar(); 02315 $qrespcondition->set_conditionvar($qconditionvar); 02316 $qvarequal = new cc_assignment_conditionvar_varequaltype($this->correct_answer_ident); 02317 $qconditionvar->set_varequal($qvarequal); 02318 $qvarequal->set_respident($this->qresponse_lid->get_ident()); 02319 02320 if (array_key_exists($this->correct_answer_ident, $this->answerlist)) { 02321 $qdisplayfeedback = new cc_assignment_displayfeedbacktype(); 02322 $qrespcondition->add_displayfeedback($qdisplayfeedback); 02323 $qdisplayfeedback->set_feedbacktype(cc_qti_values::Response); 02324 $qdisplayfeedback->set_linkrefid($this->answerlist[$this->correct_answer_ident]); 02325 } 02326 02327 foreach ($this->correct_feedbacks as $ident) { 02328 $qdisplayfeedback = new cc_assignment_displayfeedbacktype(); 02329 $qrespcondition->add_displayfeedback($qdisplayfeedback); 02330 $qdisplayfeedback->set_feedbacktype(cc_qti_values::Response); 02331 $qdisplayfeedback->set_linkrefid($ident); 02332 } 02333 02334 //rest of the conditions 02335 foreach ($this->answerlist as $ident => $refid) { 02336 if ($ident == $this->correct_answer_ident) { 02337 continue; 02338 } 02339 02340 $qrespcondition = new cc_assesment_respconditiontype(); 02341 $this->qresprocessing->add_respcondition($qrespcondition); 02342 $qsetvar = new cc_assignment_setvartype(0); 02343 $qrespcondition->add_setvar($qsetvar); 02344 //define the condition for fail 02345 $qconditionvar = new cc_assignment_conditionvar(); 02346 $qrespcondition->set_conditionvar($qconditionvar); 02347 $qvarequal = new cc_assignment_conditionvar_varequaltype($ident); 02348 $qconditionvar->set_varequal($qvarequal); 02349 $qvarequal->set_respident($this->qresponse_lid->get_ident()); 02350 02351 $qdisplayfeedback = new cc_assignment_displayfeedbacktype(); 02352 $qrespcondition->add_displayfeedback($qdisplayfeedback); 02353 $qdisplayfeedback->set_feedbacktype(cc_qti_values::Response); 02354 $qdisplayfeedback->set_linkrefid($refid); 02355 02356 foreach ($this->incorrect_feedbacks as $ident) { 02357 $qdisplayfeedback = new cc_assignment_displayfeedbacktype(); 02358 $qrespcondition->add_displayfeedback($qdisplayfeedback); 02359 $qdisplayfeedback->set_feedbacktype(cc_qti_values::Response); 02360 $qdisplayfeedback->set_linkrefid($ident); 02361 } 02362 } 02363 } 02364 }