ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilObjTestSettingsScoringResultsGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once 'Modules/Test/classes/class.ilTestSettingsGUI.php';
5
18{
22 const CMD_SHOW_FORM = 'showForm';
23 const CMD_SAVE_FORM = 'saveForm';
24 const CMD_CONFIRMED_SAVE_FORM = 'confirmedSaveForm';
25
27 protected $ctrl = null;
28
30 protected $access = null;
31
33 protected $lng = null;
34
36 protected $tpl = null;
37
39 protected $tree = null;
40
42 protected $db = null;
43
45 protected $pluginAdmin = null;
46
48 protected $testOBJ = null;
49
51 protected $testGUI = null;
52
55
61 protected $settingsTemplate = null;
62
75 public function __construct(
84 ) {
85 $this->ctrl = $ctrl;
86 $this->access = $access;
87 $this->lng = $lng;
88 $this->tpl = $tpl;
89 $this->tree = $tree;
90 $this->db = $db;
91 $this->pluginAdmin = $pluginAdmin;
92
93 $this->testGUI = $testGUI;
94 $this->testOBJ = $testGUI->object;
95
96 require_once 'Modules/Test/classes/class.ilTestQuestionSetConfigFactory.php';
97 $this->testQuestionSetConfigFactory = new ilTestQuestionSetConfigFactory($this->tree, $this->db, $this->pluginAdmin, $this->testOBJ);
98
99 $templateId = $this->testOBJ->getTemplate();
100
101 if ($templateId) {
102 include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
103 $this->settingsTemplate = new ilSettingsTemplate($templateId, ilObjAssessmentFolderGUI::getSettingsTemplateConfig());
104 }
105 }
106
110 public function executeCommand()
111 {
112 // allow only write access
113
114 if (!$this->access->checkAccess('write', '', $this->testGUI->ref_id)) {
115 ilUtil::sendInfo($this->lng->txt('cannot_edit_test'), true);
116 $this->ctrl->redirect($this->testGUI, 'infoScreen');
117 }
118
119 // process command
120
121 $nextClass = $this->ctrl->getNextClass();
122
123 switch ($nextClass) {
124 default:
125 $cmd = $this->ctrl->getCmd(self::CMD_SHOW_FORM) . 'Cmd';
126 $this->$cmd();
127 }
128 }
129
130 private function showFormCmd(ilPropertyFormGUI $form = null)
131 {
132 //$this->tpl->addJavascript("./Services/JavaScript/js/Basic.js");
133
134 if ($form === null) {
135 $form = $this->buildForm();
136 }
137
138 $this->tpl->setContent($this->ctrl->getHTML($form));
139 }
140
141 private function confirmedSaveFormCmd()
142 {
143 return $this->saveFormCmd(true);
144 }
145
146 private function saveFormCmd($isConfirmedSave = false)
147 {
148 $form = $this->buildForm();
149
150 // form validation and initialisation
151
152 $errors = !$form->checkInput(); // ALWAYS CALL BEFORE setValuesByPost()
153 $form->setValuesByPost(); // NEVER CALL THIS BEFORE checkInput()
154
155 // return to form when any form validation errors exist
156
157 if ($errors) {
158 ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
159 return $this->showFormCmd($form);
160 }
161
162 // check for required confirmation and redirect if neccessary
163
164 if (!$isConfirmedSave && $this->isScoreRecalculationRequired($form)) {
165 return $this->showConfirmation($form);
166 }
167
168 // perform save
169
170 $this->performSaveForm($form);
171
173 $this->testOBJ->recalculateScores(true);
174 }
175
176 // redirect to form output
177
178 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
179 $this->ctrl->redirect($this, self::CMD_SHOW_FORM);
180 }
181
183 {
184 $this->saveScoringSettingsFormSection($form);
185 $this->saveResultSummarySettings($form);
186 $this->saveResultDetailsSettings($form);
187 $this->saveResultMiscOptionsSettings($form);
188
189 // store settings to db
190 $this->testOBJ->saveToDb(true);
191 }
192
194 {
195 require_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
196 $confirmation = new ilConfirmationGUI();
197
198 $confirmation->setHeaderText($this->lng->txt('tst_trigger_result_refreshing'));
199
200 $confirmation->setFormAction($this->ctrl->getFormAction($this));
201 $confirmation->setCancel($this->lng->txt('cancel'), self::CMD_SHOW_FORM);
202 $confirmation->setConfirm($this->lng->txt('confirm'), self::CMD_CONFIRMED_SAVE_FORM);
203
204 foreach ($form->getInputItemsRecursive() as $key => $item) {
205 //vd("$key // {$item->getType()} // ".json_encode($_POST[$item->getPostVar()]));
206
207 switch ($item->getType()) {
208 case 'section_header':
209
210 break;
211
212 case 'datetime':
213
214 $datetime = $item->getDate();
215 if ($datetime instanceof ilDateTime) {
216 list($date, $time) = explode(' ', $datetime->get(IL_CAL_DATETIME));
217 if (!($date instanceof ilDate)) {
218 $confirmation->addHiddenItem($item->getPostVar(), $date . ' ' . $time);
219 } else {
220 $confirmation->addHiddenItem($item->getPostVar(), $date);
221 }
222 } else {
223 $confirmation->addHiddenItem($item->getPostVar(), '');
224 }
225
226 break;
227
228 case 'duration':
229
230 $confirmation->addHiddenItem("{$item->getPostVar()}[MM]", (int) $item->getMonths());
231 $confirmation->addHiddenItem("{$item->getPostVar()}[dd]", (int) $item->getDays());
232 $confirmation->addHiddenItem("{$item->getPostVar()}[hh]", (int) $item->getHours());
233 $confirmation->addHiddenItem("{$item->getPostVar()}[mm]", (int) $item->getMinutes());
234 $confirmation->addHiddenItem("{$item->getPostVar()}[ss]", (int) $item->getSeconds());
235
236 break;
237
238 case 'checkboxgroup':
239
240 if (is_array($item->getValue())) {
241 foreach ($item->getValue() as $option) {
242 $confirmation->addHiddenItem("{$item->getPostVar()}[]", $option);
243 }
244 }
245
246 break;
247
248 case 'checkbox':
249
250 if ($item->getChecked()) {
251 $confirmation->addHiddenItem($item->getPostVar(), 1);
252 }
253
254 break;
255
256 default:
257
258 $confirmation->addHiddenItem($item->getPostVar(), $item->getValue());
259 }
260 }
261
262 $this->tpl->setContent($this->ctrl->getHTML($confirmation));
263 }
264
265 private function buildForm()
266 {
267 include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
268 $form = new ilPropertyFormGUI();
269 $form->setFormAction($this->ctrl->getFormAction($this));
270 $form->setTableWidth('100%');
271 $form->setId('test_scoring_results');
272
277
278 // remove items when using template
279 if ($this->settingsTemplate) {
280 foreach ($this->settingsTemplate->getSettings() as $id => $item) {
281 if ($item["hide"]) {
282 $form->removeItemByPostVar($id);
283 }
284 }
285 }
286
287 $form->addCommandButton(self::CMD_SAVE_FORM, $this->lng->txt('save'));
288
289 return $form;
290 }
291
293 {
294 $fields = array(
295 'count_system', 'mc_scoring', 'score_cutting', 'pass_scoring', 'pass_deletion_allowed'
296 );
297
298 if ($this->isSectionHeaderRequired($fields)) {
299 // scoring settings
301 $header->setTitle($this->lng->txt('test_scoring'));
302 $form->addItem($header);
303 }
304
305 // scoring system
306 $count_system = new ilRadioGroupInputGUI($this->lng->txt('tst_text_count_system'), 'count_system');
307 $count_system->addOption($opt = new ilRadioOption($this->lng->txt('tst_count_partial_solutions'), 0, ''));
308 $opt->setInfo($this->lng->txt('tst_count_partial_solutions_desc'));
309 $count_system->addOption($opt = new ilRadioOption($this->lng->txt('tst_count_correct_solutions'), 1, ''));
310 $opt->setInfo($this->lng->txt('tst_count_correct_solutions_desc'));
311 $count_system->setValue($this->testOBJ->getCountSystem());
312 $form->addItem($count_system);
313
314 // mc questions
315 $mc_scoring = new ilRadioGroupInputGUI($this->lng->txt('tst_score_mcmr_questions'), 'mc_scoring');
316 $mc_scoring->addOption($opt = new ilRadioOption($this->lng->txt('tst_score_mcmr_zero_points_when_unanswered'), 0, ''));
317 $opt->setInfo($this->lng->txt('tst_score_mcmr_zero_points_when_unanswered_desc'));
318 $mc_scoring->addOption($opt = new ilRadioOption($this->lng->txt('tst_score_mcmr_use_scoring_system'), 1, ''));
319 $opt->setInfo($this->lng->txt('tst_score_mcmr_use_scoring_system_desc'));
320 $mc_scoring->setValue($this->testOBJ->getMCScoring());
321 // fau: testNav - set the deprecated mc scoring option to disabled
322 $mc_scoring->setDisabled(true);
323 // fau.
324 $form->addItem($mc_scoring);
325
326 // score cutting
327 $score_cutting = new ilRadioGroupInputGUI($this->lng->txt('tst_score_cutting'), 'score_cutting');
328 $score_cutting->addOption($opt = new ilRadioOption($this->lng->txt('tst_score_cut_question'), 0, ''));
329 $opt->setInfo($this->lng->txt('tst_score_cut_question_desc'));
330 $score_cutting->addOption($opt = new ilRadioOption($this->lng->txt('tst_score_cut_test'), 1, ''));
331 $opt->setInfo($this->lng->txt('tst_score_cut_test_desc'));
332 $score_cutting->setValue($this->testOBJ->getScoreCutting());
333 $form->addItem($score_cutting);
334
335 // pass scoring
336 $pass_scoring = new ilRadioGroupInputGUI($this->lng->txt('tst_pass_scoring'), 'pass_scoring');
337 $pass_scoring->addOption($opt = new ilRadioOption($this->lng->txt('tst_pass_last_pass'), 0, ''));
338 $opt->setInfo($this->lng->txt('tst_pass_last_pass_desc'));
339 $pass_scoring->addOption($opt = new ilRadioOption($this->lng->txt('tst_pass_best_pass'), 1, ''));
340 $opt->setInfo($this->lng->txt('tst_pass_best_pass_desc'));
341 $pass_scoring->setValue($this->testOBJ->getPassScoring());
342 $form->addItem($pass_scoring);
343
344 // deletion of test results
345 $passDeletion = new ilRadioGroupInputGUI($this->lng->txt('tst_pass_deletion'), 'pass_deletion_allowed');
346 $passDeletion->addOption(new ilRadioOption($this->lng->txt('tst_pass_deletion_not_allowed'), 0, ''));
347 $passDeletion->addOption(new ilRadioOption($this->lng->txt('tst_pass_deletion_allowed'), 1, ''));
348 $passDeletion->setValue($this->testOBJ->isPassDeletionAllowed());
349 $form->addItem($passDeletion);
350
351 // disable scoring settings
352 if (!$this->areScoringSettingsWritable()) {
353 $count_system->setDisabled(true);
354 $mc_scoring->setDisabled(true);
355 $score_cutting->setDisabled(true);
356 $pass_scoring->setDisabled(true);
357 }
358 }
359
364 {
365 if ($this->areScoringSettingsWritable()) {
366 if ($this->formPropertyExists($form, 'count_system')) {
367 $this->testOBJ->setCountSystem($form->getItemByPostVar('count_system')->getValue());
368 }
369
370 if ($this->formPropertyExists($form, 'mc_scoring')) {
371 $this->testOBJ->setMCScoring($form->getItemByPostVar('mc_scoring')->getValue());
372 }
373
374 if ($this->formPropertyExists($form, 'score_cutting')) {
375 $this->testOBJ->setScoreCutting($form->getItemByPostVar('score_cutting')->getValue());
376 }
377
378 if ($this->formPropertyExists($form, 'pass_scoring')) {
379 $this->testOBJ->setPassScoring($form->getItemByPostVar('pass_scoring')->getValue());
380 }
381 }
382
383 if ($this->formPropertyExists($form, 'pass_deletion_allowed')) {
384 $this->testOBJ->setPassDeletionAllowed((bool) $form->getItemByPostVar('pass_deletion_allowed')->getValue());
385 }
386 }
387
389 {
390 // HEADER: result settings
391 $header_tr = new ilFormSectionHeaderGUI();
392 $header_tr->setTitle($this->lng->txt('test_results'));
393 $form->addItem($header_tr);
394
395 // access to test results
396 $resultsAccessEnabled = new ilCheckboxInputGUI($this->lng->txt('tst_results_access_enabled'), 'results_access_enabled');
397 $resultsAccessEnabled->setInfo($this->lng->txt('tst_results_access_enabled_desc'));
398 $resultsAccessEnabled->setChecked($this->testOBJ->isScoreReportingEnabled());
399 $resultsAccessSetting = new ilRadioGroupInputGUI($this->lng->txt('tst_results_access_setting'), 'results_access_setting');
400 $resultsAccessSetting->setRequired(true);
401 $optAlways = new ilRadioOption($this->lng->txt('tst_results_access_always'), 2, '');
402 $optAlways->setInfo($this->lng->txt('tst_results_access_always_desc'));
403 $resultsAccessSetting->addOption($optAlways);
404 $optFinished = $opt = new ilRadioOption($this->lng->txt('tst_results_access_finished'), 1, '');
405 $optFinished->setInfo($this->lng->txt('tst_results_access_finished_desc'));
406 $resultsAccessSetting->addOption($optFinished);
407 $optionDate = new ilRadioOption($this->lng->txt('tst_results_access_date'), 3, '');
408 $optionDate->setInfo($this->lng->txt('tst_results_access_date_desc'));
409 // access date
410 $reportingDate = new ilDateTimeInputGUI($this->lng->txt('tst_reporting_date'), 'reporting_date');
411 $reportingDate->setRequired(true);
412 $reportingDate->setShowTime(true);
413 if (strlen($this->testOBJ->getReportingDate())) {
414 $reportingDate->setDate(new ilDateTime($this->testOBJ->getReportingDate(), IL_CAL_TIMESTAMP));
415 } else {
416 $reportingDate->setDate(new ilDateTime(time(), IL_CAL_UNIX));
417 }
418 $optionDate->addSubItem($reportingDate);
419 $resultsAccessSetting->addOption($optionDate);
420 $resultsAccessValue = $this->testOBJ->getScoreReporting();
421 $resultsAccessSetting->setValue(
422 $resultsAccessValue > 0 && $resultsAccessValue < 4 ? $resultsAccessValue : 2
423 );
424 $resultsAccessEnabled->addSubItem($resultsAccessSetting);
425 // show pass details
426 $showPassDetails = new ilCheckboxInputGUI($this->lng->txt('tst_show_pass_details'), 'pass_details');
427 $showPassDetails->setInfo($this->lng->txt('tst_show_pass_details_desc'));
428 $showPassDetails->setChecked($this->testOBJ->getShowPassDetails());
429 $resultsAccessEnabled->addSubItem($showPassDetails);
430 $form->addItem($resultsAccessEnabled);
431
432 // grading
433 $chb_only_passed_failed = new ilCheckboxInputGUI($this->lng->txt('tst_results_grading_opt_show_status'), 'grading_status');
434 $chb_only_passed_failed->setInfo($this->lng->txt('tst_results_grading_opt_show_status_desc'));
435 $chb_only_passed_failed->setValue(1);
436 $chb_only_passed_failed->setChecked($this->testOBJ->isShowGradingStatusEnabled());
437 $resultsAccessEnabled->addSubItem($chb_only_passed_failed);
438
439 $chb_resulting_mark_only = new ilCheckboxInputGUI($this->lng->txt('tst_results_grading_opt_show_mark'), 'grading_mark');
440 $chb_resulting_mark_only->setInfo($this->lng->txt('tst_results_grading_opt_show_mark_desc'));
441 $chb_resulting_mark_only->setValue(1);
442 $chb_resulting_mark_only->setChecked($this->testOBJ->isShowGradingMarkEnabled());
443 $resultsAccessEnabled->addSubItem($chb_resulting_mark_only);
444 }
445
450 {
451 if ($this->formPropertyExists($form, 'results_access_enabled')) {
452 if ($form->getItemByPostVar('results_access_enabled')->getChecked()) {
453 $this->testOBJ->setScoreReporting($form->getItemByPostVar('results_access_setting')->getValue());
454
455 if ($this->testOBJ->getScoreReporting() == REPORT_AFTER_DATE) {
456 $reporting_date = $form->getItemByPostVar('reporting_date')->getDate();
457 if ($reporting_date instanceof ilDateTime) {
458 $this->testOBJ->setReportingDate($reporting_date->get(IL_CAL_FKT_DATE, 'YmdHis'));
459 } else {
460 $this->testOBJ->setReportingDate('');
461 }
462 } else {
463 $this->testOBJ->setReportingDate('');
464 }
465
466 $this->testOBJ->setShowPassDetails($form->getItemByPostVar('pass_details')->getChecked());
467 } else {
468 $this->testOBJ->setScoreReporting(4); // never
469 $this->testOBJ->setShowPassDetails(false);
470 $this->testOBJ->setReportingDate('');
471 }
472 }
473
474 if ($this->formPropertyExists($form, 'grading_status')) {
475 $this->testOBJ->setShowGradingStatusEnabled(
476 $form->getItemByPostVar('grading_status')->getChecked()
477 );
478 }
479
480 if ($this->formPropertyExists($form, 'grading_mark')) {
481 $this->testOBJ->setShowGradingMarkEnabled(
482 (int) $form->getItemByPostVar('grading_mark')->getChecked()
483 );
484 }
485 }
486
488 {
489 // HEADER: result settings
490 $header_tr = new ilFormSectionHeaderGUI();
491 $header_tr->setTitle($this->lng->txt('tst_results_details_options'));
492 $form->addItem($header_tr);
493
494 // show solution details
495 $showSolutionDetails = new ilCheckboxInputGUI($this->lng->txt('tst_show_solution_details'), 'solution_details');
496 $showSolutionDetails->setInfo($this->lng->txt('tst_show_solution_details_desc'));
497 $showSolutionDetails->setChecked($this->testOBJ->getShowSolutionDetails());
498 $form->addItem($showSolutionDetails);
499
500 // best solution in test results
501 $results_print_best_solution = new ilCheckboxInputGUI($this->lng->txt('tst_results_print_best_solution'), 'print_bs_with_res');
502 $results_print_best_solution->setInfo($this->lng->txt('tst_results_print_best_solution_info'));
503 $results_print_best_solution->setChecked((bool) $this->testOBJ->isBestSolutionPrintedWithResult());
504 $showSolutionDetails->addSubItem($results_print_best_solution);
505
506 // show solution feedback ==> solution feedback in test results
507 $showSolutionFeedbackOption = new ilCheckboxInputGUI($this->lng->txt('tst_show_solution_feedback'), 'solution_feedback');
508 $showSolutionFeedbackOption->setInfo($this->lng->txt('tst_show_solution_feedback_desc'));
509 $showSolutionFeedbackOption->setChecked($this->testOBJ->getShowSolutionFeedback());
510 $form->addItem($showSolutionFeedbackOption);
511
512 // show suggested solution
513 $showSuggestedSolutionOption = new ilCheckboxInputGUI($this->lng->txt('tst_show_solution_suggested'), 'solution_suggested');
514 $showSuggestedSolutionOption->setInfo($this->lng->txt('tst_show_solution_suggested_desc'));
515 $showSuggestedSolutionOption->setChecked($this->testOBJ->getShowSolutionSuggested());
516 $form->addItem($showSuggestedSolutionOption);
517
518 // show solution printview ==> list of answers
519 $showSolutionPrintview = new ilCheckboxInputGUI($this->lng->txt('tst_show_solution_printview'), 'solution_printview');
520 $showSolutionPrintview->setInfo($this->lng->txt('tst_show_solution_printview_desc'));
521 $showSolutionPrintview->setChecked($this->testOBJ->getShowSolutionPrintview());
522 $form->addItem($showSolutionPrintview);
523
524 // show best solution in list of answers
525 $solutionCompareInput = new ilCheckboxInputGUI($this->lng->txt('tst_show_solution_compare'), 'solution_compare');
526 $solutionCompareInput->setInfo($this->lng->txt('tst_show_solution_compare_desc'));
527 $solutionCompareInput->setChecked($this->testOBJ->getShowSolutionListComparison());
528 $showSolutionPrintview->addSubItem($solutionCompareInput);
529
530 // solution answers only ==> printview of results (answers only)
531 $solutionAnswersOnly = new ilCheckboxInputGUI($this->lng->txt('tst_show_solution_answers_only'), 'solution_answers_only');
532 $solutionAnswersOnly->setInfo($this->lng->txt('tst_show_solution_answers_only_desc'));
533 $solutionAnswersOnly->setChecked($this->testOBJ->getShowSolutionAnswersOnly());
534 $showSolutionPrintview->addSubItem($solutionAnswersOnly);
535
536 // high score
537 $highscore = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_enabled"), "highscore_enabled");
538 $highscore->setValue(1);
539 $highscore->setChecked($this->testOBJ->getHighscoreEnabled());
540 $highscore->setInfo($this->lng->txt("tst_highscore_description"));
541 $form->addItem($highscore);
542 $highscore_tables = new ilRadioGroupInputGUI($this->lng->txt('tst_highscore_mode'), 'highscore_mode');
543 $highscore_tables->setRequired(true);
544 $highscore_tables->setValue($this->testOBJ->getHighscoreMode());
545 $highscore_table_own = new ilRadioOption($this->lng->txt('tst_highscore_own_table'), ilObjTest::HIGHSCORE_SHOW_OWN_TABLE);
546 $highscore_table_own->setInfo($this->lng->txt('tst_highscore_own_table_description'));
547 $highscore_tables->addOption($highscore_table_own);
548 $highscore_table_other = new ilRadioOption($this->lng->txt('tst_highscore_top_table'), ilObjTest::HIGHSCORE_SHOW_TOP_TABLE);
549 $highscore_table_other->setInfo($this->lng->txt('tst_highscore_top_table_description'));
550 $highscore_tables->addOption($highscore_table_other);
551 $highscore_table_other = new ilRadioOption($this->lng->txt('tst_highscore_all_tables'), ilObjTest::HIGHSCORE_SHOW_ALL_TABLES);
552 $highscore_table_other->setInfo($this->lng->txt('tst_highscore_all_tables_description'));
553 $highscore_tables->addOption($highscore_table_other);
554 $highscore->addSubItem($highscore_tables);
555 $highscore_top_num = new ilNumberInputGUI($this->lng->txt("tst_highscore_top_num"), "highscore_top_num");
556 $highscore_top_num->setSize(4);
557 $highscore_top_num->setRequired(true);
558 $highscore_top_num->setMinValue(1);
559 $highscore_top_num->setSuffix($this->lng->txt("tst_highscore_top_num_unit"));
560 $highscore_top_num->setValue($this->testOBJ->getHighscoreTopNum(null));
561 $highscore_top_num->setInfo($this->lng->txt("tst_highscore_top_num_description"));
562 $highscore->addSubItem($highscore_top_num);
563 $highscore_anon = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_anon"), "highscore_anon");
564 $highscore_anon->setValue(1);
565 $highscore_anon->setChecked($this->testOBJ->getHighscoreAnon());
566 $highscore_anon->setInfo($this->lng->txt("tst_highscore_anon_description"));
567 $highscore->addSubItem($highscore_anon);
568 $highscore_achieved_ts = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_achieved_ts"), "highscore_achieved_ts");
569 $highscore_achieved_ts->setValue(1);
570 $highscore_achieved_ts->setChecked($this->testOBJ->getHighscoreAchievedTS());
571 $highscore_achieved_ts->setInfo($this->lng->txt("tst_highscore_achieved_ts_description"));
572 $highscore->addSubItem($highscore_achieved_ts);
573 $highscore_score = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_score"), "highscore_score");
574 $highscore_score->setValue(1);
575 $highscore_score->setChecked($this->testOBJ->getHighscoreScore());
576 $highscore_score->setInfo($this->lng->txt("tst_highscore_score_description"));
577 $highscore->addSubItem($highscore_score);
578 $highscore_percentage = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_percentage"), "highscore_percentage");
579 $highscore_percentage->setValue(1);
580 $highscore_percentage->setChecked($this->testOBJ->getHighscorePercentage());
581 $highscore_percentage->setInfo($this->lng->txt("tst_highscore_percentage_description"));
582 $highscore->addSubItem($highscore_percentage);
583 $highscore_hints = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_hints"), "highscore_hints");
584 $highscore_hints->setValue(1);
585 $highscore_hints->setChecked($this->testOBJ->getHighscoreHints());
586 $highscore_hints->setInfo($this->lng->txt("tst_highscore_hints_description"));
587 $highscore->addSubItem($highscore_hints);
588 $highscore_wtime = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_wtime"), "highscore_wtime");
589 $highscore_wtime->setValue(1);
590 $highscore_wtime->setChecked($this->testOBJ->getHighscoreWTime());
591 $highscore_wtime->setInfo($this->lng->txt("tst_highscore_wtime_description"));
592 $highscore->addSubItem($highscore_wtime);
593
594 // show signature placeholder
595 $showSignaturePlaceholder = new ilCheckboxInputGUI($this->lng->txt('tst_show_solution_signature'), 'solution_signature');
596 $showSignaturePlaceholder->setInfo($this->lng->txt('tst_show_solution_signature_desc'));
597 $showSignaturePlaceholder->setChecked($this->testOBJ->getShowSolutionSignature());
598 if ($this->testOBJ->getAnonymity()) {
599 $showSignaturePlaceholder->setDisabled(true);
600 }
601 $form->addItem($showSignaturePlaceholder);
602
603 // show signature placeholder
604 $showExamId = new ilCheckboxInputGUI($this->lng->txt('examid_in_test_res'), 'examid_in_test_res');
605 $showExamId->setInfo($this->lng->txt('examid_in_test_res_desc'));
606 $showExamId->setChecked($this->testOBJ->isShowExamIdInTestResultsEnabled());
607 $form->addItem($showExamId);
608
609 // export settings
610 $export_settings = new ilCheckboxInputGUI($this->lng->txt('tst_exp_sc_short'), 'exp_sc_short');
611 $export_settings->setInfo($this->lng->txt('tst_exp_sc_short_desc'));
612 $export_settings->setChecked($this->testOBJ->getExportSettingsSingleChoiceShort());
613 $form->addItem($export_settings);
614 }
615
620 {
621 if ($this->formPropertyExists($form, 'solution_details')) {
622 if ($form->getItemByPostVar('solution_details')->getChecked()) {
623 $this->testOBJ->setShowSolutionDetails(1);
624 $this->testOBJ->setPrintBestSolutionWithResult(
625 (int) $form->getItemByPostVar('print_bs_with_res')->getChecked()
626 );
627 } else {
628 $this->testOBJ->setShowSolutionDetails(0);
629 $this->testOBJ->setPrintBestSolutionWithResult(0);
630 }
631 }
632
633 if ($this->formPropertyExists($form, 'solution_feedback')) {
634 $this->testOBJ->setShowSolutionFeedback($form->getItemByPostVar('solution_feedback')->getChecked());
635 }
636
637 if ($this->formPropertyExists($form, 'solution_suggested')) {
638 $this->testOBJ->setShowSolutionSuggested($form->getItemByPostVar('solution_suggested')->getChecked());
639 }
640
641 if ($this->formPropertyExists($form, 'solution_printview')) {
642 if ($form->getItemByPostVar('solution_printview')->getChecked()) {
643 $this->testOBJ->setShowSolutionPrintview(1);
644 $this->testOBJ->setShowSolutionListComparison(
645 (bool) $form->getItemByPostVar('solution_compare')->getChecked()
646 );
647 $this->testOBJ->setShowSolutionAnswersOnly(
648 (int) $form->getItemByPostVar('solution_answers_only')->getChecked()
649 );
650 } else {
651 $this->testOBJ->setShowSolutionPrintview(0);
652 $this->testOBJ->setShowSolutionListComparison(false);
653 $this->testOBJ->setShowSolutionAnswersOnly(0);
654 }
655 }
656
657 if ($this->formPropertyExists($form, 'highscore_enabled')) {
658 // highscore settings
659 $this->testOBJ->setHighscoreEnabled((bool) $form->getItemByPostVar('highscore_enabled')->getChecked());
660 $this->testOBJ->setHighscoreAnon((bool) $form->getItemByPostVar('highscore_anon')->getChecked());
661 $this->testOBJ->setHighscoreAchievedTS((bool) $form->getItemByPostVar('highscore_achieved_ts')->getChecked());
662 $this->testOBJ->setHighscoreScore((bool) $form->getItemByPostVar('highscore_score')->getChecked());
663 $this->testOBJ->setHighscorePercentage((bool) $form->getItemByPostVar('highscore_percentage')->getChecked());
664 $this->testOBJ->setHighscoreHints((bool) $form->getItemByPostVar('highscore_hints')->getChecked());
665 $this->testOBJ->setHighscoreWTime((bool) $form->getItemByPostVar('highscore_wtime')->getChecked());
666 $this->testOBJ->setHighscoreMode((int) $form->getItemByPostVar('highscore_mode')->getValue());
667 $this->testOBJ->setHighscoreTopNum((int) $form->getItemByPostVar('highscore_top_num')->getValue());
668 }
669
670 if ($this->formPropertyExists($form, 'solution_signature')) {
671 $this->testOBJ->setShowSolutionSignature($form->getItemByPostVar('solution_signature')->getChecked());
672 }
673
674 if ($this->formPropertyExists($form, 'examid_in_test_res')) {
675 $this->testOBJ->setShowExamIdInTestResultsEnabled($form->getItemByPostVar('examid_in_test_res')->getChecked());
676 }
677
678 if ($this->formPropertyExists($form, 'exp_sc_short')) {
679 $this->testOBJ->setExportSettingsSingleChoiceShort((int) $form->getItemByPostVar('exp_sc_short')->getChecked());
680 }
681 }
682
684 {
685 if ($this->testQuestionSetConfigFactory->getQuestionSetConfig()->isResultTaxonomyFilterSupported()) {
686 // misc settings
687 $header_misc = new ilFormSectionHeaderGUI();
688 $header_misc->setTitle($this->lng->txt('misc'));
689 $form->addItem($header_misc);
690 }
691
692 // result filter taxonomies
693 if ($this->testQuestionSetConfigFactory->getQuestionSetConfig()->isResultTaxonomyFilterSupported()) {
695
696 if (count($availableTaxonomyIds)) {
697 require_once 'Modules/Test/classes/class.ilTestTaxonomyFilterLabelTranslater.php';
698 $labelTranslater = new ilTestTaxonomyFilterLabelTranslater($this->db);
699 $labelTranslater->loadLabelsFromTaxonomyIds($availableTaxonomyIds);
700
701 $results_presentation = new ilCheckboxGroupInputGUI($this->lng->txt('tst_results_tax_filters'), 'results_tax_filters');
702
703 foreach ($availableTaxonomyIds as $taxonomyId) {
704 $results_presentation->addOption(new ilCheckboxOption(
705 $labelTranslater->getTaxonomyTreeLabel($taxonomyId),
706 $taxonomyId,
707 ''
708 ));
709 }
710
711 $results_presentation->setValue($this->testOBJ->getResultFilterTaxIds());
712
713 $form->addItem($results_presentation);
714 }
715 }
716 }
717
722 {
723 // result filter taxonomies
724 if ($this->testQuestionSetConfigFactory->getQuestionSetConfig()->isResultTaxonomyFilterSupported()) {
725 if (!$this->isHiddenFormItem('results_tax_filters') && count($this->getAvailableTaxonomyIds())) {
726 $taxFilters = array();
727
728 if (is_array($form->getItemByPostVar('results_tax_filters')->getValue())) {
729 $taxFilters = array_intersect(
731 $form->getItemByPostVar('results_tax_filters')->getValue()
732 );
733 }
734
735 $this->testOBJ->setResultFilterTaxIds($taxFilters);
736 }
737 }
738 }
739
740 private function areScoringSettingsWritable()
741 {
742 if (!$this->testOBJ->participantDataExist()) {
743 return true;
744 }
745
746 if (!$this->testOBJ->isScoreReportingAvailable()) {
747 return true;
748 }
749
750 return false;
751 }
752
754 {
755 if (!$this->testOBJ->participantDataExist()) {
756 return false;
757 }
758
759 if (!$this->areScoringSettingsWritable()) {
760 return false;
761 }
762
763 if (!$this->hasScoringSettingsChanged($form)) {
764 return false;
765 }
766
767 return true;
768 }
769
771 {
772 $countSystem = $form->getItemByPostVar('count_system');
773 if (is_object($countSystem) && $countSystem->getValue() != $this->testOBJ->getCountSystem()) {
774 return true;
775 }
776
777 $mcScoring = $form->getItemByPostVar('mc_scoring');
778 if (is_object($mcScoring) && $mcScoring->getValue() != $this->testOBJ->getMCScoring()) {
779 return true;
780 }
781
782 $scoreCutting = $form->getItemByPostVar('score_cutting');
783 if (is_object($scoreCutting) && $scoreCutting->getValue() != $this->testOBJ->getScoreCutting()) {
784 return true;
785 }
786
787 $passScoring = $form->getItemByPostVar('pass_scoring');
788 if (is_object($passScoring) && $passScoring->getValue() != $this->testOBJ->getPassScoring()) {
789 return true;
790 }
791
792 return false;
793 }
794
795 private $availableTaxonomyIds = null;
796
797 private function getAvailableTaxonomyIds()
798 {
799 if ($this->getAvailableTaxonomyIds === null) {
800 require_once 'Services/Taxonomy/classes/class.ilObjTaxonomy.php';
801 $this->availableTaxonomyIds = (array) ilObjTaxonomy::getUsageOfObject($this->testOBJ->getId());
802 }
803
805 }
806}
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_TIMESTAMP
const IL_CAL_UNIX
const IL_CAL_DATETIME
const IL_CAL_FKT_DATE
This class represents a property in a property form.
This class represents a checkbox property in a property form.
This class represents an option in a checkbox group.
Confirmation screen class.
This class provides processing control methods.
This class represents a date/time property in a property form.
@classDescription Date and time handling
Class for single dates.
This class represents a section header in a property form.
language handling
This class represents a number property in a property form.
static getUsageOfObject($a_obj_id, $a_include_titles=false)
Get usage of object.
Class ilObjTestGUI.
__construct(ilCtrl $ctrl, ilAccessHandler $access, ilLanguage $lng, ilTemplate $tpl, ilTree $tree, ilDBInterface $db, ilPluginAdmin $pluginAdmin, ilObjTestGUI $testGUI)
Constructor.
const HIGHSCORE_SHOW_ALL_TABLES
const HIGHSCORE_SHOW_OWN_TABLE
const HIGHSCORE_SHOW_TOP_TABLE
Administration class for plugins.
This class represents a property form user interface.
getItemByPostVar($a_post_var)
Get Item by POST variable.
This class represents a property in a property form.
This class represents an option in a radio group.
Settings template application class.
special template class to simplify handling of ITX/PEAR
formPropertyExists(ilPropertyFormGUI $form, $propertyId)
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
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.
$key
Definition: croninfo.php:18
if(!array_key_exists('StateId', $_REQUEST)) $id
const REPORT_AFTER_DATE
Interface ilAccessHandler.
Interface ilDBInterface.
$time
Definition: cron.php:21
$errors
Definition: index.php:6
if(isset($_POST['submit'])) $form