/** * 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 = 0; foreach ($this->getSolutionSubmit() as $val1 => $val2) { $value = ilUtil::stripSlashes($val2, FALSE); if (strlen($value)) { $gap = $this->getGap(trim(ilUtil::stripSlashes($val1))); if (is_object($gap)) { if (!($gap->getType() == CLOZE_SELECT && $value == -1)) { $affectedRows = $this->saveCurrentSolution($active_id, $pass, $val1, $value); $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; }
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. * * @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; }
/** * Saves an ASS_MarkSchema object to a database. * * @param integer $test_id The database id of the related test. */ public function saveToDb($test_id) { global $lng; global $ilDB; $oldmarks = array(); include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php"; if (ilObjAssessmentFolder::_enabledAssessmentLogging()) { $result = $ilDB->queryF("SELECT * FROM tst_mark WHERE test_fi = %s ORDER BY minimum_level", array('integer'), array($test_id)); if ($result->numRows()) { /** @noinspection PhpAssignmentInConditionInspection */ while ($row = $ilDB->fetchAssoc($result)) { $oldmarks[$row["minimum_level"]] = $row; } } } if (!$test_id) { return; } // Delete all entries $ilDB->manipulateF("DELETE FROM tst_mark WHERE test_fi = %s", array('integer'), array($test_id)); if (count($this->mark_steps) == 0) { return; } // Write new datasets foreach ($this->mark_steps as $key => $value) { $next_id = $ilDB->nextId('tst_mark'); $ilDB->manipulateF("INSERT INTO tst_mark (mark_id, test_fi, short_name, official_name, minimum_level, passed, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s)", array('integer', 'integer', 'text', 'text', 'float', 'text', 'integer'), array($next_id, $test_id, $value->getShortName(), $value->getOfficialName(), $value->getMinimumLevel(), $value->getPassed(), time())); } if (ilObjAssessmentFolder::_enabledAssessmentLogging()) { $result = $ilDB->queryF("SELECT * FROM tst_mark WHERE test_fi = %s ORDER BY minimum_level", array('integer'), array($test_id)); $newmarks = array(); if ($result->numRows()) { /** @noinspection PhpAssignmentInConditionInspection */ while ($row = $ilDB->fetchAssoc($result)) { $newmarks[$row["minimum_level"]] = $row; } } foreach ($oldmarks as $level => $row) { if (array_key_exists($level, $newmarks)) { $difffields = array(); foreach ($row as $key => $value) { if (strcmp($value, $newmarks[$level][$key]) != 0) { switch ($key) { case "mark_id": case "tstamp": break; default: array_push($difffields, "{$key}: {$value} => " . $newmarks[$level][$key]); break; } } } if (count($difffields)) { $this->logAction($test_id, $lng->txtlng("assessment", "log_mark_changed", ilObjAssessmentFolder::_getLogLanguage()) . ": " . join($difffields, ", ")); } } else { $this->logAction($test_id, $lng->txtlng("assessment", "log_mark_removed", ilObjAssessmentFolder::_getLogLanguage()) . ": " . $lng->txtlng("assessment", "tst_mark_minimum_level", ilObjAssessmentFolder::_getLogLanguage()) . " = " . $row["minimum_level"] . ", " . $lng->txtlng("assessment", "tst_mark_short_form", ilObjAssessmentFolder::_getLogLanguage()) . " = " . $row["short_name"] . ", " . $lng->txtlng("assessment", "tst_mark_official_form", ilObjAssessmentFolder::_getLogLanguage()) . " = " . $row["official_name"] . ", " . $lng->txtlng("assessment", "tst_mark_passed", ilObjAssessmentFolder::_getLogLanguage()) . " = " . $row["passed"]); } } foreach ($newmarks as $level => $row) { if (!array_key_exists($level, $oldmarks)) { $this->logAction($test_id, $lng->txtlng("assessment", "log_mark_added", ilObjAssessmentFolder::_getLogLanguage()) . ": " . $lng->txtlng("assessment", "tst_mark_minimum_level", ilObjAssessmentFolder::_getLogLanguage()) . " = " . $row["minimum_level"] . ", " . $lng->txtlng("assessment", "tst_mark_short_form", ilObjAssessmentFolder::_getLogLanguage()) . " = " . $row["short_name"] . ", " . $lng->txtlng("assessment", "tst_mark_official_form", ilObjAssessmentFolder::_getLogLanguage()) . " = " . $row["official_name"] . ", " . $lng->txtlng("assessment", "tst_mark_passed", ilObjAssessmentFolder::_getLogLanguage()) . " = " . $row["passed"]); } } } }
/** * 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) { 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. * * @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; }
public function moveRight($position, $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); } $solutions =& $this->getSolutionValues($active_id, $pass); $elements = array(); if (count($solutions) == 1) { $elements = split("{::}", $solutions[0]["value1"]); } else { $elements = $_SESSION['qst_ordering_horizontal_elements']; } if (count($elements)) { $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 ($position < count($elements) - 1) { $temp = $elements[$position]; $elements[$position] = $elements[$position + 1]; $elements[$position + 1] = $temp; } $entered_values = false; $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", join($elements, '{::}')), "value2" => array("clob", null), "pass" => array("integer", $pass), "tstamp" => array("integer", time()))); $entered_values = true; 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()); } } $this->calculateReachedPoints($active_id, $pass); } }
public function performDeletePass() { if (!$this->object->isPassDeletionAllowed()) { $this->ctrl->redirect($this, 'outUserResultsOverview'); } /** @var ilDB $ilDB */ global $ilDB; $active_fi = null; $pass = null; if (isset($_POST['active_id']) && (int) $_POST['active_id']) { $active_fi = $_POST['active_id']; } if (isset($_POST['pass']) && is_numeric($_POST['pass'])) { $pass = $_POST['pass']; } if (is_null($active_fi) || is_null($pass)) { $this->ctrl->redirect($this, 'outUserResultsOverview'); } if (!$this->object->isDynamicTest() && $pass == $this->object->_getResultPass($active_fi)) { $this->ctrl->redirect($this, 'outUserResultsOverview'); } // Get information $result = $ilDB->query("\n\t\t\t\tSELECT tst_active.tries, tst_active.last_finished_pass, tst_sequence.pass\n\t\t\t\tFROM tst_active\n\t\t\t\tLEFT JOIN tst_sequence\n\t\t\t\tON tst_sequence.active_fi = tst_active.active_id\n\t\t\t\tAND tst_sequence.pass = tst_active.tries\n\t\t\t\tWHERE tst_active.active_id = {$ilDB->quote($active_fi, 'integer')}\n\t\t\t"); $row = $ilDB->fetchAssoc($result); $tries = $row['tries']; $lastFinishedPass = is_numeric($row['last_finished_pass']) ? $row['last_finished_pass'] : -1; if ($pass < $lastFinishedPass) { $isActivePass = false; $must_renumber = true; } elseif ($pass == $lastFinishedPass) { $isActivePass = false; if ($tries == $row['pass']) { $must_renumber = true; } else { $must_renumber = false; } } elseif ($pass == $row['pass']) { $isActivePass = true; $must_renumber = false; } else { throw new ilTestException('This should not happen, please contact Bjoern Heyser to clean up this pass salad!'); } if (!$this->object->isDynamicTest() && $isActivePass) { $this->ctrl->redirect($this, 'outUserResultsOverview'); } if ($pass == 0 && ($lastFinishedPass == 0 && $tries == 1 && $tries != $row['pass'] || $isActivePass == true)) { $last_pass = true; } else { $last_pass = false; } // Work on tables: // tst_active if ($last_pass) { $ilDB->manipulate('DELETE FROM tst_active WHERE active_id = ' . $ilDB->quote($active_fi, 'integer')); } elseif (!$isActivePass) { $ilDB->manipulate('UPDATE tst_active SET tries = ' . $ilDB->quote($tries - 1, 'integer') . ', last_finished_pass = '******'integer') . ' WHERE active_id = ' . $ilDB->quote($active_fi, 'integer')); } // tst_manual_fb $ilDB->manipulate('DELETE FROM tst_manual_fb WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . ' AND pass = '******'integer')); if ($must_renumber) { $ilDB->manipulate('UPDATE tst_manual_fb SET pass = pass - 1 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . ' AND pass > ' . $ilDB->quote($pass, 'integer')); } // tst_mark -> nothing to do // // tst_pass_result $ilDB->manipulate('DELETE FROM tst_pass_result WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . ' AND pass = '******'integer')); if ($must_renumber) { $ilDB->manipulate('UPDATE tst_pass_result SET pass = pass - 1 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . ' AND pass > ' . $ilDB->quote($pass, 'integer')); } // tst_qst_solved -> nothing to do // tst_rnd_copy -> nothing to do // tst_rnd_qpl_title -> nothing to do // tst_sequence $ilDB->manipulate('DELETE FROM tst_sequence WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . ' AND pass = '******'integer')); if ($must_renumber) { $ilDB->manipulate('UPDATE tst_sequence SET pass = pass - 1 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . ' AND pass > ' . $ilDB->quote($pass, 'integer')); } if ($this->object->isDynamicTest()) { $tables = array('tst_seq_qst_tracking', 'tst_seq_qst_answstatus', 'tst_seq_qst_postponed', 'tst_seq_qst_checked'); foreach ($tables as $table) { $ilDB->manipulate("\n\t\t\t\t\t\tDELETE FROM {$table}\n\t\t\t\t\t\tWHERE active_fi = {$ilDB->quote($active_fi, 'integer')}\n\t\t\t\t\t\tAND pass = {$ilDB->quote($pass, 'integer')}\n\t\t\t\t"); if ($must_renumber) { $ilDB->manipulate("\n\t\t\t\t\t\tUPDATE {$table}\n\t\t\t\t\t\tSET pass = pass - 1\n\t\t\t\t\t\tWHERE active_fi = {$ilDB->quote($active_fi, 'integer')}\n\t\t\t\t\t\tAND pass > {$ilDB->quote($pass, 'integer')}\n\t\t\t\t\t"); } } } // tst_solutions $ilDB->manipulate('DELETE FROM tst_solutions WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . ' AND pass = '******'integer')); if ($must_renumber) { $ilDB->manipulate('UPDATE tst_solutions SET pass = pass - 1 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . ' AND pass > ' . $ilDB->quote($pass, 'integer')); } // tst_test_result $ilDB->manipulate('DELETE FROM tst_test_result WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . ' AND pass = '******'integer')); if ($must_renumber) { $ilDB->manipulate('UPDATE tst_test_result SET pass = pass - 1 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . ' AND pass > ' . $ilDB->quote($pass, 'integer')); } // tst_test_rnd_qst -> nothing to do // tst_times $ilDB->manipulate('DELETE FROM tst_times WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . ' AND pass = '******'integer')); if ($must_renumber) { $ilDB->manipulate('UPDATE tst_times SET pass = pass - 1 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . ' AND pass > ' . $ilDB->quote($pass, 'integer')); } require_once 'Modules/Test/classes/class.ilObjAssessmentFolder.php'; if (ilObjAssessmentFolder::_enabledAssessmentLogging()) { $this->object->logAction($this->lng->txtlng("assessment", "log_deleted_pass", ilObjAssessmentFolder::_getLogLanguage())); } // tst_result_cache // Ggfls. nur renumbern. require_once './Modules/TestQuestionPool/classes/class.assQuestion.php'; assQuestion::_updateTestResultCache($active_fi); if ($this->object->isDynamicTest()) { require_once 'Modules/Test/classes/tables/class.ilTestDynamicQuestionSetStatisticTableGUI.php'; unset($_SESSION['form_' . ilTestDynamicQuestionSetStatisticTableGUI::FILTERED_TABLE_ID]); } $this->redirectToPassDeletionContext($_POST['context']); }
/** * 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)) { require_once './Modules/Test/classes/class.ilObjTest.php'; $pass = ilObjTest::_getPass($active_id); } $entered_values = 0; $returnvalue = true; $numeric_result = $this->getSolutionSubmit(); if (!$this->isValidSolutionSubmit($numeric_result)) { ilUtil::sendInfo($this->lng->txt("err_no_numeric_value"), true); $returnvalue = false; } $this->getProcessLocker()->requestUserSolutionUpdateLock(); $result = $this->getCurrentSolutionResultSet($active_id, $pass); $row = $ilDB->fetchAssoc($result); $update = $row["solution_id"]; if ($update) { if (strlen($numeric_result)) { $ilDB->update("tst_solutions", array("value1" => array("clob", trim($numeric_result)), "tstamp" => array("integer", time())), array("solution_id" => array("integer", $update))); $entered_values++; } else { $ilDB->manipulateF("DELETE FROM tst_solutions WHERE solution_id = %s", array('integer'), array($update)); } } else { if (strlen($numeric_result)) { $this->saveCurrentSolution($active_id, $pass, trim($numeric_result), null); $entered_values++; } } $this->getProcessLocker()->releaseUserSolutionUpdateLock(); if ($entered_values) { require_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; }
/** * Sets the points, a learner has reached answering the question * Additionally objective results are updated * * @param integer $user_id The database ID of the learner * @param integer $test_id The database Id of the test containing the question * @param integer $points The points the user has reached answering the question * @return boolean true on success, otherwise false * @access public */ function _setReachedPoints($active_id, $question_id, $points, $maxpoints, $pass, $manualscoring, $obligationsEnabled) { global $ilDB; if ($points <= $maxpoints) { if (is_null($pass)) { $pass = assQuestion::_getSolutionMaxPass($question_id, $active_id); } // retrieve the already given points $old_points = 0; $result = $ilDB->queryF("SELECT points FROM tst_test_result WHERE active_fi = %s AND question_fi = %s AND pass = %s", array('integer', 'integer', 'integer'), array($active_id, $question_id, $pass)); $manual = $manualscoring ? 1 : 0; $rowsnum = $result->numRows(); if ($rowsnum) { $row = $ilDB->fetchAssoc($result); $old_points = $row["points"]; if ($old_points != $points) { $affectedRows = $ilDB->manipulateF("UPDATE tst_test_result SET points = %s, manual = %s, tstamp = %s WHERE active_fi = %s AND question_fi = %s AND pass = %s", array('float', 'integer', 'integer', 'integer', 'integer', 'integer'), array($points, $manual, time(), $active_id, $question_id, $pass)); } } else { $next_id = $ilDB->nextId('tst_test_result'); $affectedRows = $ilDB->manipulateF("INSERT INTO tst_test_result (test_result_id, active_fi, question_fi, points, pass, manual, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s)", array('integer', 'integer', 'integer', 'float', 'integer', 'integer', 'integer'), array($next_id, $active_id, $question_id, $points, $pass, $manual, time())); } if ($old_points != $points || !$rowsnum) { assQuestion::_updateTestPassResults($active_id, $pass, $obligationsEnabled); // finally update objective result include_once "./Modules/Test/classes/class.ilObjTest.php"; include_once './Modules/Course/classes/class.ilCourseObjectiveResult.php'; ilCourseObjectiveResult::_updateObjectiveResult(ilObjTest::_getUserIdFromActiveId($active_id), $question_id, $points); include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php"; if (ilObjAssessmentFolder::_enabledAssessmentLogging()) { global $lng, $ilUser; include_once "./Modules/Test/classes/class.ilObjTestAccess.php"; $username = ilObjTestAccess::_getParticipantData($active_id); assQuestion::_logAction(sprintf($lng->txtlng("assessment", "log_answer_changed_points", ilObjAssessmentFolder::_getLogLanguage()), $username, $old_points, $points, $ilUser->getFullname() . " (" . $ilUser->getLogin() . ")"), $active_id, $question_id); } } return TRUE; } else { return FALSE; } }
/** * 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)); foreach ($_POST['matching'][$this->getId()] as $definition => $term) { $entered_values++; $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", $term), "value2" => array("clob", $definition), "pass" => array("integer", $pass), "tstamp" => array("integer", time()))); } $saveWorkingDataResult = true; } 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 * @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); } $entered_values = FALSE; foreach ($_POST as $key => $value) { 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'])); } } $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", $matches[1]), "value2" => array("clob", str_replace(",", ".", $value)), "pass" => array("integer", $pass), "tstamp" => array("integer", time()))); } 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'])); } } $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", $matches[1] . "_unit"), "value2" => array("clob", $value), "pass" => array("integer", $pass), "tstamp" => array("integer", time()))); } } } 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; }
public function performDeletePass() { if (!$this->object->isPassDeletionAllowed()) { $this->ctrl->redirect($this, 'outUserResultsOverview'); } global $ilDB; $active_fi = $_GET['active_id']; $pass = $_GET['pass']; // Get information $result = $ilDB->query('SELECT tries FROM tst_active WHERE active_id = ' . $ilDB->quote($active_fi, 'integer')); $row = $ilDB->fetchAssoc($result); $tries = $row['tries']; $last_pass = false; $must_renumber = true; // No renumbering - last pass to be deleted. if ($tries == 1) { $must_renumber = false; $last_pass = true; } // No renumbering - high pass to be deleted. if ($tries - 1 == $pass) { $must_renumber = false; } // Work on tables: // tst_active if ($last_pass) { $ilDB->manipulate('DELETE FROM tst_active WHERE active_id = ' . $ilDB->quote($active_fi, 'integer')); } else { $ilDB->manipulate('UPDATE tst_active SET tries = ' . $ilDB->quote($tries - 1, 'integer') . ' WHERE active_id = ' . $ilDB->quote($active_fi, 'integer')); } // tst_manual_fb $ilDB->manipulate('DELETE FROM tst_manual_fb WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . ' AND pass = '******'integer')); if ($must_renumber) { $ilDB->manipulate('UPDATE tst_manual_fb SET pass = pass - 1 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer')); } // tst_mark -> nothing to do // // tst_pass_result $ilDB->manipulate('DELETE FROM tst_pass_result WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . ' AND pass = '******'integer')); if ($must_renumber) { $ilDB->manipulate('UPDATE tst_pass_result SET pass = pass - 1 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer')); } // tst_qst_solved -> nothing to do // tst_rnd_copy -> nothing to do // tst_rnd_qpl_title -> nothing to do // tst_sequence $ilDB->manipulate('DELETE FROM tst_sequence WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . ' AND pass = '******'integer')); if ($must_renumber) { $ilDB->manipulate('UPDATE tst_sequence SET pass = pass - 1 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer')); } // tst_solutions $ilDB->manipulate('DELETE FROM tst_solutions WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . ' AND pass = '******'integer')); if ($must_renumber) { $ilDB->manipulate('UPDATE tst_solutions SET pass = pass - 1 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer')); } // tst_tests -> nothing to do // tst_test_defaults -> nothing to do // tst_test_question -> nothing to do // tst_test_random -> nothing to do // tst_test_result $ilDB->manipulate('DELETE FROM tst_test_result WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . ' AND pass = '******'integer')); if ($must_renumber) { $ilDB->manipulate('UPDATE tst_test_result SET pass = pass - 1 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . ' AND pass > ' . $ilDB->quote($pass, 'integer')); } // tst_test_rnd_qst -> nothing to do // tst_times $ilDB->manipulate('DELETE FROM tst_times WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . ' AND pass = '******'integer')); if ($must_renumber) { $ilDB->manipulate('UPDATE tst_times SET pass = pass - 1 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer')); } require_once 'Modules/Test/classes/class.ilObjAssessmentFolder.php'; if (ilObjAssessmentFolder::_enabledAssessmentLogging()) { $this->object->logAction($this->lng->txtlng("assessment", "log_deleted_pass", ilObjAssessmentFolder::_getLogLanguage())); } // tst_result_cache // Ggfls. nur renumbern. require_once './Modules/TestQuestionPool/classes/class.assQuestion.php'; assQuestion::_updateTestResultCache($active_fi); $this->ctrl->redirectByClass('iltestoutputgui', 'outuserresultsoverview'); }
/** * 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 manual feedback for a question in a test * * @param integer $active_id Active ID of the user * @param integer $question_id Question ID * @param integer $pass Pass number * @param string $feedback The feedback text * @return boolean TRUE if the operation succeeds, FALSE otherwise * @access public */ function saveManualFeedback($active_id, $question_id, $pass, $feedback) { global $ilDB; $affectedRows = $ilDB->manipulateF("DELETE FROM tst_manual_fb WHERE active_fi = %s AND question_fi = %s AND pass = %s", array('integer', 'integer', 'integer'), array($active_id, $question_id, $pass)); if (strlen($feedback)) { $next_id = $ilDB->nextId('tst_manual_fb'); $affectedRows = $ilDB->manipulateF("INSERT INTO tst_manual_fb (manual_feedback_id, active_fi, question_fi, pass, feedback, tstamp) VALUES (%s, %s, %s, %s, %s, %s)", array('integer', 'integer', 'integer', 'integer', 'text', 'integer'), array($next_id, $active_id, $question_id, $pass, ilRTE::_replaceMediaObjectImageSrc($feedback, 0), time())); include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php"; if (ilObjAssessmentFolder::_enabledAssessmentLogging()) { global $lng, $ilUser; include_once "./Modules/Test/classes/class.ilObjTestAccess.php"; $username = ilObjTestAccess::_getParticipantData($active_id); include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php"; $this->logAction(sprintf($lng->txtlng("assessment", "log_manual_feedback", ilObjAssessmentFolder::_getLogLanguage()), $ilUser->getFullname() . " (" . $ilUser->getLogin() . ")", $username, assQuestion::_getQuestionTitle($question_id), $feedback)); } } if (PEAR::isError($result)) { global $ilias; $ilias->raiseError($result->getMessage()); } else { 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; $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; 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 * * @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. * * @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; }
/** * 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 * @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. * * @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; }
/** * 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; }
/** * 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; $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; }
/** * 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); } $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; }
/** * 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; 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 = false; $value = $_POST['sampleSolution']; $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"]; } if (strlen($value) > 0) { $entered_values = true; $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", $value), "value2" => array("clob", ""), "pass" => array("integer", $pass), "tstamp" => array("integer", time()))); } 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; }