ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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,
80  ilTree $tree,
81  ilDB $db,
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  continue;
221 
222  case 'datetime':
223 
224  list($date, $time) = explode(' ', $item->getDate()->get(IL_CAL_DATETIME));
225 
226  if( $item->getMode() == ilDateTimeInputGUI::MODE_SELECT )
227  {
228  list($y, $m, $d) = explode('-', $date);
229 
230  $confirmation->addHiddenItem("{$item->getPostVar()}[date][y]", $y);
231  $confirmation->addHiddenItem("{$item->getPostVar()}[date][m]", $m);
232  $confirmation->addHiddenItem("{$item->getPostVar()}[date][d]", $d);
233 
234  if( $item->getShowTime() )
235  {
236  list($h, $m, $s) = explode(':', $time);
237 
238  $confirmation->addHiddenItem("{$item->getPostVar()}[time][h]", $h);
239  $confirmation->addHiddenItem("{$item->getPostVar()}[time][m]", $m);
240  $confirmation->addHiddenItem("{$item->getPostVar()}[time][s]", $s);
241  }
242  }
243  else
244  {
245  $confirmation->addHiddenItem("{$item->getPostVar()}[date]", $date);
246  $confirmation->addHiddenItem("{$item->getPostVar()}[time]", $time);
247  }
248 
249  break;
250 
251  case 'duration':
252 
253  $confirmation->addHiddenItem("{$item->getPostVar()}[MM]", (int)$item->getMonths());
254  $confirmation->addHiddenItem("{$item->getPostVar()}[dd]", (int)$item->getDays());
255  $confirmation->addHiddenItem("{$item->getPostVar()}[hh]", (int)$item->getHours());
256  $confirmation->addHiddenItem("{$item->getPostVar()}[mm]", (int)$item->getMinutes());
257  $confirmation->addHiddenItem("{$item->getPostVar()}[ss]", (int)$item->getSeconds());
258 
259  break;
260 
261  case 'checkboxgroup':
262 
263  if( is_array($item->getValue()) )
264  {
265  foreach( $item->getValue() as $option )
266  {
267  $confirmation->addHiddenItem("{$item->getPostVar()}[]", $option);
268  }
269  }
270 
271  break;
272 
273  case 'checkbox':
274 
275  if( $item->getChecked() )
276  {
277  $confirmation->addHiddenItem($item->getPostVar(), 1);
278  }
279 
280  break;
281 
282  default:
283 
284  $confirmation->addHiddenItem($item->getPostVar(), $item->getValue());
285  }
286  }
287 
288  $this->tpl->setContent( $this->ctrl->getHTML($confirmation) );
289  }
290 
291  private function buildForm()
292  {
293  include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
294  $form = new ilPropertyFormGUI();
295  $form->setFormAction($this->ctrl->getFormAction($this));
296  $form->setTableWidth('100%');
297  $form->setId('test_scoring_results');
298 
299  $this->addScoringSettingsFormSection($form);
302  $this->addMiscSettingsFormSection($form);
303 
304  // remove items when using template
305  if($this->settingsTemplate)
306  {
307  foreach($this->settingsTemplate->getSettings() as $id => $item)
308  {
309  if($item["hide"])
310  {
311  $form->removeItemByPostVar($id);
312  }
313  }
314  }
315 
316  $form->addCommandButton(self::CMD_SAVE_FORM, $this->lng->txt('save'));
317 
318  return $form;
319  }
320 
322  {
323  $fields = array(
324  'count_system', 'mc_scoring', 'score_cutting', 'pass_scoring', 'pass_deletion_allowed'
325  );
326 
327  if( $this->isSectionHeaderRequired($fields) )
328  {
329  // scoring settings
330  $header = new ilFormSectionHeaderGUI();
331  $header->setTitle($this->lng->txt('test_scoring'));
332  $form->addItem($header);
333  }
334 
335  // scoring system
336  $count_system = new ilRadioGroupInputGUI($this->lng->txt('tst_text_count_system'), 'count_system');
337  $count_system->addOption($opt = new ilRadioOption($this->lng->txt('tst_count_partial_solutions'), 0, ''));
338  $opt->setInfo($this->lng->txt('tst_count_partial_solutions_desc'));
339  $count_system->addOption($opt = new ilRadioOption($this->lng->txt('tst_count_correct_solutions'), 1, ''));
340  $opt->setInfo($this->lng->txt('tst_count_correct_solutions_desc'));
341  $count_system->setValue($this->testOBJ->getCountSystem());
342  $form->addItem($count_system);
343 
344  // mc questions
345  $mc_scoring = new ilRadioGroupInputGUI($this->lng->txt('tst_score_mcmr_questions'), 'mc_scoring');
346  $mc_scoring->addOption($opt = new ilRadioOption($this->lng->txt('tst_score_mcmr_zero_points_when_unanswered'), 0, ''));
347  $opt->setInfo($this->lng->txt('tst_score_mcmr_zero_points_when_unanswered_desc'));
348  $mc_scoring->addOption($opt = new ilRadioOption($this->lng->txt('tst_score_mcmr_use_scoring_system'), 1, ''));
349  $opt->setInfo($this->lng->txt('tst_score_mcmr_use_scoring_system_desc'));
350  $mc_scoring->setValue($this->testOBJ->getMCScoring());
351  $form->addItem($mc_scoring);
352 
353  // score cutting
354  $score_cutting = new ilRadioGroupInputGUI($this->lng->txt('tst_score_cutting'), 'score_cutting');
355  $score_cutting->addOption($opt = new ilRadioOption($this->lng->txt('tst_score_cut_question'), 0, ''));
356  $opt->setInfo($this->lng->txt('tst_score_cut_question_desc'));
357  $score_cutting->addOption($opt = new ilRadioOption($this->lng->txt('tst_score_cut_test'), 1, ''));
358  $opt->setInfo($this->lng->txt('tst_score_cut_test_desc'));
359  $score_cutting->setValue($this->testOBJ->getScoreCutting());
360  $form->addItem($score_cutting);
361 
362  // pass scoring
363  $pass_scoring = new ilRadioGroupInputGUI($this->lng->txt('tst_pass_scoring'), 'pass_scoring');
364  $pass_scoring->addOption($opt = new ilRadioOption($this->lng->txt('tst_pass_last_pass'), 0, ''));
365  $opt->setInfo($this->lng->txt('tst_pass_last_pass_desc'));
366  $pass_scoring->addOption($opt = new ilRadioOption($this->lng->txt('tst_pass_best_pass'), 1, ''));
367  $opt->setInfo($this->lng->txt('tst_pass_best_pass_desc'));
368  $pass_scoring->setValue($this->testOBJ->getPassScoring());
369  $form->addItem($pass_scoring);
370 
371  // deletion of test results
372  $passDeletion = new ilRadioGroupInputGUI($this->lng->txt('tst_pass_deletion'), 'pass_deletion_allowed');
373  $passDeletion->addOption(new ilRadioOption($this->lng->txt('tst_pass_deletion_not_allowed'), 0, ''));
374  $passDeletion->addOption(new ilRadioOption($this->lng->txt('tst_pass_deletion_allowed'), 1, ''));
375  $passDeletion->setValue($this->testOBJ->isPassDeletionAllowed());
376  $form->addItem($passDeletion);
377 
378  // disable scoring settings
379  if( !$this->areScoringSettingsWritable() )
380  {
381  $count_system->setDisabled(true);
382  $mc_scoring->setDisabled(true);
383  $score_cutting->setDisabled(true);
384  $pass_scoring->setDisabled(true);
385  }
386  }
387 
392  {
393  if( $this->areScoringSettingsWritable() )
394  {
395  if( $this->formPropertyExists($form, 'count_system') )
396  {
397  $this->testOBJ->setCountSystem($form->getItemByPostVar('count_system')->getValue());
398  }
399 
400  if( $this->formPropertyExists($form, 'mc_scoring') )
401  {
402  $this->testOBJ->setMCScoring($form->getItemByPostVar('mc_scoring')->getValue());
403  }
404 
405  if( $this->formPropertyExists($form, 'score_cutting') )
406  {
407  $this->testOBJ->setScoreCutting($form->getItemByPostVar('score_cutting')->getValue());
408  }
409 
410  if( $this->formPropertyExists($form, 'pass_scoring') )
411  {
412  $this->testOBJ->setPassScoring($form->getItemByPostVar('pass_scoring')->getValue());
413  }
414  }
415 
416  if( $this->formPropertyExists($form, 'pass_deletion_allowed') )
417  {
418  $this->testOBJ->setPassDeletionAllowed( (bool)$form->getItemByPostVar('pass_deletion_allowed')->getValue() );
419  }
420  }
421 
423  {
424  // HEADER: result settings
425  $header_tr = new ilFormSectionHeaderGUI();
426  $header_tr->setTitle($this->lng->txt('test_results'));
427  $form->addItem($header_tr);
428 
429  // access to test results
430  $resultsAccessEnabled = new ilCheckboxInputGUI($this->lng->txt('tst_results_access_enabled'), 'results_access_enabled');
431  $resultsAccessEnabled->setInfo($this->lng->txt('tst_results_access_enabled_desc'));
432  $resultsAccessEnabled->setChecked($this->testOBJ->isScoreReportingEnabled());
433  $resultsAccessSetting = new ilRadioGroupInputGUI($this->lng->txt('tst_results_access_setting'), 'results_access_setting');
434  $resultsAccessSetting->setRequired(true);
435  $optAlways = new ilRadioOption($this->lng->txt('tst_results_access_always'), 2, '');
436  $optAlways->setInfo($this->lng->txt('tst_results_access_always_desc'));
437  $resultsAccessSetting->addOption($optAlways);
438  $optFinished = $opt = new ilRadioOption($this->lng->txt('tst_results_access_finished'), 1, '');
439  $optFinished->setInfo($this->lng->txt('tst_results_access_finished_desc'));
440  $resultsAccessSetting->addOption($optFinished);
441  $optionDate = new ilRadioOption($this->lng->txt('tst_results_access_date'), 3, '');
442  $optionDate->setInfo($this->lng->txt('tst_results_access_date_desc'));
443  // access date
444  $reportingDate = new ilDateTimeInputGUI($this->lng->txt('tst_reporting_date'), 'reporting_date');
445  $reportingDate->setShowTime(true);
446  if (strlen($this->testOBJ->getReportingDate()))
447  {
448  $reportingDate->setDate(new ilDateTime($this->testOBJ->getReportingDate(), IL_CAL_TIMESTAMP));
449  }
450  else
451  {
452  $reportingDate->setDate(new ilDateTime(time(), IL_CAL_UNIX));
453  }
454  $optionDate->addSubItem($reportingDate);
455  $resultsAccessSetting->addOption($optionDate);
456  $resultsAccessValue = $this->testOBJ->getScoreReporting();
457  $resultsAccessSetting->setValue(
458  $resultsAccessValue > 0 && $resultsAccessValue < 4 ? $resultsAccessValue : 2
459  );
460  $resultsAccessEnabled->addSubItem($resultsAccessSetting);
461  // show pass details
462  $showPassDetails = new ilCheckboxInputGUI($this->lng->txt('tst_show_pass_details'), 'pass_details');
463  $showPassDetails->setInfo($this->lng->txt('tst_show_pass_details_desc'));
464  $showPassDetails->setChecked($this->testOBJ->getShowPassDetails());
465  $resultsAccessEnabled->addSubItem($showPassDetails);
466  $form->addItem($resultsAccessEnabled);
467 
468  // grading
469  $chb_only_passed_failed = new ilCheckboxInputGUI($this->lng->txt('tst_results_grading_opt_show_status'), 'grading_status');
470  $chb_only_passed_failed->setInfo($this->lng->txt('tst_results_grading_opt_show_status_desc'));
471  $chb_only_passed_failed->setValue(1);
472  $chb_only_passed_failed->setChecked($this->testOBJ->isShowGradingStatusEnabled());
473  $form->addItem($chb_only_passed_failed);
474 
475  $chb_resulting_mark_only = new ilCheckboxInputGUI($this->lng->txt('tst_results_grading_opt_show_mark'), 'grading_mark');
476  $chb_resulting_mark_only->setInfo($this->lng->txt('tst_results_grading_opt_show_mark_desc'));
477  $chb_resulting_mark_only->setValue(1);
478  $chb_resulting_mark_only->setChecked($this->testOBJ->isShowGradingMarkEnabled());
479  $form->addItem($chb_resulting_mark_only);
480  }
481 
486  {
487  if( $this->formPropertyExists($form, 'results_access_enabled') )
488  {
489  if( $form->getItemByPostVar('results_access_enabled')->getChecked() )
490  {
491  $this->testOBJ->setScoreReporting($form->getItemByPostVar('results_access_setting')->getValue());
492 
493  if( $this->testOBJ->getScoreReporting() == REPORT_AFTER_DATE )
494  {
495  $this->testOBJ->setReportingDate(
496  $form->getItemByPostVar('reporting_date')->getDate()->get(IL_CAL_FKT_DATE, 'YmdHis')
497  );
498  }
499  else
500  {
501  $this->testOBJ->setReportingDate('');
502  }
503 
504  $this->testOBJ->setShowPassDetails($form->getItemByPostVar('pass_details')->getChecked());
505  }
506  else
507  {
508  $this->testOBJ->setScoreReporting(4); // never
509  $this->testOBJ->setShowPassDetails(false);
510  $this->testOBJ->setReportingDate('');
511  }
512  }
513 
514  if( $this->formPropertyExists($form, 'grading_status') )
515  {
516  $this->testOBJ->setShowGradingStatusEnabled(
517  $form->getItemByPostVar('grading_status')->getChecked()
518  );
519  }
520 
521  if( $this->formPropertyExists($form, 'grading_mark') )
522  {
523  $this->testOBJ->setShowGradingMarkEnabled(
524  (int)$form->getItemByPostVar('grading_mark')->getChecked()
525  );
526  }
527  }
528 
530  {
531  // HEADER: result settings
532  $header_tr = new ilFormSectionHeaderGUI();
533  $header_tr->setTitle($this->lng->txt('tst_results_details_options'));
534  $form->addItem($header_tr);
535 
536  // show solution details
537  $showSolutionDetails = new ilCheckboxInputGUI($this->lng->txt('tst_show_solution_details'), 'solution_details');
538  $showSolutionDetails->setInfo($this->lng->txt('tst_show_solution_details_desc'));
539  $showSolutionDetails->setChecked($this->testOBJ->getShowSolutionDetails());
540  $form->addItem($showSolutionDetails);
541 
542  // best solution in test results
543  $results_print_best_solution = new ilCheckboxInputGUI($this->lng->txt('tst_results_print_best_solution'), 'print_bs_with_res');
544  $results_print_best_solution->setInfo($this->lng->txt('tst_results_print_best_solution_info'));
545  $results_print_best_solution->setChecked((bool) $this->testOBJ->isBestSolutionPrintedWithResult());
546  $showSolutionDetails->addSubItem($results_print_best_solution);
547 
548  // show solution feedback ==> solution feedback in test results
549  $showSolutionFeedbackOption = new ilCheckboxInputGUI($this->lng->txt('tst_show_solution_feedback'), 'solution_feedback');
550  $showSolutionFeedbackOption->setInfo($this->lng->txt('tst_show_solution_feedback_desc'));
551  $showSolutionFeedbackOption->setChecked($this->testOBJ->getShowSolutionFeedback());
552  $form->addItem($showSolutionFeedbackOption);
553 
554  // show suggested solution
555  $showSuggestedSolutionOption = new ilCheckboxInputGUI($this->lng->txt('tst_show_solution_suggested'), 'solution_suggested');
556  $showSuggestedSolutionOption->setInfo($this->lng->txt('tst_show_solution_suggested_desc'));
557  $showSuggestedSolutionOption->setChecked($this->testOBJ->getShowSolutionSuggested());
558  $form->addItem($showSuggestedSolutionOption);
559 
560  // show solution printview ==> list of answers
561  $showSolutionPrintview = new ilCheckboxInputGUI($this->lng->txt('tst_show_solution_printview'), 'solution_printview');
562  $showSolutionPrintview->setInfo($this->lng->txt('tst_show_solution_printview_desc'));
563  $showSolutionPrintview->setChecked($this->testOBJ->getShowSolutionPrintview());
564  $form->addItem($showSolutionPrintview);
565 
566  // show best solution in list of answers
567  $solutionCompareInput = new ilCheckboxInputGUI($this->lng->txt('tst_show_solution_compare'), 'solution_compare');
568  $solutionCompareInput->setInfo($this->lng->txt('tst_show_solution_compare_desc'));
569  $solutionCompareInput->setChecked($this->testOBJ->getShowSolutionListComparison());
570  $showSolutionPrintview->addSubItem($solutionCompareInput);
571 
572  // solution answers only ==> printview of results (answers only)
573  $solutionAnswersOnly = new ilCheckboxInputGUI($this->lng->txt('tst_show_solution_answers_only'), 'solution_answers_only');
574  $solutionAnswersOnly->setInfo($this->lng->txt('tst_show_solution_answers_only_desc'));
575  $solutionAnswersOnly->setChecked($this->testOBJ->getShowSolutionAnswersOnly());
576  $showSolutionPrintview->addSubItem($solutionAnswersOnly);
577 
578  // high score
579  $highscore = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_enabled"), "highscore_enabled");
580  $highscore->setValue(1);
581  $highscore->setChecked($this->testOBJ->getHighscoreEnabled());
582  $highscore->setInfo($this->lng->txt("tst_highscore_description"));
583  $form->addItem($highscore);
584  $highscore_tables = new ilRadioGroupInputGUI($this->lng->txt('tst_highscore_mode'), 'highscore_mode');
585  $highscore_tables->setRequired(true);
586  $highscore_tables->setValue($this->testOBJ->getHighscoreMode());
587  $highscore_table_own = new ilRadioOption($this->lng->txt('tst_highscore_own_table'), ilObjTest::HIGHSCORE_SHOW_OWN_TABLE);
588  $highscore_table_own->setInfo($this->lng->txt('tst_highscore_own_table_description'));
589  $highscore_tables->addOption($highscore_table_own);
590  $highscore_table_other = new ilRadioOption($this->lng->txt('tst_highscore_top_table'), ilObjTest::HIGHSCORE_SHOW_TOP_TABLE);
591  $highscore_table_other->setInfo($this->lng->txt('tst_highscore_top_table_description'));
592  $highscore_tables->addOption($highscore_table_other);
593  $highscore_table_other = new ilRadioOption($this->lng->txt('tst_highscore_all_tables'), ilObjTest::HIGHSCORE_SHOW_ALL_TABLES);
594  $highscore_table_other->setInfo($this->lng->txt('tst_highscore_all_tables_description'));
595  $highscore_tables->addOption($highscore_table_other);
596  $highscore->addSubItem($highscore_tables);
597  $highscore_top_num = new ilNumberInputGUI($this->lng->txt("tst_highscore_top_num"), "highscore_top_num");
598  $highscore_top_num->setSize(4);
599  $highscore_top_num->setRequired(true);
600  $highscore_top_num->setMinValue(1);
601  $highscore_top_num->setSuffix($this->lng->txt("tst_highscore_top_num_unit"));
602  $highscore_top_num->setValue($this->testOBJ->getHighscoreTopNum(null));
603  $highscore_top_num->setInfo($this->lng->txt("tst_highscore_top_num_description"));
604  $highscore->addSubItem($highscore_top_num);
605  $highscore_anon = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_anon"), "highscore_anon");
606  $highscore_anon->setValue(1);
607  $highscore_anon->setChecked($this->testOBJ->getHighscoreAnon());
608  $highscore_anon->setInfo($this->lng->txt("tst_highscore_anon_description"));
609  $highscore->addSubItem($highscore_anon);
610  $highscore_achieved_ts = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_achieved_ts"), "highscore_achieved_ts");
611  $highscore_achieved_ts->setValue(1);
612  $highscore_achieved_ts->setChecked($this->testOBJ->getHighscoreAchievedTS());
613  $highscore_achieved_ts->setInfo($this->lng->txt("tst_highscore_achieved_ts_description"));
614  $highscore->addSubItem($highscore_achieved_ts);
615  $highscore_score = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_score"), "highscore_score");
616  $highscore_score->setValue(1);
617  $highscore_score->setChecked($this->testOBJ->getHighscoreScore());
618  $highscore_score->setInfo($this->lng->txt("tst_highscore_score_description"));
619  $highscore->addSubItem($highscore_score);
620  $highscore_percentage = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_percentage"), "highscore_percentage");
621  $highscore_percentage->setValue(1);
622  $highscore_percentage->setChecked($this->testOBJ->getHighscorePercentage());
623  $highscore_percentage->setInfo($this->lng->txt("tst_highscore_percentage_description"));
624  $highscore->addSubItem($highscore_percentage);
625  $highscore_hints = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_hints"), "highscore_hints");
626  $highscore_hints->setValue(1);
627  $highscore_hints->setChecked($this->testOBJ->getHighscoreHints());
628  $highscore_hints->setInfo($this->lng->txt("tst_highscore_hints_description"));
629  $highscore->addSubItem($highscore_hints);
630  $highscore_wtime = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_wtime"), "highscore_wtime");
631  $highscore_wtime->setValue(1);
632  $highscore_wtime->setChecked($this->testOBJ->getHighscoreWTime());
633  $highscore_wtime->setInfo($this->lng->txt("tst_highscore_wtime_description"));
634  $highscore->addSubItem($highscore_wtime);
635 
636  // show signature placeholder
637  $showSignaturePlaceholder = new ilCheckboxInputGUI($this->lng->txt('tst_show_solution_signature'), 'solution_signature');
638  $showSignaturePlaceholder->setInfo($this->lng->txt('tst_show_solution_signature_desc'));
639  $showSignaturePlaceholder->setChecked($this->testOBJ->getShowSolutionSignature());
640  if( $this->testOBJ->getAnonymity() ) { $showSignaturePlaceholder->setDisabled(true); }
641  $form->addItem($showSignaturePlaceholder);
642 
643  // show signature placeholder
644  $showExamId = new ilCheckboxInputGUI($this->lng->txt('examid_in_test_res'), 'examid_in_test_res');
645  $showExamId->setInfo($this->lng->txt('examid_in_test_res_desc'));
646  $showExamId->setChecked($this->testOBJ->isShowExamIdInTestResultsEnabled());
647  $form->addItem($showExamId);
648 
649  // export settings
650  $export_settings = new ilCheckboxInputGUI($this->lng->txt('tst_exp_sc_short'), 'exp_sc_short');
651  $export_settings->setInfo($this->lng->txt('tst_exp_sc_short_desc'));
652  $export_settings->setChecked($this->testOBJ->getExportSettingsSingleChoiceShort());
653  $form->addItem($export_settings);
654  }
655 
660  {
661  if( $this->formPropertyExists($form, 'solution_details') )
662  {
663  if( $form->getItemByPostVar('solution_details')->getChecked() )
664  {
665  $this->testOBJ->setShowSolutionDetails(1);
666  $this->testOBJ->setPrintBestSolutionWithResult(
667  (int)$form->getItemByPostVar('print_bs_with_res')->getChecked()
668  );
669  }
670  else
671  {
672  $this->testOBJ->setShowSolutionDetails(0);
673  $this->testOBJ->setPrintBestSolutionWithResult(0);
674  }
675  }
676 
677  if( $this->formPropertyExists($form, 'solution_feedback') )
678  {
679  $this->testOBJ->setShowSolutionFeedback($form->getItemByPostVar('solution_feedback')->getChecked());
680  }
681 
682  if( $this->formPropertyExists($form, 'solution_suggested') )
683  {
684  $this->testOBJ->setShowSolutionSuggested($form->getItemByPostVar('solution_suggested')->getChecked());
685  }
686 
687  if( $this->formPropertyExists($form, 'solution_printview') )
688  {
689  if( $form->getItemByPostVar('solution_printview')->getChecked() )
690  {
691  $this->testOBJ->setShowSolutionPrintview(1);
692  $this->testOBJ->setShowSolutionListComparison(
693  (bool)$form->getItemByPostVar('solution_compare')->getChecked()
694  );
695  $this->testOBJ->setShowSolutionAnswersOnly(
696  (int)$form->getItemByPostVar('solution_answers_only')->getChecked()
697  );
698  }
699  else
700  {
701  $this->testOBJ->setShowSolutionPrintview(0);
702  $this->testOBJ->setShowSolutionListComparison(false);
703  $this->testOBJ->setShowSolutionAnswersOnly(0);
704  }
705  }
706 
707  if( $this->formPropertyExists($form, 'highscore_enabled') )
708  {
709  // highscore settings
710  $this->testOBJ->setHighscoreEnabled((bool) $form->getItemByPostVar('highscore_enabled')->getChecked());
711  $this->testOBJ->setHighscoreAnon((bool) $form->getItemByPostVar('highscore_anon')->getChecked());
712  $this->testOBJ->setHighscoreAchievedTS((bool) $form->getItemByPostVar('highscore_achieved_ts')->getChecked());
713  $this->testOBJ->setHighscoreScore((bool) $form->getItemByPostVar('highscore_score')->getChecked());
714  $this->testOBJ->setHighscorePercentage((bool) $form->getItemByPostVar('highscore_percentage')->getChecked());
715  $this->testOBJ->setHighscoreHints((bool) $form->getItemByPostVar('highscore_hints')->getChecked());
716  $this->testOBJ->setHighscoreWTime((bool) $form->getItemByPostVar('highscore_wtime')->getChecked());
717  $this->testOBJ->setHighscoreMode((int) $form->getItemByPostVar('highscore_mode')->getValue());
718  $this->testOBJ->setHighscoreTopNum((int) $form->getItemByPostVar('highscore_top_num')->getValue());
719  }
720 
721  if( $this->formPropertyExists($form, 'solution_signature') )
722  {
723  $this->testOBJ->setShowSolutionSignature($form->getItemByPostVar('solution_signature')->getChecked());
724  }
725 
726  if( $this->formPropertyExists($form, 'examid_in_test_res') )
727  {
728  $this->testOBJ->setShowExamIdInTestResultsEnabled($form->getItemByPostVar('examid_in_test_res')->getChecked());
729  }
730 
731  if( $this->formPropertyExists($form, 'exp_sc_short') )
732  {
733  $this->testOBJ->setExportSettingsSingleChoiceShort( (int)$form->getItemByPostVar('exp_sc_short')->getChecked() );
734  }
735  }
736 
738  {
739  $fields = array('anonymity');
740 
741  if( $this->isSectionHeaderRequired($fields) || $this->testQuestionSetConfigFactory->getQuestionSetConfig()->isResultTaxonomyFilterSupported() )
742  {
743  // misc settings
744  $header_misc = new ilFormSectionHeaderGUI();
745  $header_misc->setTitle($this->lng->txt('misc'));
746  $form->addItem($header_misc);
747  }
748 
749  // result filter taxonomies
750  if( $this->testQuestionSetConfigFactory->getQuestionSetConfig()->isResultTaxonomyFilterSupported() )
751  {
753 
754  if( count($availableTaxonomyIds) )
755  {
756  require_once 'Modules/Test/classes/class.ilTestTaxonomyFilterLabelTranslater.php';
757  $labelTranslater = new ilTestTaxonomyFilterLabelTranslater($this->db);
758  $labelTranslater->loadLabelsFromTaxonomyIds($availableTaxonomyIds);
759 
760  $results_presentation = new ilCheckboxGroupInputGUI($this->lng->txt('tst_results_tax_filters'), 'results_tax_filters');
761 
762  foreach($availableTaxonomyIds as $taxonomyId)
763  {
764  $results_presentation->addOption(new ilCheckboxOption(
765  $labelTranslater->getTaxonomyTreeLabel($taxonomyId), $taxonomyId, ''
766  ));
767  }
768 
769  $results_presentation->setValue($this->testOBJ->getResultFilterTaxIds());
770 
771  $form->addItem($results_presentation);
772  }
773  }
774 
775  // anonymity
776  $anonymity = new ilRadioGroupInputGUI($this->lng->txt('tst_anonymity'), 'anonymity');
777  if ($this->testOBJ->participantDataExist()) $anonymity->setDisabled(true);
778  $rb = new ilRadioOption($this->lng->txt('tst_anonymity_no_anonymization'), 0);
779  $anonymity->addOption($rb);
780  $rb = new ilRadioOption($this->lng->txt('tst_anonymity_anonymous_test'), 1);
781  $anonymity->addOption($rb);
782  $anonymity->setValue((int)$this->testOBJ->getAnonymity());
783  $form->addItem($anonymity);
784  }
785 
790  {
791  // result filter taxonomies
792  if( $this->testQuestionSetConfigFactory->getQuestionSetConfig()->isResultTaxonomyFilterSupported() )
793  {
794  if( !$this->isHiddenFormItem('results_tax_filters') && count($this->getAvailableTaxonomyIds()) )
795  {
796  $this->testOBJ->setResultFilterTaxIds( array_intersect(
797  $this->getAvailableTaxonomyIds(), $form->getItemByPostVar('results_tax_filters')->getValue()
798  ));
799  }
800  }
801 
802  if( $this->formPropertyExists($form, 'anonymity') )
803  {
804  // anonymity setting
805  $this->testOBJ->setAnonymity($form->getItemByPostVar('anonymity')->getValue());
806  }
807  }
808 
809  private function areScoringSettingsWritable()
810  {
811  if ( !$this->testOBJ->participantDataExist() )
812  {
813  return true;
814  }
815 
816  if( !$this->testOBJ->isScoreReportingAvailable() )
817  {
818  return true;
819  }
820 
821  return false;
822  }
823 
825  {
826  if ( !$this->testOBJ->participantDataExist() )
827  {
828  return false;
829  }
830 
831  if( !$this->areScoringSettingsWritable() )
832  {
833  return false;
834  }
835 
836  if( !$this->hasScoringSettingsChanged($form) )
837  {
838  return false;
839  }
840 
841  return true;
842  }
843 
845  {
846  $countSystem = $form->getItemByPostVar('count_system');
847  if( is_object($countSystem) && $countSystem->getValue() != $this->testOBJ->getCountSystem() )
848  {
849  return true;
850  }
851 
852  $mcScoring = $form->getItemByPostVar('mc_scoring');
853  if( is_object($mcScoring) && $mcScoring->getValue() != $this->testOBJ->getMCScoring() )
854  {
855  return true;
856  }
857 
858  $scoreCutting = $form->getItemByPostVar('score_cutting');
859  if( is_object($scoreCutting) && $scoreCutting->getValue() != $this->testOBJ->getScoreCutting() )
860  {
861  return true;
862  }
863 
864  $passScoring = $form->getItemByPostVar('pass_scoring');
865  if( is_object($passScoring) && $passScoring->getValue() != $this->testOBJ->getPassScoring() )
866  {
867  return true;
868  }
869 
870  return false;
871  }
872 
873  private $availableTaxonomyIds = null;
874 
875  private function getAvailableTaxonomyIds()
876  {
877  if( $this->getAvailableTaxonomyIds === null )
878  {
879  require_once 'Services/Taxonomy/classes/class.ilObjTaxonomy.php';
880  $this->availableTaxonomyIds = (array)ilObjTaxonomy::getUsageOfObject($this->testOBJ->getId());
881  }
882 
884  }
885 }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
__construct(ilCtrl $ctrl, ilAccessHandler $access, ilLanguage $lng, ilTemplate $tpl, ilTree $tree, ilDB $db, ilPluginAdmin $pluginAdmin, ilObjTestGUI $testGUI)
Constructor.
$errors
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.
This class represents a property in a property form.
addOption($a_option)
Add Option.
setValue($a_value)
Set Value.
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.
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.
setSize($a_size)
Set Size.
Database Wrapper.
Definition: class.ilDB.php:28
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
setDisabled($a_disabled)
Set Disabled.
Settings template application class.
setRequired($a_required)
Set Required.
setShowTime($a_showtime)
Set Show Time Information.
Confirmation screen class.
Class ilAccessHandler.