ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 // allow only write access
62 ilUtil::sendFailure('no active id given!', true);
63 $ilCtrl->redirectByClass("ilobjtestgui", "infoScreen");
64 } else {
65 $activeId = (int) $_GET['active_id'];
66 }
67
68 return $activeId;
69 }
70
71 private function fetchPassParameter($activeId)
72 {
73 // fetch pass nr
74
75 $maxPass = $this->object->_getMaxPass($activeId);
76 if (isset($_GET["pass"]) && 0 <= (int) $_GET["pass"] && $maxPass >= (int) $_GET["pass"]) {
77 $pass = $_GET["pass"];
78 } elseif ($this->object->getPassScoring() == SCORE_LAST_PASS) {
79 $pass = $maxPass;
80 } else {
81 $pass = $this->object->_getResultPass($activeId);
82 }
83
84 return $pass;
85 }
86
90 public function executeCommand()
91 {
92 global $ilAccess;
93
94 if (!$ilAccess->checkAccess("write", "", $this->ref_id)) {
95 // allow only write access
96 ilUtil::sendFailure($this->lng->txt("cannot_edit_test"), true);
97 $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
98 }
99
100 require_once 'Modules/Test/classes/class.ilObjAssessmentFolder.php';
102 // allow only if at least one question type is marked for manual scoring
103 ilUtil::sendFailure($this->lng->txt("manscoring_not_allowed"), true);
104 $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
105 }
106
107 $cmd = $this->ctrl->getCmd();
108 $next_class = $this->ctrl->getNextClass($this);
109
110 if (strlen($cmd) == 0) {
111 $this->ctrl->redirect($this, "manscoring");
112 }
113
114 $cmd = $this->getCommand($cmd);
115 $this->buildSubTabs('man_scoring');
116 switch ($next_class) {
117 default:
118 $ret =&$this->$cmd();
119 break;
120 }
121
122 return $ret;
123 }
124
126 {
127 global $tpl;
128
130
131 $tpl->setContent($table->getHTML());
132 }
133
135 {
137
138 $table->resetOffset();
139 $table->writeFilterToSession();
140
142 }
143
145 {
147
148 $table->resetOffset();
149 $table->resetFilter();
150
152 }
153
155 {
156 global $tpl, $lng;
157
158 $activeId = $this->fetchActiveIdParameter();
159 $pass = $this->fetchPassParameter($activeId);
160
161 $contentHTML = '';
162
163 // pass overview table
164 require_once 'Modules/Test/classes/tables/class.ilTestPassManualScoringOverviewTableGUI.php';
165 $table = new ilTestPassManualScoringOverviewTableGUI($this, 'showManScoringParticipantScreen');
166
167 $userId = $this->object->_getUserIdFromActiveId($activeId);
168 $userFullname = $this->object->userLookupFullName($userId, false, true);
169 $tableTitle = sprintf($lng->txt('tst_pass_overview_for_participant'), $userFullname);
170 $table->setTitle($tableTitle);
171
172 $passOverviewData = $this->service->getPassOverviewData($activeId);
173 $table->setData($passOverviewData['passes']);
174
175 $contentHTML .= $table->getHTML() . '<br />';
176
177 // pass scoring form
178
179 if ($form === null) {
180 $questionGuiList = $this->service->getManScoringQuestionGuiList($activeId, $pass);
181 $form = $this->buildManScoringParticipantForm($questionGuiList, $activeId, $pass, true);
182 }
183
184 $contentHTML .= $form->getHTML();
185
186 // set content
187
188 $tpl->setContent($contentHTML);
189 }
190
195 private function saveManScoringParticipantScreen($redirect = true)
196 {
197 global $tpl, $ilCtrl, $lng;
198
199 $activeId = $this->fetchActiveIdParameter();
200 $pass = $this->fetchPassParameter($activeId);
201
202 $questionGuiList = $this->service->getManScoringQuestionGuiList($activeId, $pass);
203 $form = $this->buildManScoringParticipantForm($questionGuiList, $activeId, $pass, false);
204
205 $form->setValuesByPost();
206
207 if (!$form->checkInput()) {
208 ilUtil::sendFailure(sprintf($lng->txt('tst_save_manscoring_failed'), $pass + 1));
210 return false;
211 }
212
213 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
214
215 $maxPointsByQuestionId = array();
216 $maxPointsExceeded = false;
217 foreach ($questionGuiList as $questionId => $questionGui) {
218 $reachedPoints = $form->getItemByPostVar("question__{$questionId}__points")->getValue();
219 $maxPoints = assQuestion::_getMaximumPoints($questionId);
220
221 if ($reachedPoints > $maxPoints) {
222 $maxPointsExceeded = true;
223
224 $form->getItemByPostVar("question__{$questionId}__points")->setAlert(sprintf(
225 $lng->txt('tst_manscoring_maxpoints_exceeded_input_alert'),
226 $maxPoints
227 ));
228 }
229
230 $maxPointsByQuestionId[$questionId] = $maxPoints;
231 }
232
233 if ($maxPointsExceeded) {
234 ilUtil::sendFailure(sprintf($lng->txt('tst_save_manscoring_failed'), $pass + 1));
236 return false;
237 }
238
239 include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
240
241 foreach ($questionGuiList as $questionId => $questionGui) {
242 $reachedPoints = $form->getItemByPostVar("question__{$questionId}__points")->getValue();
243
245 $activeId,
246 $questionId,
247 $reachedPoints,
248 $maxPointsByQuestionId[$questionId],
249 $pass,
250 1,
251 $this->object->areObligationsEnabled()
252 );
253
254 $feedback = ilUtil::stripSlashes(
255 $form->getItemByPostVar("question__{$questionId}__feedback")->getValue(),
256 false,
258 );
259
260 $this->object->saveManualFeedback($activeId, $questionId, $pass, $feedback);
261
262 $notificationData[$questionId] = array(
263 'points' => $reachedPoints, 'feedback' => $feedback
264 );
265 }
266
267 include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
268 include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
270 $this->object->getId(),
272 );
273
274 $manScoringDone = $form->getItemByPostVar("manscoring_done")->getChecked();
275 ilTestService::setManScoringDone($activeId, $manScoringDone);
276
277 $manScoringNotify = $form->getItemByPostVar("manscoring_notify")->getChecked();
278 if ($manScoringNotify) {
279 require_once 'Modules/Test/classes/notifications/class.ilTestManScoringParticipantNotification.php';
280
281 $notification = new ilTestManScoringParticipantNotification(
282 $this->object->_getUserIdFromActiveId($activeId),
283 $this->object->getRefId()
284 );
285
286 $notification->setAdditionalInformation(array(
287 'test_title' => $this->object->getTitle(),
288 'test_pass' => $pass + 1,
289 'questions_gui_list' => $questionGuiList,
290 'questions_scoring_data' => $notificationData
291 ));
292
293 $notification->send();
294 }
295
296 require_once './Modules/Test/classes/class.ilTestScoring.php';
297 $scorer = new ilTestScoring($this->object);
298 $scorer->setPreserveManualScores(true);
299 $scorer->recalculateSolutions();
300
301 if ($this->object->getAnonymity() == 0) {
303 $name_real_or_anon = $user_name['firstname'] . ' ' . $user_name['lastname'];
304 } else {
305 $name_real_or_anon = $lng->txt('anonymous');
306 }
307 ilUtil::sendSuccess(sprintf($lng->txt('tst_saved_manscoring_successfully'), $pass + 1, $name_real_or_anon), true);
308 if ($redirect == true) {
309 $ilCtrl->redirect($this, 'showManScoringParticipantScreen');
310 } else {
311 return true;
312 }
313 }
314
316 {
317 global $ilCtrl;
318
320
321 if ($this->saveManScoringParticipantScreen(false)) {
322 $participantData = $table->getInternalyOrderedDataValues();
323
324 $nextIndex = null;
325 foreach ($participantData as $index => $participant) {
326 if ($participant['active_id'] == $_GET['active_id']) {
327 $nextIndex = $index + 1;
328 break;
329 }
330 }
331
332 if ($nextIndex && isset($participantData[$nextIndex])) {
333 $ilCtrl->setParameter($this, 'active_id', $participantData[$nextIndex]['active_id']);
334 $ilCtrl->redirect($this, 'showManScoringParticipantScreen');
335 }
336
337 $ilCtrl->redirectByClass("iltestscoringgui", "showManScoringParticipantsTable");
338 }
339 }
340
342 {
343 global $ilCtrl;
344
345 if ($this->saveManScoringParticipantScreen(false)) {
346 $ilCtrl->redirectByClass("iltestscoringgui", "showManScoringParticipantsTable");
347 }
348 }
349
350 private function buildManScoringParticipantForm($questionGuiList, $activeId, $pass, $initValues = false)
351 {
352 global $ilCtrl, $lng;
353
354 require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
355 require_once 'Services/Form/classes/class.ilFormSectionHeaderGUI.php';
356 require_once 'Services/Form/classes/class.ilCustomInputGUI.php';
357 require_once 'Services/Form/classes/class.ilCheckboxInputGUI.php';
358 require_once 'Services/Form/classes/class.ilTextInputGUI.php';
359 require_once 'Services/Form/classes/class.ilTextAreaInputGUI.php';
360
361 $ilCtrl->setParameter($this, 'active_id', $activeId);
362 $ilCtrl->setParameter($this, 'pass', $pass);
363
364 $form = new ilPropertyFormGUI();
365 $form->setFormAction($ilCtrl->getFormAction($this));
366
367 $form->setTitle(sprintf($lng->txt('manscoring_results_pass'), $pass + 1));
368 $form->setTableWidth('100%');
369
370 foreach ($questionGuiList as $questionId => $questionGUI) {
371 $questionHeader = sprintf($lng->txt('tst_manscoring_question_section_header'), $questionGUI->object->getTitle());
372 $questionSolution = $questionGUI->getSolutionOutput($activeId, $pass, false, false, true, false, false, true);
373 $bestSolution = $questionGUI->object->getSuggestedSolutionOutput();
374
375 $sect = new ilFormSectionHeaderGUI();
376 $sect->setTitle($questionHeader . ' [' . $this->lng->txt('question_id_short') . ': ' . $questionGUI->object->getId() . ']');
377 $form->addItem($sect);
378
379 $cust = new ilCustomInputGUI($lng->txt('tst_manscoring_input_question_and_user_solution'));
380 $cust->setHtml($questionSolution);
381 $form->addItem($cust);
382
383 $text = new ilTextInputGUI($lng->txt('tst_change_points_for_question'), "question__{$questionId}__points");
384 if ($initValues) {
385 $text->setValue(assQuestion::_getReachedPoints($activeId, $questionId, $pass));
386 }
387 $form->addItem($text);
388
389 $nonedit = new ilNonEditableValueGUI($lng->txt('tst_manscoring_input_max_points_for_question'), "question__{$questionId}__maxpoints");
390 if ($initValues) {
391 $nonedit->setValue(assQuestion::_getMaximumPoints($questionId));
392 }
393 $form->addItem($nonedit);
394
395 $area = new ilTextAreaInputGUI($lng->txt('set_manual_feedback'), "question__{$questionId}__feedback");
396 $area->setUseRTE(true);
397 if ($initValues) {
398 $area->setValue($this->object->getManualFeedback($activeId, $questionId, $pass));
399 }
400 $form->addItem($area);
401
402 if (strlen(trim($bestSolution))) {
403 $cust = new ilCustomInputGUI($lng->txt('tst_show_solution_suggested'));
404 $cust->setHtml($bestSolution);
405 $form->addItem($cust);
406 }
407 }
408
409 $sect = new ilFormSectionHeaderGUI();
410 $sect->setTitle($lng->txt('tst_participant'));
411 $form->addItem($sect);
412
413 $check = new ilCheckboxInputGUI($lng->txt('set_manscoring_done'), 'manscoring_done');
414 if ($initValues && ilTestService::isManScoringDone($activeId)) {
415 $check->setChecked(true);
416 }
417 $form->addItem($check);
418
419 $check = new ilCheckboxInputGUI($lng->txt('tst_manscoring_user_notification'), 'manscoring_notify');
420 $form->addItem($check);
421
422 $form->addCommandButton('saveManScoringParticipantScreen', $lng->txt('save'));
423 $form->addCommandButton('saveReturnManScoringParticipantScreen', $lng->txt('save_return'));
424 $form->addCommandButton('saveNextManScoringParticipantScreen', $lng->txt('save_and_next'));
425
426 return $form;
427 }
428
430 {
431 }
432
436 private function buildManScoringParticipantsTable($withData = false)
437 {
438 require_once 'Modules/Test/classes/tables/class.ilTestManScoringParticipantsTableGUI.php';
440
441 if ($withData) {
442 $participantStatusFilterValue = $table->getFilterItemByPostVar('participant_status')->getValue();
443 $table->setData($this->object->getTestParticipantsForManualScoring($participantStatusFilterValue));
444 }
445
446 return $table;
447 }
448}
sprintf('%.4f', $callTime)
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
static _getReachedPoints($active_id, $question_id, $pass=null)
Returns the points, a learner has reached answering the question.
static _getMaximumPoints($question_id)
Returns the maximum points, a learner can reach 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
global $ilCtrl
Definition: ilias.php:18
const SCORE_LAST_PASS
$index
Definition: metadata.php:60
$ret
Definition: parser.php:6
if(empty($password)) $table
Definition: pwgen.php:24
if(isset($_POST['submit'])) $form
$text
Definition: errorreport.php:18