ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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 public function __construct($parentObj)
23 {
24 $this->setFilterCommand(self::PARENT_APPLY_FILTER_CMD);
25 $this->setResetCommand(self::PARENT_RESET_FILTER_CMD);
26
30 global $ilCtrl;
31
32 $this->setId('man_scor_by_qst_' . $parentObj->object->getId());
33
34 parent::__construct($parentObj, self::PARENT_DEFAULT_CMD);
35
36 $this->disable('sort');
37
38 $this->setFormAction($ilCtrl->getFormAction($parentObj, self::PARENT_DEFAULT_CMD));
39
40 $this->setRowTemplate("tpl.il_as_tst_man_scoring_by_question_tblrow.html", "Modules/Test");
41
42 $this->setShowRowsSelector(true);
43
44 $this->addCommandButton(self::PARENT_SAVE_SCORING_CMD, $this->lng->txt('save'));
45
46 $this->initColumns();
47 $this->initFilter();
48 }
49
50 private function initColumns()
51 {
52 $this->addColumn($this->lng->txt('name'), 'lastname', '40%');
53 $this->addColumn($this->lng->txt('tst_reached_points'), 'lastname', '40%');
54 $this->addColumn('', '', '20%');
55 }
56
57 public function initFilter()
58 {
59 $this->setDisableFilterHiding(true);
60
61 include_once 'Services/Form/classes/class.ilSelectInputGUI.php';
62 $available_questions = new ilSelectInputGUI($this->lng->txt('question'), 'question');
63 $select_questions = array();
64 if(!$this->getParentObject()->object->isRandomTest())
65 {
66 $questions = $this->getParentObject()->object->getTestQuestions();
67 }
68 else
69 {
70 $questions = $this->getParentObject()->object->getPotentialRandomTestQuestions();
71 }
73 foreach($questions as $data)
74 {
75 include_once 'Modules/TestQuestionPool/classes/class.assQuestion.php';
76 $info = assQuestion::_getQuestionInfo($data['question_id']);
77 $type = $info["question_type_fi"];
78 if(in_array($type, $scoring))
79 {
80 $maxpoints = assQuestion::_getMaximumPoints($data["question_id"]);
81 if($maxpoints == 1)
82 {
83 $maxpoints = ' (' . $maxpoints . ' ' . $this->lng->txt('point') . ')';
84 }
85 else
86 {
87 $maxpoints = ' (' . $maxpoints . ' ' . $this->lng->txt('points') . ')';
88 }
89
90 $select_questions[$data["question_id"]] = $data['title'] . $maxpoints. ' ['. $this->lng->txt('question_id_short') . ': ' . $data["question_id"] . ']';
91 }
92 }
93 if(!$select_questions)
94 {
95 $select_questions[0] = $this->lng->txt('tst_no_scorable_qst_available');
96 }
97 $available_questions->setOptions(array('' => $this->lng->txt('please_choose')) + $select_questions);
98 $this->addFilterItem($available_questions);
99 $available_questions->readFromSession();
100 $this->filter['question'] = $available_questions->getValue();
101
102 $pass = new ilSelectInputGUI($this->lng->txt('pass'), 'pass');
103 $passes = array();
104 $max_pass = $this->getParentObject()->object->getMaxPassOfTest();
105 for($i = 1; $i <= $max_pass; $i++)
106 {
107 $passes[$i] = $i;
108 }
109 $pass->setOptions($passes);
110 $this->addFilterItem($pass);
111 $pass->readFromSession();
112 $this->filter['pass'] = $pass->getValue();
113 }
114
120 public function fillRow($row)
121 {
125 global $ilCtrl;
126
127 $this->tpl->setVariable('VAL_NAME', $row['participant']->getName());
128 $reached_points = new ilNumberInputGUI('', 'scoring[' . $row['pass_id'] . '][' . $row['active_id'] . '][' . $row['qst_id'] . ']');
129 $reached_points->allowDecimals(true);
130 $reached_points->setSize(5);
131 if( count($this->manPointsPostData) )
132 {
133 if( $this->isMaxPointsExceededByPostValue($row['pass_id'], $row['active_id'], $row['qst_id']) )
134 {
135 $reached_points->setAlert( sprintf(
136 $this->lng->txt('tst_manscoring_maxpoints_exceeded_input_alert'), $row['maximum_points']
137 ));
138
139 $this->tpl->setCurrentBlock("reached_points_alert");
140 $this->tpl->setVariable("REACHED_POINTS_IMG_ALERT", ilUtil::getImagePath("icon_alert.svg"));
141 $this->tpl->setVariable("REACHED_POINTS_ALT_ALERT", $this->lng->txt("alert"));
142 $this->tpl->setVariable("REACHED_POINTS_TXT_ALERT", $reached_points->getAlert());
143 $this->tpl->parseCurrentBlock();
144 }
145
146 $reached_points->setValue($this->manPointsPostData[$row['pass_id']][$row['active_id']][$row['qst_id']]);
147 }
148 else
149 {
150 $reached_points->setValue($row['reached_points']);
151 }
152 $this->tpl->setVariable('VAL_REACHED_POINTS', $reached_points->render());
153 $this->tpl->setVariable('VAL_ID', md5($row['pass_id'] . $row['active_id'] . $row['qst_id']));
154
155 $ilCtrl->setParameter($this->getParentObject(), 'qst_id', $row['qst_id']);
156 $ilCtrl->setParameter($this->getParentObject(), 'active_id', $row['active_id']);
157 $ilCtrl->setParameter($this->getParentObject(), 'pass_id', $row['pass_id']);
158 $this->tpl->setVariable('VAL_LINK_ANSWER', $ilCtrl->getLinkTarget($this->getParentObject(), 'getAnswerDetail', '', true, false));
159 $ilCtrl->setParameter($this->getParentObject(), 'qst_id', '');
160 $ilCtrl->setParameter($this->getParentObject(), 'active_id', '');
161 $ilCtrl->setParameter($this->getParentObject(), 'pass_id', '');
162 $this->tpl->setVariable('VAL_TXT_ANSWER', $this->lng->txt('tst_eval_show_answer'));
163 }
164
165 private function isMaxPointsExceededByPostValue($pass_id, $active_id, $qst_id)
166 {
167 if( !isset($this->manPointsPostData[$pass_id]) )
168 {
169 return false;
170 }
171
172 if( !isset($this->manPointsPostData[$pass_id][$active_id]) )
173 {
174 return false;
175 }
176
177 if( !isset($this->manPointsPostData[$pass_id][$active_id][$qst_id]) )
178 {
179 return false;
180 }
181
182 return $this->manPointsPostData[$pass_id][$active_id][$qst_id];
183 }
184
186 {
187 $this->manPointsPostData = $manPointsPostData;
188 }
189}
_getMaximumPoints($question_id)
Returns the maximum points, a learner can reach answering the question.
& _getQuestionInfo($question_id)
Returns question information from the database.
This class represents a number property in a property form.
_getManualScoring()
Retrieve the manual scoring settings.
This class represents a selection list property in a property form.
Class ilTable2GUI.
addColumn($a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="")
Add a column to the header.
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="")
Constructor.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
addFilterItem($a_input_item, $a_optional=false)
Add filter item.
setId($a_val)
Set id.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setFilterCommand($a_val, $a_caption=null)
Set filter command.
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
disable($a_module_name)
diesables particular modules of table
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
global $ilCtrl
Definition: ilias.php:18