ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilTestScoringGUI.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.ilTestServiceGUI.php";
6
18{
21 const PART_FILTER_ALL_USERS = 3; // default
24 //const PART_FILTER_MANSCORING_PENDING = 6;
25
34 public function __construct(ilObjTest $a_object)
35 {
36 parent::__construct($a_object);
37 }
38
42 protected function buildSubTabs($active_sub_tab = 'man_scoring_by_qst')
43 {
47 global $ilTabs;
48
49 $ilTabs->addSubTab('man_scoring_by_qst', $this->lng->txt('tst_man_scoring_by_qst'), $this->ctrl->getLinkTargetByClass('ilTestScoringByQuestionsGUI', 'showManScoringByQuestionParticipantsTable'));
50 $ilTabs->addSubTab('man_scoring', $this->lng->txt('tst_man_scoring_by_part'), $this->ctrl->getLinkTargetByClass('ilTestScoringGUI', 'showManScoringParticipantsTable'));
51 $ilTabs->setSubTabActive($active_sub_tab);
52 }
53
54 private function fetchActiveIdParameter()
55 {
56 global $ilCtrl;
57
58 // fetch active_id
59
60 if( !isset($_GET['active_id']) || !(int)$_GET['active_id'] )
61 {
62 // allow only write access
63 ilUtil::sendFailure('no active id given!', true);
64 $ilCtrl->redirectByClass("ilobjtestgui", "infoScreen");
65 }
66 else
67 {
68 $activeId = (int)$_GET['active_id'];
69 }
70
71 return $activeId;
72 }
73
74 private function fetchPassParameter($activeId)
75 {
76 // fetch pass nr
77
78 $maxPass = $this->object->_getMaxPass($activeId);
79 if( isset($_GET["pass"]) && 0 <= (int)$_GET["pass"] && $maxPass >= (int)$_GET["pass"] )
80 {
81 $pass = $_GET["pass"];
82 }
83 elseif( $this->object->getPassScoring() == SCORE_LAST_PASS )
84 {
85 $pass = $maxPass;
86 }
87 else
88 {
89 $pass = $this->object->_getResultPass($activeId);
90 }
91
92 return $pass;
93 }
94
98 function executeCommand()
99 {
100 global $ilAccess;
101
102 if( !$ilAccess->checkAccess("write", "", $this->ref_id) )
103 {
104 // allow only write access
105 ilUtil::sendFailure($this->lng->txt("cannot_edit_test"), true);
106 $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
107 }
108
109 require_once 'Modules/Test/classes/class.ilObjAssessmentFolder.php';
111 {
112 // allow only if at least one question type is marked for manual scoring
113 ilUtil::sendFailure($this->lng->txt("manscoring_not_allowed"), true);
114 $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
115 }
116
117 $cmd = $this->ctrl->getCmd();
118 $next_class = $this->ctrl->getNextClass($this);
119
120 if (strlen($cmd) == 0)
121 {
122 $this->ctrl->redirect($this, "manscoring");
123 }
124
125 $cmd = $this->getCommand($cmd);
126 $this->buildSubTabs('man_scoring');
127 switch($next_class)
128 {
129 default:
130 $ret =& $this->$cmd();
131 break;
132 }
133
134 return $ret;
135 }
136
138 {
139 global $tpl;
140
141 $table = $this->buildManScoringParticipantsTable(true);
142
143 $tpl->setContent( $table->getHTML() );
144 }
145
147 {
148 $table = $this->buildManScoringParticipantsTable(false);
149
150 $table->resetOffset();
151 $table->writeFilterToSession();
152
154 }
155
157 {
158 $table = $this->buildManScoringParticipantsTable(false);
159
160 $table->resetOffset();
161 $table->resetFilter();
162
164 }
165
167 {
168 global $tpl, $lng;
169
170 $activeId = $this->fetchActiveIdParameter();
171 $pass = $this->fetchPassParameter($activeId);
172
173 $contentHTML = '';
174
175 // pass overview table
176 require_once 'Modules/Test/classes/tables/class.ilTestPassManualScoringOverviewTableGUI.php';
177 $table = new ilTestPassManualScoringOverviewTableGUI($this, 'showManScoringParticipantScreen');
178
179 $userId = $this->object->_getUserIdFromActiveId($activeId);
180 $userFullname = $this->object->userLookupFullName($userId, false, true);
181 $tableTitle = sprintf($lng->txt('tst_pass_overview_for_participant'), $userFullname);
182 $table->setTitle($tableTitle);
183
184 $passOverviewData = $this->service->getPassOverviewData($activeId);
185 $table->setData($passOverviewData['passes']);
186
187 $contentHTML .= $table->getHTML().'<br />';
188
189 // pass scoring form
190
191 if($form === null)
192 {
193 $questionGuiList = $this->service->getManScoringQuestionGuiList($activeId, $pass);
194 $form = $this->buildManScoringParticipantForm($questionGuiList, $activeId, $pass, true);
195 }
196
197 $contentHTML .= $form->getHTML();
198
199 // set content
200
201 $tpl->setContent($contentHTML);
202 }
203
208 private function saveManScoringParticipantScreen($redirect = true)
209 {
210 global $tpl, $ilCtrl, $lng;
211
212 $activeId = $this->fetchActiveIdParameter();
213 $pass = $this->fetchPassParameter($activeId);
214
215 $questionGuiList = $this->service->getManScoringQuestionGuiList($activeId, $pass);
216 $form = $this->buildManScoringParticipantForm($questionGuiList, $activeId, $pass, false);
217
218 $form->setValuesByPost();
219
220 if( !$form->checkInput() )
221 {
222 ilUtil::sendFailure(sprintf($lng->txt('tst_save_manscoring_failed'), $pass + 1));
224 return false;
225 }
226
227 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
228
229 $maxPointsByQuestionId = array();
230 $maxPointsExceeded = false;
231 foreach($questionGuiList as $questionId => $questionGui)
232 {
233 $reachedPoints = $form->getItemByPostVar("question__{$questionId}__points")->getValue();
234 $maxPoints = assQuestion::_getMaximumPoints($questionId);
235
236 if( $reachedPoints > $maxPoints )
237 {
238 $maxPointsExceeded = true;
239
240 $form->getItemByPostVar("question__{$questionId}__points")->setAlert( sprintf(
241 $lng->txt('tst_manscoring_maxpoints_exceeded_input_alert'), $maxPoints
242 ));
243 }
244
245 $maxPointsByQuestionId[$questionId] = $maxPoints;
246 }
247
248 if( $maxPointsExceeded )
249 {
250 ilUtil::sendFailure(sprintf($lng->txt('tst_save_manscoring_failed'), $pass + 1));
252 return false;
253 }
254
255 include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
256
257 foreach($questionGuiList as $questionId => $questionGui)
258 {
259 $reachedPoints = $form->getItemByPostVar("question__{$questionId}__points")->getValue();
260
262 $activeId, $questionId, $reachedPoints, $maxPointsByQuestionId[$questionId],
263 $pass, 1, $this->object->areObligationsEnabled()
264 );
265
266 $feedback = ilUtil::stripSlashes(
267 $form->getItemByPostVar("question__{$questionId}__feedback")->getValue(),
269 );
270
271 $this->object->saveManualFeedback($activeId, $questionId, $pass, $feedback);
272
273 $notificationData[$questionId] = array(
274 'points' => $reachedPoints, 'feedback' => $feedback
275 );
276 }
277
278 include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
279 include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
281 $this->object->getId(), ilObjTestAccess::_getParticipantId($activeId)
282 );
283
284 $manScoringDone = $form->getItemByPostVar("manscoring_done")->getChecked();
285 ilTestService::setManScoringDone($activeId, $manScoringDone);
286
287 $manScoringNotify = $form->getItemByPostVar("manscoring_notify")->getChecked();
288 if($manScoringNotify)
289 {
290 require_once 'Modules/Test/classes/notifications/class.ilTestManScoringParticipantNotification.php';
291
292 $notification = new ilTestManScoringParticipantNotification(
293 $this->object->_getUserIdFromActiveId($activeId), $this->object->getRefId()
294 );
295
296 $notification->setAdditionalInformation(array(
297 'test_title' => $this->object->getTitle(),
298 'test_pass' => $pass + 1,
299 'questions_gui_list' => $questionGuiList,
300 'questions_scoring_data' => $notificationData
301 ));
302
303 $notification->send();
304 }
305
306 require_once './Modules/Test/classes/class.ilTestScoring.php';
307 $scorer = new ilTestScoring($this->object);
308 $scorer->setPreserveManualScores(true);
309 $scorer->recalculateSolutions();
310
311 if($this->object->getAnonymity() == 0)
312 {
314 $name_real_or_anon = $user_name['firstname'].' '. $user_name['lastname'];
315 }
316 else
317 {
318 $name_real_or_anon = $lng->txt('anonymous');
319 }
320 ilUtil::sendSuccess(sprintf($lng->txt('tst_saved_manscoring_successfully'), $pass + 1, $name_real_or_anon ), true);
321 if($redirect == true)
322 {
323 $ilCtrl->redirect($this, 'showManScoringParticipantScreen');
324 }
325 else
326 {
327 return true;
328 }
329 }
330
332 {
333 global $ilCtrl;
334
335 $table = $this->buildManScoringParticipantsTable(true);
336
337 if($this->saveManScoringParticipantScreen(false))
338 {
339 $participantData = $table->getInternalyOrderedDataValues();
340
341 $nextIndex = null;
342 foreach($participantData as $index => $participant)
343 {
344 if($participant['active_id'] == $_GET['active_id'])
345 {
346 $nextIndex = $index + 1;
347 break;
348 }
349 }
350
351 if($nextIndex && isset($participantData[$nextIndex]))
352 {
353 $ilCtrl->setParameter($this, 'active_id', $participantData[$nextIndex]['active_id']);
354 $ilCtrl->redirect($this, 'showManScoringParticipantScreen');
355 }
356
357 $ilCtrl->redirectByClass("iltestscoringgui", "showManScoringParticipantsTable");
358 }
359 }
360
362 {
363 global $ilCtrl;
364
365 if($this->saveManScoringParticipantScreen(false))
366 {
367 $ilCtrl->redirectByClass("iltestscoringgui", "showManScoringParticipantsTable");
368 }
369 }
370
371 private function buildManScoringParticipantForm($questionGuiList, $activeId, $pass, $initValues = false)
372 {
373 global $ilCtrl, $lng;
374
375 require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
376 require_once 'Services/Form/classes/class.ilFormSectionHeaderGUI.php';
377 require_once 'Services/Form/classes/class.ilCustomInputGUI.php';
378 require_once 'Services/Form/classes/class.ilCheckboxInputGUI.php';
379 require_once 'Services/Form/classes/class.ilTextInputGUI.php';
380 require_once 'Services/Form/classes/class.ilTextAreaInputGUI.php';
381
382 $ilCtrl->setParameter($this, 'active_id', $activeId);
383 $ilCtrl->setParameter($this, 'pass', $pass);
384
385 $form = new ilPropertyFormGUI();
386 $form->setFormAction($ilCtrl->getFormAction($this));
387
388 $form->setTitle( sprintf($lng->txt('manscoring_results_pass'), $pass + 1) );
389 $form->setTableWidth('100%');
390
391 foreach($questionGuiList as $questionId => $questionGUI)
392 {
393 $questionHeader = sprintf($lng->txt('tst_manscoring_question_section_header'), $questionGUI->object->getTitle());
394 $questionSolution = $questionGUI->getSolutionOutput($activeId, $pass, false, false, true, false, false, true);
395 $bestSolution = $questionGUI->object->getSuggestedSolutionOutput();
396
397 $sect = new ilFormSectionHeaderGUI();
398 $sect->setTitle( $questionHeader . ' ['. $this->lng->txt('question_id_short') . ': ' . $questionGUI->object->getId() . ']');
399 $form->addItem($sect);
400
401 $cust = new ilCustomInputGUI($lng->txt('tst_manscoring_input_question_and_user_solution'));
402 $cust->setHtml($questionSolution);
403 $form->addItem($cust);
404
405 $text = new ilTextInputGUI($lng->txt('tst_change_points_for_question'), "question__{$questionId}__points");
406 if( $initValues ) $text->setValue( assQuestion::_getReachedPoints($activeId, $questionId, $pass) );
407 $form->addItem($text);
408
409 $nonedit = new ilNonEditableValueGUI($lng->txt('tst_manscoring_input_max_points_for_question'), "question__{$questionId}__maxpoints");
410 if( $initValues ) $nonedit->setValue( assQuestion::_getMaximumPoints($questionId) );
411 $form->addItem($nonedit);
412
413 $area = new ilTextAreaInputGUI($lng->txt('set_manual_feedback'), "question__{$questionId}__feedback");
414 $area->setUseRTE(true);
415 if( $initValues ) $area->setValue( $this->object->getManualFeedback($activeId, $questionId, $pass) );
416 $form->addItem($area);
417
418 if(strlen(trim($bestSolution)))
419 {
420 $cust = new ilCustomInputGUI($lng->txt('tst_show_solution_suggested'));
421 $cust->setHtml($bestSolution);
422 $form->addItem($cust);
423 }
424 }
425
426 $sect = new ilFormSectionHeaderGUI();
427 $sect->setTitle($lng->txt('tst_participant'));
428 $form->addItem($sect);
429
430 $check = new ilCheckboxInputGUI($lng->txt('set_manscoring_done'), 'manscoring_done');
431 if( $initValues && ilTestService::isManScoringDone($activeId) ) $check->setChecked(true);
432 $form->addItem($check);
433
434 $check = new ilCheckboxInputGUI($lng->txt('tst_manscoring_user_notification'), 'manscoring_notify');
435 $form->addItem($check);
436
437 $form->addCommandButton('saveManScoringParticipantScreen', $lng->txt('save'));
438 $form->addCommandButton('saveReturnManScoringParticipantScreen', $lng->txt('save_return'));
439 $form->addCommandButton('saveNextManScoringParticipantScreen', $lng->txt('save_and_next'));
440
441 return $form;
442 }
443
445 {
446 }
447
451 private function buildManScoringParticipantsTable($withData = false)
452 {
453 require_once 'Modules/Test/classes/tables/class.ilTestManScoringParticipantsTableGUI.php';
454 $table = new ilTestManScoringParticipantsTableGUI($this);
455
456 if($withData)
457 {
458 $participantStatusFilterValue = $table->getFilterItemByPostVar('participant_status')->getValue();
459 $table->setData($this->object->getTestParticipantsForManualScoring($participantStatusFilterValue));
460 }
461
462 return $table;
463 }
464}
sprintf('%.4f', $callTime)
$_GET["client_id"]
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 _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...
This class represents a checkbox property in a property form.
This class represents a custom property in a property form.
This class represents a section header in a property form.
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.
This class represents a non editable value in a property form.
static _getUsedHTMLTagsAsString($a_module="")
Returns a string of all allowed HTML tags for text editing.
static _mananuallyScoreableQuestionTypesExists()
Returns the fact wether manually scoreable question types exist or not.
static _getParticipantId($active_id)
Get user id for active id.
static _lookupName($a_user_id)
lookup user name
This class represents a property form user interface.
Scoring class for tests.
executeCommand()
execute command
buildManScoringParticipantsTable($withData=false)
saveManScoringParticipantScreen($redirect=true)
__construct(ilObjTest $a_object)
ilTestScoringGUI constructor
buildManScoringParticipantForm($questionGuiList, $activeId, $pass, $initValues=false)
showManScoringParticipantScreen(ilPropertyFormGUI $form=null)
Class ilTestScoring.
Service GUI class for tests.
getCommand($cmd)
Retrieves the ilCtrl command.
static setManScoringDone($activeId, $manScoringDone)
stores the flag wether manscoring is done for the given test active or not within the global settings...
static isManScoringDone($activeId)
reads the flag wether manscoring is done for the given test active or not from the global settings (s...
This class represents a text area property in a property form.
This class represents a text property in a property form.
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 stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
$text
global $ilCtrl
Definition: ilias.php:18
const SCORE_LAST_PASS
$ret
Definition: parser.php:6
$cmd
Definition: sahs_server.php:35