/** * Returns the pass overview for a given active ID * * @return string HTML code of the pass overview * @access public * * @deprecated */ public function getPassOverview($active_id, $targetclass = "", $targetcommand = "", $short = FALSE, $hide_details = FALSE) { require_once 'Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php'; require_once 'Modules/Test/classes/tables/class.ilTestPassOverviewTableGUI.php'; $table = new ilTestPassOverviewTableGUI($this, '', $short ? ilTestPassOverviewTableGUI::CONTEXT_SHORT : ilTestPassOverviewTableGUI::CONTEXT_LONG, isset($_GET['pdf']) && $_GET['pdf'] == 1); $data = array(); $counted_pass = $this->object->_getResultPass($active_id); $reached_pass = $this->object->_getPass($active_id); for ($pass = 0; $pass <= $reached_pass; $pass++) { $row = array(); $finishdate = $this->object->getPassFinishDate($active_id, $pass); if ($finishdate > 0) { if (!$short) { $result_array =& $this->object->getTestResult($active_id, $pass); if (!$result_array['pass']['total_max_points']) { $percentage = 0; } else { $percentage = $result_array['pass']['total_reached_points'] / $result_array['pass']['total_max_points'] * 100; } $total_max = $result_array['pass']['total_max_points']; $total_reached = $result_array['pass']['total_reached_points']; $total_requested_hints = $result_array['pass']['total_requested_hints']; } if (!$hide_details) { if (strlen($targetclass) && strlen($targetcommand)) { $this->ctrl->setParameterByClass($targetclass, 'active_id', $active_id); $this->ctrl->setParameterByClass($targetclass, 'pass', $pass); $aslgui = new ilAdvancedSelectionListGUI(); $aslgui->setListTitle($this->lng->txt('actions')); $aslgui->setId($pass); $aslgui->addItem($this->lng->txt('tst_pass_details'), 'tst_pass_details', $this->ctrl->getLinkTargetByClass($targetclass, $targetcommand)); if ($this->object->isPassDeletionAllowed()) { $aslgui->addItem($this->lng->txt('delete'), 'tst_pass_delete', $this->ctrl->getLinkTargetByClass($targetclass, 'confirmDeletePass')); } $row['pass_details'] = $aslgui->getHTML(); } } if (!$short) { if ($pass == $counted_pass) { $row['scored'] = '⊗'; } else { $row['scored'] = ''; } } $row['pass'] = $pass + 1; $row['date'] = $finishdate; if (!$short) { $row['answered'] = $this->object->getAnsweredQuestionCount($active_id, $pass) . ' ' . strtolower($this->lng->txt('of')) . ' ' . (count($result_array) - 2); if ($this->object->isOfferingQuestionHintsEnabled()) { $row['hints'] = $total_requested_hints; } $row['reached'] = $total_reached . ' ' . strtolower($this->lng->txt('of')) . ' ' . $total_max; $row['percentage'] = $percentage; } $data[] = $row; } } $table->setData($data); return $table->getHTML(); }
/** * @access public * @global ilObjUser $ilUser * @param integer $active_id * @param boolean $short * @return array $passOverwiewData */ public function getPassOverviewData($active_id, $short = false) { $passOverwiewData = array(); global $ilUser; $scoredPass = $this->object->_getResultPass($active_id); $lastPass = $this->object->_getPass($active_id); $testPercentage = 0; $testReachedPoints = 0; $testMaxPoints = 0; for ($pass = 0; $pass <= $lastPass; $pass++) { $passFinishDate = $this->object->getPassFinishDate($active_id, $pass); if ($passFinishDate <= 0) { continue; } if (!$short) { $resultData =& $this->object->getTestResult($active_id, $pass); if (!$resultData["pass"]["total_max_points"]) { $passPercentage = 0; } else { $passPercentage = $resultData["pass"]["total_reached_points"] / $resultData["pass"]["total_max_points"] * 100; } $passMaxPoints = $resultData["pass"]["total_max_points"]; $passReachedPoints = $resultData["pass"]["total_reached_points"]; $passAnsweredQuestions = $this->object->getAnsweredQuestionCount($active_id, $pass); $passTotalQuestions = count($resultData) - 2; if ($pass == $scoredPass) { $isScoredPass = true; if (!$resultData["test"]["total_max_points"]) { $testPercentage = 0; } else { $testPercentage = $resultData["test"]["total_reached_points"] / $resultData["test"]["total_max_points"] * 100; } $testMaxPoints = $resultData["test"]["total_max_points"]; $testReachedPoints = $resultData["test"]["total_reached_points"]; $passOverwiewData['test'] = array('active_id' => $active_id, 'scored_pass' => $scoredPass, 'max_points' => $testMaxPoints, 'reached_points' => $testReachedPoints, 'percentage' => $testPercentage); } else { $isScoredPass = false; } $passOverwiewData['passes'][] = array('active_id' => $active_id, 'pass' => $pass, 'finishdate' => $passFinishDate, 'max_points' => $passMaxPoints, 'reached_points' => $passReachedPoints, 'percentage' => $passPercentage, 'answered_questions' => $passAnsweredQuestions, 'total_questions' => $passTotalQuestions, 'is_scored_pass' => $isScoredPass); } } return $passOverwiewData; }
/** * @param integer $active_id * @param integer|null $pass * @param bool $is_postponed * @param bool $use_post_solutions * * @return string */ public function getTestOutput($active_id, $pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE) { $solutions = NULL; // get the solution of the user for the active pass or from the last pass if allowed if ($active_id) { require_once './Modules/Test/classes/class.ilObjTest.php'; if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) { if (is_null($pass)) { $pass = ilObjTest::_getPass($active_id); } } $solutions =& $this->object->getSolutionValues($active_id, $pass); } // generate the question output require_once './Services/UICore/classes/class.ilTemplate.php'; $template = new ilTemplate("tpl.il_as_qpl_numeric_output.html", TRUE, TRUE, "Modules/TestQuestionPool"); if (is_array($solutions)) { foreach ($solutions as $solution) { $template->setVariable("NUMERIC_VALUE", " value=\"" . $solution["value1"] . "\""); } } $template->setVariable("NUMERIC_SIZE", $this->object->getMaxChars()); $questiontext = $this->object->getQuestion(); $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE)); $questionoutput = $template->get(); $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput); return $pageoutput; }
/** * 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; }
function getTestOutput($active_id, $pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE, $show_feedback = FALSE) { // generate the question output $template = new ilTemplate("tpl.il_as_qpl_errortext_output.html", TRUE, TRUE, "Modules/TestQuestionPool"); if ($active_id) { $solutions = NULL; include_once "./Modules/Test/classes/class.ilObjTest.php"; if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) { if (is_null($pass)) { $pass = ilObjTest::_getPass($active_id); } } $solutions =& $this->object->getSolutionValues($active_id, $pass); } $errortext_value = ""; $selections = array(); if (is_array($solutions)) { foreach ($solutions as $solution) { array_push($selections, $solution['value1']); } $errortext_value = join(",", $selections); } if ($this->object->getTextSize() >= 10) { $template->setVariable("STYLE", " style=\"font-size: " . $this->object->getTextSize() . "%;\""); } $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), TRUE)); $errortext = $this->object->createErrorTextOutput($selections); $this->ctrl->setParameterByClass($this->getTargetGuiClass(), 'errorvalue', ''); $template->setVariable("ERRORTEXT", $errortext); $template->setVariable("ERRORTEXT_ID", "qst_" . $this->object->getId()); $template->setVariable("ERRORTEXT_VALUE", $errortext_value); $questionoutput = $template->get(); if (!$show_question_only) { // get page object output $questionoutput = $this->getILIASPage($questionoutput); } $this->tpl->addJavascript("./Modules/TestQuestionPool/templates/default/errortext.js"); $questionoutput = $template->get(); $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput); return $pageoutput; }
/** * 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; }
function getTestOutput($active_id, $pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE, $show_feedback = FALSE) { // generate the question output $template = new ilTemplate("tpl.il_as_qpl_fileupload_output.html", TRUE, TRUE, "Modules/TestQuestionPool"); if ($active_id) { $solutions = NULL; include_once "./Modules/Test/classes/class.ilObjTest.php"; if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) { if (is_null($pass)) { $pass = ilObjTest::_getPass($active_id); } } $solutions =& $this->object->getSolutionValues($active_id, $pass); $files = $this->object->getUploadedFiles($active_id, $pass); if (count($files)) { include_once "./Modules/TestQuestionPool/classes/tables/class.assFileUploadFileTableGUI.php"; $table_gui = new assFileUploadFileTableGUI(null, $this->getQuestionActionCmd()); $table_gui->setTitle($this->lng->txt('already_delivered_files'), 'icon_file.svg', $this->lng->txt('already_delivered_files')); $table_gui->setData($files); $template->setCurrentBlock("files"); $template->setVariable('FILES', $table_gui->getHTML()); $template->parseCurrentBlock(); } } if (strlen($this->object->getAllowedExtensions())) { $template->setCurrentBlock("allowed_extensions"); $template->setVariable("TXT_ALLOWED_EXTENSIONS", $this->object->prepareTextareaOutput($this->lng->txt("allowedextensions") . ": " . $this->object->getAllowedExtensions())); $template->parseCurrentBlock(); } $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->question, TRUE)); $template->setVariable("CMD_UPLOAD", $this->getQuestionActionCmd()); $template->setVariable("TEXT_UPLOAD", $this->object->prepareTextareaOutput($this->lng->txt('upload'))); $template->setVariable("TXT_UPLOAD_FILE", $this->object->prepareTextareaOutput($this->lng->txt('file_add'))); $template->setVariable("TXT_MAX_SIZE", $this->object->prepareTextareaOutput($this->lng->txt('file_notice') . " " . $this->object->getMaxFilesizeAsString())); $questionoutput = $template->get(); if (!$show_question_only) { // get page object output $questionoutput = $this->getILIASPage($questionoutput); } $questionoutput = $template->get(); $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput); return $pageoutput; }
/** * 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; }
function getTestOutput($active_id, $pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE) { // get the solution of the user for the active pass or from the last pass if allowed $user_solution = ""; if ($active_id) { $solutions = NULL; include_once "./Modules/Test/classes/class.ilObjTest.php"; if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) { if (is_null($pass)) { $pass = ilObjTest::_getPass($active_id); } } $solutions =& $this->object->getSolutionValues($active_id, $pass); foreach ($solutions as $idx => $solution_value) { $user_solution = $solution_value["value1"]; } } // generate the question output include_once "./Services/UICore/classes/class.ilTemplate.php"; $template = new ilTemplate("tpl.il_as_qpl_text_question_output.html", TRUE, TRUE, "Modules/TestQuestionPool"); if ($this->object->getMaxNumOfChars()) { $template->setCurrentBlock("maximum_char_hint"); $template->setVariable("MAXIMUM_CHAR_HINT", sprintf($this->lng->txt("text_maximum_chars_allowed"), $this->object->getMaxNumOfChars())); $template->parseCurrentBlock(); #mbecker: No such block. $template->setCurrentBlock("has_maxchars"); $template->setVariable("MAXCHARS", $this->object->getMaxNumOfChars()); $template->parseCurrentBlock(); $template->setCurrentBlock("maxchars_counter"); $template->setVariable("MAXCHARS", $this->object->getMaxNumOfChars()); $template->setVariable("TEXTBOXSIZE", strlen($this->object->getMaxNumOfChars())); $template->setVariable("CHARACTERS", $this->lng->txt("characters")); $template->parseCurrentBlock(); } $template->setVariable("ESSAY", ilUtil::prepareFormOutput($user_solution)); $questiontext = $this->object->getQuestion(); $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE)); $questionoutput = $template->get(); $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput); include_once "./Services/YUI/classes/class.ilYuiUtil.php"; ilYuiUtil::initDomEvent(); return $pageoutput; }
function getTestOutput($active_id, $pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE, $show_feedback = FALSE) { // get the solution of the user for the active pass or from the last pass if allowed $user_solution = array(); if ($active_id) { include_once "./Modules/Test/classes/class.ilObjTest.php"; if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) { if (is_null($pass)) { $pass = ilObjTest::_getPass($active_id); } } $user_solution =& $this->object->getSolutionValues($active_id, $pass); if (!is_array($user_solution)) { $user_solution = array(); } } // generate the question output include_once "./Services/UICore/classes/class.ilTemplate.php"; $template = new ilTemplate("tpl.il_as_qpl_cloze_question_output.html", TRUE, TRUE, "Modules/TestQuestionPool"); $output = $this->object->getClozeText(); foreach ($this->object->getGaps() as $gap_index => $gap) { switch ($gap->getType()) { case CLOZE_TEXT: $gaptemplate = new ilTemplate("tpl.il_as_qpl_cloze_question_gap_text.html", TRUE, TRUE, "Modules/TestQuestionPool"); $gaptemplate->setVariable("TEXT_GAP_SIZE", $this->object->getFixedTextLength() ? $this->object->getFixedTextLength() : $gap->getMaxWidth()); $gaptemplate->setVariable("GAP_COUNTER", $gap_index); foreach ($user_solution as $solution) { if (strcmp($solution["value1"], $gap_index) == 0) { $gaptemplate->setVariable("VALUE_GAP", " value=\"" . ilUtil::prepareFormOutput($solution["value2"]) . "\""); } } $output = preg_replace("/\\[gap\\].*?\\[\\/gap\\]/", $gaptemplate->get(), $output, 1); break; case CLOZE_SELECT: $gaptemplate = new ilTemplate("tpl.il_as_qpl_cloze_question_gap_select.html", TRUE, TRUE, "Modules/TestQuestionPool"); foreach ($gap->getItems() as $item) { $gaptemplate->setCurrentBlock("select_gap_option"); $gaptemplate->setVariable("SELECT_GAP_VALUE", $item->getOrder()); $gaptemplate->setVariable("SELECT_GAP_TEXT", ilUtil::prepareFormOutput($item->getAnswerText())); foreach ($user_solution as $solution) { if (strcmp($solution["value1"], $gap_index) == 0) { if (strcmp($solution["value2"], $item->getOrder()) == 0) { $gaptemplate->setVariable("SELECT_GAP_SELECTED", " selected=\"selected\""); } } } $gaptemplate->parseCurrentBlock(); } $gaptemplate->setVariable("PLEASE_SELECT", $this->lng->txt("please_select")); $gaptemplate->setVariable("GAP_COUNTER", $gap_index); $output = preg_replace("/\\[gap\\].*?\\[\\/gap\\]/", $gaptemplate->get(), $output, 1); break; case CLOZE_NUMERIC: $gaptemplate = new ilTemplate("tpl.il_as_qpl_cloze_question_gap_numeric.html", TRUE, TRUE, "Modules/TestQuestionPool"); $gaptemplate->setVariable("TEXT_GAP_SIZE", $this->object->getFixedTextLength() ? $this->object->getFixedTextLength() : $gap->getMaxWidth()); $gaptemplate->setVariable("GAP_COUNTER", $gap_index); foreach ($user_solution as $solution) { if (strcmp($solution["value1"], $gap_index) == 0) { $gaptemplate->setVariable("VALUE_GAP", " value=\"" . ilUtil::prepareFormOutput($solution["value2"]) . "\""); } } $output = preg_replace("/\\[gap\\].*?\\[\\/gap\\]/", $gaptemplate->get(), $output, 1); break; } } $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($output, TRUE)); $questionoutput = $template->get(); $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput); return $pageoutput; }
/** * 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 * * 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. * * @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; }
function getTestOutput($active_id, $pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE, $show_feedback = FALSE) { // generate the question output $template = new ilTemplate("tpl.il_as_qpl_flash_question_output.html", TRUE, TRUE, "Modules/TestQuestionPool"); $params = array(); if (is_array($this->object->getParameters())) { foreach ($this->object->getParameters() as $name => $value) { array_push($params, urlencode($name) . "=" . urlencode($value)); } } array_push($params, "session_id=" . urlencode($_COOKIE["PHPSESSID"])); array_push($params, "client=" . urlencode(CLIENT_ID)); array_push($params, "points_max=" . urlencode($this->object->getPoints())); array_push($params, "server=" . urlencode(ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/webservice/soap/server.php?wsdl")); if (strlen($pass)) { array_push($params, "pass="******"./Modules/Test/classes/class.ilObjTest.php"; array_push($params, "pass="******"active_id=" . $active_id); } array_push($params, "question_id=" . $this->object->getId()); if (count($params)) { $template->setCurrentBlock("flash_vars"); $template->setVariable("FLASH_VARS", join($params, "&")); $template->parseCurrentBlock(); $template->setCurrentBlock("applet_parameters"); $template->setVariable("PARAM_VALUE", join($params, "&")); $template->parseCurrentBlock(); } $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), TRUE)); $template->setVariable("APPLET_WIDTH", $this->object->getWidth()); $template->setVariable("APPLET_HEIGHT", $this->object->getHeight()); $template->setVariable("ID", $this->object->getId()); $template->setVariable("APPLET_PATH", $this->object->getFlashPathWeb() . $this->object->getApplet()); $template->setVariable("APPLET_FILE", $this->object->getFlashPathWeb() . $this->object->getApplet()); $questionoutput = $template->get(); $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput); return $pageoutput; }
function getTestOutput($active_id, $pass = NULL, $is_postponed = FALSE, $user_post_solution = FALSE) { if ($this->object->getOutputType() == OUTPUT_JAVASCRIPT) { return $this->getTestOutputJS($active_id, $pass, $is_postponed, $user_post_solution); } // generate the question output include_once "./Services/UICore/classes/class.ilTemplate.php"; $template = new ilTemplate("tpl.il_as_qpl_matching_output.html", TRUE, TRUE, "Modules/TestQuestionPool"); if ($active_id) { $solutions = NULL; include_once "./Modules/Test/classes/class.ilObjTest.php"; if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) { if (is_null($pass)) { $pass = ilObjTest::_getPass($active_id); } } if (is_array($user_post_solution)) { $solutions = array(); foreach ($user_post_solution['matching'][$this->object->getId()] as $definition => $term) { array_push($solutions, array("value1" => $term, "value2" => $definition)); } } else { $solutions =& $this->object->getSolutionValues($active_id, $pass); } } // shuffle output $terms = $this->object->getTerms(); $definitions = $this->object->getDefinitions(); switch ($this->object->getShuffle()) { case 1: $terms = $this->object->pcArrayShuffle($terms); if (count($solutions)) { $definitions = $this->sortDefinitionsBySolution($solutions); } else { $definitions = $this->object->pcArrayShuffle($definitions); } break; case 2: $terms = $this->object->pcArrayShuffle($terms); break; case 3: if (count($solutions)) { $definitions = $this->sortDefinitionsBySolution($solutions); } else { $definitions = $this->object->pcArrayShuffle($definitions); } break; } $maxcount = max(count($terms), count($definitions)); for ($i = 0; $i < count($definitions); $i++) { $definition = $definitions[$i]; if (is_object($definition)) { if (strlen($definition->picture)) { $template->setCurrentBlock('definition_image'); $template->setVariable('ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $definition->picture); $template->setVariable('ANSWER_IMAGE_ALT', strlen($definition->text) ? ilUtil::prepareFormOutput($definition->text) : ilUtil::prepareFormOutput($definition->picture)); $template->setVariable('ANSWER_IMAGE_TITLE', strlen($definition->text) ? ilUtil::prepareFormOutput($definition->text) : ilUtil::prepareFormOutput($definition->picture)); $template->setVariable('URL_PREVIEW', $this->object->getImagePathWeb() . $definition->picture); $template->setVariable("TEXT_PREVIEW", $this->lng->txt('preview')); $template->setVariable("IMG_PREVIEW", ilUtil::getImagePath('enlarge.png')); $template->setVariable("TEXT_DEFINITION", strlen($definition->text) ? $this->lng->txt('definition') . ' ' . ($i + 1) . ': ' . ilUtil::prepareFormOutput($definition->text) : $this->lng->txt('definition') . ' ' . ($i + 1)); $template->parseCurrentBlock(); } else { $template->setCurrentBlock('definition_text'); $template->setVariable("DEFINITION", $this->object->prepareTextareaOutput($definition->text, true)); $template->parseCurrentBlock(); } } $template->setCurrentBlock('option'); $template->setVariable("VALUE_OPTION", 0); $template->setVariable("TEXT_OPTION", ilUtil::prepareFormOutput($this->lng->txt('please_select'))); $template->parseCurrentBlock(); $j = 1; foreach ($terms as $term) { $template->setCurrentBlock('option'); $template->setVariable("VALUE_OPTION", $term->identifier); $template->setVariable("TEXT_OPTION", strlen($term->text) ? $this->lng->txt('term') . ' ' . $j . ': ' . ilUtil::prepareFormOutput($term->text) : $this->lng->txt('term') . ' ' . $j); foreach ($solutions as $solution) { if ($solution["value1"] == $term->identifier && $solution["value2"] == $definition->identifier) { $template->setVariable("SELECTED_OPTION", " selected=\"selected\""); } } $template->parseCurrentBlock(); $j++; } $template->setCurrentBlock('row'); $template->setVariable("TEXT_MATCHES", $this->lng->txt("matches")); if ($this->object->getEstimatedElementHeight() > 0) { $template->setVariable("ELEMENT_HEIGHT", " style=\"height: " . $this->object->getEstimatedElementHeight() . "px;\""); } $template->setVariable("QUESTION_ID", $this->object->getId()); $template->setVariable("DEFINITION_ID", $definition->identifier); $template->parseCurrentBlock(); } $i = 0; foreach ($terms as $term) { if (strlen($term->picture)) { $template->setCurrentBlock('term_image'); $template->setVariable('ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $term->picture); $template->setVariable('ANSWER_IMAGE_ALT', strlen($term->text) ? ilUtil::prepareFormOutput($term->text) : ilUtil::prepareFormOutput($term->picture)); $template->setVariable('ANSWER_IMAGE_TITLE', strlen($term->text) ? ilUtil::prepareFormOutput($term->text) : ilUtil::prepareFormOutput($term->picture)); $template->setVariable('URL_PREVIEW', $this->object->getImagePathWeb() . $term->picture); $template->setVariable("TEXT_PREVIEW", $this->lng->txt('preview')); $template->setVariable("TEXT_TERM", strlen($term->text) ? $this->lng->txt('term') . ' ' . ($i + 1) . ': ' . ilUtil::prepareFormOutput($term->text) : $this->lng->txt('term') . ' ' . ($i + 1)); $template->setVariable("IMG_PREVIEW", ilUtil::getImagePath('enlarge.png')); $template->parseCurrentBlock(); } else { $template->setCurrentBlock('term_text'); $template->setVariable("TERM", $this->object->prepareTextareaOutput($term->text, true)); $template->parseCurrentBlock(); } $template->touchBlock('terms'); $i++; } $questiontext = $this->object->getQuestion(); $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE)); $template->setVariable("TEXT_TERMS", ilUtil::prepareFormOutput($this->lng->txt('available_terms'))); $template->setVariable('TEXT_SELECTION', ilUtil::prepareFormOutput($this->lng->txt('selection'))); $questiontext = $this->object->getQuestion(); $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE)); $questionoutput = $template->get(); $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput); return $pageoutput; }
/** * 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; }
/** * @param integer $active_id * @param integer|null $pass * @param bool $is_postponed * @param bool $use_post_solutions * @param bool $show_feedback * * @return string */ function getTestOutput($active_id, $pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE, $show_feedback = FALSE) { // shuffle output $keys = $this->getChoiceKeys(); // get the solution of the user for the active pass or from the last pass if allowed $user_solution = array(); if ($active_id) { $solutions = NULL; include_once "./Modules/Test/classes/class.ilObjTest.php"; if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) { if (is_null($pass)) { $pass = ilObjTest::_getPass($active_id); } } $solutions =& $this->object->getSolutionValues($active_id, $pass); foreach ($solutions as $idx => $solution_value) { array_push($user_solution, $solution_value["value1"]); } } // generate the question output include_once "./Services/UICore/classes/class.ilTemplate.php"; $template = new ilTemplate("tpl.il_as_qpl_mc_mr_output.html", TRUE, TRUE, "Modules/TestQuestionPool"); foreach ($keys as $answer_id) { $answer = $this->object->answers[$answer_id]; if (strlen($answer->getImage())) { if ($this->object->getThumbSize()) { $template->setCurrentBlock("preview"); $template->setVariable("URL_PREVIEW", $this->object->getImagePathWeb() . $answer->getImage()); $template->setVariable("TEXT_PREVIEW", $this->lng->txt('preview')); $template->setVariable("IMG_PREVIEW", ilUtil::getImagePath('enlarge.png')); $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $answer->getImage()); list($width, $height, $type, $attr) = getimagesize($this->object->getImagePath() . $answer->getImage()); $alt = $answer->getImage(); if (strlen($answer->getAnswertext())) { $alt = $answer->getAnswertext(); } $alt = preg_replace("/<[^>]*?>/", "", $alt); $template->setVariable("ANSWER_IMAGE_ALT", ilUtil::prepareFormOutput($alt)); $template->setVariable("ANSWER_IMAGE_TITLE", ilUtil::prepareFormOutput($alt)); $template->parseCurrentBlock(); } else { $template->setCurrentBlock("answer_image"); $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $answer->getImage()); list($width, $height, $type, $attr) = getimagesize($this->object->getImagePath() . $answer->getImage()); $alt = $answer->getImage(); if (strlen($answer->getAnswertext())) { $alt = $answer->getAnswertext(); } $alt = preg_replace("/<[^>]*?>/", "", $alt); $template->setVariable("ATTR", $attr); $template->setVariable("ANSWER_IMAGE_ALT", ilUtil::prepareFormOutput($alt)); $template->setVariable("ANSWER_IMAGE_TITLE", ilUtil::prepareFormOutput($alt)); $template->parseCurrentBlock(); } } if ($show_feedback && $this->object->getSpecificFeedbackSetting() == 2) { foreach ($user_solution as $mc_solution) { if (strcmp($mc_solution, $answer_id) == 0) { $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation($this->object->getId(), $answer_id); if (strlen($fb)) { $template->setCurrentBlock("feedback"); $template->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($fb, true)); $template->parseCurrentBlock(); } } } } if ($show_feedback && $this->object->getSpecificFeedbackSetting() == 1) { $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation($this->object->getId(), $answer_id); if (strlen($fb)) { $template->setCurrentBlock("feedback"); $template->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($fb, true)); $template->parseCurrentBlock(); } } if ($show_feedback && $this->object->getSpecificFeedbackSetting() == 3) { $answer = $this->object->getAnswer($answer_id); if ($answer->getPoints() > 0) { $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation($this->object->getId(), $answer_id); if (strlen($fb)) { $template->setCurrentBlock("feedback"); $template->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($fb, true)); $template->parseCurrentBlock(); } } } $template->setCurrentBlock("answer_row"); $template->setVariable("ANSWER_ID", $answer_id); $template->setVariable("ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE)); foreach ($user_solution as $mc_solution) { if (strcmp($mc_solution, $answer_id) == 0) { $template->setVariable("CHECKED_ANSWER", " checked=\"checked\""); } } $template->parseCurrentBlock(); } $questiontext = $this->object->getQuestion(); $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE)); $questionoutput = $template->get(); $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput); return $pageoutput; }
/** * 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; }
/** * @param $question_id * @param $question_pool_id * * @return ilPropertyFormGUI */ protected function buildAdjustQuestionForm($question_id, $question_pool_id) { require_once './Services/Form/classes/class.ilPropertyFormGUI.php'; require_once './Modules/TestQuestionPool/classes/class.assQuestion.php'; $form = new ilPropertyFormGUI(); $form->setFormAction($this->ctrl->getFormAction($this)); $form->setMultipart(FALSE); $form->setTableWidth("100%"); $form->setId("adjustment"); /** @var $question assQuestionGUI|ilGuiQuestionScoringAdjustable|ilGuiAnswerScoringAdjustable */ $question = assQuestion::instantiateQuestionGUI($question_id); $form->setTitle($question->object->getTitle() . '<br /><small>(' . $question->outQuestionType() . ')</small>'); $hidden_question_id = new ilHiddenInputGUI('q_id'); $hidden_question_id->setValue($question_id); $form->addItem($hidden_question_id); $hidden_qpl_id = new ilHiddenInputGUI('qpl_id'); $hidden_qpl_id->setValue($question_pool_id); $form->addItem($hidden_qpl_id); $this->populateScoringAdjustments($question, $form); $manscoring_section = new ilFormSectionHeaderGUI(); $manscoring_section->setTitle($this->lng->txt('manscoring')); $form->addItem($manscoring_section); $manscoring_preservation = new ilCheckboxInputGUI($this->lng->txt('preserve_manscoring'), 'preserve_manscoring'); $manscoring_preservation->setChecked(true); $manscoring_preservation->setInfo($this->lng->txt('preserve_manscoring_info')); $form->addItem($manscoring_preservation); $form->addCommandButton("savescoringfortest", $this->lng->txt("save")); $participants = $this->object->getParticipants(); $active_ids = array_keys($participants); $results = array(); foreach ($active_ids as $active_id) { $passes[] = $this->object->_getPass($active_id); foreach ($passes as $key => $pass) { for ($i = 0; $i <= $pass; $i++) { $results[] = $question->object->getSolutionValues($active_id, $i); } } } $relevant_answers = array(); foreach ($results as $result) { foreach ($result as $answer) { if ($answer['question_fi'] == $question->object->getId()) { $relevant_answers[] = $answer; } } } $answers_view = $question->getAggregatedAnswersView($relevant_answers); include_once 'Services/jQuery/classes/class.iljQueryUtil.php'; iljQueryUtil::initjQuery(); include_once 'Services/YUI/classes/class.ilYuiUtil.php'; ilYuiUtil::initPanel(); ilYuiUtil::initOverlay(); $this->tpl->addJavascript('./Services/UIComponent/Overlay/js/ilOverlay.js'); $this->tpl->addJavaScript("./Services/JavaScript/js/Basic.js"); $container = new ilTemplate('tpl.il_as_tst_adjust_answer_aggregation_container.html', true, true, 'Modules/Test'); $container->setVariable('FORM_ELEMENT_NAME', 'aggr_usr_answ'); $container->setVariable('CLOSE_HTML', json_encode(ilGlyphGUI::get(ilGlyphGUI::CLOSE, $this->lng->txt('close')))); $container->setVariable('TXT_SHOW_ANSWER_OVERVIEW', $this->lng->txt('show_answer_overview')); $container->setVariable('TXT_CLOSE', $this->lng->txt('close')); $container->setVariable('ANSWER_OVERVIEW', $answers_view); $custom_input = new ilCustomInputGUI('', 'aggr_usr_answ'); $custom_input->setHtml($container->get()); $form->addItem($custom_input); 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; $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); } $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; }
function getTestOutput($active_id, $pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE, $show_feedback = FALSE) { // generate the question output $template = new ilTemplate("tpl.il_as_qpl_orderinghorizontal_output.html", TRUE, TRUE, "Modules/TestQuestionPool"); $elements = $this->object->getRandomOrderingElements(); if ($active_id) { $solutions = NULL; include_once "./Modules/Test/classes/class.ilObjTest.php"; if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) { if (is_null($pass)) { $pass = ilObjTest::_getPass($active_id); } } $solutions =& $this->object->getSolutionValues($active_id, $pass); if (count($solutions) == 1) { $elements = split("{::}", $solutions[0]["value1"]); } } if (count($solutions) == 0) { $_SESSION['qst_ordering_horizontal_elements'] = $elements; } else { unset($_SESSION['qst_ordering_horizontal_elements']); } foreach ($elements as $id => $element) { $template->setCurrentBlock("element"); $template->setVariable("ELEMENT_ID", "e_" . $this->object->getId() . "_{$id}"); $template->setVariable("ORDERING_VALUE", ilUtil::prepareFormOutput($element)); $template->setVariable("ELEMENT_VALUE", ilUtil::prepareFormOutput($element)); $template->parseCurrentBlock(); } $template->setVariable("QUESTION_ID", $this->object->getId()); if ($this->object->textsize >= 10) { $template->setVariable("STYLE", " style=\"font-size: " . $this->object->textsize . "%;\""); } $template->setVariable("VALUE_ORDERRESULT", ' value="' . join($elements, '{::}') . '"'); $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), TRUE)); $questionoutput = $template->get(); if (!$show_question_only) { // get page object output $questionoutput = $this->getILIASPage($questionoutput); } $this->tpl->addJavascript("./Modules/TestQuestionPool/templates/default/orderinghorizontal.js"); $questionoutput = $template->get(); $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput); return $pageoutput; }
function getTestOutput($active_id, $pass = NULL, $is_postponed = FALSE, $user_post_solution = FALSE) { // shuffle output $keys = array(); if (is_array($user_post_solution)) { $keys = $_SESSION["ordering_keys"]; } else { $keys = array_keys($this->object->answers); shuffle($keys); } $_SESSION["ordering_keys"] = $keys; // generate the question output include_once "./Services/UICore/classes/class.ilTemplate.php"; $template = new ilTemplate("tpl.il_as_qpl_ordering_output.html", TRUE, TRUE, "Modules/TestQuestionPool"); if ($this->object->getOutputType() == OUTPUT_JAVASCRIPT) { // BEGIN: add javascript code for javascript enabled ordering questions $this->tpl->addBlockFile("CONTENT_BLOCK", "head_content", "tpl.il_as_qpl_ordering_output_javascript.html", "Modules/TestQuestionPool"); $this->tpl->setCurrentBlock("head_content"); $this->tpl->setVariable("JS_LOCATION", "./Modules/TestQuestionPool/js/toolman/"); $this->tpl->parseCurrentBlock(); // END: add javascript code for javascript enabled ordering questions // BEGIN: add additional stylesheet for javascript enabled ordering questions $this->tpl->setCurrentBlock("AdditionalStyle"); $this->tpl->setVariable("LOCATION_ADDITIONAL_STYLESHEET", ilUtil::getStyleSheetLocation("output", "test_javascript.css", "Modules/TestQuestionPool")); $this->tpl->parseCurrentBlock(); // END: add additional stylesheet for javascript enabled ordering questions // BEGIN: onsubmit form action for javascript enabled ordering questions $this->tpl->setVariable("ON_SUBMIT", "return saveOrder('orderlist');"); // END: onsubmit form action for javascript enabled ordering questions } // get the solution of the user for the active pass or from the last pass if allowed if ($active_id) { $solutions = NULL; include_once "./Modules/Test/classes/class.ilObjTest.php"; if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) { if (is_null($pass)) { $pass = ilObjTest::_getPass($active_id); } } if (is_array($user_post_solution)) { $solutions = array(); foreach ($user_post_solution as $key => $value) { if (preg_match("/order_(\\d+)/", $key, $matches)) { foreach ($this->object->getAnswers() as $answeridx => $answer) { if ($answer->getRandomID() == $matches[1]) { array_push($solutions, array("value1" => $answeridx, "value2" => $value)); } } } } } else { $solutions =& $this->object->getSolutionValues($active_id, $pass); } if ($this->object->getOutputType() == OUTPUT_JAVASCRIPT) { $solution_script .= ""; $jssolutions = array(); foreach ($solutions as $idx => $solution_value) { if (strcmp($solution_value["value2"], "") != 0 && strcmp($solution_value["value1"], "") != 0) { $jssolutions[$solution_value["value2"]] = $solution_value["value1"]; } } if (count($jssolutions)) { ksort($jssolutions); $js = ""; foreach ($jssolutions as $key => $value) { if (is_object($this->object->getAnswer($value))) { $js .= "initialorder.push('id_" . $this->object->getAnswer($value)->getRandomID() . "');"; } } $js .= "restoreInitialOrder();"; } if (strlen($js)) { $template->setCurrentBlock("javascript_restore_order"); $template->setVariable("RESTORE_ORDER", $js); $template->parseCurrentBlock(); } } } if ($this->object->getOutputType() != OUTPUT_JAVASCRIPT) { foreach ($keys as $idx) { $answer = $this->object->answers[$idx]; if ($this->object->getOrderingType() == OQ_PICTURES) { $template->setCurrentBlock("ordering_row_standard_pictures"); $template->setVariable("PICTURE_HREF", $this->object->getImagePathWeb() . $answer->getAnswertext()); $thumbweb = $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $answer->getAnswertext(); $thumb = $this->object->getImagePath() . $this->object->getThumbPrefix() . $answer->getAnswertext(); if (!@file_exists($thumb)) { $this->object->rebuildThumbnails(); } $template->setVariable("THUMB_HREF", $thumbweb); $template->setVariable("THUMB_ALT", $this->lng->txt("thumbnail")); $template->setVariable("THUMB_TITLE", $this->lng->txt("enlarge")); $template->setVariable("ANSWER_ID", $answer->getRandomID()); $template->parseCurrentBlock(); } else { $template->setCurrentBlock("ordering_row_standard_text"); $template->setVariable("ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE)); $template->setVariable("ANSWER_ID", $answer->getRandomID()); $template->parseCurrentBlock(); } $template->setCurrentBlock("ordering_row_standard"); $template->setVariable("ANSWER_ID", $answer->getRandomID()); if (is_array($solutions)) { foreach ($solutions as $solution) { if ($solution["value1"] == $idx && strlen($solution["value2"])) { $template->setVariable("ANSWER_ORDER", " value=\"" . $solution["value2"] . "\""); } } } $template->parseCurrentBlock(); } } else { foreach ($keys as $idx) { $answer = $this->object->answers[$idx]; if ($this->object->getOrderingType() == OQ_PICTURES) { $template->setCurrentBlock("ordering_row_javascript_pictures"); $template->setVariable("PICTURE_HREF", $this->object->getImagePathWeb() . $answer->getAnswertext()); $thumbweb = $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $answer->getAnswertext(); $thumb = $this->object->getImagePath() . $this->object->getThumbPrefix() . $answer->getAnswertext(); if (!@file_exists($thumb)) { $this->object->rebuildThumbnails(); } $template->setVariable("THUMB_HREF", $thumbweb); $template->setVariable("THUMB_ALT", $this->lng->txt("thumbnail")); $template->setVariable("THUMB_TITLE", $this->lng->txt("thumbnail")); $template->setVariable("ENLARGE_HREF", ilUtil::getImagePath("enlarge.png", FALSE)); $template->setVariable("ENLARGE_ALT", $this->lng->txt("enlarge")); $template->setVariable("ENLARGE_TITLE", $this->lng->txt("enlarge")); $template->setVariable("ANSWER_ID", $answer->getRandomID()); $template->parseCurrentBlock(); } else { $template->setCurrentBlock("ordering_row_javascript_text"); $template->setVariable("ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE)); $template->setVariable("ANSWER_ID", $answer->getRandomID()); $template->parseCurrentBlock(); } } $template->setCurrentBlock("ordering_with_javascript"); if ($this->object->getOrderingType() == OQ_PICTURES) { $template->setVariable("RESET_POSITIONS", $this->lng->txt("reset_pictures")); } else { $template->setVariable("RESET_POSITIONS", $this->lng->txt("reset_definitions")); } $template->parseCurrentBlock(); } $questiontext = $this->object->getQuestion(); $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE)); $questionoutput = $template->get(); $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput); return $pageoutput; }
/** * 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; }
function getTestOutput($active_id, $pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE) { $userdata = $this->object->getActiveUserData($active_id); // generate the question output include_once "./Services/UICore/classes/class.ilTemplate.php"; $template = new ilTemplate("tpl.il_as_qpl_javaapplet_question_output.html", TRUE, TRUE, "Modules/TestQuestionPool"); $template->setCurrentBlock("appletparam"); $template->setVariable("PARAM_NAME", "test_type"); include_once "./Modules/Test/classes/class.ilObjTest.php"; if (ilObjTest::_lookupAnonymity(ilObjTest::_getObjectIDFromTestID($userdata["test_id"]))) { $template->setVariable("PARAM_VALUE", "0"); } else { $template->setVariable("PARAM_VALUE", "1"); } $template->parseCurrentBlock(); $template->setCurrentBlock("appletparam"); $template->setVariable("PARAM_NAME", "active_id"); $template->setVariable("PARAM_VALUE", $active_id); $template->parseCurrentBlock(); $template->setCurrentBlock("appletparam"); $template->setVariable("PARAM_NAME", "test_id"); $template->setVariable("PARAM_VALUE", $userdata["test_id"]); $template->parseCurrentBlock(); $template->setCurrentBlock("appletparam"); $template->setVariable("PARAM_NAME", "question_id"); $template->setVariable("PARAM_VALUE", $this->object->getId()); $template->parseCurrentBlock(); $template->setCurrentBlock("appletparam"); $template->setVariable("PARAM_NAME", "user_id"); $template->setVariable("PARAM_VALUE", $userdata["user_id"]); $template->parseCurrentBlock(); $template->setCurrentBlock("appletparam"); $template->setVariable("PARAM_NAME", "points_max"); $template->setVariable("PARAM_VALUE", $this->object->getPoints()); $template->parseCurrentBlock(); $template->setCurrentBlock("appletparam"); $template->setVariable("PARAM_NAME", "session_id"); $template->setVariable("PARAM_VALUE", $_COOKIE["PHPSESSID"]); $template->parseCurrentBlock(); $template->setCurrentBlock("appletparam"); $template->setVariable("PARAM_NAME", "client"); $template->setVariable("PARAM_VALUE", CLIENT_ID); $template->parseCurrentBlock(); $template->setCurrentBlock("appletparam"); $template->setVariable("PARAM_NAME", "pass"); $actualpass = ilObjTest::_getPass($active_id); $template->setVariable("PARAM_VALUE", $actualpass); $template->parseCurrentBlock(); $template->setCurrentBlock("appletparam"); $template->setVariable("PARAM_NAME", "post_url"); $template->setVariable("PARAM_VALUE", ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/Modules/TestQuestionPool/save_question_post_data.php"); $template->parseCurrentBlock(); // additional parameters for ($i = 0; $i < $this->object->getParameterCount(); $i++) { $parameter = $this->object->getParameter($i); $template->setCurrentBlock("appletparam"); $template->setVariable("PARAM_NAME", $parameter["name"]); $template->setVariable("PARAM_VALUE", $parameter["value"]); $template->parseCurrentBlock(); } if ($active_id) { $solutions = NULL; include_once "./Modules/Test/classes/class.ilObjTest.php"; if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) { if (is_null($pass)) { $pass = ilObjTest::_getPass($active_id); } } $info = $this->object->getReachedInformation($active_id, $pass); foreach ($info as $kk => $infodata) { $template->setCurrentBlock("appletparam"); $template->setVariable("PARAM_NAME", "value_" . $infodata["order"] . "_1"); $template->setVariable("PARAM_VALUE", $infodata["value1"]); $template->parseCurrentBlock(); $template->setCurrentBlock("appletparam"); $template->setVariable("PARAM_NAME", "value_" . $infodata["order"] . "_2"); $template->setVariable("PARAM_VALUE", $infodata["value2"]); $template->parseCurrentBlock(); } include_once './Services/Administration/classes/class.ilSetting.php'; $soapSetting = new ilSetting(); if ($soapSetting->get("soap_user_administration") == 1) { $template->setCurrentBlock("appletparam"); $template->setVariable("PARAM_NAME", "server"); $template->setVariable("PARAM_VALUE", ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/webservice/soap/server.php"); } } $questiontext = $this->object->getQuestion(); $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE)); $template->setVariable("APPLET_WIDTH", $this->object->getJavaWidth()); $template->setVariable("APPLET_HEIGHT", $this->object->getJavaHeight()); $template->setVariable("APPLET_CODE", $this->object->getJavaCode()); if (strlen($this->object->getJavaArchive()) > 0) { $template->setVariable("APPLET_ARCHIVE", " archive=\"" . $this->object->getJavaArchive() . "\""); } else { if (strpos($this->object->getJavaAppletFilename(), ".jar") !== FALSE) { $template->setVariable("APPLET_ARCHIVE", " archive=\"" . $this->object->getJavaPathWeb() . $this->object->getJavaAppletFilename() . "\""); } } if (strlen($this->object->getJavaCodebase()) > 0) { $template->setVariable("APPLET_CODEBASE", " codebase=\"" . $this->object->getJavaCodebase() . "\""); } else { if (strpos($this->object->getJavaAppletFilename(), ".class") !== FALSE) { $template->setVariable("APPLET_CODEBASE", " codebase=\"" . $this->object->getJavaPathWeb() . "\""); } } $questionoutput = $template->get(); $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput); return $pageoutput; }
function getTestOutput($active_id, $pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE, $show_feedback = FALSE) { // generate the question output $template = new ilTemplate("tpl.il_as_qpl_orderinghorizontal_output.html", TRUE, TRUE, "Modules/TestQuestionPool"); $elements = $this->object->getRandomOrderingElements(); if ($active_id) { $solutions = NULL; include_once "./Modules/Test/classes/class.ilObjTest.php"; if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) { if (is_null($pass)) { $pass = ilObjTest::_getPass($active_id); } } $solutions =& $this->object->getSolutionValues($active_id, $pass); if (count($solutions) == 1) { $elements = split("{::}", $solutions[0]["value1"]); } } if (strlen($_SESSION['qst_selection'])) { $this->object->moveRight($_SESSION['qst_selection'], $active_id, $pass); unset($_SESSION['qst_selection']); $solutions =& $this->object->getSolutionValues($active_id, $pass); if (count($solutions) == 1) { $elements = split("{::}", $solutions[0]["value1"]); } } if (count($solutions) == 0) { $_SESSION['qst_ordering_horizontal_elements'] = $elements; } else { unset($_SESSION['qst_ordering_horizontal_elements']); } $idx = 0; foreach ($elements as $id => $element) { $template->setCurrentBlock("element"); $template->setVariable("ELEMENT_ID", "e_" . $this->object->getId() . "_{$id}"); $template->setVariable("ELEMENT_VALUE", ilUtil::prepareFormOutput($element)); $this->ctrl->setParameterByClass('iltestoutputgui', 'qst_selection', $idx); $idx++; $url = $this->ctrl->getLinkTargetByClass('iltestoutputgui', 'gotoQuestion'); $template->setVariable("MOVE_RIGHT", $url); $template->setVariable("TEXT_MOVE_RIGHT", $this->lng->txt('move_right')); $template->setVariable("RIGHT_IMAGE", ilUtil::getImagePath('nav_arr_R.png')); $template->parseCurrentBlock(); } if ($this->object->textsize >= 10) { echo $template->setVariable("STYLE", " style=\"font-size: " . $this->object->textsize . "%;\""); } $template->setVariable("VALUE_ORDERRESULT", ' value="' . join($elements, '{::}') . '"'); $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), TRUE)); $questionoutput = $template->get(); if (!$show_question_only) { // get page object output $questionoutput = $this->getILIASPage($questionoutput); } include_once "./Services/YUI/classes/class.ilYuiUtil.php"; ilYuiUtil::initDragDropAnimation(); $this->tpl->addJavascript("./Modules/TestQuestionPool/templates/default/orderinghorizontal.js"); $questionoutput = $template->get(); $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput); return $pageoutput; }
/** * 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; }
/** * @param integer $active_id * @param integer|null $pass * @param bool $is_postponed * @param bool $use_post_solutions * @param bool $show_feedback * * @return string */ function getTestOutput($active_id, $pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE, $showInlineFeedback = FALSE) { // shuffle output $keys = $this->getParticipantsAnswerKeySequence(); // get the solution of the user for the active pass or from the last pass if allowed $user_solution = array(); if ($active_id) { $solutions = NULL; include_once "./Modules/Test/classes/class.ilObjTest.php"; if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) { if (is_null($pass)) { $pass = ilObjTest::_getPass($active_id); } } $solutions =& $this->object->getSolutionValues($active_id, $pass); foreach ($solutions as $idx => $solution_value) { $user_solution[$solution_value["value1"]] = $solution_value["value2"]; } } // generate the question output include_once "./Services/UICore/classes/class.ilTemplate.php"; $template = new ilTemplate("tpl.il_as_qpl_mc_kprim_output.html", TRUE, TRUE, "Modules/TestQuestionPool"); foreach ($keys as $answer_id) { $answer = $this->object->getAnswer($answer_id); if (strlen($answer->getImageFile())) { if ($this->object->getThumbSize()) { $template->setCurrentBlock("preview"); $template->setVariable("URL_PREVIEW", $answer->getImageWebPath()); $template->setVariable("TEXT_PREVIEW", $this->lng->txt('preview')); $template->setVariable("IMG_PREVIEW", ilUtil::getImagePath('enlarge.svg')); $template->setVariable("ANSWER_IMAGE_URL", $answer->getThumbWebPath()); list($width, $height, $type, $attr) = getimagesize($answer->getImageFsPath()); $alt = $answer->getImageFile(); if (strlen($answer->getAnswertext())) { $alt = $answer->getAnswertext(); } $alt = preg_replace("/<[^>]*?>/", "", $alt); $template->setVariable("ANSWER_IMAGE_ALT", ilUtil::prepareFormOutput($alt)); $template->setVariable("ANSWER_IMAGE_TITLE", ilUtil::prepareFormOutput($alt)); $template->parseCurrentBlock(); } else { $template->setCurrentBlock("answer_image"); $template->setVariable("ANSWER_IMAGE_URL", $answer->getImageWebPath()); list($width, $height, $type, $attr) = getimagesize($answer->getImageFsPath()); $alt = $answer->getImageFile(); if (strlen($answer->getAnswertext())) { $alt = $answer->getAnswertext(); } $alt = preg_replace("/<[^>]*?>/", "", $alt); $template->setVariable("ATTR", $attr); $template->setVariable("ANSWER_IMAGE_ALT", ilUtil::prepareFormOutput($alt)); $template->setVariable("ANSWER_IMAGE_TITLE", ilUtil::prepareFormOutput($alt)); $template->parseCurrentBlock(); } } if ($showInlineFeedback) { $this->populateSpecificFeedbackInline($user_solution, $answer_id, $template); } $template->setCurrentBlock("answer_row"); $template->setVariable("ANSWER_ID", $answer_id); $template->setVariable("ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE)); $template->setVariable('VALUE_TRUE', 1); $template->setVariable('VALUE_FALSE', 0); if (isset($user_solution[$answer->getPosition()])) { $tplVar = $user_solution[$answer->getPosition()] ? 'CHECKED_ANSWER_TRUE' : 'CHECKED_ANSWER_FALSE'; $template->setVariable($tplVar, " checked=\"checked\""); } $template->parseCurrentBlock(); } $questiontext = $this->object->getQuestion(); $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE)); $template->setVariable("INSTRUCTIONTEXT", $this->object->getInstructionTextTranslation($this->lng, $this->object->getOptionLabel())); $template->setVariable("OPTION_LABEL_TRUE", $this->object->getTrueOptionLabelTranslation($this->lng, $this->object->getOptionLabel())); $template->setVariable("OPTION_LABEL_FALSE", $this->object->getFalseOptionLabelTranslation($this->lng, $this->object->getOptionLabel())); $questionoutput = $template->get(); $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput); return $pageoutput; }
/** * 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. * * @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; }