/** * checks wether the obligation for question with given id is possible or not * * @param integer $questionId * @return boolean $obligationPossible */ public static function isQuestionObligationPossible($questionId) { require_once 'Modules/TestQuestionPool/classes/class.assQuestion.php'; $classConcreteQuestion = assQuestion::_getQuestionType($questionId); assQuestion::_includeClass($classConcreteQuestion, 0); // static binder is not at work yet (in PHP < 5.3) //$obligationPossible = $classConcreteQuestion::isObligationPossible(); $obligationPossible = call_user_func(array($classConcreteQuestion, 'isObligationPossible'), $questionId); return $obligationPossible; }
function &createQuestion($question_type, $question_id = -1) { include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php"; if ($question_id > 0) { return assQuestion::_instanciateQuestionGUI($question_id); } assQuestion::_includeClass($question_type, 1); $question_type_gui = $question_type . "GUI"; $question_gui =& new $question_type_gui(); return $question_gui; }
/** * handler for end of element parser */ function handlerParseEndTag($a_xml_parser, $a_name) { if ($this->do_nothing && strcmp(strtolower($a_name), "item") != 0) { return; } switch (strtolower($a_name)) { case "assessment": if (is_object($this->tst_object)) { $this->tst_object->fromXML($this->assessment); } $this->in_assessment = FALSE; break; case "assessmentcontrol": $this->assessment->addAssessmentcontrol($this->assessmentcontrol); $this->assessmentcontrol = NULL; break; case "objectives": if (strcmp(strtolower($this->getParent($a_xml_parser)), "assessment") == 0) { $this->assessment->addObjectives($this->objectives); } $this->in_objectives = FALSE; break; case 'presentation_material': $this->assessment->setPresentationMaterial($this->prensentation_material); $this->in_prensentation_material = FALSE; break; case "itemmetadata": $this->in_itemmetadata = FALSE; break; case "qtimetadatafield": // handle only specific ILIAS metadata switch ($this->metadata["label"]) { case "ILIAS_VERSION": break; case "QUESTIONTYPE": if ($this->item != NULL) { $this->item->setQuestiontype($this->metadata["entry"]); } break; case "AUTHOR": if ($this->item != NULL) { $this->item->setAuthor($this->metadata["entry"]); } default: if ($this->item != NULL) { $this->item->addMetadata($this->metadata); } break; } if ($this->in_assessment) { $this->assessment->addQtiMetadata($this->metadata); } $this->metadata = array("label" => "", "entry" => ""); break; case "flow": $this->flow--; break; case "flow_mat": if (count($this->flow_mat)) { $flow_mat = array_pop($this->flow_mat); if (count($this->flow_mat)) { $this->flow_mat[count($this->flow_mat) - 1]->addFlow_mat($flow_mat); } else { if ($this->in_prensentation_material) { $this->prensentation_material->addFlowMat($flow_mat); } else { if ($this->itemfeedback != NULL) { $this->itemfeedback->addFlow_mat($flow_mat); } else { if ($this->response_label != NULL) { $this->response_label->addFlow_mat($flow_mat); } } } } } break; case "itemfeedback": if ($this->item != NULL) { if ($this->itemfeedback != NULL) { $this->item->addItemfeedback($this->itemfeedback); } } $this->itemfeedback = NULL; break; case "displayfeedback": if ($this->respcondition != NULL) { if ($this->displayfeedback != NULL) { $this->respcondition->addDisplayfeedback($this->displayfeedback); } } $this->displayfeedback = NULL; break; case "setvar": if ($this->respcondition != NULL) { if ($this->setvar != NULL) { $this->respcondition->addSetvar($this->setvar); } } $this->setvar = NULL; break; case "conditionvar": if ($this->respcondition != NULL) { $this->respcondition->setConditionvar($this->conditionvar); } $this->conditionvar = NULL; break; case "varequal": case "varlt": case "varlte": case "vargt": case "vargte": case "varsubset": case "varinside": case "varsubstring": if ($this->conditionvar != NULL) { if ($this->responsevar != NULL) { $this->conditionvar->addResponseVar($this->responsevar); } } $this->responsevar = NULL; break; case "respcondition": if ($this->resprocessing != NULL) { $this->resprocessing->addRespcondition($this->respcondition); } $this->respcondition = NULL; break; case "outcomes": if ($this->resprocessing != NULL) { $this->resprocessing->setOutcomes($this->outcomes); } $this->outcomes = NULL; break; case "decvar": if ($this->outcomes != NULL) { $this->outcomes->addDecvar($this->decvar); } $this->decvar = NULL; break; case "presentation": $this->in_presentation = FALSE; if ($this->presentation != NULL) { if ($this->item != NULL) { $this->item->setPresentation($this->presentation); } } $this->presentation = NULL; break; case "response_label": if ($this->render_type != NULL) { $this->render_type->addResponseLabel($this->response_label); $this->response_label = NULL; } break; case "render_choice": case "render_hotspot": case "render_fib": if ($this->in_response) { if ($this->response != NULL) { if ($this->render_type != NULL) { $this->response->setRenderType($this->render_type); $this->render_type = NULL; } } } break; case "response_lid": case "response_xy": case "response_str": case "response_num": case "response_grp": $this->gap_index++; if ($this->presentation != NULL) { if ($this->response != NULL) { $this->presentation->addResponse($this->response); if ($this->item != NULL) { $this->item->addPresentationitem($this->response); } } } $this->response = NULL; $this->in_response = FALSE; break; case "item": if ($this->do_nothing) { $this->do_nothing = FALSE; return; } if (strlen($this->item->getQuestionType())) { // this is an ILIAS QTI question } else { // this is a QTI question which wasn't generated by ILIAS } global $ilDB; global $ilUser; // save the item directly to save memory // the database id's of the created items are exported. if the import fails // ILIAS can delete the already imported items // problems: the object id of the parent questionpool is not yet known. must be set later // the complete flag must be calculated? $qt = $this->item->determineQuestionType(); $presentation = $this->item->getPresentation(); include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php"; assQuestion::_includeClass($qt); $question = new $qt(); $fbt = str_replace('ass', 'ilAss', $qt) . 'Feedback'; $question->feedbackOBJ = new $fbt($question, $GLOBALS['ilCtrl'], $GLOBALS['ilDB'], $GLOBALS['lng']); $question->fromXML($this->item, $this->qpl_id, $this->tst_id, $this->tst_object, $this->question_counter, $this->import_mapping); break; case "material": if ($this->material) { $mat = $this->material->getMaterial(0); if (strcmp($mat["type"], "mattext") == 0 && strcmp($mat["material"]->getLabel(), "suggested_solution") == 0) { $this->item->addSuggestedSolution($mat["material"], $this->gap_index); } if ($this->in_objectives) { $this->objectives->addMaterial($this->material); } else { if ($this->render_type != NULL && strcmp(strtolower($this->getParent($a_xml_parser)), "render_hotspot") == 0) { $this->render_type->addMaterial($this->material); } else { if (count($this->flow_mat) && strcmp(strtolower($this->getParent($a_xml_parser)), "flow_mat") == 0) { $this->flow_mat[count($this->flow_mat) - 1]->addMaterial($this->material); } else { if ($this->itemfeedback != NULL) { $this->itemfeedback->addMaterial($this->material); } else { if ($this->response_label != NULL) { $this->response_label->addMaterial($this->material); } else { if ($this->response != NULL) { if ($this->response->hasRendering()) { $this->response->setMaterial2($this->material); } else { $this->response->setMaterial1($this->material); } } elseif ($this->in_presentation && !$this->in_response) { if (!is_object($this->item->getQuestiontext())) { $this->item->setQuestiontext($this->material); } $this->presentation->addMaterial($this->material); } else { if ($this->presentation != NULL) { $this->presentation->addMaterial($this->material); if ($this->item != NULL) { $this->item->addPresentationitem($this->material); } } } } } } } } } $this->material = NULL; break; case "matimage": if ($this->material != NULL) { if ($this->matimage != NULL) { $this->material->addMatimage($this->matimage); } } $this->matimage = NULL; break; // add support for matbreak element // add support for matbreak element case "matbreak": $this->mattext = new ilQTIMattext(); $this->mattext->setContent('<br />'); $this->material->addMattext($this->mattext); $this->mattext = NULL; break; case "resprocessing": if ($this->item != NULL) { $this->item->addResprocessing($this->resprocessing); } $this->resprocessing = NULL; break; case "mattext": if ($this->material != NULL) { $this->material->addMattext($this->mattext); } $this->mattext = NULL; break; case "matapplet": if ($this->material != NULL) { $this->material->addMatapplet($this->matapplet); } $this->matapplet = NULL; break; } $this->depth[$a_xml_parser]--; }
/** * Creates a question gui representation and returns the alias to the question gui * note: please do not use $this inside this method to allow static calls * * @param string $question_type The question type as it is used in the language database * @param integer $question_id The database ID of an existing question to load it into assQuestionGUI * * @return assQuestionGUI The alias to the question object */ public function &_getQuestionGUI($question_type, $question_id = -1) { global $ilCtrl, $ilDB, $lng; include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php"; if (!$question_type and $question_id > 0) { $question_type = assQuestion::getQuestionTypeFromDb($question_id); } if (strlen($question_type) == 0) { return NULL; } assQuestion::_includeClass($question_type, 1); $question_type_gui = assQuestion::getGuiClassNameByQuestionType($question_type); $question =& new $question_type_gui(); $feedbackObjectClassname = assQuestion::getFeedbackClassNameByQuestionType($question_type); $question->object->feedbackOBJ = new $feedbackObjectClassname($question->object, $ilCtrl, $ilDB, $lng); if ($question_id > 0) { $question->object->loadFromDb($question_id); } return $question; }
/** * Creates an instance of a question gui with a given question id * * @param integer $a_question_id * * @return \assQuestionGUI The question gui instance */ public static function instantiateQuestionGUI($a_question_id) { global $ilCtrl, $ilDB, $lng, $ilUser; if (strcmp($a_question_id, "") != 0) { $question_type = assQuestion::_getQuestionType($a_question_id); assQuestion::_includeClass($question_type, 1); $question_type_gui = self::getGuiClassNameByQuestionType($question_type); $question_gui = new $question_type_gui(); $question_gui->object->loadFromDb($a_question_id); $feedbackObjectClassname = self::getFeedbackClassNameByQuestionType($question_type); $question_gui->object->feedbackOBJ = new $feedbackObjectClassname($question_gui->object, $ilCtrl, $ilDB, $lng); $assSettings = new ilSetting('assessment'); require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionProcessLockerFactory.php'; $processLockerFactory = new ilAssQuestionProcessLockerFactory($assSettings, $ilDB); $processLockerFactory->setQuestionId($question_gui->object->getId()); $processLockerFactory->setUserId($ilUser->getId()); include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php"; $processLockerFactory->setAssessmentLogEnabled(ilObjAssessmentFolder::_enabledAssessmentLogging()); $question_gui->object->setProcessLocker($processLockerFactory->getLocker()); } else { global $ilLog; $ilLog->write('Instantiate question called without question id. (instantiateQuestionGUI@assQuestion)', $ilLog->WARNING); return null; } return $question_gui; }
/** * Creates a question gui representation and returns the alias to the question gui * note: please do not use $this inside this method to allow static calls * * @param string $question_type The question type as it is used in the language database * @param integer $question_id The database ID of an existing question to load it into assQuestionGUI * @return object The alias to the question object * @access public */ function &_getQuestionGUI($question_type, $question_id = -1) { include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php"; if (!$question_type and $question_id > 0) { $question_type = assQuestion::getQuestionTypeFromDb($question_id); } if (strlen($question_type) == 0) { return NULL; } $question_type_gui = $question_type . "GUI"; assQuestion::_includeClass($question_type, 1); $question =& new $question_type_gui(); if ($question_id > 0) { $question->object->loadFromDb($question_id); } return $question; }
/** * Creates an instance of a question gui with a given question id * * @param integer $a_question_id * * @return \assQuestionGUI The question gui instance */ public static function instantiateQuestionGUI($a_question_id) { global $ilCtrl, $ilDB, $lng; if (strcmp($a_question_id, "") != 0) { $question_type = assQuestion::_getQuestionType($a_question_id); $question_type_gui = $question_type . "GUI"; assQuestion::_includeClass($question_type, 1); $question_gui = new $question_type_gui(); $question_gui->object->loadFromDb($a_question_id); $feedbackObjectClassname = str_replace('ass', 'ilAss', $question_type) . 'Feedback'; require_once "Modules/TestQuestionPool/classes/feedback/class.{$feedbackObjectClassname}.php"; $question_gui->object->feedbackOBJ = new $feedbackObjectClassname($question_gui->object, $ilCtrl, $ilDB, $lng); } else { global $ilLog; $ilLog->write('Instantiate question called without question id. (instantiateQuestionGUI@assQuestion)', $ilLog->WARNING); return null; } return $question_gui; }
/** * Creates a question gui representation and returns the alias to the question gui * note: please do not use $this inside this method to allow static calls * * @param string $question_type The question type as it is used in the language database * @param integer $question_id The database ID of an existing question to load it into assQuestionGUI * * @return assQuestionGUI The alias to the question object */ public function &_getQuestionGUI($question_type, $question_id = -1) { global $ilCtrl, $ilDB, $lng; include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php"; if (!$question_type and $question_id > 0) { $question_type = assQuestion::getQuestionTypeFromDb($question_id); } if (strlen($question_type) == 0) { return NULL; } $question_type_gui = $question_type . "GUI"; assQuestion::_includeClass($question_type, 1); $question =& new $question_type_gui(); $feedbackObjectClassname = str_replace('ass', 'ilAss', $question_type) . 'Feedback'; require_once "Modules/TestQuestionPool/classes/feedback/class.{$feedbackObjectClassname}.php"; $question->object->feedbackOBJ = new $feedbackObjectClassname($question->object, $ilCtrl, $ilDB, $lng); if ($question_id > 0) { $question->object->loadFromDb($question_id); } return $question; }
/** * Creates an instance of a question gui with a given question id * * @param integer $question_id The question id * @return object The question gui instance * @access public */ function &_instanciateQuestionGUI($question_id) { if (strcmp($question_id, "") != 0) { $question_type = assQuestion::_getQuestionType($question_id); $question_type_gui = $question_type . "GUI"; assQuestion::_includeClass($question_type, 1); $question_gui = new $question_type_gui(); $question_gui->object->loadFromDb($question_id); return $question_gui; } }