ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
SettingsFactory.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Test\Settings;
22
23use ILIAS\Test\Scoring\Settings\Settings as SettingsScoring;
40
42{
43 public function createMainSettingsFromDBRow(array $row): MainSettings
44 {
45 return new MainSettings(
46 $row['id'],
48 $row['question_set_type'],
49 (bool) $row['anonymity']
50 ),
52 (bool) $row['intro_enabled'],
53 $row['introduction_page_id'],
54 (bool) $row['conditions_checkbox_enabled'],
55 ),
57 (bool) $row['starting_time_enabled'],
58 $row['starting_time'] !== 0
59 ? \DateTimeImmutable::createFromFormat('U', (string) $row['starting_time'])
60 : null,
61 (bool) $row['ending_time_enabled'],
62 $row['ending_time'] !== 0
63 ? \DateTimeImmutable::createFromFormat('U', (string) $row['ending_time'])
64 : null,
65 (bool) $row['password_enabled'],
66 $row['password'],
67 $row['ip_range_from'],
68 $row['ip_range_to'],
69 (bool) $row['fixed_participants'],
70 ),
72 $row['nr_of_tries'],
73 (bool) $row['block_after_passed'],
74 $row['pass_waiting'],
75 (bool) $row['enable_processing_time'],
76 $row['processing_time'],
77 (bool) $row['reset_processing_time'],
78 $row['kiosk'],
79 (bool) $row['examid_in_test_pass']
80 ),
82 (int) $row['title_output'],
83 (bool) $row['autosave'],
84 $row['autosave_ival'],
85 (bool) $row['shuffle_questions'],
86 (bool) $row['answer_feedback_points'],
87 (bool) $row['answer_feedback'],
88 (bool) $row['specific_feedback'],
89 (bool) $row['instant_verification'],
90 (bool) $row['force_inst_fb'],
91 (bool) $row['inst_fb_answer_fixation'],
92 (bool) $row['follow_qst_answer_fixation']
93 ),
95 (bool) $row['use_previous_answers'],
96 (bool) $row['suspend_test_allowed'],
97 (bool) $row['sequence_settings'],
98 $row['usr_pass_overview_mode'],
99 (bool) $row['show_marker'],
100 (bool) $row['show_questionlist']
101 ),
103 (bool) $row['enable_examview'],
104 (bool) $row['showfinalstatement'],
105 $row['concluding_remarks_page_id'],
106 RedirectionModes::tryFrom($row['redirection_mode']) ?? RedirectionModes::NONE,
107 $row['redirection_url']
108 ),
110 (bool) $row['skill_service'],
111 (bool) $row['hide_info_tab']
112 )
113 );
114 }
115
117 {
118 return new MainSettings(
119 0,
120 new SettingsGeneral(),
122 new SettingsAccess(),
125 0,
126 false,
127 0,
128 false,
129 false,
130 false,
131 false,
132 false,
133 false,
134 false,
135 false
136 ),
138 new SettingsFinishing(),
140 );
141 }
142
143 public function createScoreSettingsFromDBRow(array $row): ScoreSettings
144 {
145 return new ScoreSettings(
146 $row['id'],
147 (new SettingsScoring())
148 ->withCountSystem((int) $row['count_system'])
149 ->withScoreCutting((int) $row['score_cutting'])
150 ->withPassScoring((int) $row['pass_scoring']),
152 ->withScoreReporting(ScoreReportingTypes::from($row['score_reporting']))
153 ->withReportingDate(!empty($row['reporting_date'])
154 ? \DateTimeImmutable::createFromFormat('U', (string) $row['reporting_date'])
155 : null)
156 ->withShowGradingStatusEnabled((bool) $row['show_grading_status'])
157 ->withShowGradingMarkEnabled((bool) $row['show_grading_mark'])
158 ->withPassDeletionAllowed((bool) $row['pass_deletion_allowed']),
159 //->withShowPassDetails derived from results_presentation with bit RESULTPRES_BIT_PASS_DETAILS
161 ->withResultsPresentation((int) $row['results_presentation'])
162 ->withShowExamIdInTestResults((bool) $row['examid_in_test_res'])
163 ->withExportSettings((int) $row['exportsettings']),
165 ->withHighscoreEnabled((bool) $row['highscore_enabled'])
166 ->withHighscoreAnon((bool) $row['highscore_anon'])
167 ->withHighscoreAchievedTS((bool) $row['highscore_achieved_ts'])
168 ->withHighscoreScore((bool) $row['highscore_score'])
169 ->withHighscorePercentage((bool) $row['highscore_percentage'])
170 ->withHighscoreWTime((bool) $row['highscore_wtime'])
171 ->withHighscoreOwnTable((bool) $row['highscore_own_table'])
172 ->withHighscoreTopTable((bool) $row['highscore_top_table'])
173 ->withHighscoreTopNum((int) $row['highscore_top_num'])
174 );
175 }
176
178 {
179 return new PersonalSettingsTemplate(
180 $row['test_defaults_id'],
181 $row['user_fi'],
182 $row['name'],
183 $row['description'] ?? '',
184 $row['author'] ?? '',
185 \DateTimeImmutable::createFromFormat('U', (string) $row['tstamp']),
186 $row['settings_id'] ?? -1,
187 );
188 }
189}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...