19declare(strict_types=1);
35use Psr\Http\Message\ServerRequestInterface as
Request;
63 protected readonly \
ilTree $tree,
71 protected readonly
int $test_id,
72 protected readonly UIFactory $ui_factory,
73 protected readonly UIRenderer $ui_renderer,
75 protected readonly
Request $request,
76 protected readonly \
ilObjUser $active_user
83 return $this->score_settings_repo->getFor($this->test_id);
87 $this->score_settings_repo->store($score_settings);
95 if (!$this->
access->checkAccess(
'write',
'', $this->test_gui->getRefId())) {
96 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'cannot_edit_test'),
true);
97 $this->
ctrl->redirectByClass([\ilRepositoryGUI::class, \ilObjTestGUI::class, \ilInfoScreenGUI::class]);
102 $nextClass = $this->
ctrl->getNextClass();
103 switch ($nextClass) {
105 $cmd = $this->
ctrl->getCmd(self::CMD_SHOW_FORM);
120 $this->test_object->recalculateScores(
true);
121 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"msg_score_settings_modified_and_recalc"),
true);
122 $this->
ctrl->redirect($this, self::CMD_SHOW_FORM);
125 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"msg_score_settings_not_modified"),
true);
130 throw new \Exception(
'unknown command: ' . $cmd);
137 if ($form ===
null) {
141 $this->tpl->setContent($this->ui_renderer->render($form));
147 ->withRequest($this->request);
149 $settings = $form->getData();
151 if (is_null($settings)) {
152 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'form_input_not_valid'));
158 $settings->getScoringSettings(),
159 $this->loadScoreSettings()->getScoringSettings()
166 if ($this->
logger->isLoggingEnabled()) {
167 $this->
logger->logTestAdministrationInteraction(
168 $this->
logger->getInteractionFactory()->buildTestAdministrationInteraction(
169 $this->test_gui->getRefId(),
170 $this->active_user->getId(),
171 TestAdministrationInteractionTypes::SCORING_SETTINGS_MODIFIED,
172 $settings->getArrayForLog($this->logger->getAdditionalInformationGenerator())
176 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"msg_obj_modified"),
true);
177 $this->
ctrl->redirect($this, self::CMD_SHOW_FORM);
184 $this->request->getParsedBody()[self::F_CONFIRM_SETTINGS]
187 'allowed_classes' => [
188 \GuzzleHttp\Psr7\ServerRequest::class,
189 \GuzzleHttp\Psr7\Uri::class,
190 \GuzzleHttp\Psr7\UploadedFile::class,
191 \GuzzleHttp\Psr7\Stream::class,
201 $this->ui_factory->input()->field(),
206 'user_date_format' => $this->active_user->getDateTimeFormat(),
207 'user_time_zone' => $this->active_user->getTimeZone()
214 'scoring' => $settings->getScoringSettings()->toForm(...$ui_pack)
215 ->withDisabled($disabled_flag),
216 'summary' => $settings->getResultSummarySettings()->toForm(...array_merge($ui_pack, [$environment])),
217 'details' => $settings->getResultDetailsSettings()->toForm(
220 'gameification' => $settings->getGamificationSettings()->toForm(...$ui_pack)
223 $action = $this->
ctrl->getFormAction($this, self::CMD_SAVE_FORM);
224 $form = $this->ui_factory->input()->container()->form()
225 ->standard($action, $sections)
226 ->withAdditionalTransformation(
227 $this->
refinery->custom()->transformation(
228 function ($v) use ($settings) {
230 ->withScoringSettings($v[
'scoring'])
231 ->withResultSummarySettings($v[
'summary'])
232 ->withResultDetailsSettings($v[
'details'])
233 ->withGamificationSettings($v[
'gameification'])
243 $result_summary_settings = $this->test_object->getScoreSettings()
244 ->getResultSummarySettings();
245 if (!$result_summary_settings->getScoreReporting()->isReportingEnabled()) {
249 if ($result_summary_settings->getScoreReporting() === ScoreReportingTypes::SCORE_REPORTING_DATE) {
250 return $result_summary_settings->getReportingDate()
251 <= new \DateTimeImmutable(
'now',
new \DateTimeZone(
'UTC'));
259 if (!$this->test_object->participantDataExist()) {
273 $taxononmy_translator = new \ilTestQuestionFilterLabelTranslator($this->db, $this->
lng);
274 $taxononmy_translator->loadLabelsFromTaxonomyIds($available_taxonomy_ids);
276 $taxonomy_options = [];
277 foreach ($available_taxonomy_ids as $tax_id) {
278 $taxonomy_options[$tax_id] = $taxononmy_translator->getTaxonomyTreeLabel($tax_id);
280 return $taxonomy_options;
284 SettingsScoring $new_settings,
285 SettingsScoring $old_settings
287 $settings_changed = (
288 $new_settings->getCountSystem() !== $old_settings->getCountSystem() ||
289 $new_settings->getScoreCutting() !== $old_settings->getScoreCutting() ||
290 $new_settings->getPassScoring() !== $old_settings->getPassScoring()
294 $this->test_object->participantDataExist() &&
302 $confirmation = new \ilConfirmationGUI();
303 $confirmation->setHeaderText($this->
lng->txt(
'tst_trigger_result_refreshing'));
304 $confirmation->setFormAction($this->
ctrl->getFormAction($this));
305 $confirmation->setCancel($this->
lng->txt(
'cancel'), self::CMD_CANCEL_RECALC);
306 $confirmation->setConfirm($this->
lng->txt(
'confirm'), self::CMD_CONFIRMED_RECALC);
307 $confirmation->addHiddenItem(self::F_CONFIRM_SETTINGS, base64_encode(serialize($request)));
308 $this->tpl->setContent($this->
ctrl->getHTML($confirmation));
Builds a Color from either hex- or rgb values.
const SETTINGS_SUBTAB_ID_SCORING
isScoreReportingAvailable()
showForm(?Form $form=null)
const CMD_CONFIRMED_RECALC
isScoreRecalculationRequired(SettingsScoring $new_settings, SettingsScoring $old_settings)
showConfirmation(Request $request)
storeScoreSettings(ScoreSettings $score_settings)
executeCommand()
Command Execution.
areScoringSettingsWritable()
__construct(protected readonly \ilCtrlInterface $ctrl, protected readonly \ilAccessHandler $access, protected readonly \ilLanguage $lng, protected readonly \ilTree $tree, protected readonly \ilDBInterface $db, protected readonly \ilComponentRepository $component_repository, protected readonly \ilObjTestGUI $test_gui, protected readonly \ilGlobalTemplateInterface $tpl, protected readonly \ilTabsGUI $tabs, protected readonly TestLogger $logger, protected readonly ScoreSettingsRepository $score_settings_repo, protected readonly int $test_id, protected readonly UIFactory $ui_factory, protected readonly UIRenderer $ui_renderer, protected readonly Refinery $refinery, protected readonly Request $request, protected readonly \ilObjUser $active_user)
const CMD_SHOW_FORM
command constants
static getUsageOfObject(int $a_obj_id, bool $a_include_titles=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
An entity that renders components to a string output.
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
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...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
TestAdministrationInteractionTypes