ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilTestRandomQuestionSelectionTableGUI.php
Go to the documentation of this file.
1<?php declare(strict_types=1);
2
7{
9 private $test;
10
17 public function __construct($a_parent_obj, string $a_parent_cmd, ilObjTest $test)
18 {
19 $this->test = $test;
20
21 $this->setId('tst_rnd_qst_sel_' . $test->getRefId());
22 parent::__construct($a_parent_obj, $a_parent_cmd, '');
23
24 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
25 $this->setRowTemplate('tpl.il_as_tst_random_question_offer.html', 'Modules/Test');
26 }
27
33 public function build(int $numberOfQuestions, int $selectedPool) : self
34 {
35 $this->setTitle($this->lng->txt('tst_question_offer'));
36
37 $questionIds = $this->test->randomSelectQuestions(
38 $numberOfQuestions,
39 $selectedPool
40 );
41 $questionpools = $this->test->getAvailableQuestionpools(true);
42
43 $data = [];
44 foreach ($questionIds as $questionId) {
45 $dataset = $this->test->getQuestionDataset($questionId);
46 $data[] = [
47 'title' => $dataset->title,
48 'description' => $dataset->description,
49 'type' => assQuestion::_getQuestionTypeName($dataset->type_tag),
50 'author' => $dataset->author,
51 'pool' => $questionpools[$dataset->obj_fi]['title'],
52 ];
53 }
54 $this->setData($data);
55
56 $this->addHiddenInput('nr_of_questions', $numberOfQuestions);
57 $this->addHiddenInput('sel_qpl', $selectedPool);
58 $this->addHiddenInput('chosen_questions', implode(',', $questionIds));
59
60 $this->addColumn($this->lng->txt('tst_question_title'));
61 $this->addColumn($this->lng->txt('description'));
62 $this->addColumn($this->lng->txt('tst_question_type'));
63 $this->addColumn($this->lng->txt('author'));
64 $this->addColumn($this->lng->txt('qpl'));
65
66 $this->setNoEntriesText($this->lng->txt('no_questions_available'));
67
68 if (count($data) > 0) {
69 $this->addCommandButton('insertRandomSelection', $this->lng->txt('random_accept_sample'));
70 $this->addCommandButton('createRandomSelection', $this->lng->txt('random_another_sample'));
71 }
72 $this->addCommandButton('cancelRandomSelect', $this->lng->txt('cancel'));
73
74 return $this;
75 }
76}
An exception for terminatinating execution or to throw for unit testing.
static _getQuestionTypeName($type_tag)
Return the translation for a given question type tag.
getRefId()
get reference id @access public
Class ilTable2GUI.
addHiddenInput($a_name, $a_value)
Add Hidden Input field.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
setNoEntriesText($a_text)
Set text for an empty table.
setData($a_data)
set table data @access public
setRowTemplate($a_template, $a_template_dir="")
Set row template.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setId($a_val)
Set id.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
__construct($a_parent_obj, string $a_parent_cmd, ilObjTest $test)
ilTestRandomQuestionSelectionTableGUI constructor.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc