ILIAS  trunk Revision v12.0_alpha-16-g3e876e53c80
TestSettingsSetup.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Test\Setup;
22
23const T_BOOLEAN = ['type' => \ilDBConstants::T_INTEGER, 'length' => 1, 'default' => 0];
24const T_TINYINT = ['type' => \ilDBConstants::T_INTEGER, 'length' => 4, 'default' => 0];
25const T_BIGINT = ['type' => \ilDBConstants::T_INTEGER, 'default' => 0];
26
28
30{
31 private const array SETTINGS_COLUMNS = [
32 'introduction' => [['type' => \ilDBConstants::T_TEXT, 'length' => 4000, 'default' => null], null],
33 'sequence_settings' => [T_BOOLEAN, 'SequenceSettings'],
34 'score_reporting' => [T_TINYINT, 'ScoreReporting'],
35 'instant_verification' => [T_BOOLEAN, 'InstantFeedbackSolution'],
36 'answer_feedback' => [T_BOOLEAN, 'AnswerFeedback'],
37 'answer_feedback_points' => [T_BOOLEAN, 'AnswerFeedbackPoints'],
38 'fixed_participants' => [T_BOOLEAN, 'fixed_participants'],
39 'suspend_test_allowed' => [T_BOOLEAN, 'ShowCancel'],
40 'anonymity' => [T_BOOLEAN, 'Anonymity'],
41 'nr_of_tries' => [['type' => \ilDBConstants::T_INTEGER, 'length' => 8, 'default' => 0], 'NrOfTries'],
42 'use_previous_answers' => [T_BOOLEAN, 'use_previous_answers'],
43 'title_output' => [T_TINYINT, 'TitleOutput'],
44 'processing_time' => [['type' => \ilDBConstants::T_TEXT, 'length' => 8, 'default' => null], 'ProcessingTime'],
45 'enable_processing_time' => [T_BOOLEAN, 'EnableProcessingTime'],
46 'reset_processing_time' => [T_BOOLEAN, 'ResetProcessingTime'],
47 'reporting_date' => [T_BIGINT, 'ReportingDate'],
48 'shuffle_questions' => [T_BOOLEAN, 'Shuffle'],
49 'count_system' => [T_TINYINT, 'CountSystem'],
50 'score_cutting' => [T_TINYINT, 'ScoreCutting'],
51 'pass_scoring' => [T_TINYINT, 'PassScoring'],
52 'password' => [['type' => \ilDBConstants::T_TEXT, 'length' => 20, 'default' => null], 'password'],
53 'results_presentation' => [['type' => \ilDBConstants::T_INTEGER, 'default' => 3], 'ResultsPresentation'],
54 'usr_pass_overview_mode' => [T_BIGINT, 'ListOfQuestionsSettings'],
55 'show_marker' => [T_BOOLEAN, 'ShowMarker'],
56 'kiosk' => [T_BIGINT, 'Kiosk'],
57 'finalstatement' => [['type' => \ilDBConstants::T_TEXT, 'length' => 4000, 'default' => null], null],
58 'showfinalstatement' => [T_BOOLEAN, 'ShowFinalStatement'],
59 'exportsettings' => [T_BIGINT, null],
60 'print_bs_with_res' => [['type' => \ilDBConstants::T_INTEGER, 'length' => 1, 'default' => 0], 'show_solution_list_comparison'],
61 'highscore_enabled' => [T_BOOLEAN, 'highscore_enabled'],
62 'highscore_anon' => [T_BOOLEAN, 'highscore_anon'],
63 'highscore_achieved_ts' => [T_BOOLEAN, 'highscore_achieved_ts'],
64 'highscore_score' => [T_BOOLEAN, 'highscore_score'],
65 'highscore_percentage' => [T_BOOLEAN, 'highscore_percentage'],
66 'highscore_wtime' => [T_BOOLEAN, 'highscore_wtime'],
67 'highscore_own_table' => [T_BOOLEAN, 'highscore_own_table'],
68 'highscore_top_table' => [T_BOOLEAN, 'highscore_top_table'],
69 'highscore_top_num' => [T_BIGINT, 'highscore_top_num'],
70 'specific_feedback' => [T_BOOLEAN, 'SpecificAnswerFeedback'],
71 'autosave' => [T_BOOLEAN, 'autosave'],
72 'autosave_ival' => [T_BIGINT, 'autosave_ival'],
73 'pass_deletion_allowed' => [T_BOOLEAN, 'pass_deletion_allowed'],
74 'redirection_mode' => [T_TINYINT, 'redirection_mode'],
75 'redirection_url' => [['type' => \ilDBConstants::T_TEXT, 'length' => 4000, 'default' => null], 'redirection_url'],
76 'examid_in_test_pass' => [T_BOOLEAN, 'examid_in_test_pass'],
77 'examid_in_test_res' => [T_BOOLEAN, 'examid_in_test_res'],
78 'enable_examview' => [T_BOOLEAN, 'enable_examview'],
79 'question_set_type' => [['type' => \ilDBConstants::T_TEXT, 'length' => 32, 'default' => 'FIXED_QUEST_SET'], 'questionSetType'],
80 'skill_service' => [T_BOOLEAN, 'skill_service'],
81 'show_grading_status' => [T_BOOLEAN, 'show_grading_status'],
82 'show_grading_mark' => [T_BOOLEAN, 'show_grading_mark'],
83 'inst_fb_answer_fixation' => [T_BOOLEAN, 'inst_fb_answer_fixation'],
84 'intro_enabled' => [T_BOOLEAN, 'IntroEnabled'],
85 'starting_time_enabled' => [T_BOOLEAN, 'StartingTimeEnabled'],
86 'ending_time_enabled' => [T_BOOLEAN, 'EndingTimeEnabled'],
87 'password_enabled' => [T_BOOLEAN, 'password_enabled'],
88 'force_inst_fb' => [T_BOOLEAN, 'force_inst_fb'],
89 'starting_time' => [T_BIGINT, 'StartingTime'],
90 'ending_time' => [T_BIGINT, 'EndingTime'],
91 'pass_waiting' => [['type' => \ilDBConstants::T_TEXT, 'length' => 15, 'default' => null], 'pass_waiting'],
92 'follow_qst_answer_fixation' => [T_BOOLEAN, 'follow_qst_answer_fixation'],
93 'block_after_passed' => [T_BOOLEAN, 'BlockAfterPassed'],
94 'introduction_page_id' => [['type' => \ilDBConstants::T_INTEGER, 'default' => null], null],
95 'concluding_remarks_page_id' => [['type' => \ilDBConstants::T_INTEGER, 'default' => null], null],
96 'show_questionlist' => [T_BOOLEAN, null],
97 'hide_info_tab' => [T_BOOLEAN, 'HideInfoTab'],
98 'conditions_checkbox_enabled' => [T_BOOLEAN, 'ExamConditionsCheckboxEnabled'],
99 'ip_range_from' => [['type' => \ilDBConstants::T_TEXT, 'length' => 39, 'default' => null], null],
100 'ip_range_to' => [['type' => \ilDBConstants::T_TEXT, 'length' => 39, 'default' => null], null]
101 ];
102
103 private function columnIsNullable(array $column_def): bool
104 {
105 return array_key_exists('default', $column_def) && $column_def['default'] === null;
106 }
107
108 private function convertLegacyDate(string|\DateTimeImmutable|null $date): int
109 {
110 if ($date instanceof \DateTimeImmutable) {
111 return $date->getTimestamp();
112 }
113
114 if ($date === '' || $date === null) {
115 return 0;
116 }
117
118 return \DateTimeImmutable::createFromFormat(
120 $date,
121 new \DateTimeZone('UTC')
122 )->getTimestamp();
123 }
124}
columnIsNullable(array $column_def)
convertLegacyDate(string|\DateTimeImmutable|null $date)