19declare(strict_types=1);
25use Psr\Http\Message\ServerRequestInterface as Request;
94 $this->tpl = $main_template;
101 $this->component_repository,
105 $templateId = $this->testOBJ->getTemplate();
119 $this->request = $request;
124 return $this->score_settings_repo->getFor($this->test_id);
128 $this->score_settings_repo->store($score_settings);
136 if (!$this->
access->checkAccess(
'write',
'', $this->testGUI->getRefId())) {
137 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'cannot_edit_test'),
true);
138 $this->
ctrl->redirect($this->testGUI,
'infoScreen');
143 $nextClass = $this->
ctrl->getNextClass();
144 switch ($nextClass) {
146 $cmd = $this->
ctrl->getCmd(self::CMD_SHOW_FORM);
161 $this->testOBJ->recalculateScores(
true);
162 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"msg_score_settings_modified_and_recalc"),
true);
163 $this->
ctrl->redirect($this, self::CMD_SHOW_FORM);
166 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"msg_score_settings_not_modified"),
true);
171 throw new Exception(
'unknown command: ' . $cmd);
178 if ($form ===
null) {
182 $this->tpl->setContent($this->ui_renderer->render($form));
188 ->withRequest($this->request);
193 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'form_input_not_valid'));
200 $this->loadScoreSettings()->getScoringSettings()
207 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"msg_obj_modified"),
true);
208 $this->
ctrl->redirect($this, self::CMD_SHOW_FORM);
215 $this->request->getParsedBody()[self::F_CONFIRM_SETTINGS]
218 'allowed_classes' => [
219 GuzzleHttp\Psr7\ServerRequest::class,
220 GuzzleHttp\Psr7\Uri::class,
221 GuzzleHttp\Psr7\UploadedFile::class,
222 GuzzleHttp\Psr7\Stream::class,
232 $this->ui_factory->input()->field(),
237 $df = (new \ILIAS\Data\Factory())->dateFormat();
238 switch ($this->active_user->getDateFormat()) {
240 $date_format = $df->germanShort();
244 $date_format = $df->custom()->month()->slash()->day()->slash()->year()->get();
248 $date_format = $df->standard();
250 $environment[
'user_date_format'] = $date_format;
251 $environment[
'user_time_zone'] = $this->active_user->getTimeZone();
257 'scoring' =>
$settings->getScoringSettings()->toForm(...$ui_pack)
258 ->withDisabled($disabled_flag),
259 'summary' =>
$settings->getResultSummarySettings()->toForm(...array_merge($ui_pack, [$environment])),
260 'details' =>
$settings->getResultDetailsSettings()->toForm(
263 'gameification' =>
$settings->getGamificationSettings()->toForm(...$ui_pack)
266 $action = $this->
ctrl->getFormAction($this, self::CMD_SAVE_FORM);
267 $form = $this->ui_factory->input()->container()->form()
268 ->standard($action, $sections)
269 ->withAdditionalTransformation(
270 $this->
refinery->custom()->transformation(
273 ->withScoringSettings($v[
'scoring'])
274 ->withResultSummarySettings($v[
'summary'])
275 ->withResultDetailsSettings($v[
'details'])
276 ->withGamificationSettings($v[
'gameification'])
284 private function isScoreReportingAvailable(): bool
286 if (!$this->testOBJ->getScoreReporting()) {
292 $reporting_date = $this->testOBJ->getScoreSettings()->getResultSummarySettings()->getReportingDate();
293 return $reporting_date <=
new DateTimeImmutable(
'now',
new DateTimeZone(
'UTC'));
301 if (!$this->testOBJ->participantDataExist()) {
305 if (!$this->isScoreReportingAvailable()) {
316 $taxononmy_translator->loadLabelsFromTaxonomyIds($available_taxonomy_ids);
318 $taxonomy_options = [];
319 foreach ($available_taxonomy_ids as $tax_id) {
320 $taxonomy_options[$tax_id] = $taxononmy_translator->getTaxonomyTreeLabel($tax_id);
322 return $taxonomy_options;
329 $settings_changed = (
330 $new_settings->getCountSystem() !== $old_settings->getCountSystem() ||
331 $new_settings->getScoreCutting() !== $old_settings->getScoreCutting() ||
332 $new_settings->getPassScoring() !== $old_settings->getPassScoring()
336 $this->testOBJ->participantDataExist() &&
345 $confirmation->setHeaderText($this->
lng->txt(
'tst_trigger_result_refreshing'));
346 $confirmation->setFormAction($this->
ctrl->getFormAction($this));
347 $confirmation->setCancel($this->
lng->txt(
'cancel'), self::CMD_CANCEL_RECALC);
348 $confirmation->setConfirm($this->
lng->txt(
'confirm'), self::CMD_CONFIRMED_RECALC);
349 $confirmation->addHiddenItem(self::F_CONFIRM_SETTINGS, base64_encode(serialize($request)));
350 $this->tpl->setContent($this->
ctrl->getHTML($confirmation));
static return function(ContainerConfigurator $containerConfigurator)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getSettingsTemplateConfig()
static getUsageOfObject(int $a_obj_id, bool $a_include_titles=false)
const CMD_CONFIRMED_RECALC
const CMD_SHOW_FORM
command constants
storeScoreSettings(ilObjTestScoreSettings $score_settings)
isScoreRecalculationRequired(ilObjTestSettingsScoring $new_settings, ilObjTestSettingsScoring $old_settings)
ilGlobalTemplateInterface $tpl
ScoreSettingsRepository $score_settings_repo
areScoringSettingsWritable()
ilComponentRepository $component_repository
__construct(ilCtrlInterface $ctrl, ilAccessHandler $access, ilLanguage $lng, ilTree $tree, ilDBInterface $db, ilComponentRepository $component_repository, ilObjTestGUI $testGUI, \ilGlobalTemplateInterface $main_template, ilTabsGUI $tabs, ScoreSettingsRepository $score_settings_repo, int $test_id, UIFactory $ui_factory, UIRenderer $ui_renderer, Refinery $refinery, Request $request, ilObjUser $active_user)
ilTestQuestionSetConfigFactory $testQuestionSetConfigFactory
showConfirmation(Request $request)
showForm(Form $form=null)
executeCommand()
Command Execution.
const SCORE_REPORTING_DATE
Settings template application class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This is how the factory for UI elements looks.
An entity that renders components to a string output.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Readable part of repository interface to ilComponentDataDB.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...