/**
  * Constructor
  * 
  * @access	public
  * @global	ilCtrl					$ilCtrl
  * @global	ilLanguage				$lng
  * @param	assQuestion				$questionOBJ
  * @param	ilAssQuestionHintList	$questionHintList
  * @param	ilAssQuestionHintsGUI	$parentGUI
  * @param	string					$parentCmd 
  */
 public function __construct(assQuestion $questionOBJ, ilAssQuestionHintList $questionHintList, ilAssQuestionHintAbstractGUI $parentGUI, $parentCmd, $tableMode = self::TBL_MODE_TESTOUTPUT, ilAssQuestionHintsOrderingClipboard $hintOrderingClipboard = null)
 {
     global $ilCtrl, $lng;
     $this->questionOBJ = $questionOBJ;
     $this->tableMode = $tableMode;
     $this->hintOrderingClipboard = $hintOrderingClipboard;
     $this->setPrefix('tst_question_hints' . $tableMode);
     $this->setId('tst_question_hints' . $tableMode);
     parent::__construct($parentGUI, $parentCmd);
     $this->setTitle(sprintf($lng->txt('tst_question_hints_table_header'), $questionOBJ->getTitle()));
     $this->setNoEntriesText($lng->txt('tst_question_hints_table_no_items'));
     // we don't take care about offset/limit values, so this avoids segmentation in general
     // --> required for ordering via clipboard feature
     $this->setExternalSegmentation(true);
     $tableData = $questionHintList->getTableData();
     $this->setData($tableData);
     if ($this->tableMode == self::TBL_MODE_ADMINISTRATION) {
         $this->setRowTemplate('tpl.tst_question_hints_administration_table_row.html', 'Modules/TestQuestionPool');
         $this->setSelectAllCheckbox('hint_ids[]');
         $rowCount = count($tableData);
         $this->initAdministrationColumns($rowCount);
         $this->initAdministrationCommands($rowCount);
     } else {
         $this->setRowTemplate('tpl.tst_question_hints_testoutput_table_row.html', 'Modules/TestQuestionPool');
         $this->initTestoutputColumns();
         $this->initTestoutputCommands();
     }
 }
 /**
  * @param assQuestion $question
  */
 private function deleteTestsParticipantsQuestionData(assQuestion $question)
 {
     $activeIds = $this->getActiveIds();
     if (!count($activeIds)) {
         return null;
     }
     $this->deleteTestsParticipantsResultsForQuestion($activeIds, $question->getId());
     $this->deleteTestsParticipantsTrackingsForQuestion($activeIds, $question->getId());
 }
 /**
  * Constructor
  *
  * @access	public
  * @param	assQuestion	$questionOBJ 
  */
 public function __construct(assQuestion $questionOBJ)
 {
     $this->questionId = $questionOBJ->getId();
     if (!isset($_SESSION[__CLASS__])) {
         $_SESSION[__CLASS__] = array();
     }
     if (!isset($_SESSION[__CLASS__][$this->questionId])) {
         $_SESSION[__CLASS__][$this->questionId] = null;
     }
 }
 /**
  *
  */
 protected function initData()
 {
     $rows = array();
     $total_of_answers = $this->question->getTotalAnswers();
     if ($total_of_answers) {
         $rows[] = array('result' => $this->lng->txt('qpl_assessment_total_of_answers'), 'value' => $total_of_answers);
         $rows[] = array('result' => $this->lng->txt('qpl_assessment_total_of_right_answers'), 'value' => assQuestion::_getTotalRightAnswers($this->question->getId()) * 100.0);
     } else {
         $this->disable('header');
     }
     $this->setData($rows);
 }
 /**
  * @param assQuestion $question
  */
 public function deleteTestsParticipantsResultsForQuestion(assQuestion $question)
 {
     $activeIds = $this->getActiveIds();
     if (!count($activeIds)) {
         return null;
     }
     $inActiveIds = $this->db->in('active_fi', $activeIds, false, 'integer');
     $this->db->manipulateF("DELETE FROM tst_solutions WHERE question_fi = %s AND {$inActiveIds}", array('integer'), array($question->getId()));
     $this->db->manipulateF("DELETE FROM tst_qst_solved WHERE question_fi = %s AND {$inActiveIds}", array('integer'), array($question->getId()));
     $this->db->manipulateF("DELETE FROM tst_test_result WHERE question_fi = %s AND {$inActiveIds}", array('integer'), array($question->getId()));
     $this->db->manipulate("DELETE FROM tst_pass_result WHERE {$inActiveIds}");
     $this->db->manipulate("DELETE FROM tst_result_cache WHERE {$inActiveIds}");
 }
 /**
  * Send notifications
  * @return 
  */
 public function send()
 {
     global $ilUser;
     switch ($this->getType()) {
         case self::TYPE_USER_BLOCKED:
             foreach ($this->getRecipients() as $rcp) {
                 $this->initLanguage($rcp);
                 $this->initMail();
                 $this->setSubject(sprintf($this->getLanguageText('cont_user_blocked'), $this->getObjectTitle(true)));
                 $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
                 $this->appendBody("\n\n");
                 $this->appendBody($this->getLanguageText('cont_user_blocked2'));
                 $this->appendBody("\n");
                 $this->appendBody($this->getLanguageText('cont_user_blocked3') . " '" . $this->getLanguageText('objs_qst') . "' > '" . $this->getLanguageText('cont_blocked_users') . "'");
                 $this->appendBody("\n");
                 $this->appendBody($this->getLanguageText('obj_lm') . ": " . $this->getObjectTitle(true));
                 $this->appendBody("\n");
                 include_once "./Services/User/classes/class.ilUserUtil.php";
                 $this->appendBody($this->getLanguageText('user') . ": " . ilUserUtil::getNamePresentation($ilUser->getId(), false, false, ""));
                 $this->appendBody("\n");
                 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
                 $this->appendBody($this->getLanguageText('question') . ": " . assQuestion::_getTitle($this->getQuestionId()));
                 $this->appendBody("\n");
                 $this->appendBody("\n\n");
                 $this->appendBody($this->getLanguageText('cont_lm_mail_permanent_link'));
                 $this->appendBody("\n");
                 $this->appendBody($this->createPermanentLink(array(), ""));
                 $this->getMail()->appendInstallationSignature(true);
                 $this->sendMail(array($rcp), array('system'));
             }
             break;
     }
     return true;
 }
 /**
  * 
  */
 protected function initData()
 {
     /**
      * @var $tree ilTree
      */
     global $tree;
     $path = new ilPathGUI();
     $rows = array();
     foreach ($this->question->getInstances() as $instance) {
         foreach ($instance['refs'] as $ref_id) {
             $trashed = $tree->isDeleted($ref_id);
             $rows[] = array('title' => $instance['title'], 'author' => $instance['author'], 'ref_id' => $ref_id, 'is_trashed' => $trashed, 'path' => $trashed ? $this->lng->txt('deleted') : $path->getPath(ROOT_FOLDER_ID, $ref_id));
         }
     }
     $this->setData($rows);
 }
 /**
  * renders a table row by filling wor data to table row template
  * 
  * @access	public
  * @global	ilCtrl		$ilCtrl
  * @global	ilLanguage	$lng
  * @param	array		$rowData
  */
 public function fillRow($rowData)
 {
     global $ilCtrl, $lng;
     if ($this->tableMode == self::TBL_MODE_ADMINISTRATION) {
         $list = new ilAdvancedSelectionListGUI();
         $list->setListTitle($lng->txt('actions'));
         $list->setId("advsl_hint_{$rowData['hint_id']}_actions");
         if ($this->questionOBJ->isAdditionalContentEditingModePageObject()) {
             $editPointsHref = $ilCtrl->getLinkTargetByClass('ilAssQuestionHintGUI', ilAssQuestionHintGUI::CMD_SHOW_FORM);
             $editPointsHref = ilUtil::appendUrlParameterString($editPointsHref, "hint_id={$rowData['hint_id']}", true);
             $list->addItem($lng->txt('tst_question_hints_table_link_edit_hint_points'), '', $editPointsHref);
             $editPageHref = $ilCtrl->getLinkTargetByClass('ilasshintpagegui', 'edit');
             $editPageHref = ilUtil::appendUrlParameterString($editPageHref, "hint_id={$rowData['hint_id']}", true);
             $list->addItem($lng->txt('tst_question_hints_table_link_edit_hint_page'), '', $editPageHref);
         } else {
             $editHref = $ilCtrl->getLinkTargetByClass('ilAssQuestionHintGUI', ilAssQuestionHintGUI::CMD_SHOW_FORM);
             $editHref = ilUtil::appendUrlParameterString($editHref, "hint_id={$rowData['hint_id']}", true);
             $list->addItem($lng->txt('tst_question_hints_table_link_edit_hint'), '', $editHref);
         }
         $deleteHref = $ilCtrl->getLinkTarget($this->parent_obj, ilAssQuestionHintsGUI::CMD_CONFIRM_DELETE);
         $deleteHref = ilUtil::appendUrlParameterString($deleteHref, "hint_id={$rowData['hint_id']}", true);
         $list->addItem($lng->txt('tst_question_hints_table_link_delete_hint'), '', $deleteHref);
         $this->tpl->setVariable('ACTIONS', $list->getHTML());
         $this->tpl->setVariable('HINT_ID', $rowData['hint_id']);
         $hintIndex = $rowData['hint_index'] * self::INDEX_TO_POSITION_FACTOR;
     } else {
         $showHref = $this->parent_obj->getHintPresentationLinkTarget($rowData['hint_id']);
         $this->tpl->setVariable('HINT_HREF', $showHref);
         $hintIndex = ilAssQuestionHint::getHintIndexLabel($lng, $rowData['hint_index']);
     }
     $this->tpl->setVariable('HINT_INDEX', $hintIndex);
     $this->tpl->setVariable('HINT_TEXT', $rowData['hint_text']);
     $this->tpl->setVariable('HINT_POINTS', $rowData['hint_points']);
 }
 private function purgeQuestionIds($questionIds)
 {
     require_once 'Modules/TestQuestionPool/classes/class.assQuestion.php';
     foreach ($questionIds as $questionId) {
         $question = assQuestion::_instantiateQuestion($questionId);
         $question->delete($questionId);
     }
 }
Exemplo n.º 10
0
 /**
  * @return iQuestionCondition
  */
 public function getQuestion()
 {
     if ($this->question === null && $this->questionId) {
         require_once 'Modules/TestQuestionPool/classes/class.assQuestion.php';
         $this->question = assQuestion::_instantiateQuestion($this->questionId);
     }
     return $this->question;
 }
Exemplo n.º 11
0
 /**
  * fetches the "additional content editing mode" information from qti item
  * and falls back to ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT when no or invalid information is given
  * 
  * @final
  * @access protected
  * @param type $qtiItem
  * @return string $additionalContentEditingMode
  */
 protected final function fetchAdditionalContentEditingModeInformation($qtiItem)
 {
     $additionalContentEditingMode = $qtiItem->getMetadataEntry('additional_cont_edit_mode');
     if (!$this->object->isValidAdditionalContentEditingMode($additionalContentEditingMode)) {
         $additionalContentEditingMode = assQuestion::ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT;
     }
     return $additionalContentEditingMode;
 }
 /**
  * imports the given feedback content as generic feedback for the given question id
  * for either the complete or incomplete solution
  * 
  * @access public
  * @param integer $questionId
  * @param boolean $solutionCompleted
  * @param string $feedbackContent
  */
 public function importGenericFeedback($questionId, $solutionCompleted, $feedbackContent)
 {
     if ($this->questionOBJ->isAdditionalContentEditingModePageObject()) {
         $pageObjectId = $this->getGenericFeedbackPageObjectId($questionId, $solutionCompleted);
         $pageObjectType = $this->getGenericFeedbackPageObjectType();
         $this->createPageObject($pageObjectType, $pageObjectId, $feedbackContent);
     } else {
         $this->saveGenericFeedbackContent($questionId, $solutionCompleted, $feedbackContent);
     }
 }
 private function stageQuestionsFromSourcePool($sourcePoolId)
 {
     $questionIdMapping = array();
     $query = 'SELECT question_id FROM qpl_questions WHERE obj_fi = %s AND complete = %s AND original_id IS NULL';
     $res = $this->db->queryF($query, array('integer', 'text'), array($sourcePoolId, 1));
     while ($row = $this->db->fetchAssoc($res)) {
         $question = assQuestion::_instanciateQuestion($row['question_id']);
         $duplicateId = $question->duplicate(true, null, null, null, $this->testOBJ->getId());
         $nextId = $this->db->nextId('tst_rnd_cpy');
         $this->db->insert('tst_rnd_cpy', array('copy_id' => array('integer', $nextId), 'tst_fi' => array('integer', $this->testOBJ->getTestId()), 'qst_fi' => array('integer', $duplicateId), 'qpl_fi' => array('integer', $sourcePoolId)));
         $questionIdMapping[$row['question_id']] = $duplicateId;
     }
     return $questionIdMapping;
 }
 /**
  * fill row 
  *
  * @access public
  * @param
  * @return
  */
 public function fillRow($data)
 {
     $this->tpl->setVariable("DATE", ilDatePresentation::formatDate(new ilDate($data['tstamp'], IL_CAL_UNIX)));
     $user = ilObjUser::_lookupName($data["user_fi"]);
     $this->tpl->setVariable("USER", ilUtil::prepareFormOutput(trim($user["title"] . " " . $user["firstname"] . " " . $user["lastname"])));
     $title = "";
     if ($data["question_fi"] || $data["original_fi"]) {
         include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
         $title = assQuestion::_getQuestionTitle($data["question_fi"]);
         if (strlen($title) == 0) {
             $title = assQuestion::_getQuestionTitle($data["original_fi"]);
         }
         $title = $this->lng->txt("assessment_log_question") . ": " . $title;
     }
     $this->tpl->setVariable("MESSAGE", ilUtil::prepareFormOutput($data['logtext']) . (strlen($title) ? " (" . $title . ")" : ''));
 }
 /**
  * returns the fact wether the presentation of the question sync2pool form
  * is required after saving the form or not
  * 
  * @access private
  * @return boolean $isSyncAfterSaveRequired
  */
 private function isSyncAfterSaveRequired()
 {
     global $ilUser;
     if (!$_GET["calling_test"]) {
         return false;
     }
     if ($this->questionOBJ->isAdditionalContentEditingModePageObject()) {
         return false;
     }
     if (!$this->questionOBJ->_questionExistsInPool($this->questionOBJ->original_id)) {
         return false;
     }
     if (!assQuestion::_isWriteable($this->object->original_id, $ilUser->getId())) {
         return false;
     }
     return true;
 }
 public function initFilter()
 {
     $this->setDisableFilterHiding(true);
     include_once 'Services/Form/classes/class.ilSelectInputGUI.php';
     $available_questions = new ilSelectInputGUI($this->lng->txt('question'), 'question');
     $select_questions = array();
     if (!$this->getParentObject()->object->isRandomTest()) {
         $questions = $this->getParentObject()->object->getTestQuestions();
     } else {
         $questions = $this->getParentObject()->object->getPotentialRandomTestQuestions();
     }
     $scoring = ilObjAssessmentFolder::_getManualScoring();
     foreach ($questions as $data) {
         include_once 'Modules/TestQuestionPool/classes/class.assQuestion.php';
         $info = assQuestion::_getQuestionInfo($data['question_id']);
         $type = $info["question_type_fi"];
         if (in_array($type, $scoring)) {
             $maxpoints = assQuestion::_getMaximumPoints($data["question_id"]);
             if ($maxpoints == 1) {
                 $maxpoints = ' (' . $maxpoints . ' ' . $this->lng->txt('point') . ')';
             } else {
                 $maxpoints = ' (' . $maxpoints . ' ' . $this->lng->txt('points') . ')';
             }
             $select_questions[$data["question_id"]] = $data['title'] . $maxpoints . ' [' . $this->lng->txt('question_id_short') . ': ' . $data["question_id"] . ']';
         }
     }
     if (!$select_questions) {
         $select_questions[0] = $this->lng->txt('tst_no_scorable_qst_available');
     }
     $available_questions->setOptions(array('' => $this->lng->txt('please_choose')) + $select_questions);
     $this->addFilterItem($available_questions);
     $available_questions->readFromSession();
     $this->filter['question'] = $available_questions->getValue();
     $pass = new ilSelectInputGUI($this->lng->txt('pass'), 'pass');
     $passes = array();
     $max_pass = $this->getParentObject()->object->getMaxPassOfTest();
     for ($i = 1; $i <= $max_pass; $i++) {
         $passes[$i] = $i;
     }
     $pass->setOptions($passes);
     $this->addFilterItem($pass);
     $pass->readFromSession();
     $this->filter['pass'] = $pass->getValue();
 }
Exemplo n.º 17
0
 /**
  * Copy question from pool into page
  *
  * @param
  * @return
  */
 function copyPoolQuestionIntoPage($a_q_id, $a_hier_id)
 {
     include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
     include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
     $question = assQuestion::_instanciateQuestion($a_q_id);
     $duplicate_id = $question->copyObject(0, $question->getTitle());
     $duplicate = assQuestion::_instanciateQuestion($duplicate_id);
     $duplicate->setObjId(0);
     // we remove everything not supported by the non-tiny self
     // assessment question editor
     $q = $duplicate->getQuestion();
     // we try to save all latex tags
     $try = true;
     $ls = '<span class="latex">';
     $le = '</span>';
     while ($try) {
         // search position of start tag
         $pos1 = strpos($q, $ls);
         if (is_int($pos1)) {
             $pos2 = strpos($q, $le, $pos1);
             if (is_int($pos2)) {
                 // both found: replace end tag
                 $q = substr($q, 0, $pos2) . "[/tex]" . substr($q, $pos2 + 7);
                 $q = substr($q, 0, $pos1) . "[tex]" . substr($q, $pos1 + 20);
             } else {
                 $try = false;
             }
         } else {
             $try = false;
         }
     }
     $tags = assQuestionGUI::getSelfAssessmentTags();
     $tstr = "";
     foreach ($tags as $t) {
         $tstr .= "<" . $t . ">";
     }
     $q = ilUtil::secureString($q, true, $tstr);
     // self assessment uses nl2br, not p
     $duplicate->setQuestion($q);
     $duplicate->saveQuestionDataToDb();
     $this->q_node->set_attribute("QRef", "il__qst_" . $duplicate_id);
 }
 /**
  * removes all question set config related data for cloned/copied test
  *
  * @param ilObjTest $cloneTestOBJ
  */
 public function cloneQuestionSetRelatedData($cloneTestOBJ)
 {
     global $ilLog;
     require_once 'Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
     require_once 'Modules/TestQuestionPool/classes/class.assQuestion.php';
     $cwo = ilCopyWizardOptions::_getInstance($cloneTestOBJ->getId());
     foreach ($this->questions as $key => $question_id) {
         $question = assQuestion::_instanciateQuestion($question_id);
         $cloneTestOBJ->questions[$key] = $question->duplicate(true, null, null, null, $cloneTestOBJ->getId());
         $original_id = assQuestion::_getOriginalId($question_id);
         $question = assQuestion::_instanciateQuestion($cloneTestOBJ->questions[$key]);
         $question->saveToDb($original_id);
         // Save the mapping of old question id <-> new question id
         // This will be used in class.ilObjCourse::cloneDependencies to copy learning objectives
         $originalKey = $this->testOBJ->getRefId() . '_' . $question_id;
         $mappedKey = $cloneTestOBJ->getRefId() . '_' . $cloneTestOBJ->questions[$key];
         $cwo->appendMapping($originalKey, $mappedKey);
         $ilLog->write(__METHOD__ . ": Added mapping {$originalKey} <-> {$mappedKey}");
     }
 }
 /**
  * Fill table row
  */
 protected function fillRow($a_set)
 {
     global $ilCtrl, $lng;
     $this->tpl->setVariable("PAGE_TITLE", ilLMObject::_lookupTitle($a_set["page_id"]));
     $this->tpl->setVariable("QUESTION", assQuestion::_getQuestionText($a_set["question_id"]));
     include_once "./Services/COPage/classes/class.ilPageQuestionProcessor.php";
     $stats = ilPageQuestionProcessor::getQuestionStatistics($a_set["question_id"]);
     $this->tpl->setVariable("VAL_ANSWERED", (int) $stats["all"]);
     if ($stats["all"] == 0) {
         $this->tpl->setVariable("VAL_CORRECT_FIRST", 0);
         $this->tpl->setVariable("VAL_CORRECT_SECOND", 0);
         $this->tpl->setVariable("VAL_CORRECT_THIRD_OR_MORE", 0);
         $this->tpl->setVariable("VAL_NEVER", 0);
     } else {
         $this->tpl->setVariable("VAL_CORRECT_FIRST", $stats["first"] . " (" . 100 / $stats["all"] * $stats["first"] . " %)");
         $this->tpl->setVariable("VAL_CORRECT_SECOND", $stats["second"] . " (" . 100 / $stats["all"] * $stats["second"] . " %)");
         $this->tpl->setVariable("VAL_CORRECT_THIRD_AND_MORE", $stats["third_or_more"] . " (" . 100 / $stats["all"] * $stats["third_or_more"] . " %)");
         $nev = $stats["all"] - $stats["first"] - $stats["second"] - $stats["third_or_more"];
         $this->tpl->setVariable("VAL_NEVER", $nev . " (" . 100 / $stats["all"] * $nev . " %)");
     }
 }
 public function build()
 {
     $this->setFormAction($this->ctrl->getFormAction($this->parentGUI));
     if ($this->isManipulationEnabled()) {
         $this->addCommandButton(ilAssQuestionSkillAssignmentsGUI::CMD_SHOW_SKILL_QUEST_ASSIGNS, $this->lng->txt('cancel'));
         $this->addCommandButton(ilAssQuestionSkillAssignmentsGUI::CMD_SAVE_SKILL_QUEST_ASSIGN_PROPERTIES_FORM, $this->lng->txt('save'));
     } else {
         $this->addCommandButton(ilAssQuestionSkillAssignmentsGUI::CMD_SHOW_SKILL_QUEST_ASSIGNS, $this->lng->txt('back'));
     }
     $this->setTitle($this->assignment->getSkillTitle());
     $questionTitle = new ilNonEditableValueGUI($this->lng->txt('question'));
     $questionTitle->setValue($this->question->getTitle());
     $this->addItem($questionTitle);
     $questionDesc = new ilNonEditableValueGUI($this->lng->txt('description'));
     $questionDesc->setValue($this->question->getComment());
     $this->addItem($questionDesc);
     if ($this->questionSupportsSolutionCompare()) {
         $this->populateFullProperties();
     } else {
         $this->populateLimitedProperties();
     }
 }
Exemplo n.º 21
0
 /**
  * Collects all text in the question which could contain media objects
  * which were created with the Rich Text Editor
  */
 function getRTETextWithMediaObjects()
 {
     $text = parent::getRTETextWithMediaObjects();
     foreach ($this->answers as $index => $answer) {
         $text .= $this->feedbackOBJ->getSpecificAnswerFeedbackContent($this->getId(), $index);
     }
     return $text;
 }
Exemplo n.º 22
0
 /**
  * Object setter
  */
 public function __set($key, $value)
 {
     switch ($key) {
         case "errortext":
             $this->setErrorText($value);
             break;
         case "textsize":
             $this->setTextSize($value);
             break;
         case "points_wrong":
             $this->setPointsWrong($value);
             break;
         default:
             parent::__set($key, $value);
             break;
     }
 }
Exemplo n.º 23
0
 /**
  * returns boolean wether the question
  * is answered during test pass or not
  * 
  * (overwrites method in class assQuestion)
  * 
  * @param integer $active_id
  * @param integer $pass
  * @return boolean $answered
  */
 public function isAnswered($active_id, $pass)
 {
     $answered = assQuestion::doesSolutionRecordsExist($active_id, $pass, $this->getId());
     return $answered;
 }
Exemplo n.º 24
0
 /**
  * saves the form on successfull validation and redirects to showForm command
  * 
  * @access	private
  * @global	ilCtrl		$ilCtrl
  * @global	ilLanguage	$lng
  */
 private function saveFormCmd()
 {
     global $ilCtrl, $lng, $ilUser;
     $form = $this->buildForm();
     if ($form->checkInput()) {
         $questionHint = new ilAssQuestionHint();
         if ((int) $form->getInput('hint_id')) {
             $questionHint->load((int) $form->getInput('hint_id'));
             $hintJustCreated = false;
         } else {
             $questionHint->setQuestionId($this->questionOBJ->getId());
             $questionHint->setIndex(ilAssQuestionHintList::getNextIndexByQuestionId($this->questionOBJ->getId()));
             $hintJustCreated = true;
         }
         $questionHint->setText($form->getInput('hint_text'));
         $questionHint->setPoints($form->getInput('hint_points'));
         $questionHint->save();
         ilUtil::sendSuccess($lng->txt('tst_question_hints_form_saved_msg'), true);
         $originalexists = $this->questionOBJ->_questionExistsInPool($this->questionOBJ->original_id);
         include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
         if ($_GET["calling_test"] && $originalexists && assQuestion::_isWriteable($this->questionOBJ->original_id, $ilUser->getId())) {
             $ilCtrl->redirectByClass('ilAssQuestionHintsGUI', ilAssQuestionHintsGUI::CMD_CONFIRM_SYNC);
         }
         if ($hintJustCreated && $this->questionOBJ->isAdditionalContentEditingModePageObject()) {
             $ilCtrl->setParameterByClass('ilasshintpagegui', 'hint_id', $questionHint->getId());
             $ilCtrl->redirectByClass('ilasshintpagegui', 'edit');
         } else {
             $ilCtrl->redirectByClass('ilAssQuestionHintsGUI', ilAssQuestionHintsGUI::CMD_SHOW_LIST);
         }
     }
     ilUtil::sendFailure($lng->txt('tst_question_hints_form_invalid_msg'));
     $this->showFormCmd($form);
 }
Exemplo n.º 25
0
 /**
  * Set tabs
  */
 function setTabs()
 {
     if ($this->getSelfAssessmentMode()) {
         return;
     }
     global $ilTabs, $ilCtrl, $lng;
     include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
     if ($this->content_obj != "") {
         $q_ref = $this->content_obj->getQuestionReference();
     }
     if ($q_ref != "") {
         $inst_id = ilInternalLink::_extractInstOfTarget($q_ref);
         if (!($inst_id > 0)) {
             $q_id = ilInternalLink::_extractObjIdOfTarget($q_ref);
         }
     }
     $ilTabs->addTarget("question", $ilCtrl->getLinkTarget($this, "edit"), array("editQuestion", "save", "cancel", "addSuggestedSolution", "cancelExplorer", "linkChilds", "removeSuggestedSolution", "addPair", "addTerm", "delete", "deleteTerms", "editMode", "upload", "saveEdit", "uploadingImage", "uploadingImagemap", "addArea", "deletearea", "saveShape", "back", "saveEdit", "changeGapType", "createGaps", "addItem", "addYesNo", "addTrueFalse", "toggleGraphicalAnswers", "setMediaMode"), "");
     if ($q_id > 0) {
         if (assQuestion::_getQuestionType($q_id) != "assTextQuestion") {
             require_once 'Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
             require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionFeedbackEditingGUI.php';
             $tabCommands = assQuestionGUI::getCommandsFromClassConstants('ilAssQuestionFeedbackEditingGUI');
             $tabLink = ilUtil::appendUrlParameterString($ilCtrl->getLinkTargetByClass('ilAssQuestionFeedbackEditingGUI', ilAssQuestionFeedbackEditingGUI::CMD_SHOW), "q_id=" . (int) $q_id);
             $ilTabs->addTarget('feedback', $tabLink, $tabCommands, $ilCtrl->getCmdClass(), '');
         }
     }
 }
Exemplo n.º 26
0
 /**
  * Exports the evaluation data to the Microsoft Excel file format
  *
  * @param bool    $deliver
  * @param string  $filterby
  * @param string  $filtertext Filter text for the user data
  * @param boolean $passedonly TRUE if only passed user datasets should be exported, FALSE otherwise
  *
  * @return string
  */
 public function exportToExcel($deliver = TRUE, $filterby = "", $filtertext = "", $passedonly = FALSE)
 {
     if (strcmp($this->mode, "aggregated") == 0) {
         return $this->aggregatedResultsToExcel($deliver);
     }
     require_once './Services/Excel/classes/class.ilExcelWriterAdapter.php';
     $excelfile = ilUtil::ilTempnam();
     $adapter = new ilExcelWriterAdapter($excelfile, FALSE);
     $testname = $this->test_obj->getTitle();
     switch ($this->mode) {
         case 'results':
             $testname .= '_results';
             break;
     }
     $testname = ilUtil::getASCIIFilename(preg_replace("/\\s/", "_", $testname)) . ".xls";
     $workbook = $adapter->getWorkbook();
     $workbook->setVersion(8);
     // Use Excel97/2000 Format
     // Creating a worksheet
     $format_bold =& $workbook->addFormat();
     $format_bold->setBold();
     $format_percent =& $workbook->addFormat();
     $format_percent->setNumFormat("0.00%");
     $format_datetime =& $workbook->addFormat();
     $format_datetime->setNumFormat("DD/MM/YYYY hh:mm:ss");
     $format_title =& $workbook->addFormat();
     $format_title->setBold();
     $format_title->setColor('black');
     $format_title->setPattern(1);
     $format_title->setFgColor('silver');
     require_once './Services/Excel/classes/class.ilExcelUtils.php';
     $worksheet =& $workbook->addWorksheet(ilExcelUtils::_convert_text($this->lng->txt("tst_results")));
     $additionalFields = $this->test_obj->getEvaluationAdditionalFields();
     $row = 0;
     $col = 0;
     if ($this->test_obj->getAnonymity()) {
         $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("counter")), $format_title);
     } else {
         $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("name")), $format_title);
         $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("login")), $format_title);
     }
     if (count($additionalFields)) {
         foreach ($additionalFields as $fieldname) {
             $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt($fieldname)), $format_title);
         }
     }
     $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("tst_stat_result_resultspoints")), $format_title);
     $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("maximum_points")), $format_title);
     $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("tst_stat_result_resultsmarks")), $format_title);
     if ($this->test_obj->getECTSOutput()) {
         $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("ects_grade")), $format_title);
     }
     $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("tst_stat_result_qworkedthrough")), $format_title);
     $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("tst_stat_result_qmax")), $format_title);
     $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("tst_stat_result_pworkedthrough")), $format_title);
     $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("tst_stat_result_timeofwork")), $format_title);
     $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("tst_stat_result_atimeofwork")), $format_title);
     $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("tst_stat_result_firstvisit")), $format_title);
     $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("tst_stat_result_lastvisit")), $format_title);
     $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("tst_stat_result_mark_median")), $format_title);
     $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("tst_stat_result_rank_participant")), $format_title);
     $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("tst_stat_result_rank_median")), $format_title);
     $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("tst_stat_result_total_participants")), $format_title);
     $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("tst_stat_result_median")), $format_title);
     $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("scored_pass")), $format_title);
     $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("pass")), $format_title);
     $counter = 1;
     $data =& $this->test_obj->getCompleteEvaluationData(TRUE, $filterby, $filtertext);
     $firstrowwritten = false;
     foreach ($data->getParticipants() as $active_id => $userdata) {
         $remove = FALSE;
         if ($passedonly) {
             if ($data->getParticipant($active_id)->getPassed() == FALSE) {
                 $remove = TRUE;
             }
         }
         if (!$remove) {
             $row++;
             if ($this->test_obj->isRandomTest() || $this->test_obj->getShuffleQuestions()) {
                 $row++;
             }
             $col = 0;
             if ($this->test_obj->getAnonymity()) {
                 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($counter));
             } else {
                 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($data->getParticipant($active_id)->getName()));
                 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($data->getParticipant($active_id)->getLogin()));
             }
             if (count($additionalFields)) {
                 $userfields = ilObjUser::_lookupFields($userdata->getUserID());
                 foreach ($additionalFields as $fieldname) {
                     if (strcmp($fieldname, "gender") == 0) {
                         $worksheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt("gender_" . $userfields[$fieldname])));
                     } else {
                         $worksheet->write($row, $col++, ilExcelUtils::_convert_text($userfields[$fieldname]));
                     }
                 }
             }
             $worksheet->write($row, $col++, ilExcelUtils::_convert_text($data->getParticipant($active_id)->getReached()));
             $worksheet->write($row, $col++, ilExcelUtils::_convert_text($data->getParticipant($active_id)->getMaxpoints()));
             $worksheet->write($row, $col++, ilExcelUtils::_convert_text($data->getParticipant($active_id)->getMark()));
             if ($this->test_obj->getECTSOutput()) {
                 $worksheet->write($row, $col++, ilExcelUtils::_convert_text($data->getParticipant($active_id)->getECTSMark()));
             }
             $worksheet->write($row, $col++, ilExcelUtils::_convert_text($data->getParticipant($active_id)->getQuestionsWorkedThrough()));
             $worksheet->write($row, $col++, ilExcelUtils::_convert_text($data->getParticipant($active_id)->getNumberOfQuestions()));
             $worksheet->write($row, $col++, $data->getParticipant($active_id)->getQuestionsWorkedThroughInPercent() / 100.0, $format_percent);
             $time = $data->getParticipant($active_id)->getTimeOfWork();
             $time_seconds = $time;
             $time_hours = floor($time_seconds / 3600);
             $time_seconds -= $time_hours * 3600;
             $time_minutes = floor($time_seconds / 60);
             $time_seconds -= $time_minutes * 60;
             $worksheet->write($row, $col++, ilExcelUtils::_convert_text(sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds)));
             $time = $data->getParticipant($active_id)->getQuestionsWorkedThrough() ? $data->getParticipant($active_id)->getTimeOfWork() / $data->getParticipant($active_id)->getQuestionsWorkedThrough() : 0;
             $time_seconds = $time;
             $time_hours = floor($time_seconds / 3600);
             $time_seconds -= $time_hours * 3600;
             $time_minutes = floor($time_seconds / 60);
             $time_seconds -= $time_minutes * 60;
             $worksheet->write($row, $col++, ilExcelUtils::_convert_text(sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds)));
             $fv = getdate($data->getParticipant($active_id)->getFirstVisit());
             $firstvisit = ilUtil::excelTime($fv["year"], $fv["mon"], $fv["mday"], $fv["hours"], $fv["minutes"], $fv["seconds"]);
             $worksheet->write($row, $col++, $firstvisit, $format_datetime);
             $lv = getdate($data->getParticipant($active_id)->getLastVisit());
             $lastvisit = ilUtil::excelTime($lv["year"], $lv["mon"], $lv["mday"], $lv["hours"], $lv["minutes"], $lv["seconds"]);
             $worksheet->write($row, $col++, $lastvisit, $format_datetime);
             $median = $data->getStatistics()->getStatistics()->median();
             $pct = $data->getParticipant($active_id)->getMaxpoints() ? $median / $data->getParticipant($active_id)->getMaxpoints() * 100.0 : 0;
             $mark = $this->test_obj->mark_schema->getMatchingMark($pct);
             $mark_short_name = "";
             if (is_object($mark)) {
                 $mark_short_name = $mark->getShortName();
             }
             $worksheet->write($row, $col++, ilExcelUtils::_convert_text($mark_short_name));
             $worksheet->write($row, $col++, ilExcelUtils::_convert_text($data->getStatistics()->getStatistics()->rank($data->getParticipant($active_id)->getReached())));
             $worksheet->write($row, $col++, ilExcelUtils::_convert_text($data->getStatistics()->getStatistics()->rank_median()));
             $worksheet->write($row, $col++, ilExcelUtils::_convert_text($data->getStatistics()->getStatistics()->count()));
             $worksheet->write($row, $col++, ilExcelUtils::_convert_text($median));
             if ($this->test_obj->getPassScoring() == SCORE_BEST_PASS) {
                 $worksheet->write($row, $col++, $data->getParticipant($active_id)->getBestPass() + 1);
             } else {
                 $worksheet->write($row, $col++, $data->getParticipant($active_id)->getLastPass() + 1);
             }
             $startcol = $col;
             for ($pass = 0; $pass <= $data->getParticipant($active_id)->getLastPass(); $pass++) {
                 $col = $startcol;
                 $finishdate = $this->test_obj->getPassFinishDate($active_id, $pass);
                 if ($finishdate > 0) {
                     if ($pass > 0) {
                         $row++;
                         if ($this->test_obj->isRandomTest() || $this->test_obj->getShuffleQuestions()) {
                             $row++;
                         }
                     }
                     $worksheet->write($row, $col++, ilExcelUtils::_convert_text($pass + 1));
                     if (is_object($data->getParticipant($active_id)) && is_array($data->getParticipant($active_id)->getQuestions($pass))) {
                         foreach ($data->getParticipant($active_id)->getQuestions($pass) as $question) {
                             $question_data = $data->getParticipant($active_id)->getPass($pass)->getAnsweredQuestionByQuestionId($question["id"]);
                             $worksheet->write($row, $col, ilExcelUtils::_convert_text($question_data["reached"]));
                             if ($this->test_obj->isRandomTest() || $this->test_obj->getShuffleQuestions()) {
                                 $worksheet->write($row - 1, $col, ilExcelUtils::_convert_text(preg_replace("/<.*?>/", "", $data->getQuestionTitle($question["id"]))), $format_title);
                             } else {
                                 if ($pass == 0 && !$firstrowwritten) {
                                     $worksheet->write(0, $col, ilExcelUtils::_convert_text(preg_replace("/<.*?>/", "", $data->getQuestionTitle($question["id"]))), $format_title);
                                 }
                             }
                             $col++;
                         }
                         $firstrowwritten = true;
                     }
                 }
             }
             $counter++;
         }
     }
     if ($this->test_obj->getExportSettingsSingleChoiceShort() && !$this->test_obj->isRandomTest() && $this->test_obj->hasSingleChoiceQuestions()) {
         // special tab for single choice tests
         $titles =& $this->test_obj->getQuestionTitlesAndIndexes();
         $positions = array();
         $pos = 0;
         $row = 0;
         foreach ($titles as $id => $title) {
             $positions[$id] = $pos;
             $pos++;
         }
         $usernames = array();
         $participantcount = count($data->getParticipants());
         $allusersheet = false;
         $pages = 0;
         $resultsheet =& $workbook->addWorksheet($this->lng->txt("eval_all_users"));
         $col = 0;
         $resultsheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt('name')), $format_title);
         $resultsheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt('login')), $format_title);
         if (count($additionalFields)) {
             foreach ($additionalFields as $fieldname) {
                 if (strcmp($fieldname, "matriculation") == 0) {
                     $resultsheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt('matriculation')), $format_title);
                 }
             }
         }
         $resultsheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt('test')), $format_title);
         foreach ($titles as $title) {
             $resultsheet->write($row, $col++, ilExcelUtils::_convert_text($title), $format_title);
         }
         $row++;
         foreach ($data->getParticipants() as $active_id => $userdata) {
             $username = !is_null($userdata) && ilExcelUtils::_convert_text($userdata->getName()) ? ilExcelUtils::_convert_text($userdata->getName()) : "ID {$active_id}";
             if (array_key_exists($username, $usernames)) {
                 $usernames[$username]++;
                 $username .= " ({$i})";
             } else {
                 $usernames[$username] = 1;
             }
             $col = 0;
             $resultsheet->write($row, $col++, $username);
             $resultsheet->write($row, $col++, $userdata->getLogin());
             if (count($additionalFields)) {
                 $userfields = ilObjUser::_lookupFields($userdata->getUserID());
                 foreach ($additionalFields as $fieldname) {
                     if (strcmp($fieldname, "matriculation") == 0) {
                         if (strlen($userfields[$fieldname])) {
                             $resultsheet->write($row, $col++, ilExcelUtils::_convert_text($userfields[$fieldname]));
                         } else {
                             $col++;
                         }
                     }
                 }
             }
             $resultsheet->write($row, $col++, ilExcelUtils::_convert_text($this->test_obj->getTitle()));
             $pass = $userdata->getScoredPass();
             if (is_object($userdata) && is_array($userdata->getQuestions($pass))) {
                 foreach ($userdata->getQuestions($pass) as $question) {
                     $objQuestion =& $this->test_obj->_instanciateQuestion($question["aid"]);
                     if (is_object($objQuestion) && strcmp($objQuestion->getQuestionType(), 'assSingleChoice') == 0) {
                         $solution = $objQuestion->getSolutionValues($active_id, $pass);
                         $pos = $positions[$question["aid"]];
                         $selectedanswer = "x";
                         foreach ($objQuestion->getAnswers() as $id => $answer) {
                             if (strlen($solution[0]["value1"]) && $id == $solution[0]["value1"]) {
                                 $selectedanswer = $answer->getAnswertext();
                             }
                         }
                         $resultsheet->write($row, $col + $pos, ilExcelUtils::_convert_text($selectedanswer));
                     }
                 }
             }
             $row++;
         }
         if ($this->test_obj->isSingleChoiceTestWithoutShuffle()) {
             // special tab for single choice tests without shuffle option
             $pos = 0;
             $row = 0;
             $usernames = array();
             $allusersheet = false;
             $pages = 0;
             $resultsheet =& $workbook->addWorksheet($this->lng->txt("eval_all_users") . " (2)");
             $col = 0;
             $resultsheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt('name')), $format_title);
             $resultsheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt('login')), $format_title);
             if (count($additionalFields)) {
                 foreach ($additionalFields as $fieldname) {
                     if (strcmp($fieldname, "matriculation") == 0) {
                         $resultsheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt('matriculation')), $format_title);
                     }
                 }
             }
             $resultsheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt('test')), $format_title);
             foreach ($titles as $title) {
                 $resultsheet->write($row, $col++, ilExcelUtils::_convert_text($title), $format_title);
             }
             $row++;
             foreach ($data->getParticipants() as $active_id => $userdata) {
                 $username = !is_null($userdata) && ilExcelUtils::_convert_text($userdata->getName()) ? ilExcelUtils::_convert_text($userdata->getName()) : "ID {$active_id}";
                 if (array_key_exists($username, $usernames)) {
                     $usernames[$username]++;
                     $username .= " ({$i})";
                 } else {
                     $usernames[$username] = 1;
                 }
                 $col = 0;
                 $resultsheet->write($row, $col++, $username);
                 $resultsheet->write($row, $col++, $userdata->getLogin());
                 if (count($additionalFields)) {
                     $userfields = ilObjUser::_lookupFields($userdata->getUserID());
                     foreach ($additionalFields as $fieldname) {
                         if (strcmp($fieldname, "matriculation") == 0) {
                             if (strlen($userfields[$fieldname])) {
                                 $resultsheet->write($row, $col++, ilExcelUtils::_convert_text($userfields[$fieldname]));
                             } else {
                                 $col++;
                             }
                         }
                     }
                 }
                 $resultsheet->write($row, $col++, ilExcelUtils::_convert_text($this->test_obj->getTitle()));
                 $pass = $userdata->getScoredPass();
                 if (is_object($userdata) && is_array($userdata->getQuestions($pass))) {
                     foreach ($userdata->getQuestions($pass) as $question) {
                         $objQuestion =& $this->test_obj->_instanciateQuestion($question["aid"]);
                         if (is_object($objQuestion) && strcmp($objQuestion->getQuestionType(), 'assSingleChoice') == 0) {
                             $solution = $objQuestion->getSolutionValues($active_id, $pass);
                             $pos = $positions[$question["aid"]];
                             $selectedanswer = chr(65 + $solution[0]["value1"]);
                             $resultsheet->write($row, $col + $pos, ilExcelUtils::_convert_text($selectedanswer));
                         }
                     }
                 }
                 $row++;
             }
         }
     } else {
         // test participant result export
         $usernames = array();
         $participantcount = count($data->getParticipants());
         $allusersheet = false;
         $pages = 0;
         $i = 0;
         foreach ($data->getParticipants() as $active_id => $userdata) {
             $i++;
             $username = !is_null($userdata) && ilExcelUtils::_convert_text($userdata->getName()) ? ilExcelUtils::_convert_text($userdata->getName()) : "ID {$active_id}";
             if (array_key_exists($username, $usernames)) {
                 $usernames[$username]++;
                 $username .= " ({$i})";
             } else {
                 $usernames[$username] = 1;
             }
             if ($participantcount > 250) {
                 if (!$allusersheet || $pages - 1 < floor($row / 64000)) {
                     $resultsheet =& $workbook->addWorksheet($this->lng->txt("eval_all_users") . ($pages > 0 ? " (" . ($pages + 1) . ")" : ""));
                     $allusersheet = true;
                     $row = 0;
                     $pages++;
                 }
             } else {
                 $resultsheet =& $workbook->addWorksheet($username);
             }
             if (method_exists($resultsheet, "writeString")) {
                 $pass = $userdata->getScoredPass();
                 $row = $allusersheet ? $row : 0;
                 $resultsheet->writeString($row, 0, ilExcelUtils::_convert_text(sprintf($this->lng->txt("tst_result_user_name_pass"), $pass + 1, $userdata->getName())), $format_bold);
                 $row += 2;
                 if (is_object($userdata) && is_array($userdata->getQuestions($pass))) {
                     foreach ($userdata->getQuestions($pass) as $question) {
                         require_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
                         $question = assQuestion::_instanciateQuestion($question["id"]);
                         if (is_object($question)) {
                             $row = $question->setExportDetailsXLS($resultsheet, $row, $active_id, $pass, $format_title, $format_bold);
                         }
                     }
                 }
             }
         }
     }
     $workbook->close();
     if ($deliver) {
         ilUtil::deliverFile($excelfile, $testname, "application/vnd.ms-excel", false, true);
         exit;
     } else {
         return $excelfile;
     }
 }
Exemplo n.º 27
0
 /**
  * Replaces existing question content elements with
  * new copies
  */
 function newQuestionCopies(&$temp_dom)
 {
     // Get question IDs
     $path = "//Question";
     $xpc = xpath_new_context($temp_dom);
     $res =& xpath_eval($xpc, $path);
     $q_ids = array();
     include_once "./Services/Link/classes/class.ilInternalLink.php";
     for ($i = 0; $i < count($res->nodeset); $i++) {
         $qref = $res->nodeset[$i]->get_attribute("QRef");
         $inst_id = ilInternalLink::_extractInstOfTarget($qref);
         $q_id = ilInternalLink::_extractObjIdOfTarget($qref);
         if (!($inst_id > 0)) {
             if ($q_id > 0) {
                 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
                 $question = assQuestion::_instanciateQuestion($q_id);
                 // check if page for question exists
                 // due to a bug in early 4.2.x version this is possible
                 if (!ilPageObject::_exists("qpl", $q_id)) {
                     $question->createPageObject();
                 }
                 // now copy this question and change reference to
                 // new question id
                 $duplicate_id = $question->duplicate(false);
                 $res->nodeset[$i]->set_attribute("QRef", "il__qst_" . $duplicate_id);
             }
         }
     }
 }
 /**
  * Collects all text in the question which could contain media objects
  * which were created with the Rich Text Editor
  */
 function getRTETextWithMediaObjects()
 {
     return parent::getRTETextWithMediaObjects();
 }
 /**
 * Returns an array containing the qpl_question and qpl_qst_type fields
 * of deleteable questions for an array of question ids
 *
 * @param array $question_ids An array containing the question ids
 * @return array An array containing the details of the requested questions
 * @access public
 */
 function &getDeleteableQuestionDetails($question_ids)
 {
     global $ilDB, $ilLog;
     $result = array();
     $query_result = $ilDB->query("SELECT qpl_questions.*, qpl_qst_type.type_tag FROM qpl_questions, qpl_qst_type WHERE qpl_questions.question_type_fi = qpl_qst_type.question_type_id AND " . $ilDB->in('qpl_questions.question_id', $question_ids, false, 'integer') . " ORDER BY qpl_questions.title");
     if ($query_result->numRows()) {
         include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
         while ($row = $ilDB->fetchAssoc($query_result)) {
             if (!assQuestion::_isUsedInRandomTest($row["question_id"])) {
                 array_push($result, $row);
             } else {
                 // the question was used in a random test prior to ILIAS 3.7 so it was inserted
                 // as a reference to the original question pool object and not as a copy. To allow
                 // the deletion of the question pool object, a copy must be created and all database references
                 // of the original question must changed with the reference of the copy
                 // 1. Create a copy of the original question
                 $question =& $this->createQuestion("", $row["question_id"]);
                 $duplicate_id = $question->object->duplicate(true);
                 if ($duplicate_id > 0) {
                     // 2. replace the question id in the solutions
                     $affectedRows = $ilDB->manipulateF("UPDATE tst_solutions SET question_fi = %s WHERE question_fi = %s", array('integer', 'integer'), array($duplicate_id, $row["question_id"]));
                     // 3. replace the question id in the question list of random tests
                     $affectedRows = $ilDB->manipulateF("UPDATE tst_test_rnd_qst SET question_fi = %s WHERE question_fi = %s", array('integer', 'integer'), array($duplicate_id, $row["question_id"]));
                     // 4. replace the question id in the test results
                     $affectedRows = $ilDB->manipulateF("UPDATE tst_test_result SET question_fi = %s WHERE question_fi = %s", array('integer', 'integer'), array($duplicate_id, $row["question_id"]));
                     // 5. replace the question id in the test&assessment log
                     $affectedRows = $ilDB->manipulateF("UPDATE ass_log SET question_fi = %s WHERE question_fi = %s", array('integer', 'integer'), array($duplicate_id, $row["question_id"]));
                     // 6. The original question can be deleted, so add it to the list of questions
                     array_push($result, $row);
                 }
             }
         }
     }
     return $result;
 }
Exemplo n.º 30
0
 /**
  * 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;
 }