ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 {
37 ilUtil::sendFailure($this->lng->txt('cannot_edit_test'), true);
38 $this->ctrl->redirectByClass('ilobjtestgui', 'infoScreen');
39 }
40
41 require_once 'Modules/Test/classes/class.ilObjAssessmentFolder.php';
43 {
44 ilUtil::sendFailure($this->lng->txt('manscoring_not_allowed'), true);
45 $this->ctrl->redirectByClass('ilobjtestgui', 'infoScreen');
46 }
47
48 $cmd = $this->ctrl->getCmd('showManScoringByQuestionParticipantsTable');
49 $next_class = $this->ctrl->getNextClass($this);
50
51 $cmd = $this->getCommand($cmd);
52 $this->buildSubTabs('man_scoring_by_qst');
53 switch($next_class)
54 {
55 default:
56 $ret = $this->$cmd();
57 break;
58 }
59
60 return $ret;
61 }
62
66 private function showManScoringByQuestionParticipantsTable($manPointsPost = array())
67 {
72 global $tpl, $ilAccess;
73
74 if(!$ilAccess->checkAccess('write', '', $this->ref_id))
75 {
76 ilUtil::sendInfo($this->lng->txt('cannot_edit_test'), true);
77 $this->ctrl->redirectByClass('ilobjtestgui', 'infoScreen');
78 }
79
80 include_once 'Services/jQuery/classes/class.iljQueryUtil.php';
82
83 include_once 'Services/YUI/classes/class.ilYuiUtil.php';
86
87 $mathJaxSetting = new ilSetting('MathJax');
88 if($mathJaxSetting->get("enable"))
89 {
90 $tpl->addJavaScript($mathJaxSetting->get("path_to_mathjax"));
91 }
92
93 $tpl->addJavaScript("./Services/JavaScript/js/Basic.js");
94 $tpl->addJavaScript("./Services/Form/js/Form.js");
95 $tpl->addJavascript('./Services/UIComponent/Modal/js/Modal.js');
96 $tpl->addCss($this->object->getTestStyleLocation("output"), "screen");
97
98 $this->lng->toJSMap(array('answer' => $this->lng->txt('answer')));
99
100 require_once 'Modules/Test/classes/tables/class.ilTestManScoringParticipantsBySelectedQuestionAndPassTableGUI.php';
102
103 $table->setManualScoringPointsPostData($manPointsPost);
104
105 $qst_id = $table->getFilterItemByPostVar('question')->getValue();
106 $pass_id = $table->getFilterItemByPostVar('pass')->getValue();
107
108 $table_data = array();
109
110 $selected_questionData = null;
111
112 if(is_numeric($qst_id))
113 {
116 $selected_questionData = $info;
117 $type = $info["question_type_fi"];
118 if(in_array($type, $scoring))
119 {
120 $selected_questionData = $info;
121 }
122 }
123
124 if($selected_questionData && is_numeric($pass_id))
125 {
126 $data = $this->object->getCompleteEvaluationData(FALSE);
127
128 foreach($data->getParticipants() as $active_id => $participant)
129 {
130 $testResultData = $this->object->getTestResult($active_id, $pass_id - 1);
131 foreach($testResultData as $questionData)
132 {
133 if( !isset($questionData['qid']) || $questionData['qid'] != $selected_questionData['question_id'] )
134 {
135 continue;
136 }
137
138 $table_data[] = array(
139 'pass_id' => $pass_id - 1,
140 'active_id' => $active_id,
141 'qst_id' => $questionData['qid'],
142 'reached_points' => assQuestion::_getReachedPoints($active_id, $questionData['qid'], $pass_id - 1),
143 'maximum_points' => assQuestion::_getMaximumPoints($questionData['qid']),
144 'participant' => $participant,
145 );
146 }
147 }
148 }
149 else
150 {
151 $table->disable('header');
152 }
153
154 if($selected_questionData)
155 {
156 $maxpoints = assQuestion::_getMaximumPoints($selected_questionData['question_id']);
157 $table->setCurQuestionMaxPoints($maxpoints);
158 if($maxpoints == 1)
159 {
160 $maxpoints = ' (' . $maxpoints . ' ' . $this->lng->txt('point') . ')';
161 }
162 else
163 {
164 $maxpoints = ' (' . $maxpoints . ' ' . $this->lng->txt('points') . ')';
165 }
166 $table->setTitle($this->lng->txt('tst_man_scoring_by_qst') . ': ' . $selected_questionData['title'] . $maxpoints . ' ['. $this->lng->txt('question_id_short') . ': ' . $selected_questionData['question_id'] . ']');
167 }
168 else
169 {
170 $table->setTitle($this->lng->txt('tst_man_scoring_by_qst'));
171 }
172
173 $table->setData($table_data);
174 $tpl->setContent($table->getHTML());
175 }
176
177 public function saveManScoringByQuestion()
178 {
182 global $ilAccess, $lng;
183
184 if(!$ilAccess->checkAccess('write', '', $this->ref_id))
185 {
186 ilUtil::sendInfo($this->lng->txt('cannot_edit_test'), true);
187 $this->ctrl->redirectByClass('ilobjtestgui', 'infoScreen');
188 }
189
190 if(!isset($_POST['scoring']) || !is_array($_POST['scoring']))
191 {
192 ilUtil::sendFailure($this->lng->txt('tst_save_manscoring_failed_unknown'));
193 $this->showManScoringByQuestionParticipantsTable();
194 return;
195 }
196
197 include_once 'Modules/TestQuestionPool/classes/class.assQuestion.php';
198 include_once 'Modules/Test/classes/class.ilObjTestAccess.php';
199 include_once 'Services/Tracking/classes/class.ilLPStatusWrapper.php';
200
201 $oneExceededMaxPoints = false;
202 $manPointsPost = array();
203 $skipParticipant = array();
204 $maxPointsByQuestionId = array();
205 foreach($_POST['scoring'] as $pass => $active_ids)
206 {
207 foreach((array)$active_ids as $active_id => $questions)
208 {
209 // check for existing test result data
210 if( !$this->object->getTestResult($active_id, $pass) )
211 {
212 if( !isset($skipParticipant[$pass]) )
213 {
214 $skipParticipant[$pass] = array();
215 }
216
217 $skipParticipant[$pass][$active_id] = true;
218
219 continue;
220 }
221
222 foreach((array)$questions as $qst_id => $reached_points)
223 {
224 if( !isset($manPointsPost[$pass]) )
225 {
226 $manPointsPost[$pass] = array();
227 }
228
229 if( !isset($manPointsPost[$pass][$active_id]) )
230 {
231 $manPointsPost[$pass][$active_id] = array();
232 }
233
234 $maxPointsByQuestionId[$qst_id] = assQuestion::_getMaximumPoints($qst_id);
235
236 if( $reached_points > $maxPointsByQuestionId[$qst_id] )
237 {
238 $oneExceededMaxPoints = true;
239 }
240
241 $manPointsPost[$pass][$active_id][$qst_id] = $reached_points;
242 }
243 }
244 }
245
246 if( $oneExceededMaxPoints )
247 {
248 ilUtil::sendFailure(sprintf($this->lng->txt('tst_save_manscoring_failed'), $pass + 1));
249 $this->showManScoringByQuestionParticipantsTable($manPointsPost);
250 return;
251 }
252
253 $changed_one = false;
254 $lastAndHopefullyCurrentQuestionId = null;
255 foreach($_POST['scoring'] as $pass => $active_ids)
256 {
257 foreach((array)$active_ids as $active_id => $questions)
258 {
259 $update_participant = false;
260
261 if($skipParticipant[$pass][$active_id])
262 {
263 continue;
264 }
265
266 foreach((array)$questions as $qst_id => $reached_points)
267 {
268 $update_participant = assQuestion::_setReachedPoints(
269 $active_id, $qst_id, $reached_points, $maxPointsByQuestionId[$qst_id], $pass, 1, $this->object->areObligationsEnabled()
270 );
271 }
272
273 if($update_participant)
274 {
275 $changed_one = true;
276
277 $lastAndHopefullyCurrentQuestionId = $qst_id;
278
280 $this->object->getId(), ilObjTestAccess::_getParticipantId($active_id)
281 );
282 }
283 }
284 }
285
286 if($changed_one)
287 {
288 $qTitle = '';
289 if($lastAndHopefullyCurrentQuestionId)
290 {
291 $question = assQuestion::_instantiateQuestion($lastAndHopefullyCurrentQuestionId);
292 $qTitle = $question->getTitle();
293 }
294 $msg = sprintf(
295 $this->lng->txt('tst_saved_manscoring_by_question_successfully'), $qTitle, $pass + 1
296 );
297 ilUtil::sendSuccess($msg, true);
298
299 require_once './Modules/Test/classes/class.ilTestScoring.php';
300 $scorer = new ilTestScoring($this->object);
301 $scorer->setPreserveManualScores(true);
302 $scorer->recalculateSolutions();
303 }
304
305 $this->showManScoringByQuestionParticipantsTable();
306 }
307
312 {
313 require_once 'Modules/Test/classes/tables/class.ilTestManScoringParticipantsBySelectedQuestionAndPassTableGUI.php';
315 $table->resetOffset();
316 $table->writeFilterToSession();
317 $this->showManScoringByQuestionParticipantsTable();
318 }
319
324 {
325 require_once 'Modules/Test/classes/tables/class.ilTestManScoringParticipantsBySelectedQuestionAndPassTableGUI.php';
327 $table->resetOffset();
328 $table->resetFilter();
329 $this->showManScoringByQuestionParticipantsTable();
330 }
331
332 private function getAnswerDetail()
333 {
337 global $ilAccess;
338
339 if(!$ilAccess->checkAccess('write', '', $this->ref_id))
340 {
341 exit();
342 }
343
344 $active_id = $_GET['active_id'];
345 $pass = $_GET['pass_id'];
346 $question_id = $_GET['qst_id'];
347
348 $data = $this->object->getCompleteEvaluationData(FALSE);
349 $participant = $data->getParticipant($active_id);
350
351 $question_gui = $this->object->createQuestionGUI('', $question_id);
352
353 $tmp_tpl = new ilTemplate('tpl.il_as_tst_correct_solution_output.html', TRUE, TRUE, 'Modules/Test');
354 $result_output = $question_gui->getSolutionOutput($active_id, $pass, FALSE, FALSE, FALSE, $this->object->getShowSolutionFeedback(), FALSE, TRUE);
355 $tmp_tpl->setVariable('TEXT_YOUR_SOLUTION', $this->lng->txt('answers_of') .' '. $participant->getName());
356 $maxpoints = $question_gui->object->getMaximumPoints();
357
358 $add_title = ' ['. $this->lng->txt('question_id_short') . ': ' . $question_id . ']';
359
360 if($maxpoints == 1)
361 {
362 $tmp_tpl->setVariable('QUESTION_TITLE', $this->object->getQuestionTitle($question_gui->object->getTitle()) . ' (' . $maxpoints . ' ' . $this->lng->txt('point') . ')' . $add_title);
363 }
364 else
365 {
366 $tmp_tpl->setVariable('QUESTION_TITLE', $this->object->getQuestionTitle($question_gui->object->getTitle()) . ' (' . $maxpoints . ' ' . $this->lng->txt('points') . ')' . $add_title);
367 }
368 $tmp_tpl->setVariable('SOLUTION_OUTPUT', $result_output);
369 $tmp_tpl->setVariable('RECEIVED_POINTS', sprintf($this->lng->txt('part_received_a_of_b_points'), $question_gui->object->getReachedPoints($active_id, $pass), $maxpoints));
370
371 echo $tmp_tpl->get();
372 exit();
373 }
374}
sprintf('%.4f', $callTime)
if(strpos( $jquery_path, './')===0) else if(strpos($jquery_path, '.')===0) $mathJaxSetting
Definition: latex.php:36
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
static _instantiateQuestion($question_id)
static _getMaximumPoints($question_id)
Returns the maximum points, a learner can reach answering the question.
static _getReachedPoints($active_id, $question_id, $pass=NULL)
Returns the points, a learner has reached 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)
Init yui panel.
static initOverlay()
Init YUI Overlay module.
static initjQuery($a_tpl=null)
Init jQuery.
$info
Definition: example_052.php:80
$ret
Definition: parser.php:6
$cmd
Definition: sahs_server.php:35