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