ILIAS  release_8 Revision v8.25-1-g13de6a5eca6
class.ilTestRandomQuestionSelectionTableGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
25{
27
28 public function __construct($a_parent_obj, string $a_parent_cmd, ilObjTest $test)
29 {
30 $this->test = $test;
31
32 $this->setId('tst_rnd_qst_sel_' . $test->getRefId());
33 parent::__construct($a_parent_obj, $a_parent_cmd, '');
34
35 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
36 $this->setRowTemplate('tpl.il_as_tst_random_question_offer.html', 'Modules/Test');
37 }
38
39 public function build(int $numberOfQuestions, int $selectedPool): self
40 {
41 $this->setTitle($this->lng->txt('tst_question_offer'));
42
43 $questionIds = $this->test->randomSelectQuestions(
44 $numberOfQuestions,
45 $selectedPool
46 );
47 $questionpools = $this->test->getAvailableQuestionpools(true);
48
49 $data = [];
50 foreach ($questionIds as $questionId) {
51 $dataset = $this->test->getQuestionDataset($questionId);
52 $data[] = [
53 'title' => $dataset->title,
54 'description' => $dataset->description,
55 'type' => assQuestion::_getQuestionTypeName($dataset->type_tag),
56 'author' => $dataset->author,
57 'pool' => $questionpools[$dataset->obj_fi]['title'],
58 ];
59 }
60 $this->setData($data);
61
62 $this->addHiddenInput('nr_of_questions', (string) $numberOfQuestions);
63 $this->addHiddenInput('sel_qpl', (string) $selectedPool);
64 $this->addHiddenInput('chosen_questions', implode(',', $questionIds));
65
66 $this->addColumn($this->lng->txt('tst_question_title'));
67 $this->addColumn($this->lng->txt('description'));
68 $this->addColumn($this->lng->txt('tst_question_type'));
69 $this->addColumn($this->lng->txt('author'));
70 $this->addColumn($this->lng->txt('qpl'));
71
72 $this->setNoEntriesText($this->lng->txt('no_questions_available'));
73
74 if (count($data) > 0) {
75 $this->addCommandButton('insertRandomSelection', $this->lng->txt('random_accept_sample'));
76 $this->addCommandButton('createRandomSelection', $this->lng->txt('random_another_sample'));
77 }
78 $this->addCommandButton('cancelRandomSelect', $this->lng->txt('cancel'));
79
80 return $this;
81 }
82}
static _getQuestionTypeName($type_tag)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
addHiddenInput(string $a_name, string $a_value)
setFormAction(string $a_form_action, bool $a_multipart=false)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setNoEntriesText(string $a_text)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
setData(array $a_data)
Set table data.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct($a_parent_obj, string $a_parent_cmd, ilObjTest $test)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc