Esempio n. 1
0
 function removeTestResultsForUser($user_id)
 {
     global $ilDB;
     $active_id = $this->getActiveIdOfUser($user_id);
     // remove the question from tst_solutions
     $affectedRows = $ilDB->manipulateF("DELETE FROM tst_solutions WHERE active_fi = %s", array('integer'), array($active_id));
     $affectedRows = $ilDB->manipulateF("DELETE FROM tst_qst_solved WHERE active_fi = %s", array('integer'), array($active_id));
     $affectedRows = $ilDB->manipulateF("DELETE FROM tst_test_result WHERE active_fi = %s", array('integer'), array($active_id));
     $affectedRows = $ilDB->manipulateF("DELETE FROM tst_pass_result WHERE active_fi = %s", array('integer'), array($active_id));
     if ($this->isRandomTest()) {
         $affectedRows = $ilDB->manipulateF("DELETE FROM tst_test_rnd_qst WHERE active_fi = %s", array('integer'), array($active_id));
     }
     include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
     if (ilObjAssessmentFolder::_enabledAssessmentLogging()) {
         $this->logAction(sprintf($this->lng->txtlng("assessment", "log_selected_user_data_removed", ilObjAssessmentFolder::_getLogLanguage()), $this->userLookupFullName($this->_getUserIdFromActiveId($active_id))));
     }
     $affectedRows = $ilDB->manipulateF("DELETE FROM tst_sequence WHERE active_fi = %s", array('integer'), array($active_id));
     // remove test_active entry
     $affectedRows = $ilDB->manipulateF("DELETE FROM tst_active WHERE active_id = %s", array('integer'), array($active_id));
     // remove saved user password
     if ($user_id > 0) {
         $affectedRows = $ilDB->manipulateF("DELETE FROM usr_pref WHERE usr_id = %s AND keyword = %s", array('integer', 'text'), array($user_id, "tst_password_" . $this->getTestId()));
     }
     // TODO: this shouldn't be here since it is question stuff and should be modular but there's no other solution yet
     // remove file uploads
     if (@is_dir(CLIENT_WEB_DIR . "/assessment/tst_" . $this->getTestId() . "/{$active_id}")) {
         ilUtil::delDir(CLIENT_WEB_DIR . "/assessment/tst_" . $this->getTestId() . "/{$active_id}");
     }
     require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintTracking.php';
     ilAssQuestionHintTracking::deleteRequestsByActiveIds(array($active_id));
 }
 /**
  * renders the elements for the question related navigation
  * 
  * @access private
  * @global ilTemplate $tpl
  * @global ilLanguage $lng
  * @param assQuestionGUI $questionGUI 
  */
 protected function fillQuestionRelatedNavigation(assQuestionGUI $questionGUI)
 {
     global $tpl, $lng;
     $parseQuestionRelatedNavigation = false;
     switch (1) {
         case $this->object->getSpecificAnswerFeedback():
         case $this->object->getGenericAnswerFeedback():
         case $this->object->getAnswerFeedbackPoints():
         case $this->object->getInstantFeedbackSolution():
             $tpl->setCurrentBlock("direct_feedback");
             $tpl->setVariable("CMD_SHOW_INSTANT_RESPONSE", 'showInstantResponse');
             $tpl->setVariable("TEXT_SHOW_INSTANT_RESPONSE", $lng->txt("check"));
             $tpl->parseCurrentBlock();
             $parseQuestionRelatedNavigation = true;
     }
     if ($this->object->isOfferingQuestionHintsEnabled()) {
         $questionId = $questionGUI->object->getId();
         $activeId = $this->testSession->getActiveId();
         $pass = $this->testSession->getPass();
         require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintTracking.php';
         $questionHintTracking = new ilAssQuestionHintTracking($questionId, $activeId, $pass);
         $requestsExist = $questionHintTracking->requestsExist();
         $requestsPossible = $questionHintTracking->requestsPossible();
         if ($requestsPossible) {
             if ($requestsExist) {
                 $buttonText = $lng->txt("button_request_next_question_hint");
             } else {
                 $buttonText = $lng->txt("button_request_question_hint");
             }
             $tpl->setCurrentBlock("button_request_next_question_hint");
             $tpl->setVariable("CMD_REQUEST_NEXT_QUESTION_HINT", 'confirmHintRequest');
             $tpl->setVariable("TEXT_REQUEST_NEXT_QUESTION_HINT", $buttonText);
             $tpl->parseCurrentBlock();
             $parseQuestionRelatedNavigation = true;
         }
         if ($requestsExist) {
             $tpl->setCurrentBlock("button_show_requested_question_hints");
             $tpl->setVariable("CMD_SHOW_REQUESTED_QUESTION_HINTS", 'showRequestedHintList');
             $tpl->setVariable("TEXT_SHOW_REQUESTED_QUESTION_HINTS", $lng->txt("button_show_requested_question_hints"));
             $tpl->parseCurrentBlock();
             $parseQuestionRelatedNavigation = true;
         }
     }
     if ($parseQuestionRelatedNavigation) {
         $tpl->setCurrentBlock("question_related_navigation");
         $tpl->parseCurrentBlock();
     }
 }
 /**
  * Performs a hint request and invokes the (re-)saving the question solution.
  * Redirects to local showHint command
  * 
  * @access	private
  * @global	ilCtrl $ilCtrl
  */
 private function performRequestCmd()
 {
     global $ilCtrl;
     if (!isset($_GET['hintId']) || !(int) $_GET['hintId']) {
         throw new ilTestException('no hint id given');
     }
     $nextRequestableHint = ilAssQuestionHintTracking::getNextRequestableHint($this->questionOBJ->getId(), $this->testSession->getActiveId(), $this->testSession->getPass());
     if ($nextRequestableHint->getId() != (int) $_GET['hintId']) {
         throw new ilTestException('given hint id does not relate to the next requestable hint');
     }
     ilAssQuestionHintTracking::storeRequest($nextRequestableHint, $this->questionOBJ->getId(), $this->testSession->getActiveId(), $this->testSession->getPass());
     $this->testOutputGUI->saveQuestionSolution();
     $redirectTarget = $this->getHintPresentationLinkTarget($nextRequestableHint->getId(), false);
     ilUtil::redirect($redirectTarget);
 }
Esempio n. 4
0
 /**
  * Deletes a question and all materials from the database
  *
  * @param integer $question_id The database id of the question
  * @access private
  */
 public function delete($question_id)
 {
     global $ilDB, $ilLog;
     if ($question_id < 1) {
         return true;
     }
     // nothing to do
     $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);
         $obj_id = $row["obj_fi"];
     } else {
         return true;
         // nothing to do
     }
     try {
         $this->deletePageOfQuestion($question_id);
     } catch (Exception $e) {
         $ilLog->write("EXCEPTION: Could not delete page of question {$question_id}: {$e}");
         return false;
     }
     $affectedRows = $ilDB->manipulateF("DELETE FROM qpl_questions WHERE question_id = %s", array('integer'), array($question_id));
     if ($affectedRows == 0) {
         return false;
     }
     try {
         $this->deleteAdditionalTableData($question_id);
         $this->deleteAnswers($question_id);
         $this->feedbackOBJ->deleteGenericFeedbacks($question_id, $this->isAdditionalContentEditingModePageObject());
         $this->feedbackOBJ->deleteSpecificAnswerFeedbacks($question_id, $this->isAdditionalContentEditingModePageObject());
     } catch (Exception $e) {
         $ilLog->write("EXCEPTION: Could not delete additional table data of question {$question_id}: {$e}");
         return false;
     }
     try {
         // delete the question in the tst_test_question table (list of test questions)
         $affectedRows = $ilDB->manipulateF("DELETE FROM tst_test_question WHERE question_fi = %s", array('integer'), array($question_id));
     } catch (Exception $e) {
         $ilLog->write("EXCEPTION: Could not delete delete question {$question_id} from a test: {$e}");
         return false;
     }
     try {
         // delete suggested solutions contained in the question
         $affectedRows = $ilDB->manipulateF("DELETE FROM qpl_sol_sug WHERE question_fi = %s", array('integer'), array($question_id));
     } catch (Exception $e) {
         $ilLog->write("EXCEPTION: Could not delete suggested solutions of question {$question_id}: {$e}");
         return false;
     }
     try {
         $directory = CLIENT_WEB_DIR . "/assessment/" . $obj_id . "/{$question_id}";
         if (preg_match("/\\d+/", $obj_id) and preg_match("/\\d+/", $question_id) and is_dir($directory)) {
             include_once "./Services/Utilities/classes/class.ilUtil.php";
             ilUtil::delDir($directory);
         }
     } catch (Exception $e) {
         $ilLog->write("EXCEPTION: Could not delete question file directory {$directory} of question {$question_id}: {$e}");
         return false;
     }
     try {
         include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
         $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $question_id);
         // remaining usages are not in text anymore -> delete them
         // and media objects (note: delete method of ilObjMediaObject
         // checks whether object is used in another context; if yes,
         // the object is not deleted!)
         foreach ($mobs as $mob) {
             ilObjMediaObject::_removeUsage($mob, "qpl:html", $question_id);
             if (ilObjMediaObject::_exists($mob)) {
                 $mob_obj =& new ilObjMediaObject($mob);
                 $mob_obj->delete();
             }
         }
     } catch (Exception $e) {
         $ilLog->write("EXCEPTION: Error deleting the media objects of question {$question_id}: {$e}");
         return false;
     }
     require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintTracking.php';
     ilAssQuestionHintTracking::deleteRequestsByQuestionIds(array($question_id));
     require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintList.php';
     ilAssQuestionHintList::deleteHintsByQuestionIds(array($question_id));
     require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionSkillAssignmentList.php';
     $assignmentList = new ilAssQuestionSkillAssignmentList($ilDB);
     $assignmentList->setParentObjId($obj_id);
     $assignmentList->setQuestionIdFilter($question_id);
     $assignmentList->loadFromDb();
     foreach ($assignmentList->getAssignmentsByQuestionId($question_id) as $assignment) {
         /* @var ilAssQuestionSkillAssignment $assignment */
         $assignment->deleteFromDb();
     }
     try {
         // update question count of question pool
         include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
         ilObjQuestionPool::_updateQuestionCount($this->getObjId());
     } catch (Exception $e) {
         $ilLog->write("EXCEPTION: Error updating the question pool question count of question pool " . $this->getObjId() . " when deleting question {$question_id}: {$e}");
         return false;
     }
     $this->notifyQuestionDeleted($this);
     return true;
 }
 /**
  * Performs a hint request and invokes the (re-)saving the question solution.
  * Redirects to local showHint command
  * 
  * @access	private
  * @global	ilCtrl $ilCtrl
  */
 private function performRequestCmd()
 {
     global $ilCtrl;
     if (!isset($_GET['hintId']) || !(int) $_GET['hintId']) {
         throw new ilTestException('no hint id given');
     }
     $nextRequestableHint = ilAssQuestionHintTracking::getNextRequestableHint($this->questionOBJ->getId(), $this->testSession->getActiveId(), $this->testSession->getPass());
     if ($nextRequestableHint->getId() != (int) $_GET['hintId']) {
         throw new ilTestException('given hint id does not relate to the next requestable hint');
     }
     ilAssQuestionHintTracking::storeRequest($nextRequestableHint, $this->questionOBJ->getId(), $this->testSession->getActiveId(), $this->testSession->getPass());
     $this->testOutputGUI->saveQuestionSolution();
     $redirectTarget = ilUtil::appendUrlParameterString($ilCtrl->getLinkTarget($this, self::CMD_SHOW_HINT, '', false, false), "hintId={$nextRequestableHint->getId()}");
     ilUtil::redirect($redirectTarget);
 }