ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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  {
86  $this->ctrl = $ctrl;
87  $this->access = $access;
88  $this->lng = $lng;
89  $this->tpl = $tpl;
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  {
104  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
105  $this->settingsTemplate = new ilSettingsTemplate($templateId, ilObjAssessmentFolderGUI::getSettingsTemplateConfig());
106  }
107  }
108 
112  public function executeCommand()
113  {
114  // allow only write access
115 
116  if (!$this->access->checkAccess('write', '', $this->testGUI->ref_id))
117  {
118  ilUtil::sendInfo($this->lng->txt('cannot_edit_test'), true);
119  $this->ctrl->redirect($this->testGUI, 'infoScreen');
120  }
121 
122  // process command
123 
124  $nextClass = $this->ctrl->getNextClass();
125 
126  switch($nextClass)
127  {
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  {
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  {
164  ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
165  return $this->showFormCmd($form);
166  }
167 
168  // check for required confirmation and redirect if neccessary
169 
170  if( !$isConfirmedSave && $this->isScoreRecalculationRequired($form) )
171  {
172  return $this->showConfirmation($form);
173  }
174 
175  // perform save
176 
177  $this->performSaveForm($form);
178 
179  if( $this->isScoreRecalculationRequired($form) )
180  {
181  $this->testOBJ->recalculateScores(true);
182  }
183 
184  // redirect to form output
185 
186  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
187  $this->ctrl->redirect($this, self::CMD_SHOW_FORM);
188  }
189 
190  private function performSaveForm(ilPropertyFormGUI $form)
191  {
192  $this->saveScoringSettingsFormSection($form);
193  $this->saveResultSummarySettings($form);
194  $this->saveResultDetailsSettings($form);
195  $this->saveResultMiscOptionsSettings($form);
196 
197  // store settings to db
198  $this->testOBJ->saveToDb(true);
199  }
200 
201  private function showConfirmation(ilPropertyFormGUI $form)
202  {
203  require_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
204  $confirmation = new ilConfirmationGUI();
205 
206  $confirmation->setHeaderText($this->lng->txt('tst_trigger_result_refreshing'));
207 
208  $confirmation->setFormAction( $this->ctrl->getFormAction($this) );
209  $confirmation->setCancel($this->lng->txt('cancel'), self::CMD_SHOW_FORM);
210  $confirmation->setConfirm($this->lng->txt('confirm'), self::CMD_CONFIRMED_SAVE_FORM);
211 
212  foreach ($form->getInputItemsRecursive() as $key => $item)
213  {
214  //vd("$key // {$item->getType()} // ".json_encode($_POST[$item->getPostVar()]));
215 
216  switch( $item->getType() )
217  {
218  case 'section_header':
219 
220  break;
221 
222  case 'datetime':
223 
224  $datetime = $item->getDate();
225  if($datetime instanceof ilDateTime)
226  {
227  list($date, $time) = explode(' ', $datetime->get(IL_CAL_DATETIME));
228  if(!($date instanceof ilDate))
229  {
230  $confirmation->addHiddenItem($item->getPostVar(), $date . ' ' . $time);
231  }
232  else
233  {
234  $confirmation->addHiddenItem($item->getPostVar(), $date);
235  }
236  }
237  else
238  {
239  $confirmation->addHiddenItem($item->getPostVar(), '');
240  }
241 
242  break;
243 
244  case 'duration':
245 
246  $confirmation->addHiddenItem("{$item->getPostVar()}[MM]", (int)$item->getMonths());
247  $confirmation->addHiddenItem("{$item->getPostVar()}[dd]", (int)$item->getDays());
248  $confirmation->addHiddenItem("{$item->getPostVar()}[hh]", (int)$item->getHours());
249  $confirmation->addHiddenItem("{$item->getPostVar()}[mm]", (int)$item->getMinutes());
250  $confirmation->addHiddenItem("{$item->getPostVar()}[ss]", (int)$item->getSeconds());
251 
252  break;
253 
254  case 'checkboxgroup':
255 
256  if( is_array($item->getValue()) )
257  {
258  foreach( $item->getValue() as $option )
259  {
260  $confirmation->addHiddenItem("{$item->getPostVar()}[]", $option);
261  }
262  }
263 
264  break;
265 
266  case 'checkbox':
267 
268  if( $item->getChecked() )
269  {
270  $confirmation->addHiddenItem($item->getPostVar(), 1);
271  }
272 
273  break;
274 
275  default:
276 
277  $confirmation->addHiddenItem($item->getPostVar(), $item->getValue());
278  }
279  }
280 
281  $this->tpl->setContent( $this->ctrl->getHTML($confirmation) );
282  }
283 
284  private function buildForm()
285  {
286  include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
287  $form = new ilPropertyFormGUI();
288  $form->setFormAction($this->ctrl->getFormAction($this));
289  $form->setTableWidth('100%');
290  $form->setId('test_scoring_results');
291 
292  $this->addScoringSettingsFormSection($form);
295  $this->addMiscSettingsFormSection($form);
296 
297  // remove items when using template
298  if($this->settingsTemplate)
299  {
300  foreach($this->settingsTemplate->getSettings() as $id => $item)
301  {
302  if($item["hide"])
303  {
304  $form->removeItemByPostVar($id);
305  }
306  }
307  }
308 
309  $form->addCommandButton(self::CMD_SAVE_FORM, $this->lng->txt('save'));
310 
311  return $form;
312  }
313 
315  {
316  $fields = array(
317  'count_system', 'mc_scoring', 'score_cutting', 'pass_scoring', 'pass_deletion_allowed'
318  );
319 
320  if( $this->isSectionHeaderRequired($fields) )
321  {
322  // scoring settings
324  $header->setTitle($this->lng->txt('test_scoring'));
325  $form->addItem($header);
326  }
327 
328  // scoring system
329  $count_system = new ilRadioGroupInputGUI($this->lng->txt('tst_text_count_system'), 'count_system');
330  $count_system->addOption($opt = new ilRadioOption($this->lng->txt('tst_count_partial_solutions'), 0, ''));
331  $opt->setInfo($this->lng->txt('tst_count_partial_solutions_desc'));
332  $count_system->addOption($opt = new ilRadioOption($this->lng->txt('tst_count_correct_solutions'), 1, ''));
333  $opt->setInfo($this->lng->txt('tst_count_correct_solutions_desc'));
334  $count_system->setValue($this->testOBJ->getCountSystem());
335  $form->addItem($count_system);
336 
337  // mc questions
338  $mc_scoring = new ilRadioGroupInputGUI($this->lng->txt('tst_score_mcmr_questions'), 'mc_scoring');
339  $mc_scoring->addOption($opt = new ilRadioOption($this->lng->txt('tst_score_mcmr_zero_points_when_unanswered'), 0, ''));
340  $opt->setInfo($this->lng->txt('tst_score_mcmr_zero_points_when_unanswered_desc'));
341  $mc_scoring->addOption($opt = new ilRadioOption($this->lng->txt('tst_score_mcmr_use_scoring_system'), 1, ''));
342  $opt->setInfo($this->lng->txt('tst_score_mcmr_use_scoring_system_desc'));
343  $mc_scoring->setValue($this->testOBJ->getMCScoring());
344 // fau: testNav - set the deprecated mc scoring option to disabled
345  $mc_scoring->setDisabled(true);
346 // fau.
347  $form->addItem($mc_scoring);
348 
349  // score cutting
350  $score_cutting = new ilRadioGroupInputGUI($this->lng->txt('tst_score_cutting'), 'score_cutting');
351  $score_cutting->addOption($opt = new ilRadioOption($this->lng->txt('tst_score_cut_question'), 0, ''));
352  $opt->setInfo($this->lng->txt('tst_score_cut_question_desc'));
353  $score_cutting->addOption($opt = new ilRadioOption($this->lng->txt('tst_score_cut_test'), 1, ''));
354  $opt->setInfo($this->lng->txt('tst_score_cut_test_desc'));
355  $score_cutting->setValue($this->testOBJ->getScoreCutting());
356  $form->addItem($score_cutting);
357 
358  // pass scoring
359  $pass_scoring = new ilRadioGroupInputGUI($this->lng->txt('tst_pass_scoring'), 'pass_scoring');
360  $pass_scoring->addOption($opt = new ilRadioOption($this->lng->txt('tst_pass_last_pass'), 0, ''));
361  $opt->setInfo($this->lng->txt('tst_pass_last_pass_desc'));
362  $pass_scoring->addOption($opt = new ilRadioOption($this->lng->txt('tst_pass_best_pass'), 1, ''));
363  $opt->setInfo($this->lng->txt('tst_pass_best_pass_desc'));
364  $pass_scoring->setValue($this->testOBJ->getPassScoring());
365  $form->addItem($pass_scoring);
366 
367  // deletion of test results
368  $passDeletion = new ilRadioGroupInputGUI($this->lng->txt('tst_pass_deletion'), 'pass_deletion_allowed');
369  $passDeletion->addOption(new ilRadioOption($this->lng->txt('tst_pass_deletion_not_allowed'), 0, ''));
370  $passDeletion->addOption(new ilRadioOption($this->lng->txt('tst_pass_deletion_allowed'), 1, ''));
371  $passDeletion->setValue($this->testOBJ->isPassDeletionAllowed());
372  $form->addItem($passDeletion);
373 
374  // disable scoring settings
375  if( !$this->areScoringSettingsWritable() )
376  {
377  $count_system->setDisabled(true);
378  $mc_scoring->setDisabled(true);
379  $score_cutting->setDisabled(true);
380  $pass_scoring->setDisabled(true);
381  }
382  }
383 
388  {
389  if( $this->areScoringSettingsWritable() )
390  {
391  if( $this->formPropertyExists($form, 'count_system') )
392  {
393  $this->testOBJ->setCountSystem($form->getItemByPostVar('count_system')->getValue());
394  }
395 
396  if( $this->formPropertyExists($form, 'mc_scoring') )
397  {
398  $this->testOBJ->setMCScoring($form->getItemByPostVar('mc_scoring')->getValue());
399  }
400 
401  if( $this->formPropertyExists($form, 'score_cutting') )
402  {
403  $this->testOBJ->setScoreCutting($form->getItemByPostVar('score_cutting')->getValue());
404  }
405 
406  if( $this->formPropertyExists($form, 'pass_scoring') )
407  {
408  $this->testOBJ->setPassScoring($form->getItemByPostVar('pass_scoring')->getValue());
409  }
410  }
411 
412  if( $this->formPropertyExists($form, 'pass_deletion_allowed') )
413  {
414  $this->testOBJ->setPassDeletionAllowed( (bool)$form->getItemByPostVar('pass_deletion_allowed')->getValue() );
415  }
416  }
417 
419  {
420  // HEADER: result settings
421  $header_tr = new ilFormSectionHeaderGUI();
422  $header_tr->setTitle($this->lng->txt('test_results'));
423  $form->addItem($header_tr);
424 
425  // access to test results
426  $resultsAccessEnabled = new ilCheckboxInputGUI($this->lng->txt('tst_results_access_enabled'), 'results_access_enabled');
427  $resultsAccessEnabled->setInfo($this->lng->txt('tst_results_access_enabled_desc'));
428  $resultsAccessEnabled->setChecked($this->testOBJ->isScoreReportingEnabled());
429  $resultsAccessSetting = new ilRadioGroupInputGUI($this->lng->txt('tst_results_access_setting'), 'results_access_setting');
430  $resultsAccessSetting->setRequired(true);
431  $optAlways = new ilRadioOption($this->lng->txt('tst_results_access_always'), 2, '');
432  $optAlways->setInfo($this->lng->txt('tst_results_access_always_desc'));
433  $resultsAccessSetting->addOption($optAlways);
434  $optFinished = $opt = new ilRadioOption($this->lng->txt('tst_results_access_finished'), 1, '');
435  $optFinished->setInfo($this->lng->txt('tst_results_access_finished_desc'));
436  $resultsAccessSetting->addOption($optFinished);
437  $optionDate = new ilRadioOption($this->lng->txt('tst_results_access_date'), 3, '');
438  $optionDate->setInfo($this->lng->txt('tst_results_access_date_desc'));
439  // access date
440  $reportingDate = new ilDateTimeInputGUI($this->lng->txt('tst_reporting_date'), 'reporting_date');
441  $reportingDate->setRequired(true);
442  $reportingDate->setShowTime(true);
443  if (strlen($this->testOBJ->getReportingDate()))
444  {
445  $reportingDate->setDate(new ilDateTime($this->testOBJ->getReportingDate(), IL_CAL_TIMESTAMP));
446  }
447  else
448  {
449  $reportingDate->setDate(new ilDateTime(time(), IL_CAL_UNIX));
450  }
451  $optionDate->addSubItem($reportingDate);
452  $resultsAccessSetting->addOption($optionDate);
453  $resultsAccessValue = $this->testOBJ->getScoreReporting();
454  $resultsAccessSetting->setValue(
455  $resultsAccessValue > 0 && $resultsAccessValue < 4 ? $resultsAccessValue : 2
456  );
457  $resultsAccessEnabled->addSubItem($resultsAccessSetting);
458  // show pass details
459  $showPassDetails = new ilCheckboxInputGUI($this->lng->txt('tst_show_pass_details'), 'pass_details');
460  $showPassDetails->setInfo($this->lng->txt('tst_show_pass_details_desc'));
461  $showPassDetails->setChecked($this->testOBJ->getShowPassDetails());
462  $resultsAccessEnabled->addSubItem($showPassDetails);
463  $form->addItem($resultsAccessEnabled);
464 
465  // grading
466  $chb_only_passed_failed = new ilCheckboxInputGUI($this->lng->txt('tst_results_grading_opt_show_status'), 'grading_status');
467  $chb_only_passed_failed->setInfo($this->lng->txt('tst_results_grading_opt_show_status_desc'));
468  $chb_only_passed_failed->setValue(1);
469  $chb_only_passed_failed->setChecked($this->testOBJ->isShowGradingStatusEnabled());
470  $resultsAccessEnabled->addSubItem($chb_only_passed_failed);
471 
472  $chb_resulting_mark_only = new ilCheckboxInputGUI($this->lng->txt('tst_results_grading_opt_show_mark'), 'grading_mark');
473  $chb_resulting_mark_only->setInfo($this->lng->txt('tst_results_grading_opt_show_mark_desc'));
474  $chb_resulting_mark_only->setValue(1);
475  $chb_resulting_mark_only->setChecked($this->testOBJ->isShowGradingMarkEnabled());
476  $resultsAccessEnabled->addSubItem($chb_resulting_mark_only);
477  }
478 
483  {
484  if( $this->formPropertyExists($form, 'results_access_enabled') )
485  {
486  if( $form->getItemByPostVar('results_access_enabled')->getChecked() )
487  {
488  $this->testOBJ->setScoreReporting($form->getItemByPostVar('results_access_setting')->getValue());
489 
490  if( $this->testOBJ->getScoreReporting() == REPORT_AFTER_DATE )
491  {
492  $reporting_date = $form->getItemByPostVar('reporting_date')->getDate();
493  if($reporting_date instanceof ilDateTime)
494  {
495  $this->testOBJ->setReportingDate($reporting_date->get(IL_CAL_FKT_DATE, 'YmdHis'));
496  }
497  else
498  {
499  $this->testOBJ->setReportingDate('');
500  }
501  }
502  else
503  {
504  $this->testOBJ->setReportingDate('');
505  }
506 
507  $this->testOBJ->setShowPassDetails($form->getItemByPostVar('pass_details')->getChecked());
508  }
509  else
510  {
511  $this->testOBJ->setScoreReporting(4); // never
512  $this->testOBJ->setShowPassDetails(false);
513  $this->testOBJ->setReportingDate('');
514  }
515  }
516 
517  if( $this->formPropertyExists($form, 'grading_status') )
518  {
519  $this->testOBJ->setShowGradingStatusEnabled(
520  $form->getItemByPostVar('grading_status')->getChecked()
521  );
522  }
523 
524  if( $this->formPropertyExists($form, 'grading_mark') )
525  {
526  $this->testOBJ->setShowGradingMarkEnabled(
527  (int)$form->getItemByPostVar('grading_mark')->getChecked()
528  );
529  }
530  }
531 
533  {
534  // HEADER: result settings
535  $header_tr = new ilFormSectionHeaderGUI();
536  $header_tr->setTitle($this->lng->txt('tst_results_details_options'));
537  $form->addItem($header_tr);
538 
539  // show solution details
540  $showSolutionDetails = new ilCheckboxInputGUI($this->lng->txt('tst_show_solution_details'), 'solution_details');
541  $showSolutionDetails->setInfo($this->lng->txt('tst_show_solution_details_desc'));
542  $showSolutionDetails->setChecked($this->testOBJ->getShowSolutionDetails());
543  $form->addItem($showSolutionDetails);
544 
545  // best solution in test results
546  $results_print_best_solution = new ilCheckboxInputGUI($this->lng->txt('tst_results_print_best_solution'), 'print_bs_with_res');
547  $results_print_best_solution->setInfo($this->lng->txt('tst_results_print_best_solution_info'));
548  $results_print_best_solution->setChecked((bool) $this->testOBJ->isBestSolutionPrintedWithResult());
549  $showSolutionDetails->addSubItem($results_print_best_solution);
550 
551  // show solution feedback ==> solution feedback in test results
552  $showSolutionFeedbackOption = new ilCheckboxInputGUI($this->lng->txt('tst_show_solution_feedback'), 'solution_feedback');
553  $showSolutionFeedbackOption->setInfo($this->lng->txt('tst_show_solution_feedback_desc'));
554  $showSolutionFeedbackOption->setChecked($this->testOBJ->getShowSolutionFeedback());
555  $form->addItem($showSolutionFeedbackOption);
556 
557  // show suggested solution
558  $showSuggestedSolutionOption = new ilCheckboxInputGUI($this->lng->txt('tst_show_solution_suggested'), 'solution_suggested');
559  $showSuggestedSolutionOption->setInfo($this->lng->txt('tst_show_solution_suggested_desc'));
560  $showSuggestedSolutionOption->setChecked($this->testOBJ->getShowSolutionSuggested());
561  $form->addItem($showSuggestedSolutionOption);
562 
563  // show solution printview ==> list of answers
564  $showSolutionPrintview = new ilCheckboxInputGUI($this->lng->txt('tst_show_solution_printview'), 'solution_printview');
565  $showSolutionPrintview->setInfo($this->lng->txt('tst_show_solution_printview_desc'));
566  $showSolutionPrintview->setChecked($this->testOBJ->getShowSolutionPrintview());
567  $form->addItem($showSolutionPrintview);
568 
569  // show best solution in list of answers
570  $solutionCompareInput = new ilCheckboxInputGUI($this->lng->txt('tst_show_solution_compare'), 'solution_compare');
571  $solutionCompareInput->setInfo($this->lng->txt('tst_show_solution_compare_desc'));
572  $solutionCompareInput->setChecked($this->testOBJ->getShowSolutionListComparison());
573  $showSolutionPrintview->addSubItem($solutionCompareInput);
574 
575  // solution answers only ==> printview of results (answers only)
576  $solutionAnswersOnly = new ilCheckboxInputGUI($this->lng->txt('tst_show_solution_answers_only'), 'solution_answers_only');
577  $solutionAnswersOnly->setInfo($this->lng->txt('tst_show_solution_answers_only_desc'));
578  $solutionAnswersOnly->setChecked($this->testOBJ->getShowSolutionAnswersOnly());
579  $showSolutionPrintview->addSubItem($solutionAnswersOnly);
580 
581  // high score
582  $highscore = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_enabled"), "highscore_enabled");
583  $highscore->setValue(1);
584  $highscore->setChecked($this->testOBJ->getHighscoreEnabled());
585  $highscore->setInfo($this->lng->txt("tst_highscore_description"));
586  $form->addItem($highscore);
587  $highscore_tables = new ilRadioGroupInputGUI($this->lng->txt('tst_highscore_mode'), 'highscore_mode');
588  $highscore_tables->setRequired(true);
589  $highscore_tables->setValue($this->testOBJ->getHighscoreMode());
590  $highscore_table_own = new ilRadioOption($this->lng->txt('tst_highscore_own_table'), ilObjTest::HIGHSCORE_SHOW_OWN_TABLE);
591  $highscore_table_own->setInfo($this->lng->txt('tst_highscore_own_table_description'));
592  $highscore_tables->addOption($highscore_table_own);
593  $highscore_table_other = new ilRadioOption($this->lng->txt('tst_highscore_top_table'), ilObjTest::HIGHSCORE_SHOW_TOP_TABLE);
594  $highscore_table_other->setInfo($this->lng->txt('tst_highscore_top_table_description'));
595  $highscore_tables->addOption($highscore_table_other);
596  $highscore_table_other = new ilRadioOption($this->lng->txt('tst_highscore_all_tables'), ilObjTest::HIGHSCORE_SHOW_ALL_TABLES);
597  $highscore_table_other->setInfo($this->lng->txt('tst_highscore_all_tables_description'));
598  $highscore_tables->addOption($highscore_table_other);
599  $highscore->addSubItem($highscore_tables);
600  $highscore_top_num = new ilNumberInputGUI($this->lng->txt("tst_highscore_top_num"), "highscore_top_num");
601  $highscore_top_num->setSize(4);
602  $highscore_top_num->setRequired(true);
603  $highscore_top_num->setMinValue(1);
604  $highscore_top_num->setSuffix($this->lng->txt("tst_highscore_top_num_unit"));
605  $highscore_top_num->setValue($this->testOBJ->getHighscoreTopNum(null));
606  $highscore_top_num->setInfo($this->lng->txt("tst_highscore_top_num_description"));
607  $highscore->addSubItem($highscore_top_num);
608  $highscore_anon = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_anon"), "highscore_anon");
609  $highscore_anon->setValue(1);
610  $highscore_anon->setChecked($this->testOBJ->getHighscoreAnon());
611  $highscore_anon->setInfo($this->lng->txt("tst_highscore_anon_description"));
612  $highscore->addSubItem($highscore_anon);
613  $highscore_achieved_ts = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_achieved_ts"), "highscore_achieved_ts");
614  $highscore_achieved_ts->setValue(1);
615  $highscore_achieved_ts->setChecked($this->testOBJ->getHighscoreAchievedTS());
616  $highscore_achieved_ts->setInfo($this->lng->txt("tst_highscore_achieved_ts_description"));
617  $highscore->addSubItem($highscore_achieved_ts);
618  $highscore_score = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_score"), "highscore_score");
619  $highscore_score->setValue(1);
620  $highscore_score->setChecked($this->testOBJ->getHighscoreScore());
621  $highscore_score->setInfo($this->lng->txt("tst_highscore_score_description"));
622  $highscore->addSubItem($highscore_score);
623  $highscore_percentage = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_percentage"), "highscore_percentage");
624  $highscore_percentage->setValue(1);
625  $highscore_percentage->setChecked($this->testOBJ->getHighscorePercentage());
626  $highscore_percentage->setInfo($this->lng->txt("tst_highscore_percentage_description"));
627  $highscore->addSubItem($highscore_percentage);
628  $highscore_hints = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_hints"), "highscore_hints");
629  $highscore_hints->setValue(1);
630  $highscore_hints->setChecked($this->testOBJ->getHighscoreHints());
631  $highscore_hints->setInfo($this->lng->txt("tst_highscore_hints_description"));
632  $highscore->addSubItem($highscore_hints);
633  $highscore_wtime = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_wtime"), "highscore_wtime");
634  $highscore_wtime->setValue(1);
635  $highscore_wtime->setChecked($this->testOBJ->getHighscoreWTime());
636  $highscore_wtime->setInfo($this->lng->txt("tst_highscore_wtime_description"));
637  $highscore->addSubItem($highscore_wtime);
638 
639  // show signature placeholder
640  $showSignaturePlaceholder = new ilCheckboxInputGUI($this->lng->txt('tst_show_solution_signature'), 'solution_signature');
641  $showSignaturePlaceholder->setInfo($this->lng->txt('tst_show_solution_signature_desc'));
642  $showSignaturePlaceholder->setChecked($this->testOBJ->getShowSolutionSignature());
643  if( $this->testOBJ->getAnonymity() ) { $showSignaturePlaceholder->setDisabled(true); }
644  $form->addItem($showSignaturePlaceholder);
645 
646  // show signature placeholder
647  $showExamId = new ilCheckboxInputGUI($this->lng->txt('examid_in_test_res'), 'examid_in_test_res');
648  $showExamId->setInfo($this->lng->txt('examid_in_test_res_desc'));
649  $showExamId->setChecked($this->testOBJ->isShowExamIdInTestResultsEnabled());
650  $form->addItem($showExamId);
651 
652  // export settings
653  $export_settings = new ilCheckboxInputGUI($this->lng->txt('tst_exp_sc_short'), 'exp_sc_short');
654  $export_settings->setInfo($this->lng->txt('tst_exp_sc_short_desc'));
655  $export_settings->setChecked($this->testOBJ->getExportSettingsSingleChoiceShort());
656  $form->addItem($export_settings);
657  }
658 
663  {
664  if( $this->formPropertyExists($form, 'solution_details') )
665  {
666  if( $form->getItemByPostVar('solution_details')->getChecked() )
667  {
668  $this->testOBJ->setShowSolutionDetails(1);
669  $this->testOBJ->setPrintBestSolutionWithResult(
670  (int)$form->getItemByPostVar('print_bs_with_res')->getChecked()
671  );
672  }
673  else
674  {
675  $this->testOBJ->setShowSolutionDetails(0);
676  $this->testOBJ->setPrintBestSolutionWithResult(0);
677  }
678  }
679 
680  if( $this->formPropertyExists($form, 'solution_feedback') )
681  {
682  $this->testOBJ->setShowSolutionFeedback($form->getItemByPostVar('solution_feedback')->getChecked());
683  }
684 
685  if( $this->formPropertyExists($form, 'solution_suggested') )
686  {
687  $this->testOBJ->setShowSolutionSuggested($form->getItemByPostVar('solution_suggested')->getChecked());
688  }
689 
690  if( $this->formPropertyExists($form, 'solution_printview') )
691  {
692  if( $form->getItemByPostVar('solution_printview')->getChecked() )
693  {
694  $this->testOBJ->setShowSolutionPrintview(1);
695  $this->testOBJ->setShowSolutionListComparison(
696  (bool)$form->getItemByPostVar('solution_compare')->getChecked()
697  );
698  $this->testOBJ->setShowSolutionAnswersOnly(
699  (int)$form->getItemByPostVar('solution_answers_only')->getChecked()
700  );
701  }
702  else
703  {
704  $this->testOBJ->setShowSolutionPrintview(0);
705  $this->testOBJ->setShowSolutionListComparison(false);
706  $this->testOBJ->setShowSolutionAnswersOnly(0);
707  }
708  }
709 
710  if( $this->formPropertyExists($form, 'highscore_enabled') )
711  {
712  // highscore settings
713  $this->testOBJ->setHighscoreEnabled((bool) $form->getItemByPostVar('highscore_enabled')->getChecked());
714  $this->testOBJ->setHighscoreAnon((bool) $form->getItemByPostVar('highscore_anon')->getChecked());
715  $this->testOBJ->setHighscoreAchievedTS((bool) $form->getItemByPostVar('highscore_achieved_ts')->getChecked());
716  $this->testOBJ->setHighscoreScore((bool) $form->getItemByPostVar('highscore_score')->getChecked());
717  $this->testOBJ->setHighscorePercentage((bool) $form->getItemByPostVar('highscore_percentage')->getChecked());
718  $this->testOBJ->setHighscoreHints((bool) $form->getItemByPostVar('highscore_hints')->getChecked());
719  $this->testOBJ->setHighscoreWTime((bool) $form->getItemByPostVar('highscore_wtime')->getChecked());
720  $this->testOBJ->setHighscoreMode((int) $form->getItemByPostVar('highscore_mode')->getValue());
721  $this->testOBJ->setHighscoreTopNum((int) $form->getItemByPostVar('highscore_top_num')->getValue());
722  }
723 
724  if( $this->formPropertyExists($form, 'solution_signature') )
725  {
726  $this->testOBJ->setShowSolutionSignature($form->getItemByPostVar('solution_signature')->getChecked());
727  }
728 
729  if( $this->formPropertyExists($form, 'examid_in_test_res') )
730  {
731  $this->testOBJ->setShowExamIdInTestResultsEnabled($form->getItemByPostVar('examid_in_test_res')->getChecked());
732  }
733 
734  if( $this->formPropertyExists($form, 'exp_sc_short') )
735  {
736  $this->testOBJ->setExportSettingsSingleChoiceShort( (int)$form->getItemByPostVar('exp_sc_short')->getChecked() );
737  }
738  }
739 
741  {
742  if( $this->testQuestionSetConfigFactory->getQuestionSetConfig()->isResultTaxonomyFilterSupported() )
743  {
744  // misc settings
745  $header_misc = new ilFormSectionHeaderGUI();
746  $header_misc->setTitle($this->lng->txt('misc'));
747  $form->addItem($header_misc);
748  }
749 
750  // result filter taxonomies
751  if( $this->testQuestionSetConfigFactory->getQuestionSetConfig()->isResultTaxonomyFilterSupported() )
752  {
754 
755  if( count($availableTaxonomyIds) )
756  {
757  require_once 'Modules/Test/classes/class.ilTestTaxonomyFilterLabelTranslater.php';
758  $labelTranslater = new ilTestTaxonomyFilterLabelTranslater($this->db);
759  $labelTranslater->loadLabelsFromTaxonomyIds($availableTaxonomyIds);
760 
761  $results_presentation = new ilCheckboxGroupInputGUI($this->lng->txt('tst_results_tax_filters'), 'results_tax_filters');
762 
763  foreach($availableTaxonomyIds as $taxonomyId)
764  {
765  $results_presentation->addOption(new ilCheckboxOption(
766  $labelTranslater->getTaxonomyTreeLabel($taxonomyId), $taxonomyId, ''
767  ));
768  }
769 
770  $results_presentation->setValue($this->testOBJ->getResultFilterTaxIds());
771 
772  $form->addItem($results_presentation);
773  }
774  }
775  }
776 
781  {
782  // result filter taxonomies
783  if( $this->testQuestionSetConfigFactory->getQuestionSetConfig()->isResultTaxonomyFilterSupported() )
784  {
785  if( !$this->isHiddenFormItem('results_tax_filters') && count($this->getAvailableTaxonomyIds()) )
786  {
787  $taxFilters = array();
788 
789  if( is_array($form->getItemByPostVar('results_tax_filters')->getValue()) )
790  {
791  $taxFilters = array_intersect(
792  $this->getAvailableTaxonomyIds(), $form->getItemByPostVar('results_tax_filters')->getValue()
793  );
794  }
795 
796  $this->testOBJ->setResultFilterTaxIds($taxFilters);
797  }
798  }
799  }
800 
801  private function areScoringSettingsWritable()
802  {
803  if ( !$this->testOBJ->participantDataExist() )
804  {
805  return true;
806  }
807 
808  if( !$this->testOBJ->isScoreReportingAvailable() )
809  {
810  return true;
811  }
812 
813  return false;
814  }
815 
817  {
818  if ( !$this->testOBJ->participantDataExist() )
819  {
820  return false;
821  }
822 
823  if( !$this->areScoringSettingsWritable() )
824  {
825  return false;
826  }
827 
828  if( !$this->hasScoringSettingsChanged($form) )
829  {
830  return false;
831  }
832 
833  return true;
834  }
835 
837  {
838  $countSystem = $form->getItemByPostVar('count_system');
839  if( is_object($countSystem) && $countSystem->getValue() != $this->testOBJ->getCountSystem() )
840  {
841  return true;
842  }
843 
844  $mcScoring = $form->getItemByPostVar('mc_scoring');
845  if( is_object($mcScoring) && $mcScoring->getValue() != $this->testOBJ->getMCScoring() )
846  {
847  return true;
848  }
849 
850  $scoreCutting = $form->getItemByPostVar('score_cutting');
851  if( is_object($scoreCutting) && $scoreCutting->getValue() != $this->testOBJ->getScoreCutting() )
852  {
853  return true;
854  }
855 
856  $passScoring = $form->getItemByPostVar('pass_scoring');
857  if( is_object($passScoring) && $passScoring->getValue() != $this->testOBJ->getPassScoring() )
858  {
859  return true;
860  }
861 
862  return false;
863  }
864 
865  private $availableTaxonomyIds = null;
866 
867  private function getAvailableTaxonomyIds()
868  {
869  if( $this->getAvailableTaxonomyIds === null )
870  {
871  require_once 'Services/Taxonomy/classes/class.ilObjTaxonomy.php';
872  $this->availableTaxonomyIds = (array)ilObjTaxonomy::getUsageOfObject($this->testOBJ->getId());
873  }
874 
876  }
877 }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
This class represents an option in a radio group.
const REPORT_AFTER_DATE
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.
This class represents a section header in a property form.
$cmd
Definition: sahs_server.php:35
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.
Interface ilDBInterface.
This class represents a property in a property form.
addOption($a_option)
Add Option.
Class for single dates.
$header
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...
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
setSize($a_size)
Set Size.
$errors
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
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
const IL_CAL_TIMESTAMP
const HIGHSCORE_SHOW_ALL_TABLES
Settings template application class.
setRequired($a_required)
Set Required.
Confirmation screen class.
Class ilAccessHandler.