ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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();
49 $next_class = $this->ctrl->getNextClass($this);
50 if(strlen($cmd) == 0)
51 {
52 $this->ctrl->redirect($this, 'manscoring');
53 }
54
55 $cmd = $this->getCommand($cmd);
56 $this->buildSubTabs('man_scoring_by_qst');
57 switch($next_class)
58 {
59 default:
60 $ret = $this->$cmd();
61 break;
62 }
63
64 return $ret;
65 }
66
70 private function showManScoringByQuestionParticipantsTable($manPointsPost = array())
71 {
76 global $tpl, $ilAccess;
77
78 if(!$ilAccess->checkAccess('write', '', $this->ref_id))
79 {
80 ilUtil::sendInfo($this->lng->txt('cannot_edit_test'), true);
81 $this->ctrl->redirectByClass('ilobjtestgui', 'infoScreen');
82 }
83
84 include_once 'Services/jQuery/classes/class.iljQueryUtil.php';
86
87 include_once 'Services/YUI/classes/class.ilYuiUtil.php';
90
91 $mathJaxSetting = new ilSetting('MathJax');
92 if($mathJaxSetting->get("enable"))
93 {
94 $tpl->addJavaScript($mathJaxSetting->get("path_to_mathjax"));
95 }
96
97 $tpl->addJavascript('./Services/UIComponent/Overlay/js/ilOverlay.js');
98 $tpl->addJavaScript("./Services/JavaScript/js/Basic.js");
99 $tpl->addJavaScript("./Services/Form/js/Form.js");
100 $tpl->addCss($this->object->getTestStyleLocation("output"), "screen");
101
102 require_once 'Modules/Test/classes/tables/class.ilTestManScoringParticipantsBySelectedQuestionAndPassTableGUI.php';
104
105 $table->setManualScoringPointsPostData($manPointsPost);
106
107 $qst_id = $table->getFilterItemByPostVar('question')->getValue();
108 $pass_id = $table->getFilterItemByPostVar('pass')->getValue();
109
110 $table_data = array();
111
112 $selected_questionData = null;
113
114 if(is_numeric($qst_id))
115 {
117 $info = assQuestion::_getQuestionInfo($qst_id);
118 $selected_questionData = $info;
119 $type = $info["question_type_fi"];
120 if(in_array($type, $scoring))
121 {
122 $selected_questionData = $info;
123 }
124 }
125
126 if($selected_questionData && is_numeric($pass_id))
127 {
128 $data = $this->object->getCompleteEvaluationData(FALSE);
129
130 foreach($data->getParticipants() as $active_id => $participant)
131 {
132 $testResultData = $this->object->getTestResult($active_id, $pass_id - 1);
133 foreach($testResultData as $questionData)
134 {
135 if( !isset($questionData['qid']) || $questionData['qid'] != $selected_questionData['question_id'] )
136 {
137 continue;
138 }
139
140 $table_data[] = array(
141 'pass_id' => $pass_id - 1,
142 'active_id' => $active_id,
143 'qst_id' => $questionData['qid'],
144 'reached_points' => assQuestion::_getReachedPoints($active_id, $questionData['qid'], $pass_id - 1),
145 'maximum_points' => assQuestion::_getMaximumPoints($questionData['qid']),
146 'participant' => $participant,
147 );
148 }
149 }
150 }
151 else
152 {
153 $table->disable('header');
154 }
155
156 if($selected_questionData)
157 {
158 $maxpoints = assQuestion::_getMaximumPoints($selected_questionData['question_id']);
159 if($maxpoints == 1)
160 {
161 $maxpoints = ' (' . $maxpoints . ' ' . $this->lng->txt('point') . ')';
162 }
163 else
164 {
165 $maxpoints = ' (' . $maxpoints . ' ' . $this->lng->txt('points') . ')';
166 }
167 $table->setTitle($this->lng->txt('tst_man_scoring_by_qst') . ': ' . $selected_questionData['title'] . $maxpoints . ' ['. $this->lng->txt('question_id_short') . ': ' . $selected_questionData['question_id'] . ']');
168 }
169 else
170 {
171 $table->setTitle($this->lng->txt('tst_man_scoring_by_qst'));
172 }
173
174 $table->setData($table_data);
175 $tpl->setContent($table->getHTML());
176 }
177
178 public function saveManScoringByQuestion()
179 {
183 global $ilAccess, $lng;
184
185 if(!$ilAccess->checkAccess('write', '', $this->ref_id))
186 {
187 ilUtil::sendInfo($this->lng->txt('cannot_edit_test'), true);
188 $this->ctrl->redirectByClass('ilobjtestgui', 'infoScreen');
189 }
190
191 if(!isset($_POST['scoring']) || !is_array($_POST['scoring']))
192 {
193 ilUtil::sendFailure($this->lng->txt('tst_save_manscoring_failed_unknown'));
194 $this->showManScoringByQuestionParticipantsTable();
195 return;
196 }
197
198 include_once 'Modules/TestQuestionPool/classes/class.assQuestion.php';
199 include_once 'Modules/Test/classes/class.ilObjTestAccess.php';
200 include_once 'Services/Tracking/classes/class.ilLPStatusWrapper.php';
201
202 $oneExceededMaxPoints = false;
203 $manPointsPost = array();
204 $skipParticipant = array();
205 $maxPointsByQuestionId = array();
206 foreach($_POST['scoring'] as $pass => $active_ids)
207 {
208 foreach((array)$active_ids as $active_id => $questions)
209 {
210 // check for existing test result data
211 if( !$this->object->getTestResult($active_id, $pass) )
212 {
213 if( !isset($skipParticipant[$pass]) )
214 {
215 $skipParticipant[$pass] = array();
216 }
217
218 $skipParticipant[$pass][$active_id] = true;
219
220 continue;
221 }
222
223 foreach((array)$questions as $qst_id => $reached_points)
224 {
225 if( !isset($manPointsPost[$pass]) )
226 {
227 $manPointsPost[$pass] = array();
228 }
229
230 if( !isset($manPointsPost[$pass][$active_id]) )
231 {
232 $manPointsPost[$pass][$active_id] = array();
233 }
234
235 $maxPointsByQuestionId[$qst_id] = assQuestion::_getMaximumPoints($qst_id);
236
237 if( $reached_points > $maxPointsByQuestionId[$qst_id] )
238 {
239 $oneExceededMaxPoints = true;
240 }
241
242 $manPointsPost[$pass][$active_id][$qst_id] = $reached_points;
243 }
244 }
245 }
246
247 if( $oneExceededMaxPoints )
248 {
249 ilUtil::sendFailure(sprintf($this->lng->txt('tst_save_manscoring_failed'), $pass + 1));
250 $this->showManScoringByQuestionParticipantsTable($manPointsPost);
251 return;
252 }
253
254 $changed_one = false;
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
278 $this->object->getId(), ilObjTestAccess::_getParticipantId($active_id)
279 );
280 }
281 }
282 }
283
284 if($changed_one)
285 {
286 if($this->object->getAnonymity() == 0)
287 {
288 $user_name = $user_name = ilObjUser::_lookupName( ilObjTestAccess::_getParticipantId($active_id));
289 $name_real_or_anon = $user_name['firstname'].' '. $user_name['lastname'];
290 }
291 else
292 {
293 $name_real_or_anon = $lng->txt('anonymous');
294 }
295 ilUtil::sendSuccess(sprintf($this->lng->txt('tst_saved_manscoring_successfully'), $pass + 1,$name_real_or_anon), true);
296
297 require_once './Modules/Test/classes/class.ilTestScoring.php';
298 $scorer = new ilTestScoring($this->object);
299 $scorer->setPreserveManualScores(true);
300 $scorer->recalculateSolutions();
301 }
302
303 $this->showManScoringByQuestionParticipantsTable();
304 }
305
310 {
311 require_once 'Modules/Test/classes/tables/class.ilTestManScoringParticipantsBySelectedQuestionAndPassTableGUI.php';
313 $table->resetOffset();
314 $table->writeFilterToSession();
315 $this->showManScoringByQuestionParticipantsTable();
316 }
317
322 {
323 require_once 'Modules/Test/classes/tables/class.ilTestManScoringParticipantsBySelectedQuestionAndPassTableGUI.php';
325 $table->resetOffset();
326 $table->resetFilter();
327 $this->showManScoringByQuestionParticipantsTable();
328 }
329
330 private function getAnswerDetail()
331 {
335 global $ilAccess;
336
337 if(!$ilAccess->checkAccess('write', '', $this->ref_id))
338 {
339 exit();
340 }
341
342 $active_id = $_GET['active_id'];
343 $pass = $_GET['pass_id'];
344 $question_id = $_GET['qst_id'];
345
346 $data = $this->object->getCompleteEvaluationData(FALSE);
347 $participant = $data->getParticipant($active_id);
348
349 $question_gui = $this->object->createQuestionGUI('', $question_id);
350
351 $tmp_tpl = new ilTemplate('tpl.il_as_tst_correct_solution_output.html', TRUE, TRUE, 'Modules/Test');
352 $result_output = $question_gui->getSolutionOutput($active_id, $pass, FALSE, FALSE, FALSE, $this->object->getShowSolutionFeedback());
353 $tmp_tpl->setVariable('TEXT_YOUR_SOLUTION', $this->lng->txt('answers_of') .' '. $participant->getName());
354 $maxpoints = $question_gui->object->getMaximumPoints();
355
356 $add_title = ' ['. $this->lng->txt('question_id_short') . ': ' . $question_id . ']';
357
358 if($maxpoints == 1)
359 {
360 $tmp_tpl->setVariable('QUESTION_TITLE', $this->object->getQuestionTitle($question_gui->object->getTitle()) . ' (' . $maxpoints . ' ' . $this->lng->txt('point') . ')' . $add_title);
361 }
362 else
363 {
364 $tmp_tpl->setVariable('QUESTION_TITLE', $this->object->getQuestionTitle($question_gui->object->getTitle()) . ' (' . $maxpoints . ' ' . $this->lng->txt('points') . ')' . $add_title);
365 }
366 $tmp_tpl->setVariable('SOLUTION_OUTPUT', $result_output);
367 $tmp_tpl->setVariable('RECEIVED_POINTS', sprintf($this->lng->txt('part_received_a_of_b_points'), $question_gui->object->getReachedPoints($active_id, $pass), $maxpoints));
368
369 echo $tmp_tpl->get();
370 exit();
371 }
372}
$_GET["client_id"]
_getMaximumPoints($question_id)
Returns the maximum points, a learner can reach answering the question.
_getReachedPoints($active_id, $question_id, $pass=NULL)
Returns the points, a learner has reached answering the question.
_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...
& _getQuestionInfo($question_id)
Returns question information from the database.
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_no_raise=false, $a_force_raise=false)
Update status.
static _mananuallyScoreableQuestionTypesExists()
Returns the fact wether manually scoreable question types exist or not.
_getManualScoring()
Retrieve the manual scoring settings.
_getParticipantId($active_id)
Get user id for active id.
static _lookupName($a_user_id)
lookup user name
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.
$_POST['username']
Definition: cron.php:12
exit
Definition: login.php:54
$cmd
Definition: sahs_server.php:35
if(strpos( $jquery_path, './')===0) else if(strpos($jquery_path, '.')===0) $mathJaxSetting
Definition: latex.php:34