ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilTestManScoringParticipantsBySelectedQuestionAndPassTableGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once 'Services/Form/classes/class.ilNumberInputGUI.php';
5require_once 'Services/Table/classes/class.ilTable2GUI.php';
6
14{
15 const PARENT_DEFAULT_CMD = 'showManScoringByQuestionParticipantsTable';
16 const PARENT_APPLY_FILTER_CMD = 'applyManScoringByQuestionFilter';
17 const PARENT_RESET_FILTER_CMD = 'resetManScoringByQuestionFilter';
18 const PARENT_SAVE_SCORING_CMD = 'saveManScoringByQuestion';
19
20 private $manPointsPostData = array();
21
22 private $curQuestionMaxPoints = null;
23
27 protected $first_row_rendered = false;
28
29 public function __construct($parentObj)
30 {
31 $this->setFilterCommand(self::PARENT_APPLY_FILTER_CMD);
32 $this->setResetCommand(self::PARENT_RESET_FILTER_CMD);
33
37 global $DIC;
38 $ilCtrl = $DIC['ilCtrl'];
39
40 $this->setId('man_scor_by_qst_' . $parentObj->object->getId());
41
42 parent::__construct($parentObj, self::PARENT_DEFAULT_CMD);
43
44 $this->setFormAction($ilCtrl->getFormAction($parentObj, self::PARENT_DEFAULT_CMD));
45
46 $this->setRowTemplate("tpl.il_as_tst_man_scoring_by_question_tblrow.html", "Modules/Test");
47
48 $this->setShowRowsSelector(true);
49
50 $this->addCommandButton(self::PARENT_SAVE_SCORING_CMD, $this->lng->txt('save'));
51
52 $this->initOrdering();
53 $this->initColumns();
54 $this->initFilter();
55 }
56
57 private function initColumns()
58 {
59 $this->addColumn($this->lng->txt('lastname'), 'lastname', '20%');
60 $this->addColumn($this->lng->txt('firstname'), 'firstname', '20%');
61 $this->addColumn($this->lng->txt('login'), 'login', '20%');
62 $this->addColumn($this->lng->txt('tst_reached_points'), 'reached_points', '20%');
63 $this->addColumn('', '', '20%');
64 }
65
66 private function initOrdering()
67 {
68 $this->enable('sort');
69
70 $this->setDefaultOrderField("lastname");
71 $this->setDefaultOrderDirection("asc");
72 }
73
74 public function initFilter()
75 {
76 $this->setDisableFilterHiding(true);
77
78 include_once 'Services/Form/classes/class.ilSelectInputGUI.php';
79 $available_questions = new ilSelectInputGUI($this->lng->txt('question'), 'question');
80 $select_questions = array();
81 if (!$this->getParentObject()->object->isRandomTest()) {
82 $questions = $this->getParentObject()->object->getTestQuestions();
83 } else {
84 $questions = $this->getParentObject()->object->getPotentialRandomTestQuestions();
85 }
87 foreach ($questions as $data) {
88 include_once 'Modules/TestQuestionPool/classes/class.assQuestion.php';
90 $type = $info["question_type_fi"];
91 if (in_array($type, $scoring)) {
92 $maxpoints = assQuestion::_getMaximumPoints($data["question_id"]);
93 if ($maxpoints == 1) {
94 $maxpoints = ' (' . $maxpoints . ' ' . $this->lng->txt('point') . ')';
95 } else {
96 $maxpoints = ' (' . $maxpoints . ' ' . $this->lng->txt('points') . ')';
97 }
98
99 $select_questions[$data["question_id"]] = $data['title'] . $maxpoints . ' [' . $this->lng->txt('question_id_short') . ': ' . $data["question_id"] . ']';
100 }
101 }
102 if (!$select_questions) {
103 $select_questions[0] = $this->lng->txt('tst_no_scorable_qst_available');
104 }
105 $available_questions->setOptions(array('' => $this->lng->txt('please_choose')) + $select_questions);
106 $this->addFilterItem($available_questions);
107 $available_questions->readFromSession();
108 $this->filter['question'] = $available_questions->getValue();
109
110 $pass = new ilSelectInputGUI($this->lng->txt('pass'), 'pass');
111 $passes = array();
112 $max_pass = $this->getParentObject()->object->getMaxPassOfTest();
113 for ($i = 1; $i <= $max_pass; $i++) {
114 $passes[$i] = $i;
115 }
116 $pass->setOptions($passes);
117 $this->addFilterItem($pass);
118 $pass->readFromSession();
119 $this->filter['pass'] = $pass->getValue();
120 }
121
127 public function fillRow($row)
128 {
132 global $DIC;
133 $ilCtrl = $DIC['ilCtrl'];
134
135 if (!$this->first_row_rendered) {
136 $this->first_row_rendered = true;
137 $this->tpl->touchBlock('row_js');
138 }
139
140 $this->tpl->setVariable('PARTICIPANT_LASTNAME', $row['lastname']);
141 $this->tpl->setVariable('PARTICIPANT_FIRSTNAME', $row['firstname']);
142 $this->tpl->setVariable('PARTICIPANT_LOGIN', $row['login']);
143
144 $reached_points = new ilNumberInputGUI('', 'scoring[' . $row['pass_id'] . '][' . $row['active_id'] . '][' . $row['qst_id'] . ']');
145 $reached_points->allowDecimals(true);
146 $reached_points->setSize(5);
147 if (count($this->manPointsPostData)) {
148 if ($this->isMaxPointsExceededByPostValue($row['pass_id'], $row['active_id'], $row['qst_id'])) {
149 $reached_points->setAlert(sprintf(
150 $this->lng->txt('tst_manscoring_maxpoints_exceeded_input_alert'),
151 $row['maximum_points']
152 ));
153
154 $this->tpl->setCurrentBlock("reached_points_alert");
155 $this->tpl->setVariable("REACHED_POINTS_IMG_ALERT", ilUtil::getImagePath("icon_alert.svg"));
156 $this->tpl->setVariable("REACHED_POINTS_ALT_ALERT", $this->lng->txt("alert"));
157 $this->tpl->setVariable("REACHED_POINTS_TXT_ALERT", $reached_points->getAlert());
158 $this->tpl->parseCurrentBlock();
159 }
160
161 $reached_points->setValue($this->manPointsPostData[$row['pass_id']][$row['active_id']][$row['qst_id']]);
162 } else {
163 $reached_points->setValue($row['reached_points']);
164 }
165 $this->tpl->setVariable('VAL_REACHED_POINTS', $reached_points->render());
166
167 $ilCtrl->setParameter($this->getParentObject(), 'qst_id', $row['qst_id']);
168 $ilCtrl->setParameter($this->getParentObject(), 'active_id', $row['active_id']);
169 $ilCtrl->setParameter($this->getParentObject(), 'pass_id', $row['pass_id']);
170 $this->tpl->setVariable('VAL_LINK_ANSWER', $ilCtrl->getLinkTarget($this->getParentObject(), 'getAnswerDetail', '', true, false));
171 $ilCtrl->setParameter($this->getParentObject(), 'qst_id', '');
172 $ilCtrl->setParameter($this->getParentObject(), 'active_id', '');
173 $ilCtrl->setParameter($this->getParentObject(), 'pass_id', '');
174 $this->tpl->setVariable('VAL_TXT_ANSWER', $this->lng->txt('tst_eval_show_answer'));
175 }
176
177 private function isMaxPointsExceededByPostValue($pass_id, $active_id, $qst_id)
178 {
179 if (!isset($this->manPointsPostData[$pass_id])) {
180 return false;
181 }
182
183 if (!isset($this->manPointsPostData[$pass_id][$active_id])) {
184 return false;
185 }
186
187 if (!isset($this->manPointsPostData[$pass_id][$active_id][$qst_id])) {
188 return false;
189 }
190
191 $submittedPoints = $this->manPointsPostData[$pass_id][$active_id][$qst_id];
192
193 return $submittedPoints > $this->getCurQuestionMaxPoints();
194 }
195
197 {
198 $this->manPointsPostData = $manPointsPostData;
199 }
200
201 public function getCurQuestionMaxPoints()
202 {
204 }
205
207 {
208 $this->curQuestionMaxPoints = $curQuestionMaxPoints;
209 }
210}
An exception for terminatinating execution or to throw for unit testing.
static _getMaximumPoints($question_id)
Returns the maximum points, a learner can reach answering the question.
static _getQuestionInfo($question_id)
Returns question information from the database.
This class represents a number property in a property form.
static _getManualScoring()
Retrieve the manual scoring settings.
This class represents a selection list property in a property form.
Class ilTable2GUI.
setDisableFilterHiding($a_val=true)
Set disable filter hiding.
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
getParentObject()
Get parent object.
fillRow($a_set)
Standard Version of Fill Row.
setResetCommand($a_val, $a_caption=null)
Set reset filter command.
__construct($a_parent_obj, $a_parent_cmd="", $a_template_context="")
ilTable2GUI constructor.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
addFilterItem($a_input_item, $a_optional=false)
Add filter item.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
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.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setFilterCommand($a_val, $a_caption=null)
Set filter command.
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
enable($a_module_name)
enables particular modules of table
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
$i
Definition: disco.tpl.php:19
global $ilCtrl
Definition: ilias.php:18
$info
Definition: index.php:5
$row
$type
global $DIC
Definition: saml.php:7