/** * Gets an array of preview images. * * @return array The preview images. */ public function getImages() { $images = array(); // status must be created $path = $this->getStoragePath(); if ($this->getRenderStatus() == self::RENDER_STATUS_CREATED) { // load files if ($handle = @opendir($path)) { while (false !== ($file = readdir($handle))) { $filepath = $path . "/" . $file; if (!is_file($filepath)) { continue; } if ($file != '.' && $file != '..' && strpos($file, "preview_") === 0) { $image = array(); $image["url"] = ilUtil::getHtmlPath($filepath); // get image size $size = @getimagesize($filepath); if ($size !== false) { $image["width"] = $size[0]; $image["height"] = $size[1]; } $images[$file] = $image; } } closedir($handle); // sort by key ksort($images); } } return $images; }
/** * get directory for files of media object (static) * * @param int $a_mob_id media object id */ function _getURL($a_mob_id) { return ilUtil::getHtmlPath(ilUtil::getWebspaceDir() . "/mobs/mm_" . $a_mob_id); }
/** * Get the question solution output * * @param integer $active_id The active user id * @param integer $pass The test pass * @param boolean $graphicalOutput Show visual feedback for right/wrong answers * @param boolean $result_output Show the reached points for parts of the question * @param boolean $show_question_only Show the question without the ILIAS content around * @param boolean $show_feedback Show the question feedback * @param boolean $show_correct_solution Show the correct solution instead of the user solution * @param boolean $show_manual_scoring Show specific information for the manual scoring output * @param bool $show_question_text * * @return string The solution output of the question as HTML code */ function getSolutionOutput($active_id, $pass = NULL, $graphicalOutput = FALSE, $result_output = FALSE, $show_question_only = TRUE, $show_feedback = FALSE, $show_correct_solution = FALSE, $show_manual_scoring = FALSE, $show_question_text = TRUE) { // 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 > 0 && !$show_correct_solution) { $solutions =& $this->object->getSolutionValues($active_id, $pass); foreach ($solutions as $idx => $solution_value) { array_push($user_solution, $solution_value["value1"]); } } else { // take the correct solution instead of the user solution foreach ($this->object->answers as $index => $answer) { $points_checked = $answer->getPointsChecked(); $points_unchecked = $answer->getPointsUnchecked(); if ($points_checked > $points_unchecked) { if ($points_checked > 0) { array_push($user_solution, $index); } } } } // generate the question output include_once "./Services/UICore/classes/class.ilTemplate.php"; $template = new ilTemplate("tpl.il_as_qpl_mc_mr_output_solution.html", TRUE, TRUE, "Modules/TestQuestionPool"); $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", TRUE, TRUE, "Modules/TestQuestionPool"); foreach ($keys as $answer_id) { $answer = $this->object->answers[$answer_id]; if ($active_id > 0 && !$show_correct_solution) { if ($graphicalOutput) { // output of ok/not ok icons for user entered solutions $ok = FALSE; $checked = FALSE; foreach ($user_solution as $mc_solution) { if (strcmp($mc_solution, $answer_id) == 0) { $checked = TRUE; } } if ($checked) { if ($answer->getPointsChecked() > $answer->getPointsUnchecked()) { $ok = TRUE; } else { $ok = FALSE; } } else { if ($answer->getPointsChecked() > $answer->getPointsUnchecked()) { $ok = FALSE; } else { $ok = TRUE; } } if ($ok) { $template->setCurrentBlock("icon_ok"); $template->setVariable("ICON_OK", ilUtil::getImagePath("icon_ok.png")); $template->setVariable("TEXT_OK", $this->lng->txt("answer_is_right")); $template->parseCurrentBlock(); } else { $template->setCurrentBlock("icon_ok"); $template->setVariable("ICON_NOT_OK", ilUtil::getImagePath("icon_not_ok.png")); $template->setVariable("TEXT_NOT_OK", $this->lng->txt("answer_is_wrong")); $template->parseCurrentBlock(); } } } if (strlen($answer->getImage())) { $template->setCurrentBlock("answer_image"); if ($this->object->getThumbSize()) { $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $answer->getImage()); } else { $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $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(); } if ($show_feedback) { if ($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 ($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 ($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_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE)); $checked = FALSE; if ($result_output) { $pointschecked = $this->object->answers[$answer_id]->getPointsChecked(); $pointsunchecked = $this->object->answers[$answer_id]->getPointsUnchecked(); $resulttextchecked = $pointschecked == 1 || $pointschecked == -1 ? "%s " . $this->lng->txt("point") : "%s " . $this->lng->txt("points"); $resulttextunchecked = $pointsunchecked == 1 || $pointsunchecked == -1 ? "%s " . $this->lng->txt("point") : "%s " . $this->lng->txt("points"); $template->setVariable("RESULT_OUTPUT", sprintf("(" . $this->lng->txt("checkbox_checked") . " = {$resulttextchecked}, " . $this->lng->txt("checkbox_unchecked") . " = {$resulttextunchecked})", $pointschecked, $pointsunchecked)); } foreach ($user_solution as $mc_solution) { if (strcmp($mc_solution, $answer_id) == 0) { $template->setVariable("SOLUTION_IMAGE", ilUtil::getHtmlPath(ilUtil::getImagePath("checkbox_checked.png"))); $template->setVariable("SOLUTION_ALT", $this->lng->txt("checked")); $checked = TRUE; } } if (!$checked) { $template->setVariable("SOLUTION_IMAGE", ilUtil::getHtmlPath(ilUtil::getImagePath("checkbox_unchecked.png"))); $template->setVariable("SOLUTION_ALT", $this->lng->txt("unchecked")); } $template->parseCurrentBlock(); } $questiontext = $this->object->getQuestion(); if ($show_question_text == true) { $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE)); } $questionoutput = $template->get(); $feedback = $show_feedback ? $this->getAnswerFeedbackOutput($active_id, $pass) : ""; if (strlen($feedback)) { $solutiontemplate->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($feedback, true)); } $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput); $solutionoutput = $solutiontemplate->get(); if (!$show_question_only) { // get page object output $solutionoutput = '<div class="ilc_question_Standard">' . $solutionoutput . "</div>"; } return $solutionoutput; }
/** * @param $active_id * @param null $pass * @param bool $graphicalOutput * @param bool $result_output * @param bool $show_question_only * @param bool $show_feedback * @param bool $show_correct_solution * @param bool $show_manual_scoring * @param bool $show_question_text */ public function getSolutionOutput($active_id, $pass = NULL, $graphicalOutput = FALSE, $result_output = FALSE, $show_question_only = TRUE, $show_feedback = FALSE, $show_correct_solution = FALSE, $show_manual_scoring = FALSE, $show_question_text = TRUE) { // 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 > 0 && !$show_correct_solution) { $solutions =& $this->object->getSolutionValues($active_id, $pass); foreach ($solutions as $idx => $solution_value) { $user_solution[$solution_value['value1']] = $solution_value['value2']; } } else { // take the correct solution instead of the user solution foreach ($this->object->getAnswers() as $answer) { $user_solution[$answer->getPosition()] = $answer->getCorrectness(); } } // generate the question output $template = new ilTemplate("tpl.il_as_qpl_mc_kprim_output_solution.html", TRUE, TRUE, "Modules/TestQuestionPool"); foreach ($keys as $answer_id) { $answer = $this->object->getAnswer($answer_id); if ($active_id > 0 && !$show_correct_solution) { if ($graphicalOutput) { // output of ok/not ok icons for user entered solutions if ($user_solution[$answer->getPosition()] == $answer->getCorrectness()) { $template->setCurrentBlock("icon_ok"); $template->setVariable("ICON_OK", ilUtil::getImagePath("icon_ok.svg")); $template->setVariable("TEXT_OK", $this->lng->txt("answer_is_right")); $template->parseCurrentBlock(); } else { $template->setCurrentBlock("icon_ok"); $template->setVariable("ICON_NOT_OK", ilUtil::getImagePath("icon_not_ok.svg")); $template->setVariable("TEXT_NOT_OK", $this->lng->txt("answer_is_wrong")); $template->parseCurrentBlock(); } } } if (strlen($answer->getImageFile())) { $template->setCurrentBlock("answer_image"); if ($this->object->getThumbSize()) { $template->setVariable("ANSWER_IMAGE_URL", $answer->getThumbWebPath()); } else { $template->setVariable("ANSWER_IMAGE_URL", $answer->getImageWebPath()); } $template->setVariable("ANSWER_IMAGE_ALT", ilUtil::prepareFormOutput($answer->getImageFile())); $template->setVariable("ANSWER_IMAGE_TITLE", ilUtil::prepareFormOutput($answer->getImageFile())); $template->parseCurrentBlock(); } if ($show_feedback) { $this->populateSpecificFeedbackInline($user_solution, $answer_id, $template); } $template->setCurrentBlock("answer_row"); $template->setVariable("ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE)); if (isset($user_solution[$answer->getPosition()])) { if ($user_solution[$answer->getPosition()]) { $template->setVariable("SOLUTION_IMAGE_TRUE", ilUtil::getHtmlPath(ilUtil::getImagePath("radiobutton_checked.png"))); $template->setVariable("SOLUTION_ALT_TRUE", $this->lng->txt("checked")); $template->setVariable("SOLUTION_IMAGE_FALSE", ilUtil::getHtmlPath(ilUtil::getImagePath("radiobutton_unchecked.png"))); $template->setVariable("SOLUTION_ALT_FALSE", $this->lng->txt("unchecked")); } else { $template->setVariable("SOLUTION_IMAGE_TRUE", ilUtil::getHtmlPath(ilUtil::getImagePath("radiobutton_unchecked.png"))); $template->setVariable("SOLUTION_ALT_TRUE", $this->lng->txt("unchecked")); $template->setVariable("SOLUTION_IMAGE_FALSE", ilUtil::getHtmlPath(ilUtil::getImagePath("radiobutton_checked.png"))); $template->setVariable("SOLUTION_ALT_FALSE", $this->lng->txt("checked")); } } else { $template->setVariable("SOLUTION_IMAGE_TRUE", ilUtil::getHtmlPath(ilUtil::getImagePath("radiobutton_unchecked.png"))); $template->setVariable("SOLUTION_ALT_TRUE", $this->lng->txt("unchecked")); $template->setVariable("SOLUTION_IMAGE_FALSE", ilUtil::getHtmlPath(ilUtil::getImagePath("radiobutton_unchecked.png"))); $template->setVariable("SOLUTION_ALT_FALSE", $this->lng->txt("unchecked")); } $template->parseCurrentBlock(); } if ($show_question_text == true) { $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(); $feedback = $show_feedback ? $this->getGenericFeedbackOutput($active_id, $pass) : ""; $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", TRUE, TRUE, "Modules/TestQuestionPool"); if (strlen($feedback)) { $solutiontemplate->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($feedback, true)); } $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput); $solutionoutput = $solutiontemplate->get(); if (!$show_question_only) { // get page object output $solutionoutput = $this->getILIASPage($solutionoutput); } return $solutionoutput; }
public function login() { $skipClasses = array('ilpasswordassistancegui', 'ilaccountregistrationgui'); $skipFiles = array('pwassist.php'); if (in_array(strtolower($_REQUEST['cmdClass']), $skipClasses)) { return; } else { $script = pathinfo($_SERVER['PHP_SELF'], PATHINFO_BASENAME); if (in_array(strtolower($script), $skipFiles)) { return; } } if (!$this->apache_settings->get('apache_auth_authenticate_on_login_page') && (preg_match('/.*login\\.php$/', $_SERVER['SCRIPT_NAME']) || (in_array($_REQUEST['cmd'], array('showLogin', 'showTermsOfService')) || isset($_POST['change_lang_to'])) && strtolower($_REQUEST['cmdClass']) == 'ilstartupgui')) { return; } if (!$this->apache_settings->get('apache_auth_authenticate_on_login_page') && preg_match('/.*login\\.php$/', $_SERVER['SCRIPT_NAME'])) { return; } if (ilContext::supportsRedirects() && !isset($_GET['passed_sso']) && (!defined('IL_CERT_SSO') || IL_CERT_SSO == false)) { // redirect to sso // this part is executed in default ilias context... $path = $_SERVER['REQUEST_URI']; if ($path[0] == '/') { $path = substr($path, 1); } if (substr($path, 0, 4) != 'http') { $parts = parse_url(ILIAS_HTTP_PATH); $path = $parts['scheme'] . '://' . $parts['host'] . '/' . $path; } $path = urlencode($path); ilUtil::redirect(ilUtil::getHtmlPath('/sso/index.php?force_mode_apache=1&r=' . $path . '&cookie_path=' . IL_COOKIE_PATH . '&ilias_path=' . ILIAS_HTTP_PATH)); } else { return parent::login(); } }
/** * Creates a print view of the survey questions * * @access public */ function printViewObject() { $this->questionsSubtabs("print"); $template = new ilTemplate("tpl.il_svy_svy_printview.html", TRUE, TRUE, "Modules/Survey"); include_once './Services/WebServices/RPC/classes/class.ilRPCServerSettings.php'; if (ilRPCServerSettings::getInstance()->isEnabled()) { $this->ctrl->setParameter($this, "pdf", "1"); $template->setCurrentBlock("pdf_export"); $template->setVariable("PDF_URL", $this->ctrl->getLinkTarget($this, "printView")); $this->ctrl->setParameter($this, "pdf", ""); $template->setVariable("PDF_TEXT", $this->lng->txt("pdf_export")); $template->setVariable("PDF_IMG_ALT", $this->lng->txt("pdf_export")); $template->setVariable("PDF_IMG_URL", ilUtil::getHtmlPath(ilUtil::getImagePath("application-pdf.png"))); $template->parseCurrentBlock(); } $template->setVariable("PRINT_TEXT", $this->lng->txt("print")); $template->setVariable("PRINT_URL", "javascript:window.print();"); $pages =& $this->object->getSurveyPages(); foreach ($pages as $page) { if (count($page) > 0) { foreach ($page as $question) { $questionGUI = $this->object->getQuestionGUI($question["type_tag"], $question["question_id"]); if (is_object($questionGUI)) { if (strlen($question["heading"])) { $template->setCurrentBlock("textblock"); $template->setVariable("TEXTBLOCK", $question["heading"]); $template->parseCurrentBlock(); } $template->setCurrentBlock("question"); $template->setVariable("QUESTION_DATA", $questionGUI->getPrintView($this->object->getShowQuestionTitles(), $question["questionblock_show_questiontext"], $this->object->getSurveyId())); $template->parseCurrentBlock(); } } if (count($page) > 1) { $template->setCurrentBlock("page"); $template->setVariable("BLOCKTITLE", $page[0]["questionblock_title"]); $template->parseCurrentBlock(); } else { $template->setCurrentBlock("page"); $template->parseCurrentBlock(); } } } $this->tpl->addCss("./Modules/Survey/templates/default/survey_print.css", "print"); if (array_key_exists("pdf", $_GET) && $_GET["pdf"] == 1) { $printbody = new ilTemplate("tpl.il_as_tst_print_body.html", TRUE, TRUE, "Modules/Test"); $printbody->setVariable("TITLE", sprintf($this->lng->txt("tst_result_user_name"), $uname)); $printbody->setVariable("ADM_CONTENT", $template->get()); $printoutput = $printbody->get(); $printoutput = preg_replace("/href=\".*?\"/", "", $printoutput); $fo = $this->object->processPrintoutput2FO($printoutput); // #11436 if (!$fo || !$this->object->deliverPDFfromFO($fo)) { ilUtil::sendFailure($this->lng->txt("msg_failed"), true); $this->ctrl->redirect($this, "printView"); } } else { $this->tpl->setVariable("ADM_CONTENT", $template->get()); } }
/** * Creates a HTML representation of the question * * @access private */ function getPrintView($question_title = 1, $show_questiontext = 1, $survey_id = null) { $template = new ilTemplate("tpl.il_svy_qpl_mc_printview.html", TRUE, TRUE, "Modules/SurveyQuestionPool"); switch ($this->object->getOrientation()) { case 0: // vertical orientation for ($i = 0; $i < $this->object->categories->getCategoryCount(); $i++) { $cat = $this->object->categories->getCategory($i); if ($cat->other) { $template->setCurrentBlock("other_row"); $template->setVariable("IMAGE_CHECKBOX", ilUtil::getHtmlPath(ilUtil::getImagePath("checkbox_unchecked.png"))); $template->setVariable("ALT_CHECKBOX", $this->lng->txt("unchecked")); $template->setVariable("TITLE_CHECKBOX", $this->lng->txt("unchecked")); $template->setVariable("OTHER_LABEL", ilUtil::prepareFormOutput($cat->title)); $template->setVariable("OTHER_ANSWER", " "); $template->parseCurrentBlock(); } else { $template->setCurrentBlock("mc_row"); $template->setVariable("IMAGE_CHECKBOX", ilUtil::getHtmlPath(ilUtil::getImagePath("checkbox_unchecked.png"))); $template->setVariable("ALT_CHECKBOX", $this->lng->txt("unchecked")); $template->setVariable("TITLE_CHECKBOX", $this->lng->txt("unchecked")); $template->setVariable("TEXT_MC", ilUtil::prepareFormOutput($cat->title)); $template->parseCurrentBlock(); } } break; case 1: // horizontal orientation for ($i = 0; $i < $this->object->categories->getCategoryCount(); $i++) { $template->setCurrentBlock("checkbox_col"); $template->setVariable("IMAGE_CHECKBOX", ilUtil::getHtmlPath(ilUtil::getImagePath("checkbox_unchecked.png"))); $template->setVariable("ALT_CHECKBOX", $this->lng->txt("unchecked")); $template->setVariable("TITLE_CHECKBOX", $this->lng->txt("unchecked")); $template->parseCurrentBlock(); } for ($i = 0; $i < $this->object->categories->getCategoryCount(); $i++) { $cat = $this->object->categories->getCategory($i); if ($cat->other) { $template->setCurrentBlock("other_text_col"); $template->setVariable("OTHER_LABEL", ilUtil::prepareFormOutput($cat->title)); $template->setVariable("OTHER_ANSWER", " "); $template->parseCurrentBlock(); } else { $template->setCurrentBlock("text_col"); $template->setVariable("TEXT_MC", ilUtil::prepareFormOutput($cat->title)); $template->parseCurrentBlock(); } } break; } if ($this->object->use_min_answers) { $template->setCurrentBlock('min_max_msg'); if ($this->object->nr_min_answers > 0 && $this->object->nr_max_answers > 0) { $template->setVariable('MIN_MAX_MSG', sprintf($this->lng->txt('msg_min_max_nr_answers'), $this->object->nr_min_answers, $this->object->nr_max_answers)); } else { if ($this->object->nr_min_answers > 0) { $template->setVariable('MIN_MAX_MSG', sprintf($this->lng->txt('msg_min_nr_answers'), $this->object->nr_min_answers)); } else { if ($this->object->nr_max_answers > 0) { $template->setVariable('MIN_MAX_MSG', sprintf($this->lng->txt('msg_max_nr_answers'), $this->object->nr_max_answers)); } } } $template->parseCurrentBlock(); } if ($show_questiontext) { $this->outQuestionText($template); } if ($question_title) { $template->setVariable("QUESTION_TITLE", $this->object->getTitle()); } $template->parseCurrentBlock(); return $template->get(); }
/** * Creates a HTML representation of the question * * @access private */ function getPrintView($question_title = 1, $show_questiontext = 1) { $layout = $this->object->getLayout(); $neutralstyle = "3px solid #808080"; $bordercolor = "#808080"; $template = new ilTemplate("tpl.il_svy_qpl_matrix_printview.html", TRUE, TRUE, "Modules/SurveyQuestionPool"); if ($this->show_layout_row) { $layout_row = $this->getLayoutRow(); $template->setCurrentBlock("matrix_row"); $template->setVariable("ROW", $layout_row); $template->parseCurrentBlock(); } $tplheaders = new ilTemplate("tpl.il_svy_out_matrix_columnheaders.html", TRUE, TRUE, "Modules/SurveyQuestionPool"); if (strlen($this->object->getBipolarAdjective(0)) && strlen($this->object->getBipolarAdjective(1))) { $tplheaders->setCurrentBlock("bipolar_start"); $style = array(); array_push($style, sprintf("width: %.2f%s!important", $layout["percent_bipolar_adjective1"], "%")); if (count($style) > 0) { $tplheaders->setVariable("STYLE", " style=\"" . implode(";", $style) . "\""); } $tplheaders->parseCurrentBlock(); } // column headers for ($i = 0; $i < $this->object->getColumnCount(); $i++) { $cat = $this->object->getColumn($i); if ($cat->neutral) { $tplheaders->setCurrentBlock("neutral_column_header"); $tplheaders->setVariable("TEXT", ilUtil::prepareFormOutput($cat->title)); $tplheaders->setVariable("CLASS", "rsep"); $style = array(); array_push($style, sprintf("width: %.2f%s!important", $layout["percent_neutral"], "%")); if ($this->object->getNeutralColumnSeparator()) { array_push($style, "border-left: {$neutralstyle}!important;"); } if (count($style) > 0) { $tplheaders->setVariable("STYLE", " style=\"" . implode(";", $style) . "\""); } $tplheaders->parseCurrentBlock(); } else { $style = array(); if ($this->object->getColumnSeparators() == 1) { if ($i < $this->object->getColumnCount() - 1) { array_push($style, "border-right: 1px solid {$bordercolor}!important"); } } array_push($style, sprintf("width: %.2f%s!important", $layout["percent_columns"] / $this->object->getColumnCount(), "%")); $tplheaders->setCurrentBlock("column_header"); $tplheaders->setVariable("TEXT", ilUtil::prepareFormOutput($cat->title)); $tplheaders->setVariable("CLASS", "center"); if (count($style) > 0) { $tplheaders->setVariable("STYLE", " style=\"" . implode(";", $style) . "\""); } $tplheaders->parseCurrentBlock(); } } if (strlen($this->object->getBipolarAdjective(0)) && strlen($this->object->getBipolarAdjective(1))) { $tplheaders->setCurrentBlock("bipolar_end"); $style = array(); array_push($style, sprintf("width: %.2f%s!important", $layout["percent_bipolar_adjective2"], "%")); if (count($style) > 0) { $tplheaders->setVariable("STYLE", " style=\"" . implode(";", $style) . "\""); } $tplheaders->parseCurrentBlock(); } $style = array(); array_push($style, sprintf("width: %.2f%s!important", $layout["percent_row"], "%")); if (count($style) > 0) { $tplheaders->setVariable("STYLE", " style=\"" . implode(";", $style) . "\""); } $template->setCurrentBlock("matrix_row"); $template->setVariable("ROW", $tplheaders->get()); $template->parseCurrentBlock(); $rowclass = array("tblrow1", "tblrow2"); for ($i = 0; $i < $this->object->getRowCount(); $i++) { $rowobj = $this->object->getRow($i); $tplrow = new ilTemplate("tpl.il_svy_qpl_matrix_printview_row.html", TRUE, TRUE, "Modules/SurveyQuestionPool"); for ($j = 0; $j < $this->object->getColumnCount(); $j++) { $cat = $this->object->getColumn($j); if ($i == 0 && $j == 0) { if (strlen($this->object->getBipolarAdjective(0)) && strlen($this->object->getBipolarAdjective(1))) { $tplrow->setCurrentBlock("bipolar_start"); $tplrow->setVariable("TEXT_BIPOLAR_START", ilUtil::prepareFormOutput($this->object->getBipolarAdjective(0))); $tplrow->setVariable("ROWSPAN", $this->object->getRowCount()); $tplrow->parseCurrentBlock(); } } if ($i == 0 && $j == $this->object->getColumnCount() - 1) { if (strlen($this->object->getBipolarAdjective(0)) && strlen($this->object->getBipolarAdjective(1))) { $tplrow->setCurrentBlock("bipolar_end"); $tplrow->setVariable("TEXT_BIPOLAR_END", ilUtil::prepareFormOutput($this->object->getBipolarAdjective(1))); $tplrow->setVariable("ROWSPAN", $this->object->getRowCount()); $tplrow->parseCurrentBlock(); } } switch ($this->object->getSubtype()) { case 0: if ($cat->neutral) { $tplrow->setCurrentBlock("neutral_radiobutton"); $tplrow->setVariable("IMAGE_RADIO", ilUtil::getHtmlPath(ilUtil::getImagePath("radiobutton_unchecked.png"))); $tplrow->setVariable("ALT_RADIO", $this->lng->txt("unchecked")); $tplrow->setVariable("TITLE_RADIO", $this->lng->txt("unchecked")); $tplrow->parseCurrentBlock(); } else { $tplrow->setCurrentBlock("radiobutton"); $tplrow->setVariable("IMAGE_RADIO", ilUtil::getHtmlPath(ilUtil::getImagePath("radiobutton_unchecked.png"))); $tplrow->setVariable("ALT_RADIO", $this->lng->txt("unchecked")); $tplrow->setVariable("TITLE_RADIO", $this->lng->txt("unchecked")); $tplrow->parseCurrentBlock(); } break; case 1: if ($cat->neutral) { $tplrow->setCurrentBlock("neutral_checkbox"); $tplrow->setVariable("IMAGE_CHECKBOX", ilUtil::getHtmlPath(ilUtil::getImagePath("checkbox_unchecked.png"))); $tplrow->setVariable("ALT_CHECKBOX", $this->lng->txt("unchecked")); $tplrow->setVariable("TITLE_CHECKBOX", $this->lng->txt("unchecked")); $tplrow->parseCurrentBlock(); } else { $tplrow->setCurrentBlock("checkbox"); $tplrow->setVariable("IMAGE_CHECKBOX", ilUtil::getHtmlPath(ilUtil::getImagePath("checkbox_unchecked.png"))); $tplrow->setVariable("ALT_CHECKBOX", $this->lng->txt("unchecked")); $tplrow->setVariable("TITLE_CHECKBOX", $this->lng->txt("unchecked")); $tplrow->parseCurrentBlock(); } break; } if ($cat->neutral) { $tplrow->setCurrentBlock("neutral_answer"); $style = array(); if ($this->object->getNeutralColumnSeparator()) { array_push($style, "border-left: {$neutralstyle}!important"); } if ($this->object->getColumnSeparators() == 1) { if ($j < $this->object->getColumnCount() - 1) { array_push($style, "border-right: 1px solid {$bordercolor}!important"); } } if ($this->object->getRowSeparators() == 1) { if ($i < $this->object->getRowCount() - 1) { array_push($style, "border-bottom: 1px solid {$bordercolor}!important"); } } if (count($style)) { $tplrow->setVariable("STYLE", " style=\"" . implode(";", $style) . "\""); } $tplrow->parseCurrentBlock(); } else { $tplrow->setCurrentBlock("answer"); $style = array(); if ($this->object->getColumnSeparators() == 1) { if ($j < $this->object->getColumnCount() - 1) { array_push($style, "border-right: 1px solid {$bordercolor}!important"); } } if ($this->object->getRowSeparators() == 1) { if ($i < $this->object->getRowCount() - 1) { array_push($style, "border-bottom: 1px solid {$bordercolor}!important"); } } if (count($style)) { $tplrow->setVariable("STYLE", " style=\"" . implode(";", $style) . "\""); } $tplrow->parseCurrentBlock(); } } if ($rowobj->other) { $tplrow->setCurrentBlock("text_other"); $tplrow->setVariable("TEXT_OTHER", " "); $tplrow->parseCurrentBlock(); } $tplrow->setVariable("TEXT_ROW", ilUtil::prepareFormOutput($rowobj->title)); $tplrow->setVariable("ROWCLASS", $rowclass[$i % 2]); if ($this->object->getRowSeparators() == 1) { if ($i < $this->object->getRowCount() - 1) { $tplrow->setVariable("STYLE", " style=\"border-bottom: 1px solid {$bordercolor}!important\""); } } $template->setCurrentBlock("matrix_row"); $template->setVariable("ROW", $tplrow->get()); $template->parseCurrentBlock(); } if ($question_title) { $template->setVariable("QUESTION_TITLE", ilUtil::prepareFormOutput($this->object->getTitle())); } $template->setCurrentBlock(); if ($show_questiontext) { $this->outQuestionText($template); } $template->parseCurrentBlock(); return $template->get(); }
public function show() { require_once 'class.ilTestEvaluationGUI.php'; require_once './Services/PDFGeneration/classes/class.ilPDFGeneration.php'; global $ilUser; if (array_key_exists("pass", $_GET) && strlen($_GET["pass"]) > 0 || !is_null($pass)) { if (is_null($pass)) { $pass = $_GET["pass"]; } } $template = new ilTemplate("tpl.il_as_tst_submission_review.html", TRUE, TRUE, "Modules/Test"); $this->ilCtrl->setParameter($this, "crs_show_result", $_GET['crs_show_result']); $this->ilCtrl->setParameter($this, "skipfinalstatement", 1); $template->setVariable("FORMACTION", $this->ilCtrl->getFormAction($this->testOutputGUI, 'redirectBack') . '&reviewed=1'); $template->setVariable("BUTTON_CONTINUE", $this->lng->txt("btn_next")); $template->setVariable("BUTTON_BACK", $this->lng->txt("btn_previous")); $this->ilCtrl->setParameter($this, "pass", ""); $this->ilCtrl->setParameter($this, "pdf", ""); $active = $this->test->getActiveIdOfUser($ilUser->getId()); $testevaluationgui = new ilTestEvaluationGUI($this->test); $results = $this->test->getTestResult($active, $pass); $results_output = $testevaluationgui->getPassListOfAnswers($results, $active, $pass, false, false, false, false); if ($this->test->getShowExamviewPdf()) { $template->setCurrentBlock("pdf_export"); $template->setVariable("PDF_TEXT", $this->lng->txt("pdf_export")); $template->setVariable("PDF_IMG_ALT", $this->lng->txt("pdf_export")); $template->setVariable("PDF_IMG_URL", ilUtil::getHtmlPath(ilUtil::getImagePath("application-pdf.png"))); global $ilSetting; $inst_id = $ilSetting->get('inst_id', null); $path = ilUtil::getWebspaceDir() . '/assessment/' . $this->testOutputGUI->object->getId() . '/exam_pdf'; if (!is_dir($path)) { ilUtil::makeDirParents($path); } $filename = $path . '/exam_N' . $inst_id . '-' . $this->testOutputGUI->object->getId() . '-' . $active . '-' . $pass . '.pdf'; require_once 'class.ilTestPDFGenerator.php'; ilTestPDFGenerator::generatePDF($results_output, ilTestPDFGenerator::PDF_OUTPUT_FILE, $filename); $template->setVariable("PDF_FILE_LOCATION", $filename); } if ($this->test->getShowExamviewHtml()) { $template->setCurrentBlock('html_review'); $template->setVariable('HTML_REVIEW', $results_output); } $this->tpl->setVariable($this->getContentBlockName(), $template->get()); }
/** * Creates a HTML representation of the question * * @access private */ function getPrintView($question_title = 1, $show_questiontext = 1, $survey_id = null) { $template = new ilTemplate("tpl.il_svy_qpl_sc_printview.html", TRUE, TRUE, "Modules/SurveyQuestionPool"); switch ($this->object->orientation) { case 0: // vertical orientation for ($i = 0; $i < $this->object->categories->getCategoryCount(); $i++) { $cat = $this->object->categories->getCategory($i); if ($cat->other) { $template->setCurrentBlock("other_row"); $template->setVariable("IMAGE_RADIO", ilUtil::getHtmlPath(ilUtil::getImagePath("radiobutton_unchecked.png"))); $template->setVariable("ALT_RADIO", $this->lng->txt("unchecked")); $template->setVariable("TITLE_RADIO", $this->lng->txt("unchecked")); $template->setVariable("OTHER_LABEL", ilUtil::prepareFormOutput($cat->title)); $template->setVariable("OTHER_ANSWER", " "); $template->parseCurrentBlock(); } else { $template->setCurrentBlock("row"); $template->setVariable("IMAGE_RADIO", ilUtil::getHtmlPath(ilUtil::getImagePath("radiobutton_unchecked.png"))); $template->setVariable("ALT_RADIO", $this->lng->txt("unchecked")); $template->setVariable("TITLE_RADIO", $this->lng->txt("unchecked")); $template->setVariable("TEXT_SC", ilUtil::prepareFormOutput($cat->title)); $template->parseCurrentBlock(); } } break; case 1: // horizontal orientation for ($i = 0; $i < $this->object->categories->getCategoryCount(); $i++) { $template->setCurrentBlock("radio_col"); $template->setVariable("IMAGE_RADIO", ilUtil::getHtmlPath(ilUtil::getImagePath("radiobutton_unchecked.png"))); $template->setVariable("ALT_RADIO", $this->lng->txt("unchecked")); $template->setVariable("TITLE_RADIO", $this->lng->txt("unchecked")); $template->parseCurrentBlock(); } for ($i = 0; $i < $this->object->categories->getCategoryCount(); $i++) { $cat = $this->object->categories->getCategory($i); if ($cat->other) { $template->setCurrentBlock("other_text_col"); $template->setVariable("OTHER_LABEL", ilUtil::prepareFormOutput($cat->title)); $template->setVariable("OTHER_ANSWER", " "); $template->parseCurrentBlock(); } else { $template->setCurrentBlock("text_col"); $template->setVariable("TEXT_SC", ilUtil::prepareFormOutput($cat->title)); $template->parseCurrentBlock(); } } break; case 2: // combobox output for ($i = 0; $i < $this->object->categories->getCategoryCount(); $i++) { $cat = $this->object->categories->getCategory($i); $template->setCurrentBlock("comborow"); $template->setVariable("TEXT_SC", ilUtil::prepareFormOutput($cat->title)); $template->setVariable("VALUE_SC", $cat->scale ? $cat->scale - 1 : $i); if (is_array($working_data)) { if (strcmp($working_data[0]["value"], "") != 0) { if ($working_data[0]["value"] == $i) { $template->setVariable("SELECTED_SC", " selected=\"selected\""); } } } $template->parseCurrentBlock(); } $template->setCurrentBlock("combooutput"); $template->setVariable("QUESTION_ID", $this->object->getId()); $template->setVariable("SELECT_OPTION", $this->lng->txt("select_option")); $template->setVariable("TEXT_SELECTION", $this->lng->txt("selection")); $template->parseCurrentBlock(); break; } if ($question_title) { $template->setVariable("QUESTION_TITLE", $this->object->getTitle()); } if ($show_questiontext) { $this->outQuestionText($template); } $template->parseCurrentBlock(); return $template->get(); }
/** * Get the question solution output * * @param integer $active_id The active user id * @param integer $pass The test pass * @param boolean $graphicalOutput Show visual feedback for right/wrong answers * @param boolean $result_output Show the reached points for parts of the question * @param boolean $show_question_only Show the question without the ILIAS content around * @param boolean $show_feedback Show the question feedback * @param boolean $show_correct_solution Show the correct solution instead of the user solution * @param boolean $show_manual_scoring Show specific information for the manual scoring output * @return The solution output of the question as HTML code */ function getSolutionOutput($active_id, $pass = NULL, $graphicalOutput = FALSE, $result_output = FALSE, $show_question_only = TRUE, $show_feedback = FALSE, $show_correct_solution = FALSE, $show_manual_scoring = FALSE, $show_question_text = TRUE) { // shuffle output $keys = $this->getChoiceKeys(); // get the solution of the user for the active pass or from the last pass if allowed $user_solution = ""; if ($active_id > 0 && !$show_correct_solution) { $solutions =& $this->object->getSolutionValues($active_id, $pass); foreach ($solutions as $idx => $solution_value) { $user_solution = $solution_value["value1"]; } } else { $found_index = -1; $max_points = 0; foreach ($this->object->answers as $index => $answer) { if ($answer->getPoints() > $max_points) { $max_points = $answer->getPoints(); $found_index = $index; } } $user_solution = $found_index; } // generate the question output include_once "./Services/UICore/classes/class.ilTemplate.php"; $template = new ilTemplate("tpl.il_as_qpl_mc_sr_output_solution.html", TRUE, TRUE, "Modules/TestQuestionPool"); $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", TRUE, TRUE, "Modules/TestQuestionPool"); foreach ($keys as $answer_id) { $answer = $this->object->answers[$answer_id]; if ($active_id > 0 && !$show_correct_solution) { if ($graphicalOutput) { // output of ok/not ok icons for user entered solutions $ok = FALSE; if (strcmp($user_solution, $answer_id) == 0) { if ($answer->getPoints() == $this->object->getMaximumPoints()) { $ok = TRUE; } else { $ok = FALSE; } if ($ok) { $template->setCurrentBlock("icon_ok"); $template->setVariable("ICON_OK", ilUtil::getImagePath("icon_ok.png")); $template->setVariable("TEXT_OK", $this->lng->txt("answer_is_right")); $template->parseCurrentBlock(); } else { $template->setCurrentBlock("icon_not_ok"); if ($answer->getPoints() > 0) { $template->setVariable("ICON_NOT_OK", ilUtil::getImagePath("icon_mostly_ok.png")); $template->setVariable("TEXT_NOT_OK", $this->lng->txt("answer_is_not_correct_but_positive")); } else { $template->setVariable("ICON_NOT_OK", ilUtil::getImagePath("icon_not_ok.png")); $template->setVariable("TEXT_NOT_OK", $this->lng->txt("answer_is_wrong")); } $template->parseCurrentBlock(); } } if (strlen($user_solution) == 0) { $template->setCurrentBlock("icon_not_ok"); $template->setVariable("ICON_NOT_OK", ilUtil::getImagePath("icon_not_ok.png")); $template->setVariable("TEXT_NOT_OK", $this->lng->txt("answer_is_wrong")); $template->parseCurrentBlock(); } } } if (strlen($answer->getImage())) { $template->setCurrentBlock("answer_image"); if ($this->object->getThumbSize()) { $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $this->object->getThumbPrefix() . $answer->getImage()); } else { $template->setVariable("ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $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(); } if ($show_feedback) { if (strcmp($user_solution, $answer_id) == 0) { $fb = $this->object->getFeedbackSingleAnswer($answer_id); if (strlen($fb)) { $template->setCurrentBlock("feedback"); $template->setVariable("FEEDBACK", $fb); $template->parseCurrentBlock(); } } } $template->setCurrentBlock("answer_row"); $template->setVariable("ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE)); if (strcmp($user_solution, $answer_id) == 0) { $template->setVariable("SOLUTION_IMAGE", ilUtil::getHtmlPath(ilUtil::getImagePath("radiobutton_checked.png"))); $template->setVariable("SOLUTION_ALT", $this->lng->txt("checked")); } else { $template->setVariable("SOLUTION_IMAGE", ilUtil::getHtmlPath(ilUtil::getImagePath("radiobutton_unchecked.png"))); $template->setVariable("SOLUTION_ALT", $this->lng->txt("unchecked")); } if ($result_output) { $points = $this->object->answers[$answer_id]->getPoints(); $resulttext = $points == 1 ? "(%s " . $this->lng->txt("point") . ")" : "(%s " . $this->lng->txt("points") . ")"; $template->setVariable("RESULT_OUTPUT", sprintf($resulttext, $points)); } $template->parseCurrentBlock(); } $questiontext = $this->object->getQuestion(); if ($show_question_text == true) { $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE)); } $questionoutput = $template->get(); $feedback = $show_feedback ? $this->getAnswerFeedbackOutput($active_id, $pass) : ""; if (strlen($feedback)) { $solutiontemplate->setVariable("FEEDBACK", $feedback); } $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput); $solutionoutput = $solutiontemplate->get(); if (!$show_question_only) { // get page object output $solutionoutput = '<div class="ilc_question_Standard">' . $solutionoutput . "</div>"; } return $solutionoutput; }
public function getPrintView($question_title = 1, $show_questiontext = 1, $survey_id = null) { $template = new ilTemplate("tpl.il_svy_qpl_text_printview.html", TRUE, TRUE, "Modules/SurveyQuestionPool"); if ($show_questiontext) { $this->outQuestionText($template); } if ($question_title) { $template->setVariable("QUESTION_TITLE", $this->object->getTitle()); } $template->setVariable("TEXT_ANSWER", $this->lng->txt("answer")); $template->setVariable("TEXTBOX_IMAGE", ilUtil::getHtmlPath(ilUtil::getImagePath("textbox.png"))); $template->setVariable("TEXTBOX", $this->lng->txt("textbox")); $template->setVariable("TEXTBOX_WIDTH", $this->object->getTextWidth() * 16); $template->setVariable("TEXTBOX_HEIGHT", $this->object->getTextHeight() * 16); $template->setVariable("QUESTION_ID", $this->object->getId()); if ($this->object->getMaxChars()) { $template->setVariable("TEXT_MAXCHARS", sprintf($this->lng->txt("text_maximum_chars_allowed"), $this->object->getMaxChars())); } return $template->get(); }
/** * Creates a HTML representation of the question * * @access private */ function getPrintView($question_title = 1, $show_questiontext = 1, $survey_id = null, array $a_working_data = null) { $options = $this->getParsedAnswers($a_working_data); // rendering $template = new ilTemplate("tpl.il_svy_qpl_sc_printview.html", TRUE, TRUE, "Modules/SurveyQuestionPool"); switch ($this->object->orientation) { case 0: // vertical orientation foreach ($options as $option) { if ($option["other"]) { $template->setCurrentBlock("other_row"); $template->setVariable("IMAGE_RADIO", ilUtil::getHtmlPath(ilUtil::getImagePath("radiobutton_" . $option["checked"] . ".png"))); $template->setVariable("ALT_RADIO", $this->lng->txt($option["checked"])); $template->setVariable("TITLE_RADIO", $this->lng->txt($option["checked"])); $template->setVariable("OTHER_LABEL", ilUtil::prepareFormOutput($option["title"])); $template->setVariable("OTHER_ANSWER", $option["textanswer"] ? ilUtil::prepareFormOutput($option["textanswer"]) : " "); $template->parseCurrentBlock(); } else { $template->setCurrentBlock("row"); $template->setVariable("IMAGE_RADIO", ilUtil::getHtmlPath(ilUtil::getImagePath("radiobutton_" . $option["checked"] . ".png"))); $template->setVariable("ALT_RADIO", $this->lng->txt($option["checked"])); $template->setVariable("TITLE_RADIO", $this->lng->txt($option["checked"])); $template->setVariable("TEXT_SC", ilUtil::prepareFormOutput($option["title"])); $template->parseCurrentBlock(); } } break; case 1: // horizontal orientation foreach ($options as $option) { $template->setCurrentBlock("radio_col"); $template->setVariable("IMAGE_RADIO", ilUtil::getHtmlPath(ilUtil::getImagePath("radiobutton_" . $option["checked"] . ".png"))); $template->setVariable("ALT_RADIO", $this->lng->txt($option["checked"])); $template->setVariable("TITLE_RADIO", $this->lng->txt($option["checked"])); $template->parseCurrentBlock(); } foreach ($options as $option) { if ($option["other"]) { $template->setCurrentBlock("other_text_col"); $template->setVariable("OTHER_LABEL", ilUtil::prepareFormOutput($option["title"])); $template->setVariable("OTHER_ANSWER", $option["textanswer"] ? ilUtil::prepareFormOutput($option["textanswer"]) : " "); $template->parseCurrentBlock(); } else { $template->setCurrentBlock("text_col"); $template->setVariable("TEXT_SC", ilUtil::prepareFormOutput($option["title"])); $template->parseCurrentBlock(); } } break; case 2: foreach ($options as $option) { $template->setCurrentBlock("comborow"); $template->setVariable("TEXT_SC", ilUtil::prepareFormOutput($option["title"])); $template->setVariable("VALUE_SC", $option["value"]); if ($option["checked"] == "checked") { $template->setVariable("SELECTED_SC", ' selected="selected"'); } $template->parseCurrentBlock(); } $template->setCurrentBlock("combooutput"); $template->setVariable("QUESTION_ID", $this->object->getId()); $template->setVariable("SELECT_OPTION", $this->lng->txt("select_option")); $template->setVariable("TEXT_SELECTION", $this->lng->txt("selection")); $template->parseCurrentBlock(); break; } if ($question_title) { $template->setVariable("QUESTION_TITLE", $this->object->getTitle()); } if ($show_questiontext) { $this->outQuestionText($template); } $template->parseCurrentBlock(); return $template->get(); }
/** * Print tab to create a print of all questions with points and solutions * * Print tab to create a print of all questions with points and solutions * * @access public */ function printobject() { global $ilAccess, $ilias; if (!$ilAccess->checkAccess("write", "", $this->ref_id)) { // allow only write access ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true); $this->ctrl->redirect($this, "infoScreen"); } $this->getQuestionsSubTabs(); $template = new ilTemplate("tpl.il_as_tst_print_test_confirm.html", TRUE, TRUE, "Modules/Test"); include_once './Services/WebServices/RPC/classes/class.ilRPCServerSettings.php'; if (ilRPCServerSettings::getInstance()->isEnabled()) { $this->ctrl->setParameter($this, "pdf", "1"); $template->setCurrentBlock("pdf_export"); $template->setVariable("PDF_URL", $this->ctrl->getLinkTarget($this, "print")); $this->ctrl->setParameter($this, "pdf", ""); $template->setVariable("PDF_TEXT", $this->lng->txt("pdf_export")); $template->setVariable("PDF_IMG_ALT", $this->lng->txt("pdf_export")); $template->setVariable("PDF_IMG_URL", ilUtil::getHtmlPath(ilUtil::getImagePath("application-pdf.png"))); $template->parseCurrentBlock(); } $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print"); global $ilUser; $print_date = mktime(date("H"), date("i"), date("s"), date("m"), date("d"), date("Y")); $max_points = 0; $counter = 1; foreach ($this->object->questions as $question) { $template->setCurrentBlock("question"); $question_gui = $this->object->createQuestionGUI("", $question); $template->setVariable("COUNTER_QUESTION", $counter . "."); $template->setVariable("QUESTION_TITLE", ilUtil::prepareFormOutput($question_gui->object->getTitle())); if ($question_gui->object->getMaximumPoints() == 1) { $template->setVariable("QUESTION_POINTS", $question_gui->object->getMaximumPoints() . " " . $this->lng->txt("point")); } else { $template->setVariable("QUESTION_POINTS", $question_gui->object->getMaximumPoints() . " " . $this->lng->txt("points")); } $result_output = $question_gui->getSolutionOutput("", NULL, FALSE, TRUE, FALSE, $this->object->getShowSolutionFeedback()); if (strlen($result_output) == 0) { $result_output = $question_gui->getPreview(FALSE); } $template->setVariable("SOLUTION_OUTPUT", $result_output); $template->parseCurrentBlock("question"); $counter++; $max_points += $question_gui->object->getMaximumPoints(); } $template->setCurrentBlock("navigation_buttons"); $template->setVariable("BUTTON_PRINT", $this->lng->txt("print")); $template->parseCurrentBlock(); $template->setVariable("TITLE", ilUtil::prepareFormOutput($this->object->getTitle())); $template->setVariable("PRINT_TEST", ilUtil::prepareFormOutput($this->lng->txt("tst_print"))); $template->setVariable("TXT_PRINT_DATE", ilUtil::prepareFormOutput($this->lng->txt("date"))); $template->setVariable("VALUE_PRINT_DATE", ilUtil::prepareFormOutput(strftime("%c", $print_date))); $template->setVariable("TXT_MAXIMUM_POINTS", ilUtil::prepareFormOutput($this->lng->txt("tst_maximum_points"))); $template->setVariable("VALUE_MAXIMUM_POINTS", ilUtil::prepareFormOutput($max_points)); if (array_key_exists("pdf", $_GET) && $_GET["pdf"] == 1) { $this->object->deliverPDFfromHTML($template->get(), $this->object->getTitle()); } else { $this->tpl->setVariable("PRINT_CONTENT", $template->get()); } }
/** * Creates a HTML representation of the question * * @access private */ function getPrintView($question_title = 1, $show_questiontext = 1, $survey_id = null, array $a_working_data = null) { $options = $this->getParsedAnswers($a_working_data); $template = new ilTemplate("tpl.il_svy_qpl_mc_printview.html", TRUE, TRUE, "Modules/SurveyQuestionPool"); switch ($this->object->getOrientation()) { case 0: // vertical orientation foreach ($options as $option) { if ($option["other"]) { $template->setCurrentBlock("other_row"); $template->setVariable("IMAGE_CHECKBOX", ilUtil::getHtmlPath(ilUtil::getImagePath("checkbox_" . $option["checked"] . ".png"))); $template->setVariable("ALT_CHECKBOX", $this->lng->txt($option["checked"])); $template->setVariable("TITLE_CHECKBOX", $this->lng->txt($option["checked"])); $template->setVariable("OTHER_LABEL", ilUtil::prepareFormOutput($option["title"])); $template->setVariable("OTHER_ANSWER", $option["textanswer"] ? ilUtil::prepareFormOutput($option["textanswer"]) : " "); $template->parseCurrentBlock(); } else { $template->setCurrentBlock("mc_row"); $template->setVariable("IMAGE_CHECKBOX", ilUtil::getHtmlPath(ilUtil::getImagePath("checkbox_" . $option["checked"] . ".png"))); $template->setVariable("ALT_CHECKBOX", $this->lng->txt($option["checked"])); $template->setVariable("TITLE_CHECKBOX", $this->lng->txt($option["checked"])); $template->setVariable("TEXT_MC", ilUtil::prepareFormOutput($option["title"])); $template->parseCurrentBlock(); } } break; case 1: // horizontal orientation foreach ($options as $option) { $template->setCurrentBlock("checkbox_col"); $template->setVariable("IMAGE_CHECKBOX", ilUtil::getHtmlPath(ilUtil::getImagePath("checkbox_" . $option["checked"] . ".png"))); $template->setVariable("ALT_CHECKBOX", $this->lng->txt($option["checked"])); $template->setVariable("TITLE_CHECKBOX", $this->lng->txt($option["checked"])); $template->parseCurrentBlock(); } foreach ($options as $option) { if ($option["other"]) { $template->setCurrentBlock("other_text_col"); $template->setVariable("OTHER_LABEL", ilUtil::prepareFormOutput($option["title"])); $template->setVariable("OTHER_ANSWER", $option["textanswer"] ? ilUtil::prepareFormOutput($option["textanswer"]) : " "); $template->parseCurrentBlock(); } else { $template->setCurrentBlock("text_col"); $template->setVariable("TEXT_MC", ilUtil::prepareFormOutput($option["title"])); $template->parseCurrentBlock(); } } break; } if ($this->object->use_min_answers) { $template->setCurrentBlock('min_max_msg'); if ($this->object->nr_min_answers > 0 && $this->object->nr_max_answers > 0) { $template->setVariable('MIN_MAX_MSG', sprintf($this->lng->txt('msg_min_max_nr_answers'), $this->object->nr_min_answers, $this->object->nr_max_answers)); } else { if ($this->object->nr_min_answers > 0) { $template->setVariable('MIN_MAX_MSG', sprintf($this->lng->txt('msg_min_nr_answers'), $this->object->nr_min_answers)); } else { if ($this->object->nr_max_answers > 0) { $template->setVariable('MIN_MAX_MSG', sprintf($this->lng->txt('msg_max_nr_answers'), $this->object->nr_max_answers)); } } } $template->parseCurrentBlock(); } if ($show_questiontext) { $this->outQuestionText($template); } if ($question_title) { $template->setVariable("QUESTION_TITLE", $this->object->getTitle()); } $template->parseCurrentBlock(); return $template->get(); }
/** * Output of the pass overview for a test called by a test participant * * Output of the pass overview for a test called by a test participant * * @access public */ function outUserResultsOverview() { global $ilUser, $ilias, $ilLog; if (!$this->object->canShowTestResults($ilUser->getId())) { $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen"); } include_once "./Services/UICore/classes/class.ilTemplate.php"; $templatehead = new ilTemplate("tpl.il_as_tst_results_participants.html", TRUE, TRUE, "Modules/Test"); $template = new ilTemplate("tpl.il_as_tst_results_participant.html", TRUE, TRUE, "Modules/Test"); $pass = null; $user_id = $ilUser->getId(); $uname = $this->object->userLookupFullName($user_id, TRUE); $active_id = $this->object->getTestSession()->getActiveId(); $hide_details = !$this->object->getShowPassDetails(); if ($hide_details) { $executable = $this->object->isExecutable($ilUser->getId()); if (!$executable["executable"]) { $hide_details = FALSE; } } $begin = microtime(true); if ($this->object->getNrOfTries() == 1 && !$hide_details) { $pass = 0; } else { $template->setCurrentBlock("pass_overview"); $overview = $this->getPassOverview($active_id, "iltestevaluationgui", "outUserResultsOverview", FALSE, $hide_details); $template->setVariable("PASS_OVERVIEW", $overview); $template->setVariable("TEXT_RESULTS", $this->lng->txt("tst_results_overview")); $template->parseCurrentBlock(); } if (array_key_exists("pass", $_GET) && strlen($_GET["pass"]) > 0 || !is_null($pass)) { if (is_null($pass)) { $pass = $_GET["pass"]; } } include_once './Services/WebServices/RPC/classes/class.ilRPCServerSettings.php'; if (ilRPCServerSettings::getInstance()->isEnabled()) { $this->ctrl->setParameter($this, "pass", $pass); $this->ctrl->setParameter($this, "pdf", "1"); $templatehead->setCurrentBlock("pdf_export"); $templatehead->setVariable("PDF_URL", $this->ctrl->getLinkTarget($this, "outUserResultsOverview")); $this->ctrl->setParameter($this, "pass", ""); $this->ctrl->setParameter($this, "pdf", ""); $templatehead->setVariable("PDF_TEXT", $this->lng->txt("pdf_export")); $templatehead->setVariable("PDF_IMG_ALT", $this->lng->txt("pdf_export")); $templatehead->setVariable("PDF_IMG_URL", ilUtil::getHtmlPath(ilUtil::getImagePath("application-pdf.png"))); $templatehead->parseCurrentBlock(); if ($this->object->canShowCertificate($user_id, $active_id)) { $templatehead->setVariable("CERTIFICATE_URL", $this->ctrl->getLinkTarget($this, "outCertificate")); $templatehead->setVariable("CERTIFICATE_TEXT", $this->lng->txt("certificate")); } } $templatehead->setVariable("BACK_TEXT", $this->lng->txt("tst_results_back_introduction")); $templatehead->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass("ilobjtestgui", "infoScreen")); $templatehead->setVariable("PRINT_TEXT", $this->lng->txt("print")); $templatehead->setVariable("PRINT_URL", "javascript:window.print();"); $statement = $this->getFinalStatement($active_id); $user_data = $this->getResultsUserdata($active_id, TRUE); // output of the details of a selected pass $this->ctrl->saveParameter($this, "pass"); $this->ctrl->saveParameter($this, "active_id"); if (!is_null($pass)) { $result_array =& $this->object->getTestResult($active_id, $pass); $command_solution_details = ""; if ($this->object->getShowSolutionDetails()) { $command_solution_details = "outCorrectSolution"; } $detailsoverview = !$hide_details ? $this->getPassDetailsOverview($result_array, $active_id, $pass, "iltestevaluationgui", "outUserResultsOverview", $command_solution_details) : ''; $user_id = $this->object->_getUserIdFromActiveId($active_id); if (!$hide_details && $this->object->canShowSolutionPrintview()) { $list_of_answers = $this->getPassListOfAnswers($result_array, $active_id, $pass); } else { if ($this->object->getShowSolutionDetails()) { // if this is not commented out, all questions with checkmarks/crosses will be shown // $list_of_answers = $this->getPassListOfAnswers($result_array, $active_id, $pass, true); } } $template->setVariable("LIST_OF_ANSWERS", $list_of_answers); $template->setVariable("PASS_RESULTS_OVERVIEW", sprintf($this->lng->txt("tst_results_overview_pass"), $pass + 1)); $template->setVariable("PASS_DETAILS", $detailsoverview); $signature = $this->getResultsSignature(); $template->setVariable("SIGNATURE", $signature); } if ($this->object->getAnonymity()) { $template->setVariable("TEXT_HEADING", $this->lng->txt("tst_result")); } else { $template->setVariable("TEXT_HEADING", sprintf($this->lng->txt("tst_result_user_name"), $uname)); $template->setVariable("USER_DATA", $user_data); } $template->setVariable("USER_MARK", $statement["mark"]); if (strlen($statement["markects"])) { $template->setVariable("USER_MARK_ECTS", $statement["markects"]); } $template->parseCurrentBlock(); $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print"); if ($this->object->getShowSolutionAnswersOnly()) { $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print"); } $templatehead->setVariable("RESULTS_PARTICIPANT", $template->get()); if (array_key_exists("pdf", $_GET) && $_GET["pdf"] == 1) { $this->object->deliverPDFfromHTML($template->get(), sprintf($this->lng->txt("tst_result_user_name"), $uname)); } else { $this->tpl->setVariable("PRINT_CONTENT", $templatehead->get()); } }