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