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