4require_once 
'./Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
 
    5require_once 
'./Modules/TestQuestionPool/interfaces/interface.ilGuiQuestionScoringAdjustable.php';
 
    6include_once 
'./Modules/Test/classes/inc.AssessmentConstants.php';
 
   23        parent::__construct();
 
   24        include_once 
'./Modules/TestQuestionPool/classes/class.assLongMenu.php';
 
   27            $this->
object->loadFromDb(
$id);
 
   45        $user_solution = array();
 
   49            #include_once "./Modules/Test/classes/class.ilObjTest.php";
 
   50            #if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) 
   52            #   if (is_null($pass)) $pass = ilObjTest::_getPass($active_id); 
   57            foreach ($solutions as $idx => $solution_value) {
 
   58                $user_solution[$solution_value[
"value1"]] = $solution_value[
"value2"];
 
   60            return $user_solution;
 
   62        return $user_solution;
 
   76        $form->setValuesByPost();
 
   79        $custom_check = $this->
object->checkQuestionCustomPart(
$form);
 
   80        if (!
$form->checkInput() || !$custom_check) {
 
   97        $this->
object->setQuestion(
$_POST[
'question']);
 
   98        $this->
object->setLongMenuTextValue(
$_POST[
"longmenu_text"]);
 
   99        $this->
object->setMinAutoComplete((
int) 
$_POST[
"min_auto_complete"]);
 
  100        $this->
object->setIdenticalScoring((
int) $_POST[
"identical_scoring"]);
 
  106        if (
$form === 
null) {
 
  111        $this->tpl->addCss(
'Modules/Test/templates/default/ta.css');
 
  113        $this->tpl->setVariable(
"QUESTION_DATA", $this->ctrl->getHTML(
$form));
 
  139        $long_menu_text = 
new ilTextAreaInputGUI($this->lng->txt(
"longmenu_text"), 
'longmenu_text');
 
  140        $long_menu_text->setRequired(
true);
 
  142        $long_menu_text->setRows(10);
 
  143        $long_menu_text->setCols(80);
 
  144        if (!$this->object->getSelfAssessmentEditingMode()) {
 
  146                include_once 
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
 
  148                $long_menu_text->addPlugin(
"latex");
 
  149                $long_menu_text->addButton(
"latex");
 
  150                $long_menu_text->addButton(
"pastelatex");
 
  151                $long_menu_text->setRTESupport($this->object->getId(), 
"qpl", 
"assessment");
 
  152                $long_menu_text->setUseRte(
true);
 
  155            require_once 
'Modules/TestQuestionPool/classes/questions/class.ilAssSelfAssessmentQuestionFormatter.php';
 
  157            $long_menu_text->setUseTagsForRteOnly(
false);
 
  160        $long_menu_text->setValue($this->object->prepareTextareaOutput($this->object->getLongMenuTextValue()));
 
  161        $form->addItem($long_menu_text);
 
  163        $tpl = 
new ilTemplate(
"tpl.il_as_qpl_long_menu_gap_button_code.html", 
true, 
true, 
"Modules/TestQuestionPool");
 
  164        $tpl->setVariable(
'INSERT_GAP', $this->lng->txt(
'insert_gap'));
 
  165        $tpl->parseCurrentBlock();
 
  167        $button->setHtml(
$tpl->get());
 
  168        $form->addItem($button);
 
  170        require_once(
"./Services/UIComponent/Modal/classes/class.ilModalGUI.php");
 
  172        $modal->setHeading(
'');
 
  173        $modal->setId(
"ilGapModal");
 
  177        $min_auto_complete = 
new ilNumberInputGUI($this->lng->txt(
"min_auto_complete"), 
'min_auto_complete');
 
  179        $auto_complete = $this->
object->getMinAutoComplete();
 
  180        if ($auto_complete == 0) {
 
  183        $min_auto_complete->setValue($auto_complete);
 
  184        $min_auto_complete->setMinValue(1);
 
  185        $min_auto_complete->setMaxValue(99);
 
  186        $min_auto_complete->setSize(5);
 
  187        $form->addItem($min_auto_complete);
 
  189        $identical_scoring = 
new ilCheckboxInputGUI($this->lng->txt(
"identical_scoring"), 
"identical_scoring");
 
  190        $identical_scoring->setValue(1);
 
  191        $identical_scoring->setChecked($this->object->getIdenticalScoring());
 
  192        $identical_scoring->setInfo($this->lng->txt(
'identical_scoring_desc'));
 
  193        $identical_scoring->setRequired(
false);
 
  194        $form->addItem($identical_scoring);
 
  196        $form->addItem($hidden_text);
 
  199        $form->addItem($hidden_correct);
 
  201        $tpl = 
new ilTemplate(
"tpl.il_as_qpl_long_menu_gap.html", 
true, 
true, 
"Modules/TestQuestionPool");
 
  202        if (is_array(
$_POST) && array_key_exists(
'hidden_text_files', 
$_POST)) {
 
  203            $tpl->setVariable(
'CORRECT_ANSWERS', 
$_POST[
'hidden_correct_answers']);
 
  204            $tpl->setVariable(
'ALL_ANSWERS', 
$_POST[
'hidden_text_files']);
 
  206            $tpl->setVariable(
'CORRECT_ANSWERS', $this->object->getJsonStructure());
 
  207            $tpl->setVariable(
'ALL_ANSWERS', $this->object->getAnswersObject());
 
  211        $tpl->setVariable(
'SELECT_BOX', $this->lng->txt(
'insert_gap'));
 
  212        $tpl->setVariable(
"SELECT", $this->lng->txt(
'answers_select'));
 
  213        $tpl->setVariable(
"TEXT", $this->lng->txt(
'answers_text_box'));
 
  214        $tpl->setVariable(
"POINTS", $this->lng->txt(
'points'));
 
  215        $tpl->setVariable(
"INFO_TEXT_UPLOAD", $this->lng->txt(
'info_text_upload'));
 
  216        $tpl->setVariable(
"TXT_BROWSE", $this->lng->txt(
'select_file'));
 
  217        $tpl->setVariable(
"MANUAL_EDITING", $this->lng->txt(
'manual_editing'));
 
  218        $tpl->setVariable(
"CORRECT_ANSWER_TXT", $this->lng->txt(
'correct_answers'));
 
  219        $tpl->setVariable(
"ANSWER_OPTIONS_TXT", $this->lng->txt(
'answer_options'));
 
  220        $tpl->setVariable(
"ANSWERS_TXT", $this->lng->txt(
'answers'));
 
  221        $tpl->setVariable(
"TYPE_TXT", $this->lng->txt(
'type'));
 
  222        $tpl->setVariable(
"EDIT_TXT", $this->lng->txt(
'edit'));
 
  223        $tpl->setVariable(
"ADD_ANSWER_TXT", $this->lng->txt(
'add_answers'));
 
  224        $tpl->setVariable(
'POINTS_ERROR', $this->lng->txt(
'enter_enough_positive_points'));
 
  225        $tpl->setVariable(
'AUTOCOMPLETE_ERROR', $this->lng->txt(
'autocomplete_error'));
 
  226        $tpl->setVariable(
'MISSING_VALUE', $this->lng->txt(
'msg_input_is_required'));
 
  227        $tpl->setVariable(
'SAVE', $this->lng->txt(
'save'));
 
  228        $tpl->setVariable(
'CANCEL', $this->lng->txt(
'cancel'));
 
  229        require_once(
"Services/Form/classes/class.ilTagInputGUI.php");
 
  231        $tag_input->setTypeAhead(
true);
 
  232        $tag_input->setPostVar(
'taggable');
 
  233        $tag_input->setJsSelfInit(
false);
 
  234        $tag_input->setTypeAheadMinLength(1);
 
  235        $tpl->setVariable(
"TAGGING_PROTOTYPE", $tag_input->render(
''));
 
  237        $tpl->setVariable(
"MY_MODAL", $modal->getHTML());
 
  239        $tpl->parseCurrentBlock();
 
  241        $button->setHtml(
$tpl->get());
 
  242        $form->addItem($button);
 
  281        $graphicalOutput = 
false,
 
  282        $result_output = 
false,
 
  283        $show_question_only = 
true,
 
  284        $show_feedback = 
false,
 
  285        $show_correct_solution = 
false,
 
  286        $show_manual_scoring = 
false,
 
  287        $show_question_text = 
true 
  289        include_once 
"./Services/UICore/classes/class.ilTemplate.php";
 
  290        $template = 
new ilTemplate(
"tpl.il_as_qpl_lome_question_output_solution.html", 
true, 
true, 
"Modules/TestQuestionPool");
 
  292        if ($show_question_text) {
 
  293            $question_text = $this->
object->getQuestion();
 
  294            $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($question_text, 
true));
 
  296        if (($active_id > 0) && (!$show_correct_solution)) {
 
  299            $correct_solution = $this->
object->getCorrectAnswersForQuestionSolution($this->object->getId());
 
  302        $solution_template = 
new ilTemplate(
"tpl.il_as_tst_solution_output.html", 
true, 
true, 
"Modules/TestQuestionPool");
 
  305        if ($show_feedback) {
 
  308                $feedback .= strlen($fb) ? $fb : 
'';
 
  312            $feedback .= strlen($fb) ? $fb : 
'';
 
  314        if (strlen($feedback)) {
 
  320            $solution_template->setVariable(
"ILC_FB_CSS_CLASS", $cssClass);
 
  321            $solution_template->setVariable(
"FEEDBACK", $this->object->prepareTextareaOutput($feedback, 
true));
 
  324        $solution_template->setVariable(
"SOLUTION_OUTPUT", $question_output);
 
  326        $solution_output = $solution_template->get();
 
  328        if (!$show_question_only) {
 
  329            $solution_output = $this->
getILIASPage($solution_output);
 
  332        return $solution_output;
 
  335    public function getPreview($show_question_only = 
false, $showInlineFeedback = 
false)
 
  338        $user_solution = array_values($user_solution);
 
  340        include_once 
"./Services/UICore/classes/class.ilTemplate.php";
 
  341        $template = 
new ilTemplate(
"tpl.il_as_qpl_longmenu_output.html", 
true, 
true, 
"Modules/TestQuestionPool");
 
  343        $question_text = $this->
object->getQuestion();
 
  344        $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($question_text, 
true));
 
  345        $template->setVariable(
"ANSWER_OPTIONS_JSON", json_encode($this->object->getAvailableAnswerOptions()));
 
  346        $template->setVariable(
'AUTOCOMPLETE_LENGTH', $this->object->getMinAutoComplete());
 
  350        if (!$show_question_only) {
 
  351            $question_output = $this->
getILIASPage($question_output);
 
  353        return $question_output;
 
  363                           $is_postponed = 
false,
 
  364        $use_post_solutions = 
false,
 
  365        $show_feedback = 
false 
  367        $user_solution = array();
 
  370            include_once 
"./Modules/Test/classes/class.ilObjTest.php";
 
  372                if (is_null(
$pass)) {
 
  376            $solutions = $this->
object->getUserSolutionPreferingIntermediate($active_id, 
$pass);
 
  377            foreach ($solutions as $idx => $solution_value) {
 
  378                $user_solution[$solution_value[
"value1"]] = $solution_value[
"value2"];
 
  383        include_once 
"./Services/UICore/classes/class.ilTemplate.php";
 
  384        $template = 
new ilTemplate(
"tpl.il_as_qpl_longmenu_output.html", 
true, 
true, 
"Modules/TestQuestionPool");
 
  386        $question_text = $this->
object->getQuestion();
 
  387        $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($question_text, 
true));
 
  388        $template->setVariable(
"ANSWER_OPTIONS_JSON", json_encode($this->object->getAvailableAnswerOptions()));
 
  390        $template->setVariable(
'AUTOCOMPLETE_LENGTH', $this->object->getMinAutoComplete());
 
  392        $page_output = $this->
outQuestionPage(
"", $is_postponed, $active_id, $question_output);
 
  404        $this->ilTabs->clearTargets();
 
  406        $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI", 
"q_id", 
$_GET[
"q_id"]);
 
  407        include_once 
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
 
  408        $q_type = $this->
object->getQuestionType();
 
  410        if (strlen($q_type)) {
 
  411            $classname = $q_type . 
"GUI";
 
  412            $this->ctrl->setParameterByClass(strtolower($classname), 
"sel_question_types", $q_type);
 
  413            $this->ctrl->setParameterByClass(strtolower($classname), 
"q_id", 
$_GET[
"q_id"]);
 
  417            if ($this->rbacsystem->checkAccess(
'write', 
$_GET[
"ref_id"])) {
 
  419                $this->ilTabs->addTarget(
 
  421                    $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI", 
"edit"),
 
  422                    array(
"edit", 
"insert", 
"exec_pg"),
 
  432        $force_active = 
false;
 
  433        if ($this->rbacsystem->checkAccess(
'write', 
$_GET[
"ref_id"])) {
 
  436                $url = $this->ctrl->getLinkTargetByClass($classname, 
"editQuestion");
 
  438            $commands = 
$_POST[
"cmd"];
 
  439            if (is_array($commands)) {
 
  440                foreach ($commands as 
$key => $value) {
 
  441                    if (preg_match(
"/^delete_.*/", 
$key, $matches)) {
 
  442                        $force_active = 
true;
 
  447            $this->ilTabs->addTarget(
 
  450                array(
"editQuestion", 
"save", 
"saveEdit", 
"addkvp", 
"removekvp", 
"originalSyncForm"),
 
  468            $this->ilTabs->addTarget(
 
  470                $this->ctrl->getLinkTargetByClass($classname, 
"assessment"),
 
  482        if (!$this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation($this->object->getId(), 0, 0)) {
 
  486        $feedback = 
'<table class="test_specific_feedback"><tbody>';
 
  487        $gaps = $this->
object->getCorrectAnswers();
 
  488        foreach ($gaps as 
$index => $answer) {
 
  490            $caption .= 
$index + 1 . 
': ';
 
  492            $feedback .= 
'<tr><td>';
 
  494            $feedback .= $caption . 
'</td><td>';
 
  495            $feedback .= $this->
object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
 
  496                $this->object->getId(),
 
  501        $feedback .= 
'</tbody></table>';
 
  502        return $this->
object->prepareTextareaOutput($feedback, 
true);
 
  531        $aggregation = array();
 
  532        foreach ($relevant_answers as $answer) {
 
  533            $overview[$answer[
'active_fi']][$answer[
'pass']][$answer[
'value1']] = $answer[
'value2'];
 
  536        foreach ($overview as $active) {
 
  537            foreach ($active as $answer) {
 
  538                foreach ($answer as $option => $value) {
 
  539                    $aggregation[$option][$value] = $aggregation[$option][$value] + 1;
 
  543        $tpl = 
new ilTemplate(
'tpl.il_as_aggregated_long_menu_answers_table.html', 
true, 
true, 
"Modules/TestQuestionPool");
 
  544        $json = json_decode($this->object->getJsonStructure());
 
  545        foreach ($json as 
$key => $value) {
 
  546            $tpl->setVariable(
'TITLE', 
'Longmenu ' . (
$key + 1));
 
  547            if (array_key_exists(
$key, $aggregation)) {
 
  548                $aggregate = $aggregation[
$key];
 
  549                foreach ($aggregate as $answer => $counts) {
 
  550                    $tpl->setVariable(
'OPTION', $answer);
 
  551                    $tpl->setVariable(
'COUNT', $counts);
 
  552                    $tpl->parseCurrentBlock();
 
  564        $correct_answers = $this->
object->getCorrectAnswers();
 
  565        $answers = $this->
object->getAnswers();
 
  566        foreach ($text_array as 
$key => $value) {
 
  567            $answer_is_correct = 
false;
 
  569            $return_value .= $value;
 
  570            if (
$key < 
sizeof($text_array) - 1) {
 
  572                    if (array_key_exists(
$key, $user_solution)) {
 
  573                        $user_value = $user_solution[
$key];
 
  574                        if (in_array($user_value, $correct_answers[
$key][0])) {
 
  575                            $answer_is_correct = 
true;
 
  581                    if (array_key_exists(
$key, $user_solution)) {
 
  582                        $user_value = $user_solution[
$key];
 
  583                        if (in_array($user_value, $correct_answers[
$key][0])) {
 
  584                            $answer_is_correct = 
true;
 
  591        return $return_value;
 
  596        $tpl = 
new ilTemplate(
"tpl.il_as_qpl_long_menu_text_gap.html", 
true, 
true, 
"Modules/TestQuestionPool");
 
  598            $tpl->setVariable(
'DISABLED', 
'disabled');
 
  599            $tpl->setVariable(
'JS_IGNORE', 
'_ignore');
 
  603                    $tpl->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
 
  606                    $tpl->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_wrong"));
 
  610        $tpl->setVariable(
'VALUE', $value);
 
  618        $tpl = 
new ilTemplate(
"tpl.il_as_qpl_long_menu_select_gap.html", 
true, 
true, 
"Modules/TestQuestionPool");
 
  621            $tpl->setVariable(
'DISABLED', 
'disabled');
 
  622            $tpl->setVariable(
'JS_IGNORE', 
'_ignore');
 
  623            $tpl->setCurrentBlock(
'best_solution');
 
  624            if ($user_value == -1) {
 
  625                $tpl->setVariable(
"SOLUTION", $this->lng->txt(
"please_select"));
 
  627                $tpl->setVariable(
'SOLUTION', $user_value);
 
  632                    $tpl->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
 
  635                    $tpl->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_wrong"));
 
  638            $tpl->parseCurrentBlock();
 
  640            $tpl->setVariable(
"PLEASE_SELECT", $this->lng->txt(
"please_select"));
 
  641            foreach ($answers as $value) {
 
  642                $tpl->setCurrentBlock(
'select_option');
 
  643                $tpl->setVariable(
'VALUE', $value);
 
  644                if ($value == $user_value) {
 
  645                    $tpl->setVariable(
'SELECTED', 
'selected');
 
  647                $tpl->parseCurrentBlock();
 
  655        return array_keys($this->object->getAnswers());
 
  662        foreach ($relevant_answers as 
$row) {
 
  663            if (
$row[
'value1'] != $questionIndex) {
 
  667            if (!isset($answers[
$row[
'value2']])) {
 
  670                $answers[
$row[
'value2']] = array(
 
  671                    'answer' => 
$row[
'value2'], 
'frequency' => 0
 
  675            $answers[
$row[
'value2']][
'frequency']++;
 
  685        $table = parent::getAnswerFrequencyTableGUI(
 
  693            $DIC->language()->txt(
'tst_corrections_answers_tbl_subindex'),
 
  694            $DIC->language()->txt(
'longmenu') . 
' ' . ($questionIndex + 1)
 
  702        $correctAnswers = $this->
object->getCorrectAnswers();
 
  704        foreach ($this->object->getAnswers() as $lmIndex => $lm) {
 
  706                'answers_all' => array(0 => $lm),
 
  707                'answers_all_count' => count($lm),
 
  708                'answers_correct' => $correctAnswers[$lmIndex][0]
 
  711            $lmPoints = $correctAnswers[$lmIndex][1];
 
  714            $section->setTitle($this->lng->txt(
'longmenu') . 
' ' . ($lmIndex + 1));
 
  718                $this->lng->txt(
'answers'),
 
  719                'longmenu_' . $lmIndex
 
  722            $lmInput->setRequired(
true);
 
  724            $lmInput->setValues($lmValues);
 
  726            $form->addItem($lmInput);
 
  728            $pointsInp = 
new ilNumberInputGUI($this->lng->txt(
"points"), 
'points_' . $lmIndex);
 
  729            $pointsInp->setRequired(
true);
 
  730            $pointsInp->allowDecimals(
true);
 
  731            $pointsInp->setSize(4);
 
  732            $pointsInp->setMinValue(0);
 
  733            $pointsInp->setMinvalueShouldBeGreater(
false);
 
  734            $pointsInp->setValue($lmPoints);
 
  735            $form->addItem($pointsInp);
 
  744        $correctAnswers = $this->
object->getCorrectAnswers();
 
  746        foreach ($this->object->getAnswers() as $lmIndex => $lm) {
 
  747            $pointsInput = (float) 
$form->getInput(
'points_' . $lmIndex);
 
  748            $correctAnswersInput = (array) 
$form->getInput(
'longmenu_' . $lmIndex . 
'_tags');
 
  750            foreach ($correctAnswersInput as $idx => $answer) {
 
  751                if (in_array($answer, $lm)) {
 
  755                unset($correctAnswersInput[$idx]);
 
  758            $correctAnswersInput = array_values($correctAnswersInput);
 
  760            $correctAnswers[$lmIndex][0] = $correctAnswersInput;
 
  761            $correctAnswers[$lmIndex][1] = $pointsInput;
 
  764        $this->
object->setCorrectAnswers($correctAnswers);
 
An exception for terminatinating execution or to throw for unit testing.
Basic GUI class for assessment questions.
populateTaxonomyFormSection(ilPropertyFormGUI $form)
addTab_QuestionHints(ilTabsGUI $tabs)
adds the hints tab to ilTabsGUI
writeQuestionGenericPostData()
addQuestionFormCommandButtons($form)
Add the command buttons of a question properties form.
getILIASPage($html="")
Returns the ILIAS Page around a question.
getQuestionTemplate()
get question template
addTab_SuggestedSolution(ilTabsGUI $tabs, $classname)
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
output question page
getUseIntermediateSolution()
Get if intermediate solution should be used for solution output.
saveTaxonomyAssignments()
buildBasicEditFormObject()
addBackTab(ilTabsGUI $ilTabs)
isTestPresentationContext()
hasCorrectSolution($activeId, $passIndex)
addTab_QuestionFeedback(ilTabsGUI $tabs)
adds the feedback tab to ilTabsGUI
addBasicQuestionFormProperties($form)
Add basic question form properties: assessment: title, author, description, question,...
addTab_QuestionPreview(ilTabsGUI $tabsGUI)
getGenericFeedbackOutput($active_id, $pass)
Returns the answer specific feedback for the question.
const ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT
constant for additional content editing mode "default"
const CSS_CLASS_FEEDBACK_WRONG
const CSS_CLASS_FEEDBACK_CORRECT
static getInstance()
Get instance.
static _getUsedHTMLTags($a_module="")
Returns an array of all allowed HTML tags for text editing.
static _getUsePreviousAnswers($active_id, $user_active_user_setting=false)
Returns if the previous results should be hidden for a learner.
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
special template class to simplify handling of ITX/PEAR
This class represents a text area property in a property form.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static stripSlashesRecursive($a_data, $a_strip_html=true, $a_allow="")
Strip slashes from array and sub-arrays.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
if(!array_key_exists('StateId', $_REQUEST)) $id
Interface ilGuiQuestionScoringAdjustable.
if(empty($password)) $table
if(isset($_POST['submit'])) $form