ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilTestScoringByQuestionsGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once 'Modules/Test/classes/inc.AssessmentConstants.php';
5include_once 'Modules/Test/classes/class.ilTestScoringGUI.php';
6
16{
20 public function __construct(ilObjTest $a_object)
21 {
22 parent::__construct($a_object);
23 }
24
28 public function executeCommand()
29 {
33 global $ilAccess;
34
35 if (!$ilAccess->checkAccess('write', '', $this->ref_id)) {
36 ilUtil::sendFailure($this->lng->txt('cannot_edit_test'), true);
37 $this->ctrl->redirectByClass('ilobjtestgui', 'infoScreen');
38 }
39
40 require_once 'Modules/Test/classes/class.ilObjAssessmentFolder.php';
42 ilUtil::sendFailure($this->lng->txt('manscoring_not_allowed'), true);
43 $this->ctrl->redirectByClass('ilobjtestgui', 'infoScreen');
44 }
45
46 $cmd = $this->ctrl->getCmd('showManScoringByQuestionParticipantsTable');
47 $next_class = $this->ctrl->getNextClass($this);
48
49 $cmd = $this->getCommand($cmd);
50 $this->buildSubTabs('man_scoring_by_qst');
51 switch ($next_class) {
52 default:
53 $ret = $this->$cmd();
54 break;
55 }
56
57 return $ret;
58 }
59
63 private function showManScoringByQuestionParticipantsTable($manPointsPost = array())
64 {
69 global $tpl, $ilAccess;
70
71 if (!$ilAccess->checkAccess('write', '', $this->ref_id)) {
72 ilUtil::sendInfo($this->lng->txt('cannot_edit_test'), true);
73 $this->ctrl->redirectByClass('ilobjtestgui', 'infoScreen');
74 }
75
76 include_once 'Services/jQuery/classes/class.iljQueryUtil.php';
78
79 include_once 'Services/YUI/classes/class.ilYuiUtil.php';
82
83 $mathJaxSetting = new ilSetting('MathJax');
84 if ($mathJaxSetting->get("enable")) {
85 $tpl->addJavaScript($mathJaxSetting->get("path_to_mathjax"));
86 }
87
88 $tpl->addJavaScript("./Services/JavaScript/js/Basic.js");
89 $tpl->addJavaScript("./Services/Form/js/Form.js");
90 $tpl->addJavascript('./Services/UIComponent/Modal/js/Modal.js');
91 $tpl->addCss($this->object->getTestStyleLocation("output"), "screen");
92
93 $this->lng->toJSMap(array('answer' => $this->lng->txt('answer')));
94
95 require_once 'Modules/Test/classes/tables/class.ilTestManScoringParticipantsBySelectedQuestionAndPassTableGUI.php';
97
98 $table->setManualScoringPointsPostData($manPointsPost);
99
100 $qst_id = $table->getFilterItemByPostVar('question')->getValue();
101 $pass_id = $table->getFilterItemByPostVar('pass')->getValue();
102
103 $table_data = array();
104
105 $selected_questionData = null;
106
107 if (is_numeric($qst_id)) {
110 $selected_questionData = $info;
111 $type = $info["question_type_fi"];
112 if (in_array($type, $scoring)) {
113 $selected_questionData = $info;
114 }
115 }
116
117 if ($selected_questionData && is_numeric($pass_id)) {
118 $data = $this->object->getCompleteEvaluationData(false);
119
120 foreach ($data->getParticipants() as $active_id => $participant) {
121 $testResultData = $this->object->getTestResult($active_id, $pass_id - 1);
122 foreach ($testResultData as $questionData) {
123 if (!isset($questionData['qid']) || $questionData['qid'] != $selected_questionData['question_id']) {
124 continue;
125 }
126
127 $table_data[] = array(
128 'pass_id' => $pass_id - 1,
129 'active_id' => $active_id,
130 'qst_id' => $questionData['qid'],
131 'reached_points' => assQuestion::_getReachedPoints($active_id, $questionData['qid'], $pass_id - 1),
132 'maximum_points' => assQuestion::_getMaximumPoints($questionData['qid']),
133 'participant' => $participant,
134 );
135 }
136 }
137 } else {
138 $table->disable('header');
139 }
140
141 if ($selected_questionData) {
142 $maxpoints = assQuestion::_getMaximumPoints($selected_questionData['question_id']);
143 $table->setCurQuestionMaxPoints($maxpoints);
144 if ($maxpoints == 1) {
145 $maxpoints = ' (' . $maxpoints . ' ' . $this->lng->txt('point') . ')';
146 } else {
147 $maxpoints = ' (' . $maxpoints . ' ' . $this->lng->txt('points') . ')';
148 }
149 $table->setTitle($this->lng->txt('tst_man_scoring_by_qst') . ': ' . $selected_questionData['title'] . $maxpoints . ' [' . $this->lng->txt('question_id_short') . ': ' . $selected_questionData['question_id'] . ']');
150 } else {
151 $table->setTitle($this->lng->txt('tst_man_scoring_by_qst'));
152 }
153
154 $table->setData($table_data);
155 $tpl->setContent($table->getHTML());
156 }
157
158 public function saveManScoringByQuestion()
159 {
163 global $ilAccess, $lng;
164
165 if (!$ilAccess->checkAccess('write', '', $this->ref_id)) {
166 ilUtil::sendInfo($this->lng->txt('cannot_edit_test'), true);
167 $this->ctrl->redirectByClass('ilobjtestgui', 'infoScreen');
168 }
169
170 if (!isset($_POST['scoring']) || !is_array($_POST['scoring'])) {
171 ilUtil::sendFailure($this->lng->txt('tst_save_manscoring_failed_unknown'));
172 $this->showManScoringByQuestionParticipantsTable();
173 return;
174 }
175
176 include_once 'Modules/TestQuestionPool/classes/class.assQuestion.php';
177 include_once 'Modules/Test/classes/class.ilObjTestAccess.php';
178 include_once 'Services/Tracking/classes/class.ilLPStatusWrapper.php';
179
180 $oneExceededMaxPoints = false;
181 $manPointsPost = array();
182 $skipParticipant = array();
183 $maxPointsByQuestionId = array();
184 foreach ($_POST['scoring'] as $pass => $active_ids) {
185 foreach ((array) $active_ids as $active_id => $questions) {
186 // check for existing test result data
187 if (!$this->object->getTestResult($active_id, $pass)) {
188 if (!isset($skipParticipant[$pass])) {
189 $skipParticipant[$pass] = array();
190 }
191
192 $skipParticipant[$pass][$active_id] = true;
193
194 continue;
195 }
196
197 foreach ((array) $questions as $qst_id => $reached_points) {
198 if (!isset($manPointsPost[$pass])) {
199 $manPointsPost[$pass] = array();
200 }
201
202 if (!isset($manPointsPost[$pass][$active_id])) {
203 $manPointsPost[$pass][$active_id] = array();
204 }
205
206 $maxPointsByQuestionId[$qst_id] = assQuestion::_getMaximumPoints($qst_id);
207
208 if ($reached_points > $maxPointsByQuestionId[$qst_id]) {
209 $oneExceededMaxPoints = true;
210 }
211
212 $manPointsPost[$pass][$active_id][$qst_id] = $reached_points;
213 }
214 }
215 }
216
217 if ($oneExceededMaxPoints) {
218 ilUtil::sendFailure(sprintf($this->lng->txt('tst_save_manscoring_failed'), $pass + 1));
219 $this->showManScoringByQuestionParticipantsTable($manPointsPost);
220 return;
221 }
222
223 $changed_one = false;
224 $lastAndHopefullyCurrentQuestionId = null;
225 foreach ($_POST['scoring'] as $pass => $active_ids) {
226 foreach ((array) $active_ids as $active_id => $questions) {
227 $update_participant = false;
228
229 if ($skipParticipant[$pass][$active_id]) {
230 continue;
231 }
232
233 foreach ((array) $questions as $qst_id => $reached_points) {
234 $update_participant = assQuestion::_setReachedPoints(
235 $active_id,
236 $qst_id,
237 $reached_points,
238 $maxPointsByQuestionId[$qst_id],
239 $pass,
240 1,
241 $this->object->areObligationsEnabled()
242 );
243 }
244
245 if ($update_participant) {
246 $changed_one = true;
247
248 $lastAndHopefullyCurrentQuestionId = $qst_id;
249
251 $this->object->getId(),
253 );
254 }
255 }
256 }
257
258 if ($changed_one) {
259 $qTitle = '';
260 if ($lastAndHopefullyCurrentQuestionId) {
261 $question = assQuestion::_instantiateQuestion($lastAndHopefullyCurrentQuestionId);
262 $qTitle = $question->getTitle();
263 }
264 $msg = sprintf(
265 $this->lng->txt('tst_saved_manscoring_by_question_successfully'),
266 $qTitle,
267 $pass + 1
268 );
269 ilUtil::sendSuccess($msg, true);
270
271 require_once './Modules/Test/classes/class.ilTestScoring.php';
272 $scorer = new ilTestScoring($this->object);
273 $scorer->setPreserveManualScores(true);
274 $scorer->recalculateSolutions();
275 }
276
277 $this->showManScoringByQuestionParticipantsTable();
278 }
279
284 {
285 require_once 'Modules/Test/classes/tables/class.ilTestManScoringParticipantsBySelectedQuestionAndPassTableGUI.php';
287 $table->resetOffset();
288 $table->writeFilterToSession();
289 $this->showManScoringByQuestionParticipantsTable();
290 }
291
296 {
297 require_once 'Modules/Test/classes/tables/class.ilTestManScoringParticipantsBySelectedQuestionAndPassTableGUI.php';
299 $table->resetOffset();
300 $table->resetFilter();
301 $this->showManScoringByQuestionParticipantsTable();
302 }
303
304 private function getAnswerDetail()
305 {
309 global $ilAccess;
310
311 if (!$ilAccess->checkAccess('write', '', $this->ref_id)) {
312 exit();
313 }
314
315 $active_id = $_GET['active_id'];
316 $pass = $_GET['pass_id'];
317 $question_id = $_GET['qst_id'];
318
319 $data = $this->object->getCompleteEvaluationData(false);
320 $participant = $data->getParticipant($active_id);
321
322 $question_gui = $this->object->createQuestionGUI('', $question_id);
323
324 $tmp_tpl = new ilTemplate('tpl.il_as_tst_correct_solution_output.html', true, true, 'Modules/Test');
325 $result_output = $question_gui->getSolutionOutput($active_id, $pass, false, false, false, $this->object->getShowSolutionFeedback(), false, true);
326 $tmp_tpl->setVariable('TEXT_YOUR_SOLUTION', $this->lng->txt('answers_of') . ' ' . $participant->getName());
327 $maxpoints = $question_gui->object->getMaximumPoints();
328
329 $add_title = ' [' . $this->lng->txt('question_id_short') . ': ' . $question_id . ']';
330
331 if ($maxpoints == 1) {
332 $tmp_tpl->setVariable('QUESTION_TITLE', $this->object->getQuestionTitle($question_gui->object->getTitle()) . ' (' . $maxpoints . ' ' . $this->lng->txt('point') . ')' . $add_title);
333 } else {
334 $tmp_tpl->setVariable('QUESTION_TITLE', $this->object->getQuestionTitle($question_gui->object->getTitle()) . ' (' . $maxpoints . ' ' . $this->lng->txt('points') . ')' . $add_title);
335 }
336 $tmp_tpl->setVariable('SOLUTION_OUTPUT', $result_output);
337 $tmp_tpl->setVariable('RECEIVED_POINTS', sprintf($this->lng->txt('part_received_a_of_b_points'), $question_gui->object->getReachedPoints($active_id, $pass), $maxpoints));
338
339 echo $tmp_tpl->get();
340 exit();
341 }
342}
sprintf('%.4f', $callTime)
if(strpos( $jquery_path, './')===0) elseif(strpos($jquery_path, '.')===0) $mathJaxSetting
Definition: latex.php:32
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
static _instantiateQuestion($question_id)
static _getReachedPoints($active_id, $question_id, $pass=null)
Returns the points, a learner has reached answering the question.
static _getMaximumPoints($question_id)
Returns the maximum points, a learner can reach answering the question.
static _setReachedPoints($active_id, $question_id, $points, $maxpoints, $pass, $manualscoring, $obligationsEnabled)
Sets the points, a learner has reached answering the question Additionally objective results are upda...
static _getQuestionInfo($question_id)
Returns question information from the database.
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.
static _getManualScoring()
Retrieve the manual scoring settings.
static _mananuallyScoreableQuestionTypesExists()
Returns the fact wether manually scoreable question types exist or not.
static _getParticipantId($active_id)
Get user id for active id.
ILIAS Setting Class.
special template class to simplify handling of ITX/PEAR
Scoring class for tests.
executeCommand()
execute command
Class ilTestScoring.
getCommand($cmd)
Retrieves the ilCtrl command.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static initPanel($a_resize=false, ilTemplate $a_main_tpl=null)
Init yui panel.
static initOverlay(ilTemplate $a_main_tpl=null)
Init YUI Overlay module.
static initjQuery($a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
$info
Definition: index.php:5
$ret
Definition: parser.php:6
$type
if(empty($password)) $table
Definition: pwgen.php:24