41             $this->
object->loadFromDb(
$id);
    45         $this->
lng = $DIC[
'lng'];
    46         $this->ui_factory = $DIC[
'ui.factory'];
    47         $this->ui_renderer = $DIC[
'ui.renderer'];
    61         $this->editForm->setValuesByPost();
    70         $custom_check = $this->
object->checkQuestionCustomPart($this->editForm);
    72             $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'form_input_not_valid'));
    83         $hidden_text_files = $this->request_data_collector->string(
'hidden_text_files');
    84         $hidden_correct_answers = $this->request_data_collector->string(
'hidden_correct_answers');
    85         $long_menu_type = $this->request_data_collector->raw(
'long_menu_type') ?? [];
    86         $this->
object->setLongMenuTextValue($this->request_data_collector->string(
'longmenu_text'));
    90         $this->
object->setQuestion($this->request_data_collector->string(
'question'));
    91         $this->
object->setMinAutoComplete($min_auto_complete);
    92         $this->
object->setIdenticalScoring($this->request_data_collector->int(
'identical_scoring'));
    99         $longmenu_text = $this->request_data_collector->raw(
'longmenu_text') ?? 
'';
   100         $hidden_text_files = $this->request_data_collector->raw(
'hidden_text_files') ?? 
'';
   101         $answer_options_from_text = preg_split(
   107         if (count($answer_options_from_text) - 1 !== count($answer_options_from_files)) {
   108             $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'longmenu_answeroptions_differ'));
   112         $correct_answers = $this->
stripSlashesRecursive(json_decode($this->request_data_collector->raw(
'hidden_correct_answers')));
   113         foreach ($correct_answers as $answer) {
   114             if (!is_numeric(str_replace(
',', 
'.', $answer[1]))) {
   115                 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'points_non_numeric_or_negative_msg'));
   125             function (
string|array $v): 
string|array {
   138             function (
string|array $v): 
string|array {
   149         bool $checkonly = 
false,
   150         ?
bool $is_save_cmd = null
   153         if ($form === null) {
   162         if ($this->
object->getId() > 0) {
   163             $this->
ctrl->setParameterByClass(self::class, 
'q_id', $this->
object->getId());
   165         $form->setFormAction($this->
ctrl->getFormActionByClass(self::class));
   187         $long_menu_text->setRows(10);
   188         $long_menu_text->setCols(80);
   189         if (!$this->
object->getSelfAssessmentEditingMode()) {
   192                 $long_menu_text->setRTESupport($this->
object->getId(), 
"qpl", 
"assessment");
   193                 $long_menu_text->setUseRte(
true);
   197             $long_menu_text->setUseTagsForRteOnly(
false);
   200         $long_menu_text->setValue($this->
object->getLongMenuTextValue());
   201         $form->
addItem($long_menu_text);
   203         $tpl = 
new ilTemplate(
'tpl.il_as_qpl_longmenu_question_gap_button_code.html', 
true, 
true, 
'components/ILIAS/TestQuestionPool');
   210         $min_auto_complete = 
new ilNumberInputGUI($this->
lng->txt(
'min_auto_complete'), 
'min_auto_complete');
   212         $auto_complete = $this->
object->getMinAutoComplete();
   213         if ($auto_complete === 0) {
   216         $min_auto_complete->setDecimals(0);
   217         $min_auto_complete->setValue($auto_complete);
   218         $min_auto_complete->setMinValue(1);
   219         $min_auto_complete->setMaxValue(99);
   220         $min_auto_complete->setSize(5);
   221         $form->
addItem($min_auto_complete);
   223         $identical_scoring = 
new ilCheckboxInputGUI($this->
lng->txt(
'identical_scoring'), 
'identical_scoring');
   224         $identical_scoring->setValue(1);
   225         $identical_scoring->setChecked($this->
object->getIdenticalScoring());
   226         $identical_scoring->setInfo($this->
lng->txt(
'identical_scoring_desc'));
   227         $identical_scoring->setRequired(
false);
   228         $form->
addItem($identical_scoring);
   233         $form->
addItem($hidden_correct);
   235         $long_menu_language = [
   236             'edit' => 
'[' . $this->
lng->txt(
'edit') . 
']',
   237             'type' => $this->
lng->txt(
'type'),
   238             'answers' => $this->
lng->txt(
'answers'),
   239             'answer_options' => $this->
lng->txt(
'answer_options'),
   240             'correct_answers' => $this->
lng->txt(
'correct_answers') . 
':',
   241             'add_answers' => 
'[' . $this->
lng->txt(
'add_answers') . 
']',
   242             'manual_editing' => $this->
lng->txt(
'manual_editing')
   246             'list' => json_decode($this->
object->getJsonStructure()) ?? [],
   248             'last_updated_element' => 0,
   249             'replacement_word' => 
'',
   250             'filereader_usable' => 
false,
   253         $answers = $this->
object->getAnswersObject();
   255         if ($this->request_data_collector->isset(
'hidden_text_files')) {
   256             $question_parts[
'list'] = json_decode($this->request_data_collector->raw(
'hidden_correct_answers')) ?? [];
   257             $answers = $this->request_data_collector->raw(
'hidden_text_files');
   260         $this->tpl->addJavaScript(
'assets/js/longMenuQuestionGapBuilder.js');
   261         $this->tpl->addJavaScript(
'assets/js/longMenuQuestion.js');
   262         $tpl = 
new ilTemplate(
"tpl.il_as_qpl_longmenu_question_gap.html", 
true, 
true, 
"components/ILIAS/TestQuestionPool");
   277             $this->ui_factory->symbol()->glyph()->add()->withAction(
'#')
   280             $this->ui_factory->symbol()->glyph()->remove()->withAction(
'#')
   283         $tag_input->setPostVar(
'taggable');
   284         $tag_input->setJsSelfInit(
false);
   285         $tag_input->setTypeAheadMinLength(1);
   288         $modal_id = self::DEFAULT_MODAL_ID;
   291         $this->tpl->addOnLoadCode(
   292             'longMenuQuestion.Init(' .
   294                 json_encode($long_menu_language),
   295                 json_encode($question_parts),
   296                 $answers === 
'' ? 
'{}' : $answers,
   297                 json_encode($modal_id)
   310         $modal = $this->ui_factory->modal()->interruptive(
'', 
'', 
'');
   312         @$doc->loadHTML($this->ui_renderer->render($modal));
   313         $dialogs = $doc->getElementsByTagName(
'dialog');
   314         $modal_id = $dialogs->item(0)->attributes->getNamedItem(
'id')->nodeValue ?? self::DEFAULT_MODAL_ID;
   315         return $doc->saveHTML();
   330         bool $graphical_output = 
false,
   331         bool $result_output = 
false,
   332         bool $show_question_only = 
true,
   333         bool $show_feedback = 
false,
   334         bool $show_correct_solution = 
false,
   335         bool $show_manual_scoring = 
false,
   336         bool $show_question_text = 
true,
   337         bool $show_inline_feedback = 
true   339         if (($active_id > 0) && (!$show_correct_solution)) {
   340             $user_solutions = $this->
object->getSolutionValues($active_id, $pass, 
true);
   342             $user_solutions = [];
   343             foreach ($this->
object->getCorrectAnswersForQuestionSolution($this->object->getId()) as $idx => $val) {
   344                 $user_solutions[] = [
   359             $show_correct_solution,
   360             $show_manual_scoring,
   363             $show_inline_feedback
   368         mixed $user_solutions,
   371         bool $graphical_output = 
false,
   372         bool $result_output = 
false,
   373         bool $show_question_only = 
true,
   374         bool $show_feedback = 
false,
   375         bool $show_correct_solution = 
false,
   376         bool $show_manual_scoring = 
false,
   377         bool $show_question_text = 
true,
   378         bool $show_autosave_title = 
false,
   379         bool $show_inline_feedback = 
false,
   383         foreach ($user_solutions as $idx => $solution_value) {
   384             $user_solution[$solution_value[
"value1"]] = $solution_value[
"value2"];
   387         $template = 
new ilTemplate(
"tpl.il_as_qpl_longmenu_question_output_solution.html", 
true, 
true, 
"components/ILIAS/TestQuestionPool");
   388         if ($show_question_text) {
   389             $template->setVariable(
"QUESTIONTEXT", $this->
object->getQuestionForHTMLOutput());
   393         $solution_template = 
new ilTemplate(
"tpl.il_as_tst_solution_output.html", 
true, 
true, 
"components/ILIAS/TestQuestionPool");
   394         $question_output = $template->get();
   396         if ($show_feedback) {
   399                 $feedback .= strlen($fb) ? $fb : 
'';
   403             $feedback .= strlen($fb) ? $fb : 
'';
   405         if (strlen($feedback)) {
   411             $solution_template->setVariable(
"ILC_FB_CSS_CLASS", $cssClass);
   415         $solution_template->setVariable(
"SOLUTION_OUTPUT", $question_output);
   417         $solution_output = $solution_template->get();
   419         if (!$show_question_only) {
   420             $solution_output = $this->
getILIASPage($solution_output);
   423         return $solution_output;
   427         bool $show_question_only = 
false,
   428         bool $show_inline_feedback = 
false   431         $user_solution = array_values($user_solution);
   435         $question_output = $template->get();
   436         if (!$show_question_only) {
   437             $question_output = $this->
getILIASPage($question_output);
   439         return $question_output;
   445         bool $is_question_postponed = 
false,
   446         array|
bool $user_post_solutions = 
false,
   447         bool $show_specific_inline_feedback = 
false   451             $solutions = $this->
object->getUserSolutionPreferingIntermediate($active_id, $pass);
   452             foreach ($solutions as $idx => $solution_value) {
   453                 $user_solution[$solution_value[
'value1']] = $solution_value[
'value2'];
   459         $question_output = $template->get();
   460         $page_output = $this->
outQuestionPage(
'', $is_question_postponed, $active_id, $question_output);
   466         $template = 
new ilTemplate(
'tpl.il_as_qpl_longmenu_question_output.html', 
true, 
true, 
'components/ILIAS/TestQuestionPool');
   467         $this->tpl->addJavaScript(
'assets/js/longMenuQuestionPlayer.js');
   468         $this->tpl->addOnLoadCode(
'il.test.player.longmenu.init('   469             . $this->
object->getMinAutoComplete() . 
', '   470             . json_encode($this->
object->getAvailableAnswerOptions())
   473         $template->setVariable(
'QUESTIONTEXT', $this->
object->getQuestionForHTMLOutput());
   480         if (!$this->
object->feedbackOBJ->specificAnswerFeedbackExists()) {
   484         $feedback = 
'<table class="test_specific_feedback"><tbody>';
   485         $gaps = $this->
object->getCorrectAnswers();
   486         foreach ($gaps as $index => $answer) {
   488             $caption .= $index + 1 . 
': ';
   490             $feedback .= 
'<tr><td>';
   492             $feedback .= $caption . 
'</td><td>';
   493             $feedback .= $this->
object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
   499         $feedback .= 
'</tbody></table>';
   522         $correct_answers = $this->
object->getCorrectAnswers();
   523         $answers = $this->
object->getAnswers();
   524         foreach ($text_array as $key => $value) {
   525             $answer_is_correct = 
false;
   528             if ($key < 
sizeof($text_array) - 1) {
   529                 if (!array_key_exists($key, $correct_answers)) {
   530                     $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'longmenu_answeroptions_differ'));
   534                     if (array_key_exists($key, $user_solution)) {
   535                         $user_value = $user_solution[$key];
   536                         if (in_array($user_value, $correct_answers[$key][0])) {
   537                             $answer_is_correct = 
true;
   541                     $return_value .= $this->
getTextGapTemplate($key, $user_value, $solution, $answer_is_correct, $graphical);
   543                     if (array_key_exists($key, $user_solution)) {
   544                         $user_value = $user_solution[$key];
   545                         if (in_array($user_value, $correct_answers[$key][0])) {
   546                             $answer_is_correct = 
true;
   549                     $return_value .= $this->
getSelectGapTemplate($key, $answers[$key], $user_value, $solution, $answer_is_correct, $graphical);
   553         return $return_value;
   556     private function getTextGapTemplate($key, $value, $solution, $ok = 
false, $graphical = 
false): string
   558         $tpl = 
new ilTemplate(
'tpl.il_as_qpl_longmenu_question_text_gap.html', 
true, 
true, 
'components/ILIAS/TestQuestionPool');
   579     private function getSelectGapTemplate($key, $answers, $user_value, $solution, $ok = 
false, $graphical = 
false): string
   581         $tpl = 
new ilTemplate(
"tpl.il_as_qpl_longmenu_question_select_gap.html", 
true, 
true, 
"components/ILIAS/TestQuestionPool");
   587             if ($user_value == -1) {
   602             foreach ($answers as $value) {
   605                 if ($value == $user_value) {
   616         return array_keys($this->
object->getAnswers());
   623         foreach ($relevantAnswers as $row) {
   624             if ($row[
'value1'] != $questionIndex) {
   628             if (!isset($answers[$row[
'value2']])) {
   631                 $answers[$row[
'value2']] = [
   632                     'answer' => $row[
'value2'], 
'frequency' => 0
   636             $answers[$row[
'value2']][
'frequency']++;
   646         $table = parent::getAnswerFrequencyTableGUI(
   655                 $DIC->language()->txt(
'tst_corrections_answers_tbl_subindex'),
   656                 $DIC->language()->txt(
'longmenu') . 
' ' . ($questionIndex + 1)
   665         $correct_answers = $this->
object->getCorrectAnswers();
   667         foreach ($this->
object->getAnswers() as $lm_index => $lm) {
   669                 'answers_all' => [0 => $lm],
   670                 'answers_all_count' => count($lm),
   671                 'answers_correct' => $correct_answers[$lm_index][0]
   674             $lm_points = $correct_answers[$lm_index][1];
   677             $section->setTitle($this->
lng->txt(
'longmenu') . 
' ' . ($lm_index + 1));
   681                 $this->
lng->txt(
'answers'),
   682                 'longmenu_' . $lm_index
   687             $lm_input->setValues($lm_values);
   692             $points_inp->setRequired(
true);
   693             $points_inp->allowDecimals(
true);
   694             $points_inp->setSize(4);
   695             $points_inp->setMinValue(0);
   696             $points_inp->setMinvalueShouldBeGreater(
false);
   697             $points_inp->setValue($lm_points);
   704         $correct_answers = $this->
object->getCorrectAnswers();
   706         foreach ($this->
object->getAnswers() as $lm_index => $lm) {
   707             $points_input = (float) str_replace(
',', 
'.', $form->
getInput(
'points_' . $lm_index));
   708             $correct_answers_input = (array) $form->
getInput(
'longmenu_' . $lm_index . 
'_tags');
   710             foreach ($correct_answers_input as $idx => $answer) {
   711                 if (in_array($answer, $lm)) {
   715                 unset($correct_answers_input[$idx]);
   718             $correct_answers[$lm_index][0] = array_values($correct_answers_input);
   719             $correct_answers[$lm_index][1] = $points_input;
   722         $this->
object->setCorrectAnswers($correct_answers);
 isTestPresentationContext()
 
hasCorrectSolution($activeId, $passIndex)
 
generateCorrectnessIconsForCorrectness(int $correctness)
 
static stripSlashesRecursive($a_data, bool $a_strip_html=true, string $a_allow="")
 
setCurrentBlock(string $blockname=self::DEFAULT_BLOCK)
Sets the template to the given block. 
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
ilPropertyFormGUI $editForm
 
buildBasicEditFormObject()
 
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
 
addBasicQuestionFormProperties(ilPropertyFormGUI $form)
 
parseCurrentBlock(string $blockname=self::DEFAULT_BLOCK)
Parses the given block. 
 
const CSS_CLASS_FEEDBACK_CORRECT
 
ilGlobalPageTemplate $tpl
 
populateTaxonomyFormSection(ilPropertyFormGUI $form)
 
addQuestionFormCommandButtons(ilPropertyFormGUI $form)
 
writeQuestionGenericPostData()
 
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string. 
 
const CSS_CLASS_FEEDBACK_WRONG
 
saveTaxonomyAssignments()
 
getILIASPage(string $html="")
Returns the ILIAS Page around a question. 
 
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
 
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins 
 
__construct(Container $dic, ilPlugin $plugin)
 
This class represents a text area property in a property form. 
 
const ADDITIONAL_CONTENT_EDITING_MODE_RTE
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
setVariable(string $variable, $value='')
Sets the given variable to the given value. 
 
static _getUsedHTMLTags(string $a_module="")
Returns an array of all allowed HTML tags for text editing. 
 
renderEditForm(ilPropertyFormGUI $form)
 
getGenericFeedbackOutput(int $active_id, ?int $pass)