/**
  * execute command
  */
 function &executeCommand()
 {
     global $ilAccess;
     if (!$ilAccess->checkAccess("write", "", $this->ref_id)) {
         // allow only write access
         ilUtil::sendFailure($this->lng->txt("cannot_edit_test"), true);
         $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
     }
     require_once 'Modules/Test/classes/class.ilObjAssessmentFolder.php';
     if (!ilObjAssessmentFolder::_mananuallyScoreableQuestionTypesExists()) {
         // allow only if at least one question type is marked for manual scoring
         ilUtil::sendFailure($this->lng->txt("manscoring_not_allowed"), true);
         $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
     }
     $cmd = $this->ctrl->getCmd();
     $next_class = $this->ctrl->getNextClass($this);
     if (strlen($cmd) == 0) {
         $this->ctrl->redirect($this, "manscoring");
     }
     $cmd = $this->getCommand($cmd);
     switch ($next_class) {
         default:
             $ret =& $this->{$cmd}();
             break;
     }
     return $ret;
 }
 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();
 }
 function saveQuestion($sid, $active_id, $question_id, $pass, $solution)
 {
     $this->initAuth($sid);
     $this->initIlias();
     if (!$this->__checkSession($sid)) {
         return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
     }
     if (!$this->isAllowedCall($sid, $active_id)) {
         return $this->__raiseError("The required user information is only available for active users.", "");
     }
     if (is_array($solution) && array_key_exists("item", $solution)) {
         $solution = $solution["item"];
     }
     global $ilDB, $ilUser;
     require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionProcessLockerFactory.php';
     $processLockerFactory = new ilAssQuestionProcessLockerFactory(new ilSetting('assessment'), $ilDB);
     $processLockerFactory->setQuestionId($question_id);
     $processLockerFactory->setUserId($ilUser->getId());
     include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
     $processLockerFactory->setAssessmentLogEnabled(ilObjAssessmentFolder::_enabledAssessmentLogging());
     $processLocker = $processLockerFactory->getLocker();
     $processLocker->requestPersistWorkingStateLock();
     $processLocker->requestUserSolutionUpdateLock();
     $ilDB = $GLOBALS['ilDB'];
     if ($active_id > 0 && $question_id > 0 && strlen($pass) > 0) {
         $affectedRows = $ilDB->manipulateF("DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s", array('integer', 'integer', 'integer'), array($active_id, $question_id, $pass));
     }
     $totalrows = 0;
     for ($i = 0; $i < count($solution); $i += 3) {
         $next_id = $ilDB->nextId('tst_solutions');
         $affectedRows = $ilDB->insert("tst_solutions", array("solution_id" => array("integer", $next_id), "active_fi" => array("integer", $active_id), "question_fi" => array("integer", $question_id), "value1" => array("clob", $solution[$i]), "value2" => array("clob", $solution[$i + 1]), "points" => array("float", $solution[$i + 2]), "pass" => array("integer", $pass), "tstamp" => array("integer", time())));
         $totalrows += $affectedRows;
     }
     $processLocker->releaseUserSolutionUpdateLock();
     if ($totalrows == 0) {
         $processLocker->releasePersistWorkingStateLock();
         return $this->__raiseError("Wrong solution data. ILIAS did not execute any database queries: Solution data: " . print_r($solution, true), 'No result');
     } else {
         include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
         $question = assQuestion::_instanciateQuestion($question_id);
         $question->setProcessLocker($processLocker);
         $question->calculateResultsFromSolution($active_id, $pass);
         $processLocker->releasePersistWorkingStateLock();
     }
     return true;
 }
 /**
  * Saves the learners input of the question to the database.
  * 
  * @access public
  * @param integer $active_id Active id of the user
  * @param integer $pass Test pass
  * @return boolean $status
  */
 public function saveWorkingData($active_id, $pass = NULL)
 {
     global $ilDB;
     $submittedMatchings = $this->fetchSubmittedMatchingsFromPost();
     $submittedMatchingsValid = $this->checkSubmittedMatchings($submittedMatchings);
     $matchingsExist = false;
     if ($submittedMatchingsValid) {
         if (is_null($pass)) {
             include_once "./Modules/Test/classes/class.ilObjTest.php";
             $pass = ilObjTest::_getPass($active_id);
         }
         $this->getProcessLocker()->requestUserSolutionUpdateLock();
         $affectedRows = $this->removeCurrentSolution($active_id, $pass);
         foreach ($submittedMatchings as $definition => $terms) {
             foreach ($terms as $i => $term) {
                 $affectedRows = $this->saveCurrentSolution($active_id, $pass, $term, $definition);
                 $matchingsExist = true;
             }
         }
         $this->getProcessLocker()->releaseUserSolutionUpdateLock();
         $saveWorkingDataResult = true;
     } else {
         $saveWorkingDataResult = false;
     }
     include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
     if (ilObjAssessmentFolder::_enabledAssessmentLogging()) {
         if ($matchingsExist) {
             $this->logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
         } else {
             $this->logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
         }
     }
     return $saveWorkingDataResult;
 }
 /**
  * Saves the learners input of the question to the database.
  * 
  * @access public
  * @param integer $active_id Active id of the user
  * @param integer $pass Test pass
  * @return boolean $status
  */
 public function saveWorkingData($active_id, $pass = NULL)
 {
     global $ilDB;
     global $ilUser;
     if (is_null($pass)) {
         include_once "./Modules/Test/classes/class.ilObjTest.php";
         $pass = ilObjTest::_getPass($active_id);
     }
     $entered_values = 0;
     $numeric_result = str_replace(",", ".", $_POST["numeric_result"]);
     include_once "./Services/Math/classes/class.EvalMath.php";
     $math = new EvalMath();
     $math->suppress_errors = TRUE;
     $result = $math->evaluate($numeric_result);
     $returnvalue = true;
     if (($result === FALSE || $result === TRUE) && strlen($result) > 0) {
         ilUtil::sendInfo($this->lng->txt("err_no_numeric_value"), true);
         $returnvalue = false;
     }
     $result = $ilDB->queryF("SELECT solution_id FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s", array('integer', 'integer', 'integer'), array($active_id, $this->getId(), $pass));
     $row = $ilDB->fetchAssoc($result);
     $update = $row["solution_id"];
     if ($update) {
         if (strlen($numeric_result)) {
             $affectedRows = $ilDB->update("tst_solutions", array("value1" => array("clob", trim($numeric_result)), "tstamp" => array("integer", time())), array("solution_id" => array("integer", $update)));
             $entered_values++;
         } else {
             $affectedRows = $ilDB->manipulateF("DELETE FROM tst_solutions WHERE solution_id = %s", array('integer'), array($update));
         }
     } else {
         if (strlen($numeric_result)) {
             $next_id = $ilDB->nextId('tst_solutions');
             $affectedRows = $ilDB->insert("tst_solutions", array("solution_id" => array("integer", $next_id), "active_fi" => array("integer", $active_id), "question_fi" => array("integer", $this->getId()), "value1" => array("clob", trim($numeric_result)), "value2" => array("clob", null), "pass" => array("integer", $pass), "tstamp" => array("integer", time())));
             $entered_values++;
         }
     }
     if ($entered_values) {
         include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
         if (ilObjAssessmentFolder::_enabledAssessmentLogging()) {
             $this->logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
         }
     } else {
         include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
         if (ilObjAssessmentFolder::_enabledAssessmentLogging()) {
             $this->logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
         }
     }
     return $returnvalue;
 }
 /**
  * edit question
  */
 function edit()
 {
     global $ilCtrl, $ilTabs;
     $ilTabs->setTabActive('question');
     if ($this->getSelfAssessmentMode()) {
         $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);
             }
         }
         $q_type = $_POST["q_type"] != "" ? $_POST["q_type"] : $_GET["q_type"];
         $ilCtrl->setParameter($this, "q_type", $q_type);
         if ($q_id == "" && $q_type == "") {
             return $this->insert("edit_empty");
         }
         include_once "./Modules/TestQuestionPool/classes/class.ilQuestionEditGUI.php";
         include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
         include_once "./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php";
         /*			$ilCtrl->setCmdClass("ilquestioneditgui");
         			$ilCtrl->setCmd("editQuestion");
         			$edit_gui = new ilQuestionEditGUI();*/
         // create question first-hand (needed for uploads)
         if ($q_id < 1 && $q_type) {
             include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
             $q_gui =& assQuestionGUI::_getQuestionGUI($q_type);
             // feedback editing mode
             include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
             if (ilObjAssessmentFolder::isAdditionalQuestionContentEditingModePageObjectEnabled() && $_REQUEST['add_quest_cont_edit_mode'] != "") {
                 $addContEditMode = $_GET['add_quest_cont_edit_mode'];
             } else {
                 $addContEditMode = assQuestion::ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT;
             }
             $q_gui->object->setAdditionalContentEditingMode($addContEditMode);
             //set default tries
             $q_gui->object->setDefaultNrOfTries(ilObjSAHSLearningModule::_getTries($this->scormlmid));
             $q_id = $q_gui->object->createNewQuestion(true);
             $this->content_obj->setQuestionReference("il__qst_" . $q_id);
             $this->pg_obj->update();
             unset($q_gui);
         }
         $ilCtrl->setParameterByClass("ilQuestionEditGUI", "q_id", $q_id);
         $ilCtrl->redirectByClass(array(get_class($this->pg_obj) . "GUI", "ilQuestionEditGUI"), "editQuestion");
         /*			$edit_gui->setPoolObjId(0);
         			$edit_gui->setQuestionId($q_id);	
         			$edit_gui->setQuestionType($q_type);
         			$edit_gui->setSelfAssessmentEditingMode(true);
         			$edit_gui->setPageConfig($this->getPageConfig());
         			$ret = $ilCtrl->forwardCommand($edit_gui);
         			$this->tpl->setContent($ret);*/
         return $ret;
     } else {
         require_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
         $q_gui =& assQuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
         $this->ctrl->redirectByClass(array("ilobjquestionpoolgui", get_class($q_gui)), "editQuestion");
     }
 }
 /**
  * Saves the learners input of the question to the database.
  *
  * @access public
  * @param integer $active_id Active id of the user
  * @param integer $pass Test pass
  * @return boolean $status
  */
 public function saveWorkingData($active_id, $pass = NULL)
 {
     global $ilDB;
     global $ilUser;
     if (is_null($pass)) {
         include_once "./Modules/Test/classes/class.ilObjTest.php";
         $pass = ilObjTest::_getPass($active_id);
     }
     $this->getProcessLocker()->requestUserSolutionUpdateLock();
     $affectedRows = $this->removeCurrentSolution($active_id, $pass);
     $entered_values = false;
     if (strlen($_POST["qst_" . $this->getId()])) {
         $selected = split(",", $_POST["qst_" . $this->getId()]);
         foreach ($selected as $position) {
             $affectedRows = $this->saveCurrentSolution($active_id, $pass, $position, null);
         }
         $entered_values = true;
     }
     $this->getProcessLocker()->releaseUserSolutionUpdateLock();
     if ($entered_values) {
         include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
         if (ilObjAssessmentFolder::_enabledAssessmentLogging()) {
             $this->logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
         }
     } else {
         include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
         if (ilObjAssessmentFolder::_enabledAssessmentLogging()) {
             $this->logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
         }
     }
     return true;
 }
 /**
  * Logs an action into the Test&Assessment log.
  *
  * @param integer 	$test_id The database id of the test.
  * @param string 	$logtext The log text.
  *
  * @return void
  */
 public function logAction($test_id, $logtext = "")
 {
     /** @var $ilUser ilObjUser */
     global $ilUser;
     include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
     ilObjAssessmentFolder::_addLog($ilUser->id, ilObjTest::_getObjectIDFromTestID($test_id), $logtext, "", "", TRUE, $_GET["ref_id"]);
 }
 /**
  * Saves the learners input of the question to the database.
  * 
  * @access public
  * @param integer $active_id Active id of the user
  * @param integer $pass Test pass
  * @return boolean $status
  */
 public function saveWorkingData($active_id, $pass = NULL)
 {
     global $ilDB;
     global $ilUser;
     if (is_null($pass)) {
         include_once "./Modules/Test/classes/class.ilObjTest.php";
         $pass = ilObjTest::_getPass($active_id);
     }
     $affectedRows = $ilDB->manipulateF("DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s", array("integer", "integer", "integer"), array($active_id, $this->getId(), $pass));
     if (strlen($_GET["selImage"])) {
         $next_id = $ilDB->nextId('tst_solutions');
         $affectedRows = $ilDB->insert("tst_solutions", array("solution_id" => array("integer", $next_id), "active_fi" => array("integer", $active_id), "question_fi" => array("integer", $this->getId()), "value1" => array("clob", $_GET['selImage']), "value2" => array("clob", null), "pass" => array("integer", $pass), "tstamp" => array("integer", time())));
         include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
         if (ilObjAssessmentFolder::_enabledAssessmentLogging()) {
             $this->logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
         }
     } else {
         include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
         if (ilObjAssessmentFolder::_enabledAssessmentLogging()) {
             $this->logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
         }
     }
     return true;
 }
 /**
  * Saves the learners input of the question to the database.
  * 
  * @access public
  * @param integer $active_id Active id of the user
  * @param integer $pass Test pass
  * @return boolean $status
  */
 public function saveWorkingData($active_id, $pass = NULL)
 {
     $saveWorkingDataResult = $this->checkSaveData();
     if ($saveWorkingDataResult) {
         if (is_null($pass)) {
             include_once "./Modules/Test/classes/class.ilObjTest.php";
             $pass = ilObjTest::_getPass($active_id);
         }
         $this->getProcessLocker()->requestUserSolutionUpdateLock();
         $affectedRows = $this->removeCurrentSolution($active_id, $pass);
         $entered_values = 0;
         foreach ($this->getSolutionSubmit() as $val1 => $val2) {
             $this->saveCurrentSolution($active_id, $pass, $val1, trim($val2));
             $entered_values++;
         }
         $this->getProcessLocker()->releaseUserSolutionUpdateLock();
     }
     if ($entered_values) {
         include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
         if (ilObjAssessmentFolder::_enabledAssessmentLogging()) {
             $this->logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
         }
     } else {
         include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
         if (ilObjAssessmentFolder::_enabledAssessmentLogging()) {
             $this->logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
         }
     }
     return $saveWorkingDataResult;
 }
 /**
  * Saves the learners input of the question to the database.
  * 
  * @access public
  * @param integer $active_id Active id of the user
  * @param integer $pass Test pass
  * @return boolean $status
  */
 public function saveWorkingData($active_id, $pass = NULL)
 {
     global $ilDB;
     global $ilUser;
     $saveWorkingDataResult = $this->checkSaveData();
     $entered_values = 0;
     if ($saveWorkingDataResult) {
         if (is_null($pass)) {
             include_once "./Modules/Test/classes/class.ilObjTest.php";
             $pass = ilObjTest::_getPass($active_id);
         }
         $affectedRows = $ilDB->manipulateF("DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s", array('integer', 'integer', 'integer'), array($active_id, $this->getId(), $pass));
         if (array_key_exists("orderresult", $_POST)) {
             $orderresult = $_POST["orderresult"];
             if (strlen($orderresult)) {
                 $orderarray = explode(":", $orderresult);
                 $ordervalue = 1;
                 foreach ($orderarray as $index) {
                     if (preg_match("/id_(\\d+)/", $index, $idmatch)) {
                         $randomid = $idmatch[1];
                         foreach ($this->getAnswers() as $answeridx => $answer) {
                             if ($answer->getRandomID() == $randomid) {
                                 $next_id = $ilDB->nextId('tst_solutions');
                                 $affectedRows = $ilDB->insert("tst_solutions", array("solution_id" => array("integer", $next_id), "active_fi" => array("integer", $active_id), "question_fi" => array("integer", $this->getId()), "value1" => array("clob", $answeridx), "value2" => array("clob", trim($ordervalue)), "pass" => array("integer", $pass), "tstamp" => array("integer", time())));
                                 $ordervalue++;
                                 $entered_values++;
                             }
                         }
                     }
                 }
             }
         } else {
             foreach ($_POST as $key => $value) {
                 if (preg_match("/^order_(\\d+)/", $key, $matches)) {
                     if (!preg_match("/initial_value_\\d+/", $value)) {
                         if (strlen($value)) {
                             foreach ($this->getAnswers() as $answeridx => $answer) {
                                 if ($answer->getRandomID() == $matches[1]) {
                                     $next_id = $ilDB->nextId('tst_solutions');
                                     $affectedRows = $ilDB->insert("tst_solutions", array("solution_id" => array("integer", $next_id), "active_fi" => array("integer", $active_id), "question_fi" => array("integer", $this->getId()), "value1" => array("clob", $answeridx), "value2" => array("clob", $value), "pass" => array("integer", $pass), "tstamp" => array("integer", time())));
                                     $entered_values++;
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     if ($entered_values) {
         include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
         if (ilObjAssessmentFolder::_enabledAssessmentLogging()) {
             $this->logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
         }
     } else {
         include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
         if (ilObjAssessmentFolder::_enabledAssessmentLogging()) {
             $this->logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
         }
     }
     return $saveWorkingDataResult;
 }
 /**
  * Saves the learners input of the question to the database
  *
  * Saves the learners input of the question to the database
  *
  * @param integer $test_id The database id of the test containing this question
  * @return boolean Indicates the save status (true if saved successful, false otherwise)
  * @access public
  * @see $ranges
  */
 function saveWorkingData($active_id, $pass = NULL)
 {
     global $ilDB;
     global $ilUser;
     if (is_null($pass)) {
         include_once "./Modules/Test/classes/class.ilObjTest.php";
         $pass = ilObjTest::_getPass($active_id);
     }
     $entered_values = 0;
     $query = sprintf("DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s", $ilDB->quote($active_id . ""), $ilDB->quote($this->getId() . ""), $ilDB->quote($pass . ""));
     $result = $ilDB->query($query);
     foreach ($_POST as $key => $value) {
         if (preg_match("/^SYNTAXTREE_(\\d+)/", $key, $matches)) {
             if (strlen($value)) {
                 $tstamp = array("integer", time());
                 $next_id = $ilDB->nextId('tst_solutions');
                 $query = sprintf("INSERT INTO tst_solutions (solution_id, active_fi, question_fi, value1, value2, pass, tstamp) VALUES (%s, %s, %s, %s, NULL, %s, %s)", $ilDB->quote($next_id), $ilDB->quote($active_id), $ilDB->quote($this->getId()), $ilDB->quote(trim($value)), $ilDB->quote($pass . ""), $ilDB->quote($tstamp));
                 $result = $ilDB->query($query);
                 $entered_values++;
             }
         }
     }
     if ($entered_values) {
         include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
         if (ilObjAssessmentFolder::_enabledAssessmentLogging()) {
             $this->logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
         }
     } else {
         include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
         if (ilObjAssessmentFolder::_enabledAssessmentLogging()) {
             $this->logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
         }
     }
     parent::saveWorkingData($active_id, $pass);
     return true;
 }
 /**
  * Saves the learners input of the question to the database.
  * 
  * @access public
  * @param integer $active_id Active id of the user
  * @param integer $pass Test pass
  * @return boolean $status
  */
 public function saveWorkingData($active_id, $pass = NULL)
 {
     global $ilDB;
     global $ilUser;
     if (is_null($pass)) {
         include_once "./Modules/Test/classes/class.ilObjTest.php";
         $pass = ilObjTest::_getPass($active_id);
     }
     if ($_POST['cmd'][$this->questionActionCmd] != $this->lng->txt('delete') && strlen($_FILES["upload"]["tmp_name"])) {
         $checkUploadResult = $this->checkUpload();
     } else {
         $checkUploadResult = false;
     }
     $result = $ilDB->queryF("SELECT test_fi FROM tst_active WHERE active_id = %s", array('integer'), array($active_id));
     $test_id = 0;
     if ($result->numRows() == 1) {
         $row = $ilDB->fetchAssoc($result);
         $test_id = $row["test_fi"];
     }
     $this->getProcessLocker()->requestUserSolutionUpdateLock();
     $entered_values = false;
     if ($_POST['cmd'][$this->questionActionCmd] == $this->lng->txt('delete')) {
         if (is_array($_POST['deletefiles']) && count($_POST['deletefiles']) > 0) {
             $this->deleteUploadedFiles($_POST['deletefiles'], $test_id, $active_id);
         } else {
             ilUtil::sendInfo($this->lng->txt('no_checkbox'), true);
         }
     } elseif ($checkUploadResult) {
         if (!@file_exists($this->getFileUploadPath($test_id, $active_id))) {
             ilUtil::makeDirParents($this->getFileUploadPath($test_id, $active_id));
         }
         $version = time();
         $filename_arr = pathinfo($_FILES["upload"]["name"]);
         $extension = $filename_arr["extension"];
         $newfile = "file_" . $active_id . "_" . $pass . "_" . $version . "." . $extension;
         ilUtil::moveUploadedFile($_FILES["upload"]["tmp_name"], $_FILES["upload"]["name"], $this->getFileUploadPath($test_id, $active_id) . $newfile);
         $next_id = $ilDB->nextId('tst_solutions');
         $affectedRows = $ilDB->insert("tst_solutions", array("solution_id" => array("integer", $next_id), "active_fi" => array("integer", $active_id), "question_fi" => array("integer", $this->getId()), "value1" => array("clob", $newfile), "value2" => array("clob", $_FILES['upload']['name']), "pass" => array("integer", $pass), "tstamp" => array("integer", time())));
         $entered_values = true;
     }
     $this->getProcessLocker()->releaseUserSolutionUpdateLock();
     if ($entered_values) {
         include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
         if (ilObjAssessmentFolder::_enabledAssessmentLogging()) {
             $this->logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
         }
     } else {
         include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
         if (ilObjAssessmentFolder::_enabledAssessmentLogging()) {
             $this->logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
         }
     }
     return true;
 }
 /**
  * Saves the learners input of the question to the database.
  * 
  * @param integer $active_id Active id of the user
  * @param integer $pass Test pass
  *                      
  * @return boolean $status
  */
 public function saveWorkingData($active_id, $pass = NULL)
 {
     /** @var $ilDB ilDB */
     global $ilDB;
     if (is_null($pass)) {
         include_once "./Modules/Test/classes/class.ilObjTest.php";
         $pass = ilObjTest::_getPass($active_id);
     }
     $entered_values = 0;
     $ilDB->manipulateF("DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s", array('integer', 'integer', 'integer'), array($active_id, $this->getId(), $pass));
     foreach ($_POST as $key => $value) {
         if (preg_match("/^multiple_choice_result_(\\d+)/", $key, $matches)) {
             if (strlen($value)) {
                 $next_id = $ilDB->nextId('tst_solutions');
                 $ilDB->insert("tst_solutions", array("solution_id" => array("integer", $next_id), "active_fi" => array("integer", $active_id), "question_fi" => array("integer", $this->getId()), "value1" => array("clob", $value), "value2" => array("clob", null), "pass" => array("integer", $pass), "tstamp" => array("integer", time())));
                 $entered_values++;
             }
         }
     }
     if ($entered_values) {
         include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
         if (ilObjAssessmentFolder::_enabledAssessmentLogging()) {
             $this->logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
         }
     } else {
         include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
         if (ilObjAssessmentFolder::_enabledAssessmentLogging()) {
             $this->logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
         }
     }
     return true;
 }
 /**
  * Saves the learners input of the question to the database.
  * 
  * @access public
  * @param integer $active_id Active id of the user
  * @param integer $pass Test pass
  * @return boolean $status
  */
 public function saveWorkingData($active_id, $pass = NULL)
 {
     global $ilDB;
     global $ilUser;
     if (is_null($pass)) {
         include_once "./Modules/Test/classes/class.ilObjTest.php";
         $pass = ilObjTest::_getPass($active_id);
     }
     $entered_values = 0;
     $this->getProcessLocker()->requestUserSolutionUpdateLock();
     $result = $this->getCurrentSolutionResultSet($active_id, $pass);
     $row = $ilDB->fetchAssoc($result);
     $update = $row["solution_id"];
     if ($update) {
         if (strlen($_POST["multiple_choice_result"])) {
             $affectedRows = $ilDB->update("tst_solutions", array("value1" => array("clob", $_POST["multiple_choice_result"]), "tstamp" => array("integer", time())), array("solution_id" => array("integer", $update)));
             $entered_values++;
         } else {
             $affectedRows = $ilDB->manipulateF("DELETE FROM tst_solutions WHERE solution_id = %s", array('integer'), array($update));
         }
     } else {
         if (strlen($_POST["multiple_choice_result"])) {
             $affectedRows = $this->saveCurrentSolution($active_id, $pass, $_POST['multiple_choice_result'], null);
             $entered_values++;
         }
     }
     $this->getProcessLocker()->releaseUserSolutionUpdateLock();
     if ($entered_values) {
         include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
         if (ilObjAssessmentFolder::_enabledAssessmentLogging()) {
             $this->logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
         }
     } else {
         include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
         if (ilObjAssessmentFolder::_enabledAssessmentLogging()) {
             $this->logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
         }
     }
     return true;
 }
 /**
  * Returns the list of answers of a users test pass and offers a scoring option
  *
  * @param array $result_array An array containing the results of the users test pass (generated by ilObjTest::getTestResult)
  * @param integer $active_id Active ID of the active user
  * @param integer $pass Test pass
  * @param boolean $show_solutions TRUE, if the solution output should be shown in the answers, FALSE otherwise
  * @return string HTML code of the list of answers
  * @access public
  * 
  * @deprecated
  */
 function getPassListOfAnswersWithScoring(&$result_array, $active_id, $pass, $show_solutions = FALSE)
 {
     include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
     $maintemplate = new ilTemplate("tpl.il_as_tst_list_of_answers.html", TRUE, TRUE, "Modules/Test");
     include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
     $scoring = ilObjAssessmentFolder::_getManualScoring();
     $counter = 1;
     // output of questions with solutions
     foreach ($result_array as $question_data) {
         $question = $question_data["qid"];
         if (is_numeric($question)) {
             $question_gui = $this->object->createQuestionGUI("", $question);
             if (in_array($question_gui->object->getQuestionTypeID(), $scoring)) {
                 $template = new ilTemplate("tpl.il_as_qpl_question_printview.html", TRUE, TRUE, "Modules/TestQuestionPool");
                 $scoretemplate = new ilTemplate("tpl.il_as_tst_manual_scoring_points.html", TRUE, TRUE, "Modules/Test");
                 #mbecker: No such block. $this->tpl->setCurrentBlock("printview_question");
                 $template->setVariable("COUNTER_QUESTION", $counter . ". ");
                 $template->setVariable("QUESTION_TITLE", $this->object->getQuestionTitle($question_gui->object->getTitle()));
                 $points = $question_gui->object->getMaximumPoints();
                 if ($points == 1) {
                     $template->setVariable("QUESTION_POINTS", $points . " " . $this->lng->txt("point"));
                 } else {
                     $template->setVariable("QUESTION_POINTS", $points . " " . $this->lng->txt("points"));
                 }
                 $show_question_only = $this->object->getShowSolutionAnswersOnly() ? TRUE : FALSE;
                 $result_output = $question_gui->getSolutionOutput($active_id, $pass, $show_solutions, FALSE, $show_question_only, $this->object->getShowSolutionFeedback(), FALSE, TRUE);
                 $solout = $question_gui->object->getSuggestedSolutionOutput();
                 if (strlen($solout)) {
                     $scoretemplate->setCurrentBlock("suggested_solution");
                     $scoretemplate->setVariable("TEXT_SUGGESTED_SOLUTION", $this->lng->txt("solution_hint"));
                     $scoretemplate->setVariable("VALUE_SUGGESTED_SOLUTION", $solout);
                     $scoretemplate->parseCurrentBlock();
                 }
                 $scoretemplate->setCurrentBlock("feedback");
                 $scoretemplate->setVariable("FEEDBACK_NAME_INPUT", $question);
                 $feedback = $this->object->getManualFeedback($active_id, $question, $pass);
                 $scoretemplate->setVariable("VALUE_FEEDBACK", ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($feedback, TRUE)));
                 $scoretemplate->setVariable("TEXT_MANUAL_FEEDBACK", $this->lng->txt("set_manual_feedback"));
                 $scoretemplate->parseCurrentBlock();
                 $scoretemplate->setVariable("NAME_INPUT", $question);
                 $this->ctrl->setParameter($this, "active_id", $active_id);
                 $this->ctrl->setParameter($this, "pass", $pass);
                 $scoretemplate->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "manscoring"));
                 $scoretemplate->setVariable("LABEL_INPUT", $this->lng->txt("tst_change_points_for_question"));
                 $scoretemplate->setVariable("VALUE_INPUT", " value=\"" . assQuestion::_getReachedPoints($active_id, $question_data["qid"], $pass) . "\"");
                 $scoretemplate->setVariable("VALUE_SAVE", $this->lng->txt("save"));
                 $template->setVariable("SOLUTION_OUTPUT", $result_output);
                 $maintemplate->setCurrentBlock("printview_question");
                 $maintemplate->setVariable("QUESTION_PRINTVIEW", $template->get());
                 $maintemplate->setVariable("QUESTION_SCORING", $scoretemplate->get());
                 $maintemplate->parseCurrentBlock();
             }
             $counter++;
         }
     }
     if ($counter == 1) {
         // no scorable questions found
         $maintemplate->setVariable("NO_QUESTIONS_FOUND", $this->lng->txt("manscoring_questions_not_found"));
     }
     $maintemplate->setVariable("RESULTS_OVERVIEW", sprintf($this->lng->txt("manscoring_results_pass"), $pass + 1));
     include_once "./Services/YUI/classes/class.ilYuiUtil.php";
     ilYuiUtil::initDomEvent();
     return $maintemplate->get();
 }
 private function buildCreateQuestionForm()
 {
     global $ilUser;
     // form
     require_once "Services/Form/classes/class.ilPropertyFormGUI.php";
     $form = new ilPropertyFormGUI();
     $form->setTitle($this->lng->txt('ass_create_question'));
     $form->setFormAction($this->ctrl->getFormAction($this));
     // question type
     $options = array();
     foreach ($this->object->getQuestionTypes(false, true) as $translation => $data) {
         $options[$data['type_tag']] = $translation;
     }
     require_once "Services/Form/classes/class.ilSelectInputGUI.php";
     $si = new ilSelectInputGUI($this->lng->txt('question_type'), 'sel_question_types');
     $si->setOptions($options);
     //$si->setValue($ilUser->getPref("tst_lastquestiontype"));
     $form->addItem($si);
     // content editing mode
     if (ilObjAssessmentFolder::isAdditionalQuestionContentEditingModePageObjectEnabled()) {
         $ri = new ilRadioGroupInputGUI($this->lng->txt("tst_add_quest_cont_edit_mode"), "add_quest_cont_edit_mode");
         $ri->addOption(new ilRadioOption($this->lng->txt('tst_add_quest_cont_edit_mode_default'), assQuestion::ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT));
         $ri->addOption(new ilRadioOption($this->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);
     }
     // commands
     $form->addCommandButton('createQuestion', $this->lng->txt('create'));
     $form->addCommandButton('questions', $this->lng->txt('cancel'));
     return $form;
 }
 /**
  * Saves the learners input of the question to the database.
  * 
  * @access public
  * @param integer $active_id Active id of the user
  * @param integer $pass Test pass
  * @return boolean $status
  */
 public function saveWorkingData($active_id, $pass = NULL)
 {
     global $ilDB;
     global $ilUser;
     if (is_null($pass)) {
         include_once "./Modules/Test/classes/class.ilObjTest.php";
         $pass = ilObjTest::_getPass($active_id);
     }
     $affectedRows = $ilDB->manipulateF("DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s", array("integer", "integer", "integer"), array($active_id, $this->getId(), $pass));
     $entered_values = 0;
     foreach ($_POST as $key => $value) {
         if (preg_match("/^gap_(\\d+)/", $key, $matches)) {
             $value = ilUtil::stripSlashes($value, FALSE);
             if (strlen($value)) {
                 $gap = $this->getGap($matches[1]);
                 if (is_object($gap)) {
                     if (!($gap->getType() == CLOZE_SELECT && $value == -1)) {
                         if ($gap->getType() == CLOZE_NUMERIC) {
                             $value = str_replace(",", ".", $value);
                         }
                         $next_id = $ilDB->nextId("tst_solutions");
                         $affectedRows = $ilDB->insert("tst_solutions", array("solution_id" => array("integer", $next_id), "active_fi" => array("integer", $active_id), "question_fi" => array("integer", $this->getId()), "value1" => array("clob", trim($matches[1])), "value2" => array("clob", trim($value)), "pass" => array("integer", $pass), "tstamp" => array("integer", time())));
                         $entered_values++;
                     }
                 }
             }
         }
     }
     if ($entered_values) {
         include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
         if (ilObjAssessmentFolder::_enabledAssessmentLogging()) {
             $this->logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
         }
     } else {
         include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
         if (ilObjAssessmentFolder::_enabledAssessmentLogging()) {
             $this->logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
         }
     }
     return TRUE;
 }
 /**
  * Saves the learners input of the question to the database.
  *
  * @access public
  * @param integer $active_id Active id of the user
  * @param integer $pass Test pass
  * @return boolean $status
  */
 public function saveWorkingData($active_id, $pass = NULL)
 {
     /** @var $ilDB ilDB */
     global $ilDB;
     if (is_null($pass)) {
         include_once "./Modules/Test/classes/class.ilObjTest.php";
         $pass = ilObjTest::_getPass($active_id);
     }
     $entered_values = 0;
     $this->getProcessLocker()->requestUserSolutionUpdateLock();
     $ilDB->manipulateF("DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s", array('integer', 'integer', 'integer'), array($active_id, $this->getId(), $pass));
     $solutionSubmit = $this->getSolutionSubmit();
     foreach ($solutionSubmit as $answerIndex => $answerValue) {
         $next_id = $ilDB->nextId('tst_solutions');
         $ilDB->insert("tst_solutions", array("solution_id" => array("integer", $next_id), "active_fi" => array("integer", $active_id), "question_fi" => array("integer", $this->getId()), "value1" => array("clob", (int) $answerIndex), "value2" => array("clob", (int) $answerValue), "pass" => array("integer", $pass), "tstamp" => array("integer", time())));
         $entered_values++;
     }
     $this->getProcessLocker()->releaseUserSolutionUpdateLock();
     if ($entered_values) {
         include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
         if (ilObjAssessmentFolder::_enabledAssessmentLogging()) {
             $this->logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
         }
     } else {
         include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
         if (ilObjAssessmentFolder::_enabledAssessmentLogging()) {
             $this->logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
         }
     }
     return true;
 }
Exemple #20
0
 public function addExtraTime($active_id, $minutes)
 {
     global $ilDB;
     $participants = array();
     if ($active_id == 0) {
         $result = $ilDB->queryF("SELECT active_id FROM tst_active WHERE test_fi = %s", array('integer'), array($this->getTestId()));
         while ($row = $ilDB->fetchAssoc($result)) {
             array_push($participants, $row['active_id']);
         }
     } else {
         array_push($participants, $active_id);
     }
     foreach ($participants as $active_id) {
         $result = $ilDB->queryF("SELECT active_fi FROM tst_addtime WHERE active_fi = %s", array('integer'), array($active_id));
         if ($result->numRows() > 0) {
             $ilDB->manipulateF("DELETE FROM tst_addtime WHERE active_fi = %s", array('integer'), array($active_id));
         }
         $ilDB->manipulateF("UPDATE tst_active SET tries = %s, submitted = %s, submittimestamp = %s WHERE active_id = %s", array('integer', 'integer', 'timestamp', 'integer'), array(0, 0, NULL, $active_id));
         $ilDB->manipulateF("INSERT INTO tst_addtime (active_fi, additionaltime, tstamp) VALUES (%s, %s, %s)", array('integer', 'integer', 'integer'), array($active_id, $minutes, time()));
         require_once 'Modules/Test/classes/class.ilObjAssessmentFolder.php';
         if (ilObjAssessmentFolder::_enabledAssessmentLogging()) {
             $this->logAction(sprintf($this->lng->txtlng("assessment", "log_added_extratime", ilObjAssessmentFolder::_getLogLanguage()), $minutes, $active_id));
         }
     }
 }
 /**
  * Saves the learners input of the question to the database
  * @param integer $test_id The database id of the test containing this question
  * @return boolean Indicates the save status (true if saved successful, false otherwise)
  * @access public
  * @see    $answers
  */
 function saveWorkingData($active_id, $pass = NULL)
 {
     global $ilDB;
     if (is_null($pass)) {
         include_once "./Modules/Test/classes/class.ilObjTest.php";
         $pass = ilObjTest::_getPass($active_id);
     }
     $this->getProcessLocker()->requestUserSolutionUpdateLock();
     $solutionSubmit = $this->getSolutionSubmit();
     $entered_values = FALSE;
     foreach ($solutionSubmit as $key => $value) {
         $matches = null;
         if (preg_match("/^result_(\\\$r\\d+)\$/", $key, $matches)) {
             if (strlen($value)) {
                 $entered_values = TRUE;
             }
             $result = $ilDB->queryF("SELECT solution_id FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s  AND " . $ilDB->like('value1', 'clob', $matches[1]), array('integer', 'integer', 'integer'), array($active_id, $pass, $this->getId()));
             if ($result->numRows()) {
                 while ($row = $ilDB->fetchAssoc($result)) {
                     $affectedRows = $ilDB->manipulateF("DELETE FROM tst_solutions WHERE solution_id = %s", array('integer'), array($row['solution_id']));
                 }
             }
             $affectedRows = $this->saveCurrentSolution($active_id, $pass, $matches[1], str_replace(",", ".", $value));
         } else {
             if (preg_match("/^result_(\\\$r\\d+)_unit\$/", $key, $matches)) {
                 $result = $ilDB->queryF("SELECT solution_id FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND " . $ilDB->like('value1', 'clob', $matches[1] . "_unit"), array('integer', 'integer', 'integer'), array($active_id, $pass, $this->getId()));
                 if ($result->numRows()) {
                     while ($row = $ilDB->fetchAssoc($result)) {
                         $affectedRows = $ilDB->manipulateF("DELETE FROM tst_solutions WHERE solution_id = %s", array('integer'), array($row['solution_id']));
                     }
                 }
                 $affectedRows = $this->saveCurrentSolution($active_id, $pass, $matches[1] . "_unit", $value);
             }
         }
     }
     $this->getProcessLocker()->releaseUserSolutionUpdateLock();
     if ($entered_values) {
         include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
         if (ilObjAssessmentFolder::_enabledAssessmentLogging()) {
             $this->logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
         }
     } else {
         include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
         if (ilObjAssessmentFolder::_enabledAssessmentLogging()) {
             $this->logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
         }
     }
     return true;
 }
 /**
  * Saves the learners input of the question to the database
  *
  * @param    integer	active_id of the user
  * @param	 integer	pass number
  * @return   boolean 	successful saving
  *
  * @see    self::getSolutionStored()
  */
 function saveWorkingData($active_id, $pass = NULL, $authorized = true)
 {
     if (is_null($pass)) {
         include_once "./Modules/Test/classes/class.ilObjTest.php";
         $pass = ilObjTest::_getPass($active_id);
     }
     // get the values to be stored
     $solution = $this->getSolutionSubmit();
     $inputs = array();
     foreach ($solution as $part_id => $input) {
         $inputs[] = $input;
     }
     $value1 = 'accqst_input';
     // key to idenify the storage format
     $value2 = implode('<partBreak />', $inputs);
     // concatenated xml inputs for all parts
     // update the solution with process log
     $this->getProcessLocker()->requestUserSolutionUpdateLock();
     $this->removeCurrentSolution($active_id, $pass, $authorized);
     $this->saveCurrentSolution($active_id, $pass, $value1, $value2, $authorized);
     $this->getProcessLocker()->releaseUserSolutionUpdateLock();
     // log the saving, we assume that values have been entered
     include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
     if (ilObjAssessmentFolder::_enabledAssessmentLogging()) {
         $this->logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
     }
     return true;
 }
 /**
  * Saves the learners input of the question to the database.
  * 
  * @param integer $active_id Active id of the user
  * @param integer $pass Test pass
  *                      
  * @return boolean $status
  */
 public function saveWorkingData($active_id, $pass = NULL)
 {
     /** @var $ilDB ilDB */
     global $ilDB;
     if (is_null($pass)) {
         include_once "./Modules/Test/classes/class.ilObjTest.php";
         $pass = ilObjTest::_getPass($active_id);
     }
     $entered_values = 0;
     $this->getProcessLocker()->requestUserSolutionUpdateLock();
     $this->removeCurrentSolution($active_id, $pass);
     $solutionSubmit = $this->getSolutionSubmit();
     foreach ($solutionSubmit as $value) {
         if (strlen($value)) {
             $this->saveCurrentSolution($active_id, $pass, $value, null);
             $entered_values++;
         }
     }
     $this->getProcessLocker()->releaseUserSolutionUpdateLock();
     if ($entered_values) {
         include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
         if (ilObjAssessmentFolder::_enabledAssessmentLogging()) {
             $this->logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
         }
     } else {
         include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
         if (ilObjAssessmentFolder::_enabledAssessmentLogging()) {
             $this->logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
         }
     }
     return true;
 }
 /**
  * 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');
 }
 function &_getQuestionTypes($all_tags = FALSE, $fixOrder = false)
 {
     global $ilDB;
     global $lng;
     include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
     $forbidden_types = ilObjAssessmentFolder::_getForbiddenQuestionTypes();
     $lng->loadLanguageModule("assessment");
     $result = $ilDB->query("SELECT * FROM qpl_qst_type");
     $types = array();
     while ($row = $ilDB->fetchAssoc($result)) {
         if ($all_tags || !in_array($row["question_type_id"], $forbidden_types)) {
             global $ilLog;
             if ($row["plugin"] == 0) {
                 $types[$lng->txt($row["type_tag"])] = $row;
             } else {
                 global $ilPluginAdmin;
                 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_MODULE, "TestQuestionPool", "qst");
                 foreach ($pl_names as $pl_name) {
                     $pl = ilPlugin::getPluginObject(IL_COMP_MODULE, "TestQuestionPool", "qst", $pl_name);
                     if (strcmp($pl->getQuestionType(), $row["type_tag"]) == 0) {
                         $types[$pl->getQuestionTypeTranslation()] = $row;
                     }
                 }
             }
         }
     }
     require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionTypeOrderer.php';
     $orderMode = $fixOrder ? ilAssQuestionTypeOrderer::ORDER_MODE_FIX : ilAssQuestionTypeOrderer::ORDER_MODE_ALPHA;
     $orderer = new ilAssQuestionTypeOrderer($types, $orderMode);
     $types = $orderer->getOrderedTypes();
     return $types;
 }
 /**
  * Saves the learners input of the question to the database.
  * 
  * @access public
  * @param integer $active_id Active id of the user
  * @param integer $pass Test pass
  * @return boolean $status
  */
 public function saveWorkingData($active_id, $pass = NULL)
 {
     global $ilDB;
     global $ilUser;
     include_once "./Services/Utilities/classes/class.ilStr.php";
     if (is_null($pass)) {
         include_once "./Modules/Test/classes/class.ilObjTest.php";
         $pass = ilObjTest::_getPass($active_id);
     }
     $affectedRows = $ilDB->manipulateF("DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s", array('integer', 'integer', 'integer'), array($active_id, $this->getId(), $pass));
     $text = ilUtil::stripSlashes($_POST["TEXT"], FALSE);
     if ($this->getMaxNumOfChars()) {
         include_once "./Services/Utilities/classes/class.ilStr.php";
         $text_without_tags = preg_replace("/<[^>*?]>/is", "", $text);
         $len_with_tags = ilStr::strLen($text);
         $len_without_tags = ilStr::strLen($text_without_tags);
         if ($this->getMaxNumOfChars() < $len_without_tags) {
             if (!$this->isHTML($text)) {
                 $text = ilStr::subStr($text, 0, $this->getMaxNumOfChars());
             }
         }
     }
     if ($this->isHTML($text)) {
         $text = preg_replace("/<[^>]*\$/ims", "", $text);
     } else {
         //$text = htmlentities($text, ENT_QUOTES, "UTF-8");
     }
     $entered_values = 0;
     if (strlen($text)) {
         $next_id = $ilDB->nextId('tst_solutions');
         $affectedRows = $ilDB->insert("tst_solutions", array("solution_id" => array("integer", $next_id), "active_fi" => array("integer", $active_id), "question_fi" => array("integer", $this->getId()), "value1" => array("clob", trim($text)), "value2" => array("clob", null), "pass" => array("integer", $pass), "tstamp" => array("integer", time())));
         $entered_values++;
     }
     if ($entered_values) {
         include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
         if (ilObjAssessmentFolder::_enabledAssessmentLogging()) {
             $this->logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
         }
     } else {
         include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
         if (ilObjAssessmentFolder::_enabledAssessmentLogging()) {
             $this->logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
         }
     }
     return true;
 }
 /**
  * Saves the learners input of the question to the database.
  * 
  * @access public
  * @param integer $active_id Active id of the user
  * @param integer $pass Test pass
  * @return boolean $status
  */
 public function saveWorkingData($active_id, $pass = NULL)
 {
     global $ilDB;
     global $ilUser;
     if (is_null($pass)) {
         include_once "./Modules/Test/classes/class.ilObjTest.php";
         $pass = ilObjTest::_getPass($active_id);
     }
     $entered_values = 0;
     $result = $ilDB->queryF("SELECT solution_id FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s", array('integer', 'integer', 'integer'), array($active_id, $this->getId(), $pass));
     $row = $ilDB->fetchAssoc($result);
     $update = $row["solution_id"];
     if ($update) {
         if (strlen($_POST["multiple_choice_result"])) {
             $affectedRows = $ilDB->update("tst_solutions", array("value1" => array("clob", $_POST["multiple_choice_result"]), "tstamp" => array("integer", time())), array("solution_id" => array("integer", $update)));
             $entered_values++;
         } else {
             $affectedRows = $ilDB->manipulateF("DELETE FROM tst_solutions WHERE solution_id = %s", array('integer'), array($update));
         }
     } else {
         if (strlen($_POST["multiple_choice_result"])) {
             $next_id = $ilDB->nextId('tst_solutions');
             $affectedRows = $ilDB->insert("tst_solutions", array("solution_id" => array("integer", $next_id), "active_fi" => array("integer", $active_id), "question_fi" => array("integer", $this->getId()), "value1" => array("clob", $_POST['multiple_choice_result']), "value2" => array("clob", null), "pass" => array("integer", $pass), "tstamp" => array("integer", time())));
             $entered_values++;
         }
     }
     if ($entered_values) {
         include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
         if (ilObjAssessmentFolder::_enabledAssessmentLogging()) {
             $this->logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
         }
     } else {
         include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
         if (ilObjAssessmentFolder::_enabledAssessmentLogging()) {
             $this->logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
         }
     }
     return true;
 }
Exemple #28
0
 /**
  * adds tabs to tab gui object
  *
  * @param ilTabsGUI $tabs_gui
  */
 function getTabs(&$tabs_gui)
 {
     global $ilAccess, $ilUser, $ilHelp;
     if (preg_match('/^ass(.*?)gui$/i', $this->ctrl->getNextClass($this))) {
         return;
     } else {
         if ($this->ctrl->getNextClass($this) == 'ilassquestionpagegui') {
             return;
         }
     }
     $ilHelp->setScreenIdComponent("tst");
     $hidden_tabs = array();
     $template = $this->object->getTemplate();
     if ($template) {
         include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
         $template = new ilSettingsTemplate($template, ilObjAssessmentFolderGUI::getSettingsTemplateConfig());
         $hidden_tabs = $template->getHiddenTabs();
     }
     // for local use in this f*****g sledge hammer method
     $curUserHasWriteAccess = $ilAccess->checkAccess("write", "", $this->ref_id);
     switch ($this->ctrl->getCmdClass()) {
         // no tabs .. no subtabs .. during test pass
         case 'iltestoutputgui':
             // tab handling happens within GUIs
         // tab handling happens within GUIs
         case 'iltestevaluationgui':
         case 'iltestevalobjectiveorientedgui':
             return;
         case 'ilmarkschemagui':
         case 'ilobjtestsettingsgeneralgui':
         case 'ilobjtestsettingsscoringresultsgui':
             if ($curUserHasWriteAccess) {
                 $this->getSettingsSubTabs($hidden_tabs);
             }
             break;
     }
     if ($this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) {
         require_once 'Services/Link/classes/class.ilLink.php';
         $courseLink = ilLink::_getLink($this->getObjectiveOrientedContainer()->getRefId());
         $tabs_gui->setBackTarget($this->lng->txt('back_to_objective_container'), $courseLink);
     }
     switch ($this->ctrl->getCmd()) {
         case "resume":
         case "previous":
         case "next":
         case "summary":
         case "directfeedback":
         case "finishTest":
         case "outCorrectSolution":
         case "passDetails":
         case "showAnswersOfUser":
         case "outUserResultsOverview":
         case "backFromSummary":
         case "show_answers":
         case "setsolved":
         case "resetsolved":
         case "confirmFinish":
         case "outTestSummary":
         case "outQuestionSummary":
         case "gotoQuestion":
         case "selectImagemapRegion":
         case "confirmSubmitAnswers":
         case "finalSubmission":
         case "postpone":
         case "redirectQuestion":
         case "outUserPassDetails":
         case "checkPassword":
         case "exportCertificate":
         case "finishListOfAnswers":
         case "backConfirmFinish":
         case "showFinalStatement":
             return;
             break;
             /*case "browseForQuestions":
             		case "filter":
             		case "resetFilter":
             		case "resetTextFilter":
             		case "insertQuestions":
             			// #8497: resetfilter is also used in lp
             			if($this->ctrl->getNextClass($this) != "illearningprogressgui")
             			{
             				return $this->getBrowseForQuestionsTab($tabs_gui);
             			}				
             			break;*/
         /*case "browseForQuestions":
         		case "filter":
         		case "resetFilter":
         		case "resetTextFilter":
         		case "insertQuestions":
         			// #8497: resetfilter is also used in lp
         			if($this->ctrl->getNextClass($this) != "illearningprogressgui")
         			{
         				return $this->getBrowseForQuestionsTab($tabs_gui);
         			}				
         			break;*/
         case "scoring":
         case "certificate":
         case "certificateservice":
         case "certificateImport":
         case "certificateUpload":
         case "certificateEditor":
         case "certificateDelete":
         case "certificateSave":
         case "defaults":
         case "deleteDefaults":
         case "addDefaults":
         case "applyDefaults":
         case "inviteParticipants":
         case "searchParticipants":
             if ($curUserHasWriteAccess && in_array($this->ctrl->getCmdClass(), array('ilobjtestgui', 'ilcertificategui'))) {
                 $this->getSettingsSubTabs($hidden_tabs);
             }
             break;
         case "export":
         case "print":
             break;
         case "statistics":
         case "eval_a":
         case "detailedEvaluation":
         case "outEvaluation":
         case "singleResults":
         case "exportEvaluation":
         case "evalUserDetail":
         case "passDetails":
         case "outStatisticsResultsOverview":
         case "statisticsPassDetails":
             $this->getStatisticsSubTabs();
             break;
     }
     if (strcmp(strtolower(get_class($this->object)), "ilobjtest") == 0) {
         // questions tab
         if ($ilAccess->checkAccess("write", "", $this->ref_id) && !in_array('assQuestions', $hidden_tabs)) {
             $force_active = $_GET["up"] != "" || $_GET["down"] != "" ? true : false;
             if (!$force_active) {
                 if ($_GET["browse"] == 1) {
                     $force_active = true;
                 }
             }
             switch ($this->object->getQuestionSetType()) {
                 case ilObjTest::QUESTION_SET_TYPE_FIXED:
                     $target = $this->ctrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'showPage');
                     break;
                 case ilObjTest::QUESTION_SET_TYPE_RANDOM:
                     $target = $this->ctrl->getLinkTargetByClass('ilTestRandomQuestionSetConfigGUI');
                     break;
                 case ilObjTest::QUESTION_SET_TYPE_DYNAMIC:
                     $target = $this->ctrl->getLinkTargetByClass('ilObjTestDynamicQuestionSetConfigGUI');
                     break;
             }
             $tabs_gui->addTarget("assQuestions", $target, array("questions", "createQuestion", "randomselect", "back", "createRandomSelection", "cancelRandomSelect", "insertRandomSelection", "removeQuestions", "moveQuestions", "insertQuestionsBefore", "insertQuestionsAfter", "confirmRemoveQuestions", "cancelRemoveQuestions", "executeCreateQuestion", "cancelCreateQuestion", "addQuestionpool", "saveRandomQuestions", "saveQuestionSelectionMode", "print", "addsource", "removesource", "randomQuestions"), "", "", $force_active);
         }
         // info tab
         if ($ilAccess->checkAccess("read", "", $this->ref_id) && !in_array('info_short', $hidden_tabs)) {
             $tabs_gui->addTarget("info_short", $this->ctrl->getLinkTarget($this, 'infoScreen'), array("infoScreen", "outIntroductionPage", "showSummary", "setAnonymousId", "outUserListOfAnswerPasses", "redirectToInfoScreen"));
         }
         // settings tab
         if ($ilAccess->checkAccess("write", "", $this->ref_id)) {
             if (!in_array('settings', $hidden_tabs)) {
                 $settingsCommands = array("marks", "showMarkSchema", "addMarkStep", "deleteMarkSteps", "addSimpleMarkSchema", "saveMarks", "certificate", "certificateEditor", "certificateRemoveBackground", "certificateSave", "certificatePreview", "certificateDelete", "certificateUpload", "certificateImport", "scoring", "defaults", "addDefaults", "deleteDefaults", "applyDefaults", "inviteParticipants", "saveFixedParticipantsStatus", "searchParticipants", "addParticipants");
                 require_once 'Modules/Test/classes/class.ilObjTestSettingsGeneralGUI.php';
                 $reflection = new ReflectionClass('ilObjTestSettingsGeneralGUI');
                 foreach ($reflection->getConstants() as $name => $value) {
                     if (substr($name, 0, 4) == 'CMD_') {
                         $settingsCommands[] = $value;
                     }
                 }
                 require_once 'Modules/Test/classes/class.ilObjTestSettingsScoringResultsGUI.php';
                 $reflection = new ReflectionClass('ilObjTestSettingsScoringResultsGUI');
                 foreach ($reflection->getConstants() as $name => $value) {
                     if (substr($name, 0, 4) == 'CMD_') {
                         $settingsCommands[] = $value;
                     }
                 }
                 $settingsCommands[] = "";
                 // DO NOT KNOW WHAT THIS IS DOING, BUT IT'S REQUIRED
                 $tabs_gui->addTarget("settings", $this->ctrl->getLinkTargetByClass('ilObjTestSettingsGeneralGUI'), $settingsCommands, array("ilmarkschemagui", "ilobjtestsettingsgeneralgui", "ilobjtestsettingsscoringresultsgui", "ilobjtestgui", "ilcertificategui"));
             }
             // skill service
             if ($this->object->isSkillServiceEnabled() && ilObjTest::isSkillManagementGloballyActivated()) {
                 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionSkillAssignmentsGUI.php';
                 $link = $this->ctrl->getLinkTargetByClass(array('ilTestSkillAdministrationGUI', 'ilAssQuestionSkillAssignmentsGUI'), ilAssQuestionSkillAssignmentsGUI::CMD_SHOW_SKILL_QUEST_ASSIGNS);
                 $tabs_gui->addTarget('tst_tab_competences', $link, array(), array());
             }
             if (!in_array('participants', $hidden_tabs)) {
                 // participants
                 $tabs_gui->addTarget("participants", $this->ctrl->getLinkTarget($this, 'participants'), array("participants", "saveClientIP", "removeParticipant", "showParticipantAnswersForAuthor", "deleteAllUserResults", "cancelDeleteAllUserData", "deleteSingleUserResults", "outParticipantsResultsOverview", "outParticipantsPassDetails", "showPassOverview", "showUserAnswers", "participantsAction", "showDetailedResults", 'timing', 'timingOverview', 'npResetFilter', 'npSetFilter', 'showTimingForm'), "");
             }
         }
         include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
         if (ilLearningProgressAccess::checkAccess($this->object->getRefId()) && !in_array('learning_progress', $hidden_tabs)) {
             $tabs_gui->addTarget('learning_progress', $this->ctrl->getLinkTargetByClass(array('illearningprogressgui'), ''), '', array('illplistofobjectsgui', 'illplistofsettingsgui', 'illearningprogressgui', 'illplistofprogressgui'));
         }
         if ($ilAccess->checkAccess("write", "", $this->ref_id) && !in_array('manscoring', $hidden_tabs)) {
             include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
             $scoring = ilObjAssessmentFolder::_getManualScoring();
             if (count($scoring)) {
                 // scoring tab
                 $tabs_gui->addTarget("manscoring", $this->ctrl->getLinkTargetByClass('ilTestScoringGUI', 'showManScoringParticipantsTable'), array('showManScoringParticipantsTable', 'applyManScoringParticipantsFilter', 'resetManScoringParticipantsFilter', 'showManScoringParticipantScreen', 'showManScoringByQuestionParticipantsTable', 'applyManScoringByQuestionFilter', 'resetManScoringByQuestionFilter', 'saveManScoringByQuestion'), '');
             }
         }
         // Scoring Adjustment
         $setting = new ilSetting('assessment');
         $scoring_adjust_active = (bool) $setting->get('assessment_adjustments_enabled', false);
         if ($ilAccess->checkAccess("write", "", $this->ref_id) && $scoring_adjust_active && !in_array('scoringadjust', $hidden_tabs)) {
             // scoring tab
             $tabs_gui->addTarget("scoringadjust", $this->ctrl->getLinkTargetByClass('ilScoringAdjustmentGUI', 'showquestionlist'), array('showquestionlist', 'savescoringfortest', 'adjustscoringfortest'), '');
         }
         if (($ilAccess->checkAccess("tst_statistics", "", $this->ref_id) || $ilAccess->checkAccess("write", "", $this->ref_id)) && !in_array('statistics', $hidden_tabs)) {
             // statistics tab
             $tabs_gui->addTarget("statistics", $this->ctrl->getLinkTargetByClass("iltestevaluationgui", "outEvaluation"), array("statistics", "outEvaluation", "exportEvaluation", "detailedEvaluation", "eval_a", "evalUserDetail", "passDetails", "outStatisticsResultsOverview", "statisticsPassDetails", "singleResults"), "");
         }
         if ($ilAccess->checkAccess("write", "", $this->ref_id)) {
             if (!in_array('history', $hidden_tabs)) {
                 // history
                 $tabs_gui->addTarget("history", $this->ctrl->getLinkTarget($this, 'history'), "history", "");
             }
             if (!in_array('meta_data', $hidden_tabs)) {
                 // meta data
                 $tabs_gui->addTarget("meta_data", $this->ctrl->getLinkTargetByClass('ilmdeditorgui', 'listSection'), "", "ilmdeditorgui");
             }
             if (!in_array('export', $hidden_tabs)) {
                 // export tab
                 $tabs_gui->addTarget("export", $this->ctrl->getLinkTargetByClass('iltestexportgui', ''), '', array('iltestexportgui'));
             }
         }
         if ($ilAccess->checkAccess("edit_permission", "", $this->ref_id) && !in_array('permissions', $hidden_tabs)) {
             $tabs_gui->addTarget("perm_settings", $this->ctrl->getLinkTargetByClass(array(get_class($this), 'ilpermissiongui'), "perm"), array("perm", "info", "owner"), 'ilpermissiongui');
         }
     }
     if ($this->testQuestionSetConfigFactory->getQuestionSetConfig()->areDepenciesBroken()) {
         $hideTabs = array('settings', 'manscoring', 'scoringadjust', 'statistics', 'history', 'export');
         foreach ($hideTabs as $tabId) {
             $tabs_gui->removeTab($tabId);
         }
     }
 }
 /**
  * Saves the learners input of the question to the database.
  * 
  * @access public
  * @param integer $active_id Active id of the user
  * @param integer $pass Test pass
  * @return boolean $status
  */
 public function saveWorkingData($active_id, $pass = NULL)
 {
     global $ilDB;
     global $ilUser;
     if (is_null($pass)) {
         include_once "./Modules/Test/classes/class.ilObjTest.php";
         $pass = ilObjTest::_getPass($active_id);
     }
     $this->getProcessLocker()->requestUserSolutionUpdateLock();
     if ($this->is_multiple_choice && strlen($_GET['remImage'])) {
         $query = "DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s AND value1 = %s";
         $types = array("integer", "integer", "integer", "integer");
         $values = array($active_id, $this->getId(), $pass, $_GET['remImage']);
         if ($this->getStep() !== NULL) {
             $query .= " AND step = %s ";
             $types[] = 'integer';
             $values[] = $this->getStep();
         }
         $affectedRows = $ilDB->manipulateF($query, $types, $values);
     } elseif (!$this->is_multiple_choice) {
         $affectedRows = $this->removeCurrentSolution($active_id, $pass);
     }
     if (strlen($_GET["selImage"])) {
         $imageWasSelected = true;
         $types = array('integer', 'integer', 'integer', 'integer');
         $values = array($active_id, $this->getId(), $pass, (int) $_GET['selImage']);
         $query = 'DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s AND value1 = %s';
         if ($this->getStep() != null) {
             $types[] = 'integer';
             $values[] = $this->getStep();
             $query .= ' AND step = %s';
         }
         $ilDB->manipulateF($query, $types, $values);
         $affectedRows = $this->saveCurrentSolution($active_id, $pass, $_GET['selImage'], null);
     } else {
         $imageWasSelected = false;
     }
     $this->getProcessLocker()->releaseUserSolutionUpdateLock();
     require_once 'Modules/Test/classes/class.ilObjAssessmentFolder.php';
     if (ilObjAssessmentFolder::_enabledAssessmentLogging()) {
         if ($imageWasSelected) {
             $this->logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
         } else {
             $this->logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
         }
     }
     return true;
 }
 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());
 }