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