ILIAS  trunk Revision v12.0_alpha-16-g3e876e53c80
ilLOTestAssignmentTableDataRetrieval Class Reference
+ Inheritance diagram for ilLOTestAssignmentTableDataRetrieval:
+ Collaboration diagram for ilLOTestAssignmentTableDataRetrieval:

Public Member Functions

 __construct (protected ilLanguage $lng, protected ilDBInterface $db, protected ilUIServices $ui_services, protected ilCtrl $ctrl, protected int $assignment_type)
 
 getRows (\ILIAS\UI\Component\Table\DataRowBuilder $row_builder, array $visible_column_ids, \ILIAS\Data\Range $range, \ILIAS\Data\Order $order, mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
 
 getTotalRowCount (mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
 Mainly for the purpose of pagination-support, it is important to know about the total number of records available. More...
 
 parseSingleAssignment (int $a_tst_ref_id, int $a_objective_id=0)
 
 parseMultipleAssignments (int $container_id, int $test_type)
 
 allIds ()
 
- Public Member Functions inherited from ILIAS\UI\Component\Table\DataRetrieval
 getRows (DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
 This is called by the table to retrieve rows; map data-records to rows using the $row_builder e.g. More...
 
 getTotalRowCount (mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
 Mainly for the purpose of pagination-support, it is important to know about the total number of records available. More...
 

Protected Member Functions

 doParse (int $a_tst_ref_id, int $a_objective_id=0)
 

Protected Attributes

array $data
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilLOTestAssignmentTableDataRetrieval::__construct ( protected ilLanguage  $lng,
protected ilDBInterface  $db,
protected ilUIServices  $ui_services,
protected ilCtrl  $ctrl,
protected int  $assignment_type 
)

Definition at line 28 of file class.ilLOTestAssignmentTableDataRetrieval.php.

34 {
35 }

Member Function Documentation

◆ allIds()

ilLOTestAssignmentTableDataRetrieval::allIds ( )

Definition at line 186 of file class.ilLOTestAssignmentTableDataRetrieval.php.

186 : array
187 {
188 $ids = [];
189 foreach ($this->data as $assignment) {
191 ? $assignment['assignment_id']
192 : $assignment['ref_id'];
193 $ids[] = $id;
194 }
195 return $ids;
196 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

References $id, and ilLOTestAssignmentTableGUI\TYPE_MULTIPLE_ASSIGNMENTS.

◆ doParse()

ilLOTestAssignmentTableDataRetrieval::doParse ( int  $a_tst_ref_id,
int  $a_objective_id = 0 
)
protected

Definition at line 101 of file class.ilLOTestAssignmentTableDataRetrieval.php.

104 : array {
105 $tst = ilObjectFactory::getInstanceByRefId($a_tst_ref_id, false);
106 if (!$tst instanceof ilObjTest) {
107 throw new ilLOInvalidConfigurationException('No valid test given');
108 }
109 $tst_data['ref_id'] = $tst->getRefId();
110 $tst_data['title'] = $tst->getTitle();
111 $tst_data['description'] = $tst->getLongDescription();
112 $tst_data['ttype'] = $tst->getQuestionSetType();
113 if ($this->assignment_type == ilLOTestAssignmentTableGUI::TYPE_MULTIPLE_ASSIGNMENTS) {
114 $tst_data['objective'] = ilCourseObjective::lookupObjectiveTitle($a_objective_id);
115 }
116 switch ($tst->getQuestionSetType()) {
118 $tst_data['qst_info'] = $this->lng->txt('crs_loc_tst_num_qst');
119 $tst_data['qst_info'] .= (' ' . count($tst->getAllQuestions()));
120 break;
121 default:
122 // get available assiged question pools
124 $GLOBALS['DIC']['ilDB'],
125 $tst,
127 $GLOBALS['DIC']['ilDB'],
128 $tst
129 )
130 );
131 $list->loadDefinitions();
132 // tax translations
133 $translator = new ilTestQuestionFilterLabelTranslator($this->db, $this->lng);
134 $translator->loadLabels($list);
135 $tst_data['qst_info'] = $this->lng->txt('crs_loc_tst_qpls');
136 $num = 0;
137 foreach ($list as $definition) {
138 $title = $definition->getPoolTitle();
139 $filterTitle = [];
140 $filterTitle[] = $translator->getTaxonomyFilterLabel($definition->getMappedTaxonomyFilter());
141 $filterTitle[] = $translator->getTypeFilterLabel($definition->getTypeFilter());
142 if (!empty($filterTitle)) {
143 $title .= ' -> ' . implode(' / ', $filterTitle);
144 }
145 $tst_data['qpls'][] = $title;
146 ++$num;
147 }
148 if ($num === 0) {
149 $tst_data['qst_info'] .= (' ' . 0);
150 }
151 break;
152 }
153 return $tst_data;
154 }
static lookupObjectiveTitle(int $a_objective_id, bool $a_add_description=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const QUESTION_SET_TYPE_FIXED
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
$GLOBALS["DIC"]
Definition: wac.php:54

◆ getRows()

ilLOTestAssignmentTableDataRetrieval::getRows ( \ILIAS\UI\Component\Table\DataRowBuilder  $row_builder,
array  $visible_column_ids,
\ILIAS\Data\Range  $range,
\ILIAS\Data\Order  $order,
mixed  $additional_viewcontrol_data,
mixed  $filter_data,
mixed  $additional_parameters 
)

Definition at line 37 of file class.ilLOTestAssignmentTableDataRetrieval.php.

45 : Generator {
46 [$column_name, $direction] = $order->join([], fn($ret, $key, $value) => [$key, $value]);
48 uasort($this->data, function ($a, $b) {
49 return strcmp($a['title'], $b['title']);
50 });
51 }
52 if ($direction === 'DESC') {
53 $rows = array_reverse($this->data);
54 } else {
55 $rows = $this->data;
56 }
57 foreach ($rows as $row) {
59 ? $row['assignment_id']
60 : $row['ref_id'];
61 $type = '';
62 switch ($row['ttype']) {
64 $type = $this->lng->txt('tst_question_set_type_fixed');
65 break;
66
68 $type = $this->lng->txt('tst_question_set_type_random');
69 break;
70 }
71 $this->ctrl->setParameterByClass('ilobjtestgui', 'ref_id', $row['ref_id']);
72 $this->ctrl->setParameterByClass('ilobjtestgui', 'cmd', 'questionsTabGateway');
73 $title_link = $this->ui_services->factory()->link()->standard($row['title'], $this->ctrl->getLinkTargetByClass('ilobjtestgui'));
74 $data = [];
76 if ($this->assignment_type === ilLOTestAssignmentTableGUI::TYPE_MULTIPLE_ASSIGNMENTS) {
78 }
81
82 if (isset($row['qpls']) && count($row['qpls']) > 0) {
83 $data[ilLOTestAssignmentTableGUI::TABLE_COL_QESTIONS] .= '<br>' . implode('<br>', $row['qpls']);
84 }
85
86 yield $row_builder->buildDataRow(
87 $id . '',
88 $data
89 );
90 }
91 }
const QUESTION_SET_TYPE_RANDOM
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples

References Vendor\Package\$a, and Vendor\Package\$b.

◆ getTotalRowCount()

ilLOTestAssignmentTableDataRetrieval::getTotalRowCount ( mixed  $additional_viewcontrol_data,
mixed  $filter_data,
mixed  $additional_parameters 
)

Mainly for the purpose of pagination-support, it is important to know about the total number of records available.

Given the nature of a DataTable, which is, opposite to a PresentationTable, rather administrative than explorative, this information will increase user experience quite a bit. However, you may return null, if the call is to costly, but expect the View Control to look a little different in this case.

Make sure that potential filters or user restrictions are being applied to the count.

Implements ILIAS\UI\Component\Table\DataRetrieval.

Definition at line 93 of file class.ilLOTestAssignmentTableDataRetrieval.php.

97 : ?int {
98 return count($this->data);
99 }

◆ parseMultipleAssignments()

ilLOTestAssignmentTableDataRetrieval::parseMultipleAssignments ( int  $container_id,
int  $test_type 
)

Definition at line 163 of file class.ilLOTestAssignmentTableDataRetrieval.php.

166 : void {
167 $assignments = ilLOTestAssignments::getInstance($container_id);
168 $available = $assignments->getAssignmentsByType($test_type);
169 $data = [];
170 foreach ($available as $assignment) {
171 try {
172 $tmp = $this->doParse($assignment->getTestRefId(), $assignment->getObjectiveId());
174 $assignment->delete();
175 continue;
176 }
177 if ($tmp !== []) {
178 // add assignment id
179 $tmp['assignment_id'] = $assignment->getAssignmentId();
180 $data[] = $tmp;
181 }
182 }
183 $this->data = $data;
184 }
static getInstance(int $a_container_id)

References $data, and Vendor\Package\$e.

◆ parseSingleAssignment()

ilLOTestAssignmentTableDataRetrieval::parseSingleAssignment ( int  $a_tst_ref_id,
int  $a_objective_id = 0 
)

Definition at line 156 of file class.ilLOTestAssignmentTableDataRetrieval.php.

159 : void {
160 $this->data = [$this->doParse($a_tst_ref_id, $a_objective_id)];
161 }

Field Documentation

◆ $data

array ilLOTestAssignmentTableDataRetrieval::$data
protected

The documentation for this class was generated from the following file: