/**
  * forward method
  */
 public function forward()
 {
     $this->tabs->setTabActive('settings');
     $this->lng->loadLanguageModule('tax');
     require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionList.php';
     $questionList = new ilAssQuestionList($this->db, $this->lng, $this->pluginAdmin, $this->poolOBJ->getId());
     $questionList->load();
     require_once 'Services/Taxonomy/classes/class.ilObjTaxonomyGUI.php';
     $taxGUI = new ilObjTaxonomyGUI();
     $taxGUI->setAssignedObject($this->poolOBJ->getId());
     $taxGUI->setMultiple(true);
     $taxGUI->activateAssignedItemSorting($questionList, 'qpl', $this->poolOBJ->getId(), 'quest');
     $this->ctrl->forwardCommand($taxGUI);
 }
 public function executeCommand()
 {
     if ($this->isAccessDenied()) {
         $this->ilias->raiseError($this->lng->txt("permission_denied"), $this->ilias->error_obj->MESSAGE);
     }
     $nextClass = $this->ctrl->getNextClass();
     $this->manageTabs($nextClass);
     switch ($nextClass) {
         case 'ilassquestionskillassignmentsgui':
             require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionList.php';
             $questionList = new ilAssQuestionList($this->db, $this->lng, $this->pluginAdmin);
             $questionList->setParentObjId($this->poolOBJ->getId());
             $questionList->setQuestionInstanceTypeFilter(ilAssQuestionList::QUESTION_INSTANCE_TYPE_ORIGINALS);
             $questionList->load();
             $gui = new ilAssQuestionSkillAssignmentsGUI($this->ctrl, $this->access, $this->tpl, $this->lng, $this->db);
             $gui->setAssignmentEditingEnabled(true);
             $gui->setQuestionContainerId($this->poolOBJ->getId());
             $gui->setQuestionList($questionList);
             $this->ctrl->forwardCommand($gui);
             break;
         case 'ilassquestionskillusagestablegui':
             $gui = new ilAssQuestionSkillUsagesTableGUI($this->ctrl, $this->tpl, $this->lng, $this->db, $this->poolOBJ->getId());
             $this->ctrl->forwardCommand($gui);
             break;
     }
 }
 /**
  * @param array $taxIds
  * @global ilRbacSystem  $rbacsystem
  * @global ilDB $ilDB
  * @global ilLanguage $lng
  * @global ilPluginAdmin $ilPluginAdmin
  * @return ilQuestionBrowserTableGUI
  */
 private function buildQuestionBrowserTableGUI($taxIds)
 {
     global $rbacsystem, $ilDB, $lng, $ilPluginAdmin;
     include_once "./Modules/TestQuestionPool/classes/tables/class.ilQuestionBrowserTableGUI.php";
     $table_gui = new ilQuestionBrowserTableGUI($this, 'questions', $rbacsystem->checkAccess('write', $_GET['ref_id']) ? true : false, false, $taxIds);
     $table_gui->setEditable($rbacsystem->checkAccess('write', $_GET['ref_id']));
     require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionList.php';
     $questionList = new ilAssQuestionList($ilDB, $lng, $ilPluginAdmin, $this->object->getId());
     foreach ($table_gui->getFilterItems() as $item) {
         if (substr($item->getPostVar(), 0, strlen('tax_')) == 'tax_') {
             $v = $item->getValue();
             if (is_array($v) && count($v) && !(int) $v[0]) {
                 continue;
             }
             $taxId = substr($item->getPostVar(), strlen('tax_'));
             $questionList->addTaxonomyFilter($taxId, $item->getValue());
         } elseif ($item->getValue() !== false) {
             $questionList->addFieldFilter($item->getPostVar(), $item->getValue());
         }
     }
     if ($this->object->isNavTaxonomyActive() && (int) $_GET['tax_node']) {
         $questionList->addTaxonomyFilter($this->object->getNavTaxonomyId(), array((int) $_GET['tax_node']));
     }
     $questionList->load();
     $data = $questionList->getQuestionDataArray();
     $table_gui->setData($data);
     return $table_gui;
 }
 /**
  * Get questions
  *
  * @param
  * @return
  */
 function getQuestions()
 {
     global $ilAccess, $ilDB, $lng, $ilPluginAdmin;
     include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
     $all_types = ilObjQuestionPool::_getSelfAssessmentQuestionTypes();
     $all_ids = array();
     foreach ($all_types as $k => $v) {
         $all_ids[] = $v["question_type_id"];
     }
     $questions = array();
     if ($ilAccess->checkAccess("read", "", $this->pool_ref_id)) {
         require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionList.php';
         $questionList = new ilAssQuestionList($ilDB, $lng, $ilPluginAdmin, $this->pool_obj_id);
         $questionList->load();
         $data = $questionList->getQuestionDataArray();
         $questions = array();
         foreach ($data as $d) {
             // list only self assessment question types
             if (in_array($d["question_type_fi"], $all_ids)) {
                 $questions[] = $d;
             }
         }
     }
     $this->setData($questions);
 }
 /**
  * show information screen
  */
 function infoScreenForward()
 {
     global $ilErr, $ilAccess;
     if (!$ilAccess->checkAccess("visible", "", $this->ref_id)) {
         $ilErr->raiseError($this->lng->txt("msg_no_perm_read"));
     }
     include_once "./Services/InfoScreen/classes/class.ilInfoScreenGUI.php";
     $info = new ilInfoScreenGUI($this);
     $info->enablePrivateNotes();
     // standard meta data
     $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
     $this->ctrl->forwardCommand($info);
 }
 /**
  * Init filter
  */
 function initFilter()
 {
     global $lng;
     // title
     include_once "./Services/Form/classes/class.ilTextInputGUI.php";
     $ti = new ilTextInputGUI($lng->txt("title"), "title");
     $ti->setMaxLength(64);
     $ti->setSize(20);
     $ti->setValidationRegexp('/^[^%]+$/is');
     $this->addFilterItem($ti);
     $ti->readFromSession();
     $this->filter["title"] = $ti->getValue();
     // description
     $ti = new ilTextInputGUI($lng->txt("description"), "description");
     $ti->setMaxLength(64);
     $ti->setSize(20);
     $ti->setValidationRegexp('/^[^%]+$/is');
     $this->addFilterItem($ti);
     $ti->readFromSession();
     $this->filter["description"] = $ti->getValue();
     // questiontype
     include_once "./Services/Form/classes/class.ilSelectInputGUI.php";
     include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
     $types = ilObjQuestionPool::_getQuestionTypes();
     $options = array();
     $options[""] = $lng->txt('filter_all_question_types');
     foreach ($types as $translation => $row) {
         $options[$row['type_tag']] = $translation;
     }
     $si = new ilSelectInputGUI($this->lng->txt("question_type"), "type");
     $si->setOptions($options);
     $this->addFilterItem($si);
     $si->readFromSession();
     $this->filter["type"] = $si->getValue();
     // author
     $ti = new ilTextInputGUI($lng->txt("author"), "author");
     $ti->setMaxLength(64);
     $ti->setSize(20);
     $this->addFilterItem($ti);
     $ti->setValidationRegexp('/^[^%]+$/is');
     $ti->readFromSession();
     $this->filter["author"] = $ti->getValue();
     // question pool
     $ti = new ilTextInputGUI($lng->txt("qpl"), "qpl");
     $ti->setMaxLength(64);
     $ti->setSize(20);
     $ti->setValidationRegexp('/^[^%]+$/is');
     $this->addFilterItem($ti);
     $ti->readFromSession();
     $this->filter["qpl"] = $ti->getValue();
 }
예제 #7
0
 /**
  * Is node visible
  *
  * @param array $a_node node data
  * @return bool visible true/false
  */
 function isNodeVisible($a_node)
 {
     if (parent::isNodeVisible($a_node)) {
         //hide empty container
         if (count($this->getChildsOfNode($a_node["child"])) > 0 || $this->isNodeClickable($a_node)) {
             // #16523
             if ($a_node["type"] == "qpl") {
                 include_once "Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
                 return ilObjQuestionPool::_lookupOnline($a_node["obj_id"]);
             }
             return true;
         }
     }
     return false;
 }
 /**
  * Import XML
  *
  * @param
  * @return
  */
 function importXmlRepresentation($a_entity, $a_id, $a_xml, $a_mapping)
 {
     include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
     ilObjQuestionPool::_setImportDirectory($this->getImportDirectory());
     // Container import => test object already created
     if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_id)) {
         $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
     } else {
         // Shouldn't happen
         $GLOBALS['ilLog']->write(__METHOD__ . ': Called in non container mode');
         return false;
     }
     list($xml_file, $qti_file) = $this->parseXmlFileNames();
     if (!@file_exists($xml_file)) {
         $GLOBALS['ilLog']->write(__METHOD__ . ': Cannot find xml definition: ' . $xml_file);
         return false;
     }
     if (!@file_exists($qti_file)) {
         $GLOBALS['ilLog']->write(__METHOD__ . ': Cannot find xml definition: ' . $qti_file);
         return false;
     }
     include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
     ilObjQuestionPool::_setImportDirectory($this->getImportDirectory());
     // FIXME: Copied from ilObjQuestionPoolGUI::importVerifiedFileObject
     // TODO: move all logic to ilObjQuestionPoolGUI::importVerifiedFile and call
     // this method from ilObjQuestionPoolGUI and ilTestImporter
     $GLOBALS['ilLog']->write(__METHOD__ . ': xml file: ' . $xml_file . ", qti file:" . $qti_file);
     $newObj->setOnline(true);
     $newObj->saveToDb();
     // start parsing of QTI files
     include_once "./Services/QTI/classes/class.ilQTIParser.php";
     $qtiParser = new ilQTIParser($qti_file, IL_MO_PARSE_QTI, $newObj->getId(), null);
     $result = $qtiParser->startParsing();
     // import page data
     if (strlen($xml_file)) {
         include_once "./Modules/LearningModule/classes/class.ilContObjParser.php";
         $contParser = new ilContObjParser($newObj, $xml_file, basename($this->getImportDirectory()));
         $contParser->setQuestionMapping($qtiParser->getImportMapping());
         $contParser->startParsing();
     }
     $a_mapping->addMapping("Modules/TestQuestionPool", "qpl", $a_id, $newObj->getId());
     ilObjQuestionPool::_setImportDirectory(null);
 }
 /**
  * Get questions
  *
  * @param
  * @return
  */
 function getQuestions()
 {
     global $ilAccess;
     $filter = array();
     include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
     $all_types = ilObjQuestionPool::_getSelfAssessmentQuestionTypes();
     $all_ids = array();
     foreach ($all_types as $k => $v) {
         $all_ids[] = $v["question_type_id"];
     }
     $questions = array();
     if ($ilAccess->checkAccess("read", "", $this->pool_ref_id)) {
         $data = $this->pool->getQuestionBrowserData($filter);
         $questions = array();
         foreach ($data as $d) {
             // list only self assessment question types
             if (in_array($d["question_type_fi"], $all_ids)) {
                 $questions[] = $d;
             }
         }
     }
     $this->setData($questions);
 }
 /**
  * Get item properties
  *
  * @return	array		array of property arrays:
  *						"alert" (boolean) => display as an alert property (usually in red)
  *						"property" (string) => property name
  *						"value" (string) => property value
  */
 function getProperties()
 {
     global $lng, $ilUser;
     $props = array();
     include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
     if (!ilObjQuestionPool::_lookupOnline($this->obj_id)) {
         $props[] = array("alert" => true, "property" => $lng->txt("status"), "value" => $lng->txt("offline"));
     }
     return $props;
 }
예제 #11
0
 /**
 * Returns true if the question is writeable by a certain user
 *
 * @param integer $question_id The database id of the question
 * @param integer $user_id The database id of the user
 * @result boolean True, if the question exists, otherwise False
 * @access public
 */
 function _isWriteable($question_id, $user_id)
 {
     global $ilDB;
     if ($question_id < 1 || $user_id < 1) {
         return false;
     }
     $result = $ilDB->queryF("SELECT obj_fi FROM qpl_questions WHERE question_id = %s", array('integer'), array($question_id));
     if ($result->numRows() == 1) {
         $row = $ilDB->fetchAssoc($result);
         $qpl_object_id = $row["obj_fi"];
         include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
         return ilObjQuestionPool::_isWriteable($qpl_object_id, $user_id);
     } else {
         return false;
     }
 }
예제 #12
0
 function questionsObject()
 {
     global $ilAccess, $ilTabs;
     $ilTabs->activateTab('assQuestions');
     if (!$ilAccess->checkAccess("write", "", $this->ref_id)) {
         // allow only write access
         ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
         $this->ctrl->redirect($this, "infoScreen");
     }
     if ($_GET['browse']) {
         return $this->questionbrowser();
     }
     $this->getQuestionsSubTabs();
     if ($_GET["eqid"] && $_GET["eqpl"]) {
         ilUtil::redirect("ilias.php?baseClass=ilObjQuestionPoolGUI&ref_id=" . $_GET["eqpl"] . "&cmd=editQuestionForTest&calling_test=" . $_GET["ref_id"] . "&q_id=" . $_GET["eqid"]);
     }
     if ($_GET["up"] > 0) {
         $this->object->questionMoveUp($_GET["up"]);
     }
     if ($_GET["down"] > 0) {
         $this->object->questionMoveDown($_GET["down"]);
     }
     if ($_GET["add"]) {
         $selected_array = array();
         array_push($selected_array, $_GET["add"]);
         $total = $this->object->evalTotalPersons();
         if ($total) {
             // the test was executed previously
             ilUtil::sendInfo(sprintf($this->lng->txt("tst_insert_questions_and_results"), $total));
         } else {
             ilUtil::sendInfo($this->lng->txt("tst_insert_questions"));
         }
         $this->insertQuestions($selected_array);
         return;
     }
     $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_questions.html", "Modules/Test");
     $total = $this->object->evalTotalPersons();
     if ($ilAccess->checkAccess("write", "", $this->ref_id)) {
         if ($total != 0) {
             $link = $this->ctrl->getLinkTarget($this, "participants");
             $link = "<a href=\"" . $link . "\">" . $this->lng->txt("test_has_datasets_warning_page_view_link") . "</a>";
             ilUtil::sendInfo($this->lng->txt("test_has_datasets_warning_page_view") . " " . $link);
         } else {
             global $ilToolbar;
             $qtypes = array();
             include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
             foreach (ilObjQuestionPool::_getQuestionTypes(false, true) as $trans => $data) {
                 $qtypes[$data['type_tag']] = $trans;
             }
             $ilToolbar->setFormAction($this->ctrl->getFormAction($this));
             include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
             $types = new ilSelectInputGUI($this->lng->txt("create_new"), "sel_question_types");
             $types->setOptions($qtypes);
             $ilToolbar->addInputItem($types);
             $ilToolbar->addFormButton($this->lng->txt("ass_create_question"), "createQuestion");
             if ($this->object->getPoolUsage()) {
                 $ilToolbar->addSeparator();
                 $ilToolbar->addButton($this->lng->txt("tst_browse_for_questions"), $this->ctrl->getLinkTarget($this, 'browseForQuestions'));
             }
             $ilToolbar->addSeparator();
             $ilToolbar->addButton($this->lng->txt("random_selection"), $this->ctrl->getLinkTarget($this, "randomselect"));
             global $ilAccess, $ilUser, $lng, $ilCtrl;
             $online_access = false;
             if ($this->object->getFixedParticipants()) {
                 include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
                 $online_access_result = ilObjTestAccess::_lookupOnlineTestAccess($this->object->getId(), $ilUser->getId());
                 if ($online_access_result === true) {
                     $online_access = true;
                 }
             }
             if ($this->object->isOnline() && $this->object->isComplete($this->testQuestionSetConfigFactory->getQuestionSetConfig())) {
                 if ((!$this->object->getFixedParticipants() || $online_access) && $ilAccess->checkAccess("read", "", $this->ref_id)) {
                     $testSession = $this->testSessionFactory->getSession();
                     $executable = $this->object->isExecutable($testSession, $ilUser->getId(), $allowPassIncrease = TRUE);
                     if ($executable["executable"]) {
                         if ($testSession->getActiveId() > 0) {
                             $ilToolbar->addSeparator();
                             $ilToolbar->addButton($lng->txt('tst_resume_test'), $ilCtrl->getLinkTargetByClass('iltestoutputgui', 'resume'));
                         } else {
                             $ilToolbar->addSeparator();
                             $ilToolbar->addButton($lng->txt('tst_start_test'), $ilCtrl->getLinkTargetByClass('iltestoutputgui', 'startTest'));
                         }
                     }
                 }
             }
         }
     }
     $this->tpl->setCurrentBlock("adm_content");
     include_once "./Modules/Test/classes/tables/class.ilTestQuestionsTableGUI.php";
     $checked_move = is_array($_SESSION['tst_qst_move_' . $this->object->getTestId()]) && count($_SESSION['tst_qst_move_' . $this->object->getTestId()]);
     $table_gui = new ilTestQuestionsTableGUI($this, 'questions', $ilAccess->checkAccess("write", "", $this->ref_id) ? true : false, $checked_move, $total);
     $data = $this->object->getTestQuestions();
     $table_gui->setData($data);
     $this->tpl->setVariable('QUESTIONBROWSER', $table_gui->getHTML());
     $this->tpl->setVariable("ACTION_QUESTION_FORM", $this->ctrl->getFormAction($this));
     $this->tpl->parseCurrentBlock();
 }
 private function buildForm()
 {
     require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
     $form = new ilPropertyFormGUI();
     $form->setFormAction($this->ctrl->getFormAction($this));
     $form->addCommandButton(self::CMD_SAVE_FORM, $this->lng->txt('save'));
     $form->setTitle($this->lng->txt('qpl_form_general_settings'));
     $form->setId('properties');
     // online
     $online = new ilCheckboxInputGUI($this->lng->txt('qpl_settings_general_form_property_online'), 'online');
     $online->setInfo($this->lng->txt('qpl_settings_general_form_property_online_description'));
     $online->setChecked($this->poolOBJ->getOnline());
     $form->addItem($online);
     // show taxonomies
     $showTax = new ilCheckboxInputGUI($this->lng->txt('qpl_settings_general_form_property_show_taxonomies'), 'show_taxonomies');
     $showTax->setInfo($this->lng->txt('qpl_settings_general_form_prop_show_tax_desc'));
     $showTax->setChecked($this->poolOBJ->getShowTaxonomies());
     $form->addItem($showTax);
     $taxSelectOptions = $this->getTaxonomySelectInputOptions();
     // pool navigation taxonomy
     $navTax = new ilSelectInputGUI($this->lng->txt('qpl_settings_general_form_property_nav_taxonomy'), 'nav_taxonomy');
     $navTax->setInfo($this->lng->txt('qpl_settings_general_form_property_nav_taxonomy_description'));
     $navTax->setValue($this->poolOBJ->getNavTaxonomyId());
     $navTax->setOptions($taxSelectOptions);
     $showTax->addSubItem($navTax);
     // skill service activation
     if (ilObjQuestionPool::isSkillManagementGloballyActivated()) {
         $skillService = new ilCheckboxInputGUI($this->lng->txt('tst_activate_skill_service'), 'skill_service');
         $skillService->setChecked($this->poolOBJ->isSkillServiceEnabled());
         $form->addItem($skillService);
     }
     return $form;
 }
 /**
  * Updates the number of available questions for a question pool in the database
  *
  * @param integer $object_id Object id of the questionpool to examine
  * @access public
  */
 public static function _updateQuestionCount($object_id)
 {
     global $ilDB;
     $result = $ilDB->manipulateF("UPDATE qpl_questionpool SET questioncount = %s, tstamp = %s WHERE obj_fi = %s", array('integer', 'integer', 'integer'), array(ilObjQuestionPool::_getQuestionCount($object_id, TRUE), time(), $object_id));
 }
 /**
  * Creates a question from a QTI file
  *
  * Receives parameters from a QTI parser and creates a valid ILIAS question object
  *
  * @param object $item The QTI item object
  * @param integer $questionpool_id The id of the parent questionpool
  * @param integer $tst_id The id of the parent test if the question is part of a test
  * @param object $tst_object A reference to the parent test object
  * @param integer $question_counter A reference to a question counter to count the questions of an imported question pool
  * @param array $import_mapping An array containing references to included ILIAS objects
  * @access public
  */
 function fromXML(&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
 {
     global $ilUser;
     // empty session variable for imported xhtml mobs
     unset($_SESSION["import_mob_xhtml"]);
     $presentation = $item->getPresentation();
     $duration = $item->getDuration();
     $now = getdate();
     $created = sprintf("%04d%02d%02d%02d%02d%02d", $now['year'], $now['mon'], $now['mday'], $now['hours'], $now['minutes'], $now['seconds']);
     $feedbacksgeneric = array();
     $this->object->setTitle($item->getTitle());
     $this->object->setComment($item->getComment());
     $this->object->setAuthor($item->getAuthor());
     $this->object->setOwner($ilUser->getId());
     $this->object->setQuestion($this->object->QTIMaterialToString($item->getQuestiontext()));
     $this->object->setObjId($questionpool_id);
     $this->object->setEstimatedWorkingTime($duration["h"], $duration["m"], $duration["s"]);
     $this->object->setPoints($item->getMetadataEntry("points"));
     $this->object->setOptionString($item->getMetadataEntry("option_string"));
     $this->object->setSampleSolution($item->getMetadataEntry("sample_solution"));
     $this->object->saveToDb('', false);
     // handle the import of media objects in XHTML code
     $questiontext = $this->object->getQuestion();
     if (is_array($_SESSION["import_mob_xhtml"])) {
         include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
         include_once "./Services/RTE/classes/class.ilRTE.php";
         foreach ($_SESSION["import_mob_xhtml"] as $mob) {
             if ($tst_id > 0) {
                 include_once "./Modules/Test/classes/class.ilObjTest.php";
                 $importfile = ilObjTest::_getImportDirectory() . '/' . $mob["uri"];
             } else {
                 include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
                 $importfile = ilObjQuestionPool::_getImportDirectory() . '/' . $mob["uri"];
             }
             $media_object =& ilObjMediaObject::_saveTempFileAsMediaObject(basename($importfile), $importfile, FALSE);
             ilObjMediaObject::_saveUsage($media_object->getId(), "qpl:html", $this->object->getId());
             $questiontext = str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $questiontext);
         }
     }
     $this->object->setQuestion(ilRTE::_replaceMediaObjectImageSrc($questiontext, 1));
     // feedback
     $feedbacksgeneric = array();
     foreach ($item->itemfeedback as $ifb) {
         if (strcmp($ifb->getIdent(), "response_allcorrect") == 0) {
             // found a feedback for the identifier
             if (count($ifb->material)) {
                 foreach ($ifb->material as $material) {
                     $feedbacksgeneric[1] = $material;
                 }
             }
             if (count($ifb->flow_mat) > 0) {
                 foreach ($ifb->flow_mat as $fmat) {
                     if (count($fmat->material)) {
                         foreach ($fmat->material as $material) {
                             $feedbacksgeneric[1] = $material;
                         }
                     }
                 }
             }
         } else {
             if (strcmp($ifb->getIdent(), "response_onenotcorrect") == 0) {
                 // found a feedback for the identifier
                 if (count($ifb->material)) {
                     foreach ($ifb->material as $material) {
                         $feedbacksgeneric[0] = $material;
                     }
                 }
                 if (count($ifb->flow_mat) > 0) {
                     foreach ($ifb->flow_mat as $fmat) {
                         if (count($fmat->material)) {
                             foreach ($fmat->material as $material) {
                                 $feedbacksgeneric[0] = $material;
                             }
                         }
                     }
                 }
             }
         }
     }
     // genericFeedback
     foreach ($feedbacksgeneric as $correctness => $material) {
         $m = $this->object->QTIMaterialToString($material);
         $feedbacksgeneric[$correctness] = $m;
     }
     foreach ($feedbacksgeneric as $correctness => $material) {
         //$this->object->saveFeedbackGeneric($correctness, ilRTE::_replaceMediaObjectImageSrc($material, 1));
         $this->object->feedbackOBJ->importGenericFeedback($this->object->getId(), $correctness, ilRTE::_replaceMediaObjectImageSrc($material, 1));
     }
     $this->object->saveToDb();
     if ($tst_id > 0) {
         $q_1_id = $this->object->getId();
         $question_id = $this->object->duplicate(true);
         $tst_object->questions[$question_counter++] = $question_id;
         $import_mapping[$item->getIdent()] = array("pool" => $q_1_id, "test" => $question_id);
     } else {
         $import_mapping[$item->getIdent()] = array("pool" => $this->object->getId(), "test" => 0);
     }
 }
 /**
  * Returns if the question type is allowed for adjustments in the global test administration.
  * 
  * @param assQuestionGUI $question_object
  * @return bool
  */
 protected function allowedInAdjustment(\assQuestionGUI $question_object)
 {
     $setting = new ilSetting('assessment');
     $types = explode(',', $setting->get('assessment_scoring_adjustment'));
     require_once './Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php';
     $type_def = array();
     foreach ($types as $type) {
         $type_def[$type] = ilObjQuestionPool::getQuestionTypeByTypeId($type);
     }
     $type = $question_object->getQuestionType();
     if (in_array($type, $type_def)) {
         return true;
     }
     return false;
 }
예제 #17
0
 /**
  * returns the full path to extracted qpl import archiv (qpl import dir + qpl archiv subdir)
  */
 protected function getQplImportArchivDirectory()
 {
     include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
     return ilObjQuestionPool::_getImportDirectory() . '/' . $_SESSION["qpl_import_subdir"];
 }
 public function copyQuestionsToPoolObject($returnResult = false)
 {
     //var_dump($_REQUEST);
     include_once 'Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php';
     $qpool = new ilObjQuestionPool($_REQUEST['sel_qpl'], true);
     $qpool->setOnline(ilObjQuestionPool::_lookupOnline($_REQUEST['sel_qpl'], true));
     $newIds = array();
     foreach ($_REQUEST['q_id'] as $q_id) {
         $newId = $qpool->copyQuestion($q_id, $qpool->getId());
         $newIds[$q_id] = $newId;
     }
     $result = new stdClass();
     $result->ids = $newIds;
     $result->qpool = $qpool;
     if ($returnResult) {
         return $result;
     } else {
         $this->backObject();
     }
 }
 /**
  * export object to xml (see ilias_co.dtd)
  *
  * @param	object		$a_xml_writer	ilXmlWriter object that receives the
  *										xml data
  */
 function exportXML(&$a_xml_writer, $a_inst, $a_target_dir, &$expLog)
 {
     global $ilBench;
     $attrs = array();
     switch ($this->getType()) {
         case "lm":
             $attrs["Type"] = "LearningModule";
             break;
         case "dbk":
             $attrs["Type"] = "LibObject";
             break;
     }
     $a_xml_writer->xmlStartTag("ContentObject", $attrs);
     // MetaData
     $this->exportXMLMetaData($a_xml_writer);
     // StructureObjects
     //echo "ContObj:".$a_inst.":<br>";
     $expLog->write(date("[y-m-d H:i:s] ") . "Start Export Structure Objects");
     $ilBench->start("ContentObjectExport", "exportStructureObjects");
     $this->exportXMLStructureObjects($a_xml_writer, $a_inst, $expLog);
     $ilBench->stop("ContentObjectExport", "exportStructureObjects");
     $expLog->write(date("[y-m-d H:i:s] ") . "Finished Export Structure Objects");
     // PageObjects
     $expLog->write(date("[y-m-d H:i:s] ") . "Start Export Page Objects");
     $ilBench->start("ContentObjectExport", "exportPageObjects");
     $this->exportXMLPageObjects($a_xml_writer, $a_inst, $expLog);
     $ilBench->stop("ContentObjectExport", "exportPageObjects");
     $expLog->write(date("[y-m-d H:i:s] ") . "Finished Export Page Objects");
     // MediaObjects
     $expLog->write(date("[y-m-d H:i:s] ") . "Start Export Media Objects");
     $ilBench->start("ContentObjectExport", "exportMediaObjects");
     $this->exportXMLMediaObjects($a_xml_writer, $a_inst, $a_target_dir, $expLog);
     $ilBench->stop("ContentObjectExport", "exportMediaObjects");
     $expLog->write(date("[y-m-d H:i:s] ") . "Finished Export Media Objects");
     // FileItems
     $expLog->write(date("[y-m-d H:i:s] ") . "Start Export File Items");
     $ilBench->start("ContentObjectExport", "exportFileItems");
     $this->exportFileItems($a_target_dir, $expLog);
     $ilBench->stop("ContentObjectExport", "exportFileItems");
     $expLog->write(date("[y-m-d H:i:s] ") . "Finished Export File Items");
     // Questions
     if (count($this->q_ids) > 0) {
         $qti_file = fopen($a_target_dir . "/qti.xml", "w");
         include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
         $pool = new ilObjQuestionPool();
         fwrite($qti_file, $pool->toXML($this->q_ids));
         fclose($qti_file);
     }
     // To do: implement version selection/detection
     // Properties
     $expLog->write(date("[y-m-d H:i:s] ") . "Start Export Properties");
     $this->exportXMLProperties($a_xml_writer, $expLog);
     $expLog->write(date("[y-m-d H:i:s] ") . "Finished Export Properties");
     $a_xml_writer->xmlEndTag("ContentObject");
 }
 /**
  * Creates a question from a QTI file
  *
  * Receives parameters from a QTI parser and creates a valid ILIAS question object
  *
  * @param object $item The QTI item object
  * @param integer $questionpool_id The id of the parent questionpool
  * @param integer $tst_id The id of the parent test if the question is part of a test
  * @param object $tst_object A reference to the parent test object
  * @param integer $question_counter A reference to a question counter to count the questions of an imported question pool
  * @param array $import_mapping An array containing references to included ILIAS objects
  * @access public
  */
 function fromXML(&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
 {
     global $ilUser;
     // empty session variable for imported xhtml mobs
     unset($_SESSION["import_mob_xhtml"]);
     $presentation = $item->getPresentation();
     $duration = $item->getDuration();
     $now = getdate();
     $created = sprintf("%04d%02d%02d%02d%02d%02d", $now['year'], $now['mon'], $now['mday'], $now['hours'], $now['minutes'], $now['seconds']);
     $feedbacksgeneric = array();
     $this->object->setTitle($item->getTitle());
     $this->object->setComment($item->getComment());
     $this->object->setAuthor($item->getAuthor());
     $this->object->setOwner($ilUser->getId());
     $this->object->setQuestion($this->object->QTIMaterialToString($item->getQuestiontext()));
     $this->object->setObjId($questionpool_id);
     $this->object->setEstimatedWorkingTime($duration["h"], $duration["m"], $duration["s"]);
     if (preg_match_all("/(\\\$v\\d+)/ims", $this->object->getQuestion(), $matches)) {
         foreach ($matches[1] as $variable) {
             $data = unserialize($item->getMetadataEntry($variable));
             $unit = $this->object->getUnitRepository()->getUnit($data["unitvalue"]);
             require_once 'Modules/TestQuestionPool/classes/class.assFormulaQuestionVariable.php';
             $varObj = new assFormulaQuestionVariable($variable, $data["rangemin"], $data["rangemax"], $unit, $data["precision"], $data["intprecision"]);
             $this->object->addVariable($varObj);
         }
     }
     if (preg_match_all("/(\\\$r\\d+)/ims", $this->object->getQuestion(), $rmatches)) {
         foreach ($rmatches[1] as $result) {
             $data = unserialize($item->getMetadataEntry($result));
             $unit = $this->object->getUnitRepository()->getUnit($data["unitvalue"]);
             require_once 'Modules/TestQuestionPool/classes/class.assFormulaQuestionResult.php';
             if (!is_array($data["rating"])) {
                 $resObj = new assFormulaQuestionResult($result, $data["rangemin"], $data["rangemax"], $data["tolerance"], $unit, $data["formula"], $data["points"], $data["precision"], TRUE);
             } else {
                 $resObj = new assFormulaQuestionResult($result, $data["rangemin"], $data["rangemax"], $data["tolerance"], $unit, $data["formula"], $data["points"], $data["precision"], FALSE, $data["rating"]["sign"], $data["rating"]["value"], $data["rating"]["unit"]);
             }
             $this->object->addResult($resObj);
             if (is_array($data["resultunits"])) {
                 foreach ($data["resultunits"] as $resu) {
                     $ru = $this->object->getUnitRepository()->getUnit($resu["unitvalue"]);
                     if (is_object($ru)) {
                         $this->object->addResultUnit($resObj, $ru);
                     }
                 }
             }
         }
     }
     $this->object->setPoints($item->getMetadataEntry("points"));
     $this->addGeneralMetadata($item);
     // additional content editing mode information
     $this->object->setAdditionalContentEditingMode($this->fetchAdditionalContentEditingModeInformation($item));
     $this->object->saveToDb();
     // handle the import of media objects in XHTML code
     $questiontext = $this->object->getQuestion();
     if (is_array($_SESSION["import_mob_xhtml"])) {
         include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
         include_once "./Services/RTE/classes/class.ilRTE.php";
         foreach ($_SESSION["import_mob_xhtml"] as $mob) {
             if ($tst_id > 0) {
                 include_once "./Modules/Test/classes/class.ilObjTest.php";
                 $importfile = ilObjTest::_getImportDirectory() . "/" . $_SESSION["tst_import_subdir"] . "/" . $mob["uri"];
             } else {
                 include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
                 $importfile = ilObjQuestionPool::_getImportDirectory() . "/" . $_SESSION["qpl_import_subdir"] . "/" . $mob["uri"];
             }
             $media_object =& ilObjMediaObject::_saveTempFileAsMediaObject(basename($importfile), $importfile, FALSE);
             ilObjMediaObject::_saveUsage($media_object->getId(), "qpl:html", $this->object->getId());
             $questiontext = str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $questiontext);
         }
     }
     $this->object->setQuestion(ilRTE::_replaceMediaObjectImageSrc($questiontext, 1));
     // additional content editing mode information
     $this->object->setAdditionalContentEditingMode($this->fetchAdditionalContentEditingModeInformation($item));
     $this->object->saveToDb();
     if (count($item->suggested_solutions)) {
         foreach ($item->suggested_solutions as $suggested_solution) {
             $this->object->setSuggestedSolution($suggested_solution["solution"]->getContent(), $suggested_solution["gap_index"], true);
         }
         $this->object->saveToDb();
     }
     if ($tst_id > 0) {
         $q_1_id = $this->object->getId();
         $question_id = $this->object->duplicate(true);
         $tst_object->questions[$question_counter++] = $question_id;
         $import_mapping[$item->getIdent()] = array("pool" => $q_1_id, "test" => $question_id);
     } else {
         $import_mapping[$item->getIdent()] = array("pool" => $this->object->getId(), "test" => 0);
     }
 }
 /**
  * Save Assessment settings
  */
 public function saveSettingsObject()
 {
     global $ilAccess;
     if (!$ilAccess->checkAccess("write", "", $this->object->getRefId())) {
         $this->ctrl->redirect($this, 'settings');
     }
     $form = $this->buildSettingsForm();
     if (!$form->checkInput()) {
         $form->setValuesByPost();
         return $this->settingsObject($form);
     }
     $this->object->_setManualScoring($_POST["chb_manual_scoring"]);
     include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
     $questiontypes =& ilObjQuestionPool::_getQuestionTypes(TRUE);
     $forbidden_types = array();
     foreach ($questiontypes as $name => $row) {
         if (!in_array($row["question_type_id"], $_POST["chb_allowed_questiontypes"])) {
             array_push($forbidden_types, $row["question_type_id"]);
         }
     }
     $this->object->_setForbiddenQuestionTypes($forbidden_types);
     $this->object->setScoringAdjustmentEnabled($_POST['chb_scoring_adjust']);
     $scoring_types = array();
     foreach ($questiontypes as $name => $row) {
         if (in_array($row["question_type_id"], (array) $_POST["chb_scoring_adjustment"])) {
             array_push($scoring_types, $row["question_type_id"]);
         }
     }
     $this->object->setScoringAdjustableQuestions($scoring_types);
     if (!$_POST['ass_process_lock']) {
         $this->object->setAssessmentProcessLockMode(ilObjAssessmentFolder::ASS_PROC_LOCK_MODE_NONE);
     } elseif (in_array($_POST['ass_process_lock_mode'], ilObjAssessmentFolder::getValidAssessmentProcessLockModes())) {
         $this->object->setAssessmentProcessLockMode($_POST['ass_process_lock_mode']);
     }
     $assessmentSetting = new ilSetting('assessment');
     $assessmentSetting->set('use_javascript', '1');
     if (strlen($_POST['imap_line_color']) == 6) {
         $assessmentSetting->set('imap_line_color', ilUtil::stripSlashes($_POST['imap_line_color']));
     }
     $assessmentSetting->set('user_criteria', ilUtil::stripSlashes($_POST['user_criteria']));
     ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
     $this->ctrl->redirect($this, 'settings');
 }
 /**
  * Save Assessment settings
  */
 public function saveSettingsObject()
 {
     global $ilAccess;
     if (!$ilAccess->checkAccess("write", "", $this->object->getRefId())) {
         $this->ctrl->redirect($this, 'settings');
     }
     if ($_POST["chb_assessment_logging"] == 1) {
         $this->object->_enableAssessmentLogging(1);
     } else {
         $this->object->_enableAssessmentLogging(0);
     }
     $this->object->_setLogLanguage($_POST["reporting_language"]);
     $this->object->_setManualScoring($_POST["chb_manual_scoring"]);
     include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
     $questiontypes =& ilObjQuestionPool::_getQuestionTypes(TRUE);
     $forbidden_types = array();
     foreach ($questiontypes as $name => $row) {
         if (!in_array($row["question_type_id"], $_POST["chb_allowed_questiontypes"])) {
             array_push($forbidden_types, $row["question_type_id"]);
         }
     }
     $this->object->_setForbiddenQuestionTypes($forbidden_types);
     ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
     $this->ctrl->redirect($this, 'settings');
 }
 public function addQuestion()
 {
     global $lng, $ilCtrl, $tpl;
     include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
     $ilCtrl->setParameter($this, 'qtype', $_REQUEST['qtype']);
     $form = new ilPropertyFormGUI();
     $ilCtrl->setParameter($this, 'test_express_mode', 1);
     $form->setFormAction($ilCtrl->getFormAction($this, "handleToolbarCommand"));
     $form->setTitle($lng->txt("ass_create_question"));
     include_once 'Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php';
     $pool = new ilObjQuestionPool();
     $questionTypes = $pool->getQuestionTypes(false, true);
     $options = array();
     // question type
     foreach ($questionTypes as $label => $data) {
         $options[$data['question_type_id']] = $label;
     }
     include_once "./Services/Form/classes/class.ilSelectInputGUI.php";
     $si = new ilSelectInputGUI($lng->txt("question_type"), "qtype");
     $si->setOptions($options);
     $form->addItem($si, true);
     // position
     $questions = $this->test_object->getQuestionTitlesAndIndexes();
     if ($questions) {
         $si = new ilSelectInputGUI($lng->txt("position"), "position");
         $options = array('0' => $lng->txt('first'));
         foreach ($questions as $key => $title) {
             $options[$key] = $lng->txt('behind') . ' ' . $title . ' [' . $this->lng->txt('question_id_short') . ': ' . $key . ']';
         }
         $si->setOptions($options);
         $si->setValue($_REQUEST['q_id']);
         $form->addItem($si, true);
     }
     // content editing mode
     if (ilObjAssessmentFolder::isAdditionalQuestionContentEditingModePageObjectEnabled()) {
         $ri = new ilRadioGroupInputGUI($lng->txt("tst_add_quest_cont_edit_mode"), "add_quest_cont_edit_mode");
         $ri->addOption(new ilRadioOption($lng->txt('tst_add_quest_cont_edit_mode_default'), assQuestion::ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT));
         $ri->addOption(new ilRadioOption($lng->txt('tst_add_quest_cont_edit_mode_page_object'), assQuestion::ADDITIONAL_CONTENT_EDITING_MODE_PAGE_OBJECT));
         $ri->setValue(assQuestion::ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT);
         $form->addItem($ri, true);
     } else {
         $hi = new ilHiddenInputGUI("question_content_editing_type");
         $hi->setValue(assQuestion::ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT);
         $form->addItem($hi, true);
     }
     if ($this->test_object->getPoolUsage()) {
         // use pool
         $usage = new ilRadioGroupInputGUI($this->lng->txt("assessment_pool_selection"), "usage");
         $usage->setRequired(true);
         $no_pool = new ilRadioOption($this->lng->txt("assessment_no_pool"), 1);
         $usage->addOption($no_pool);
         $existing_pool = new ilRadioOption($this->lng->txt("assessment_existing_pool"), 3);
         $usage->addOption($existing_pool);
         $new_pool = new ilRadioOption($this->lng->txt("assessment_new_pool"), 2);
         $usage->addOption($new_pool);
         $form->addItem($usage);
         $usage->setValue(1);
         $questionpools = ilObjQuestionPool::_getAvailableQuestionpools(FALSE, FALSE, TRUE, FALSE, FALSE, "write");
         $pools_data = array();
         foreach ($questionpools as $key => $p) {
             $pools_data[$key] = $p['title'];
         }
         $pools = new ilSelectInputGUI($this->lng->txt("select_questionpool"), "sel_qpl");
         $pools->setOptions($pools_data);
         $existing_pool->addSubItem($pools);
         $name = new ilTextInputGUI($this->lng->txt("name"), "txt_qpl");
         $name->setSize(50);
         $name->setMaxLength(50);
         $new_pool->addSubItem($name);
     }
     $form->addCommandButton("handleToolbarCommand", $lng->txt("submit"));
     $form->addCommandButton("questions", $lng->txt("cancel"));
     return $tpl->setContent($form->getHTML());
 }
 /**
  * Init filter
  */
 function initFilter()
 {
     global $lng, $rbacreview, $ilUser;
     // title
     include_once "./Services/Form/classes/class.ilTextInputGUI.php";
     $ti = new ilTextInputGUI($lng->txt("title"), "title");
     $ti->setMaxLength(64);
     $ti->setValidationRegexp('/^[^%]+$/is');
     $ti->setSize(20);
     $this->addFilterItem($ti);
     $ti->readFromSession();
     $this->filter["title"] = $ti->getValue();
     // description
     $ti = new ilTextInputGUI($lng->txt("description"), "description");
     $ti->setMaxLength(64);
     $ti->setSize(20);
     $ti->setValidationRegexp('/^[^%]+$/is');
     $this->addFilterItem($ti);
     $ti->readFromSession();
     $this->filter["description"] = $ti->getValue();
     if (!$this->confirmdelete) {
         // author
         $ti = new ilTextInputGUI($lng->txt("author"), "author");
         $ti->setMaxLength(64);
         $ti->setSize(20);
         $ti->setValidationRegexp('/^[^%]+$/is');
         $this->addFilterItem($ti);
         $ti->readFromSession();
         $this->filter["author"] = $ti->getValue();
     }
     // questiontype
     include_once "./Services/Form/classes/class.ilSelectInputGUI.php";
     include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
     $types = ilObjQuestionPool::_getQuestionTypes();
     $options = array();
     $options[""] = $lng->txt('filter_all_question_types');
     foreach ($types as $translation => $row) {
         $options[$row['type_tag']] = $translation;
     }
     $si = new ilSelectInputGUI($this->lng->txt("question_type"), "type");
     $si->setOptions($options);
     $this->addFilterItem($si);
     $si->readFromSession();
     $this->filter["type"] = $si->getValue();
     if ($this->parent_obj->object->getShowTaxonomies()) {
         require_once 'Services/Taxonomy/classes/class.ilTaxSelectInputGUI.php';
         foreach ($this->taxIds as $taxId) {
             if ($taxId == $this->parent_obj->object->getNavTaxonomyId()) {
                 continue;
             }
             $postvar = "tax_{$taxId}";
             $inp = new ilTaxSelectInputGUI($taxId, $postvar, true);
             $this->addFilterItem($inp);
             $inp->readFromSession();
             $this->filter[$postvar] = $inp->getValue();
         }
     }
 }
 public function initFilter()
 {
     // title
     include_once "./Services/Form/classes/class.ilTextInputGUI.php";
     $ti = new ilTextInputGUI($this->lng->txt("tst_qbt_filter_question_title"), "title");
     $ti->setMaxLength(64);
     $ti->setSize(20);
     $ti->setValidationRegexp('/(^[^%]+$)|(^$)/is');
     $this->addFilterItem($ti);
     $ti->readFromSession();
     $this->filter["title"] = $ti->getValue();
     // description
     $ti = new ilTextInputGUI($this->lng->txt("description"), "description");
     $ti->setMaxLength(64);
     $ti->setSize(20);
     $ti->setValidationRegexp('/(^[^%]+$)|(^$)/is');
     $this->addFilterItem($ti);
     $ti->readFromSession();
     $this->filter["description"] = $ti->getValue();
     // questiontype
     include_once "./Services/Form/classes/class.ilSelectInputGUI.php";
     include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
     $types = ilObjQuestionPool::_getQuestionTypes();
     $options = array();
     $options[""] = $this->lng->txt('filter_all_question_types');
     foreach ($types as $translation => $row) {
         $options[$row['type_tag']] = $translation;
     }
     $si = new ilSelectInputGUI($this->lng->txt("question_type"), "type");
     $si->setOptions($options);
     $this->addFilterItem($si);
     $si->readFromSession();
     $this->filter["type"] = $si->getValue();
     // author
     $ti = new ilTextInputGUI($this->lng->txt("author"), "author");
     $ti->setMaxLength(64);
     $ti->setSize(20);
     $this->addFilterItem($ti);
     $ti->setValidationRegexp('/(^[^%]+$)|(^$)/is');
     $ti->readFromSession();
     $this->filter["author"] = $ti->getValue();
     // question pool
     $ti = new ilTextInputGUI($this->getParentObjectLabel(), 'parent_title');
     $ti->setMaxLength(64);
     $ti->setSize(20);
     $ti->setValidationRegexp('/(^[^%]+$)|(^$)/is');
     $this->addFilterItem($ti);
     $ti->readFromSession();
     $this->filter['parent_title'] = $ti->getValue();
     // repo root node
     require_once 'Services/Form/classes/class.ilRepositorySelectorInputGUI.php';
     $ri = new ilRepositorySelectorInputGUI($this->lng->txt('repository'), 'repository_root_node');
     $ri->setHeaderMessage($this->lng->txt('question_browse_area_info'));
     $this->addFilterItem($ri);
     $ri->readFromSession();
     $this->filter['repository_root_node'] = $ri->getValue();
 }
예제 #26
0
 /**
  * Creates a question from a QTI file
  *
  * Receives parameters from a QTI parser and creates a valid ILIAS question object
  *
  * @param object $item The QTI item object
  * @param integer $questionpool_id The id of the parent questionpool
  * @param integer $tst_id The id of the parent test if the question is part of a test
  * @param object $tst_object A reference to the parent test object
  * @param integer $question_counter A reference to a question counter to count the questions of an imported question pool
  * @param array $import_mapping An array containing references to included ILIAS objects
  * @access public
  */
 function fromXML(&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
 {
     global $ilUser;
     // empty session variable for imported xhtml mobs
     unset($_SESSION["import_mob_xhtml"]);
     $presentation = $item->getPresentation();
     $duration = $item->getDuration();
     $now = getdate();
     $maxchars = 0;
     $maxpoints = 0;
     $created = sprintf("%04d%02d%02d%02d%02d%02d", $now['year'], $now['mon'], $now['mday'], $now['hours'], $now['minutes'], $now['seconds']);
     foreach ($presentation->order as $entry) {
         switch ($entry["type"]) {
             case "response":
                 $response = $presentation->response[$entry["index"]];
                 $rendertype = $response->getRenderType();
                 switch (strtolower(get_class($rendertype))) {
                     case "ilqtirenderfib":
                         $maxchars = $rendertype->getMaxchars();
                         break;
                 }
                 break;
         }
     }
     $feedbacksgeneric = array();
     foreach ($item->resprocessing as $resprocessing) {
         $outcomes = $resprocessing->getOutcomes();
         foreach ($outcomes->decvar as $decvar) {
             $maxpoints = $decvar->getMaxvalue();
         }
         foreach ($resprocessing->respcondition as $respcondition) {
             foreach ($respcondition->displayfeedback as $feedbackpointer) {
                 if (strlen($feedbackpointer->getLinkrefid())) {
                     foreach ($item->itemfeedback as $ifb) {
                         if (strcmp($ifb->getIdent(), "response_allcorrect") == 0) {
                             // found a feedback for the identifier
                             if (count($ifb->material)) {
                                 foreach ($ifb->material as $material) {
                                     $feedbacksgeneric[1] = $material;
                                 }
                             }
                             if (count($ifb->flow_mat) > 0) {
                                 foreach ($ifb->flow_mat as $fmat) {
                                     if (count($fmat->material)) {
                                         foreach ($fmat->material as $material) {
                                             $feedbacksgeneric[1] = $material;
                                         }
                                     }
                                 }
                             }
                         } else {
                             if (strcmp($ifb->getIdent(), "response_onenotcorrect") == 0) {
                                 // found a feedback for the identifier
                                 if (count($ifb->material)) {
                                     foreach ($ifb->material as $material) {
                                         $feedbacksgeneric[0] = $material;
                                     }
                                 }
                                 if (count($ifb->flow_mat) > 0) {
                                     foreach ($ifb->flow_mat as $fmat) {
                                         if (count($fmat->material)) {
                                             foreach ($fmat->material as $material) {
                                                 $feedbacksgeneric[0] = $material;
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $this->object->setTitle($item->getTitle());
     $this->object->setComment($item->getComment());
     $this->object->setAuthor($item->getAuthor());
     $this->object->setOwner($ilUser->getId());
     $this->object->setQuestion($this->object->QTIMaterialToString($item->getQuestiontext()));
     $this->object->setObjId($questionpool_id);
     $this->object->setEstimatedWorkingTime($duration["h"], $duration["m"], $duration["s"]);
     $this->object->setPoints($maxpoints);
     $this->object->setMaxNumOfChars($maxchars);
     $textrating = $item->getMetadataEntry("textrating");
     if (strlen($textrating)) {
         $this->object->setTextRating($textrating);
     }
     $keywords = $item->getMetadataEntry("keywords");
     if (strlen($keywords)) {
         $this->object->setKeywords($keywords);
     }
     $this->object->saveToDb();
     if (count($item->suggested_solutions)) {
         foreach ($item->suggested_solutions as $suggested_solution) {
             $this->object->setSuggestedSolution($suggested_solution["solution"]->getContent(), $suggested_solution["gap_index"], true);
         }
         $this->object->saveToDb();
     }
     foreach ($feedbacksgeneric as $correctness => $material) {
         $m = $this->object->QTIMaterialToString($material);
         $feedbacksgeneric[$correctness] = $m;
     }
     // handle the import of media objects in XHTML code
     $questiontext = $this->object->getQuestion();
     if (is_array($_SESSION["import_mob_xhtml"])) {
         include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
         include_once "./Services/RTE/classes/class.ilRTE.php";
         foreach ($_SESSION["import_mob_xhtml"] as $mob) {
             if ($tst_id > 0) {
                 include_once "./Modules/Test/classes/class.ilObjTest.php";
                 $importfile = ilObjTest::_getImportDirectory() . "/" . $_SESSION["tst_import_subdir"] . "/" . $mob["uri"];
             } else {
                 include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
                 $importfile = ilObjQuestionPool::_getImportDirectory() . "/" . $_SESSION["qpl_import_subdir"] . "/" . $mob["uri"];
             }
             $media_object =& ilObjMediaObject::_saveTempFileAsMediaObject(basename($importfile), $importfile, FALSE);
             ilObjMediaObject::_saveUsage($media_object->getId(), "qpl:html", $this->object->getId());
             $questiontext = str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $questiontext);
             foreach ($feedbacksgeneric as $correctness => $material) {
                 $feedbacksgeneric[$correctness] = str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $material);
             }
         }
     }
     $this->object->setQuestion(ilRTE::_replaceMediaObjectImageSrc($questiontext, 1));
     foreach ($feedbacksgeneric as $correctness => $material) {
         $this->object->saveFeedbackGeneric($correctness, ilRTE::_replaceMediaObjectImageSrc($material, 1));
     }
     $this->object->saveToDb();
     if ($tst_id > 0) {
         $q_1_id = $this->object->getId();
         $question_id = $this->object->duplicate(true);
         $tst_object->questions[$question_counter++] = $question_id;
         $import_mapping[$item->getIdent()] = array("pool" => $q_1_id, "test" => $question_id);
     } else {
         $import_mapping[$item->getIdent()] = array("pool" => $this->object->getId(), "test" => 0);
     }
 }
예제 #27
0
 /**
 * Calculates the available questions for a test
 *
 * @access public
 */
 function getAvailableQuestions($arrFilter, $completeonly = 0)
 {
     global $ilUser;
     global $ilDB;
     include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
     $available_pools = array_keys(ilObjQuestionPool::_getAvailableQuestionpools($use_object_id = TRUE, $equal_points = FALSE, $could_be_offline = FALSE, $showPath = FALSE, $with_questioncount = FALSE));
     $available = "";
     if (count($available_pools)) {
         $available = " AND " . $ilDB->in('qpl_questions.obj_fi', $available_pools, false, 'integer');
     } else {
         return array();
     }
     if ($completeonly) {
         $available .= " AND qpl_questions.complete = " . $ilDB->quote("1", 'text');
     }
     $where = "";
     if (is_array($arrFilter)) {
         if (array_key_exists('title', $arrFilter) && strlen($arrFilter['title'])) {
             $where .= " AND " . $ilDB->like('qpl_questions.title', 'text', "%%" . $arrFilter['title'] . "%%");
         }
         if (array_key_exists('description', $arrFilter) && strlen($arrFilter['description'])) {
             $where .= " AND " . $ilDB->like('qpl_questions.description', 'text', "%%" . $arrFilter['description'] . "%%");
         }
         if (array_key_exists('author', $arrFilter) && strlen($arrFilter['author'])) {
             $where .= " AND " . $ilDB->like('qpl_questions.author', 'text', "%%" . $arrFilter['author'] . "%%");
         }
         if (array_key_exists('type', $arrFilter) && strlen($arrFilter['type'])) {
             $where .= " AND qpl_qst_type.type_tag = " . $ilDB->quote($arrFilter['type'], 'text');
         }
         if (array_key_exists('qpl', $arrFilter) && strlen($arrFilter['qpl'])) {
             $where .= " AND " . $ilDB->like('object_data.title', 'text', "%%" . $arrFilter['qpl'] . "%%");
         }
     }
     $original_ids =& $this->getExistingQuestions();
     $original_clause = " AND qpl_questions.original_id IS NULL";
     if (count($original_ids)) {
         $original_clause = " AND qpl_questions.original_id IS NULL AND " . $ilDB->in('qpl_questions.question_id', $original_ids, true, 'integer');
     }
     $query_result = $ilDB->query("\n\t\t\tSELECT\t\tqpl_questions.*,\n\t\t\t\t\t\tqpl_questions.tstamp,\n\t\t\t\t\t\tqpl_qst_type.type_tag,\n\t\t\t\t\t\tqpl_qst_type.plugin,\n\t\t\t\t\t\tobject_data.title qpl\n\t\t\t\t\t\t\n\t\t\tFROM\t\tqpl_questions\n\t\t\t\n\t\t\tINNER JOIN\tqpl_qst_type\n\t\t\tON \t\t\tqpl_qst_type.question_type_id = qpl_questions.question_type_fi\n\t\t\t\n\t\t\tINNER JOIN\tobject_data\n\t\t\tON\t\t\tobject_data.obj_id = qpl_questions.obj_fi\n\t\t\t\t\t\t\n\t\t\tWHERE\t\tqpl_questions.tstamp > 0\n\t\t\t\n\t\t\t{$original_clause}\n\t\t\t{$available}\n\t\t\t{$where}\n\t\t");
     $rows = array();
     $types = $this->getQuestionTypeTranslations();
     if ($query_result->numRows()) {
         while ($row = $ilDB->fetchAssoc($query_result)) {
             $row['ttype'] = $types[$row['type_tag']];
             if ($row["plugin"]) {
                 if ($this->isPluginActive($row["type_tag"])) {
                     array_push($rows, $row);
                 }
             } else {
                 array_push($rows, $row);
             }
         }
     }
     return $rows;
 }
예제 #28
0
 public static function isSkillManagementGloballyActivated()
 {
     if (self::$isSkillManagementGloballyActivated === null) {
         include_once 'Services/Skill/classes/class.ilSkillManagementSettings.php';
         $skmgSet = new ilSkillManagementSettings();
         self::$isSkillManagementGloballyActivated = $skmgSet->isActivated();
     }
     return self::$isSkillManagementGloballyActivated;
 }
예제 #29
0
 /**
  * Creates a new questionpool and returns the reference id
  *
  * Creates a new questionpool and returns the reference id
  *
  * @return integer Reference id of the newly created questionpool
  * @access	public
  */
 function createQuestionPool($name = "Dummy")
 {
     global $tree;
     $parent_ref = $tree->getParentId($_GET["ref_id"]);
     include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
     $qpl = new ilObjQuestionPool();
     $qpl->setType("qpl");
     $qpl->setTitle($name);
     $qpl->setDescription("");
     $qpl->create();
     $qpl->createReference();
     $qpl->putInTree($parent_ref);
     $qpl->setPermissions($parent_ref);
     $qpl->setOnline(1);
     // must be online to be available
     $qpl->saveToDb();
     return $qpl->getRefId();
 }
예제 #30
0
 private function loadQPList($qpItem)
 {
     $retval = array();
     $curT = intval(time());
     // $this->log(json_encode($qpItem));
     // check predefined timings
     if (intval($qpItem["timing_type"]) == 0) {
         // ensure that the correct timings are used
         if (array_key_exists("start", $qpItem) && ($curT < intval($qpItem["start"]) || $curT > intval($qpItem["end"])) || array_key_exists("timing_start", $qpItem) && ($curT < intval($qpItem["timing_start"]) || $curT > intval($qpItem["timing_end"]))) {
             $this->log('bad timig, skip question pool');
             return $retval;
         }
     }
     $questionPool = new ilObjQuestionPool($qpItem["ref_id"]);
     $questionPool->read();
     // check online state
     if ($questionPool->getOnline() == 0) {
         $this->log('offline, skip question pool');
         return $retval;
     }
     $questions = $questionPool->getQuestionList();
     if (empty($questions)) {
         // ignore empty question pools
         return $retval;
     }
     // load the actual questions.
     if ($this->iliasVersion != "4.2") {
         $retval["questions"] = $this->getQuestionListNew($questions);
     } else {
         $retval["questions"] = $this->getQuestionListOld($questions);
     }
     $retval["id"] = $qpItem["ref_id"];
     // pass only the reference id
     $retval["title"] = $questionPool->getTitle();
     $retval["description"] = $questionPool->getDescription();
     if (intval($qpItem["timing_type"]) == 0) {
         // pass the end-date on, so the remote broker can switch
         // the pool off if necessary.
         if (array_key_exists("end", $qpItem)) {
             $retval["end-date"] = intval($qpItem["end"]);
         } else {
             if (array_key_exists("timing_end", $qpItem)) {
                 $retval["end-date"] = intval($qpItem["timing_end"]);
             }
         }
     }
     return $retval;
 }