ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
208 {
209 global $tpl, $ilCtrl, $lng;
210
211 $activeId = $this->fetchActiveIdParameter();
212 $pass = $this->fetchPassParameter($activeId);
213
214 $questionGuiList = $this->service->getManScoringQuestionGuiList($activeId, $pass);
215 $form = $this->buildManScoringParticipantForm($questionGuiList, $activeId, $pass, false);
216
217 $form->setValuesByPost();
218
219 if( !$form->checkInput() )
220 {
221 ilUtil::sendFailure(sprintf($lng->txt('tst_save_manscoring_failed'), $pass + 1));
223 return false;
224 }
225
226 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
227
228 $maxPointsByQuestionId = array();
229 $maxPointsExceeded = false;
230 foreach($questionGuiList as $questionId => $questionGui)
231 {
232 $reachedPoints = $form->getItemByPostVar("question__{$questionId}__points")->getValue();
233 $maxPoints = assQuestion::_getMaximumPoints($questionId);
234
235 if( $reachedPoints > $maxPoints )
236 {
237 $maxPointsExceeded = true;
238
239 $form->getItemByPostVar("question__{$questionId}__points")->setAlert( sprintf(
240 $lng->txt('tst_manscoring_maxpoints_exceeded_input_alert'), $maxPoints
241 ));
242 }
243
244 $maxPointsByQuestionId[$questionId] = $maxPoints;
245 }
246
247 if( $maxPointsExceeded )
248 {
249 ilUtil::sendFailure(sprintf($lng->txt('tst_save_manscoring_failed'), $pass + 1));
251 return false;
252 }
253
254 include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
255
256 foreach($questionGuiList as $questionId => $questionGui)
257 {
258 $reachedPoints = $form->getItemByPostVar("question__{$questionId}__points")->getValue();
259
261 $activeId, $questionId, $reachedPoints, $maxPointsByQuestionId[$questionId],
262 $pass, 1, $this->object->areObligationsEnabled()
263 );
264
265 $feedback = ilUtil::stripSlashes(
266 $form->getItemByPostVar("question__{$questionId}__feedback")->getValue(),
268 );
269
270 $this->object->saveManualFeedback($activeId, $questionId, $pass, $feedback);
271
272 $notificationData[$questionId] = array(
273 'points' => $reachedPoints, 'feedback' => $feedback
274 );
275 }
276
277 include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
278 include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
280 $this->object->getId(), ilObjTestAccess::_getParticipantId($activeId)
281 );
282
283 $manScoringDone = $form->getItemByPostVar("manscoring_done")->getChecked();
284 ilTestService::setManScoringDone($activeId, $manScoringDone);
285
286 $manScoringNotify = $form->getItemByPostVar("manscoring_notify")->getChecked();
287 if($manScoringNotify)
288 {
289 require_once 'Modules/Test/classes/notifications/class.ilTestManScoringParticipantNotification.php';
290
291 $notification = new ilTestManScoringParticipantNotification(
292 $this->object->_getUserIdFromActiveId($activeId), $this->object->getRefId()
293 );
294
295 $notification->setAdditionalInformation(array(
296 'test_title' => $this->object->getTitle(),
297 'test_pass' => $pass + 1,
298 'questions_gui_list' => $questionGuiList,
299 'questions_scoring_data' => $notificationData
300 ));
301
302 $notification->send();
303 }
304
305 require_once './Modules/Test/classes/class.ilTestScoring.php';
306 $scorer = new ilTestScoring($this->object);
307 $scorer->setPreserveManualScores(true);
308 $scorer->recalculateSolutions();
309
310 if($this->object->getAnonymity() == 0)
311 {
313 $name_real_or_anon = $user_name['firstname'].' '. $user_name['lastname'];
314 }
315 else
316 {
317 $name_real_or_anon = $lng->txt('anonymous');
318 }
319 ilUtil::sendSuccess(sprintf($lng->txt('tst_saved_manscoring_successfully'), $pass + 1, $name_real_or_anon ), true);
320 if($redirect == true)
321 {
322 $ilCtrl->redirect($this, 'showManScoringParticipantScreen');
323 }
324 else
325 {
326 return true;
327 }
328 }
329
331 {
332 global $ilCtrl;
333
334 $table = $this->buildManScoringParticipantsTable(true);
335
336 if($this->saveManScoringParticipantScreen(false))
337 {
338 $participantData = $table->getInternalyOrderedDataValues();
339
340 $nextIndex = null;
341 foreach($participantData as $index => $participant)
342 {
343 if($participant['active_id'] == $_GET['active_id'])
344 {
345 $nextIndex = $index + 1;
346 break;
347 }
348 }
349
350 if($nextIndex && isset($participantData[$nextIndex]))
351 {
352 $ilCtrl->setParameter($this, 'active_id', $participantData[$nextIndex]['active_id']);
353 $ilCtrl->redirect($this, 'showManScoringParticipantScreen');
354 }
355
356 $ilCtrl->redirectByClass("iltestscoringgui", "showManScoringParticipantsTable");
357 }
358 }
359
361 {
362 global $ilCtrl;
363
364 if($this->saveManScoringParticipantScreen(false))
365 {
366 $ilCtrl->redirectByClass("iltestscoringgui", "showManScoringParticipantsTable");
367 }
368 }
369
370 private function buildManScoringParticipantForm($questionGuiList, $activeId, $pass, $initValues = false)
371 {
372 global $ilCtrl, $lng;
373
374 require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
375 require_once 'Services/Form/classes/class.ilFormSectionHeaderGUI.php';
376 require_once 'Services/Form/classes/class.ilCustomInputGUI.php';
377 require_once 'Services/Form/classes/class.ilCheckboxInputGUI.php';
378 require_once 'Services/Form/classes/class.ilTextInputGUI.php';
379 require_once 'Services/Form/classes/class.ilTextAreaInputGUI.php';
380
381 $ilCtrl->setParameter($this, 'active_id', $activeId);
382 $ilCtrl->setParameter($this, 'pass', $pass);
383
384 $form = new ilPropertyFormGUI();
385 $form->setFormAction($ilCtrl->getFormAction($this));
386
387 $form->setTitle( sprintf($lng->txt('manscoring_results_pass'), $pass + 1) );
388 $form->setTableWidth('100%');
389
390 foreach($questionGuiList as $questionId => $questionGUI)
391 {
392 $questionHeader = sprintf($lng->txt('tst_manscoring_question_section_header'), $questionGUI->object->getTitle());
393 $questionSolution = $questionGUI->getSolutionOutput($activeId, $pass, false, false, true, false, false, true);
394 $bestSolution = $questionGUI->object->getSuggestedSolutionOutput();
395
396 $sect = new ilFormSectionHeaderGUI();
397 $sect->setTitle( $questionHeader . ' ['. $this->lng->txt('question_id_short') . ': ' . $questionGUI->object->getId() . ']');
398 $form->addItem($sect);
399
400 $cust = new ilCustomInputGUI($lng->txt('tst_manscoring_input_question_and_user_solution'));
401 $cust->setHtml($questionSolution);
402 $form->addItem($cust);
403
404 $text = new ilTextInputGUI($lng->txt('tst_change_points_for_question'), "question__{$questionId}__points");
405 if( $initValues ) $text->setValue( assQuestion::_getReachedPoints($activeId, $questionId, $pass) );
406 $form->addItem($text);
407
408 $nonedit = new ilNonEditableValueGUI($lng->txt('tst_manscoring_input_max_points_for_question'), "question__{$questionId}__maxpoints");
409 if( $initValues ) $nonedit->setValue( assQuestion::_getMaximumPoints($questionId) );
410 $form->addItem($nonedit);
411
412 $area = new ilTextAreaInputGUI($lng->txt('set_manual_feedback'), "question__{$questionId}__feedback");
413 $area->setUseRTE(true);
414 if( $initValues ) $area->setValue( $this->object->getManualFeedback($activeId, $questionId, $pass) );
415 $form->addItem($area);
416
417 if(strlen(trim($bestSolution)))
418 {
419 $cust = new ilCustomInputGUI($lng->txt('tst_show_solution_suggested'));
420 $cust->setHtml($bestSolution);
421 $form->addItem($cust);
422 }
423 }
424
425 $sect = new ilFormSectionHeaderGUI();
426 $sect->setTitle($lng->txt('tst_participant'));
427 $form->addItem($sect);
428
429 $check = new ilCheckboxInputGUI($lng->txt('set_manscoring_done'), 'manscoring_done');
430 if( $initValues && ilTestService::isManScoringDone($activeId) ) $check->setChecked(true);
431 $form->addItem($check);
432
433 $check = new ilCheckboxInputGUI($lng->txt('tst_manscoring_user_notification'), 'manscoring_notify');
434 $form->addItem($check);
435
436 $form->addCommandButton('saveManScoringParticipantScreen', $lng->txt('save'));
437 $form->addCommandButton('saveReturnManScoringParticipantScreen', $lng->txt('save_return'));
438 $form->addCommandButton('saveNextManScoringParticipantScreen', $lng->txt('save_and_next'));
439
440 return $form;
441 }
442
444 {
445 }
446
450 private function buildManScoringParticipantsTable($withData = false)
451 {
452 require_once 'Modules/Test/classes/tables/class.ilTestManScoringParticipantsTableGUI.php';
453 $table = new ilTestManScoringParticipantsTableGUI($this);
454
455 if($withData)
456 {
457 $participantStatusFilterValue = $table->getFilterItemByPostVar('participant_status')->getValue();
458 $table->setData($this->object->getTestParticipantsForManualScoring($participantStatusFilterValue));
459 }
460
461 return $table;
462 }
463}
$_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_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
$text
global $ilCtrl
Definition: ilias.php:18
const SCORE_LAST_PASS
$cmd
Definition: sahs_server.php:35
$redirect
Definition: index.php:18