19 declare(strict_types=1);
68 $uri = ILIAS_HTTP_PATH .
'/' . $this->
ctrl->getLinkTargetByClass([\ilRepositoryGUI::class, \ilObjTestGUI::class, self::class], self::DEFAULT_CMD);
75 $this->action_parameter_token,
78 [
'marks',
'overview_table'],
86 $cmd = $this->
ctrl->getCmd(self::DEFAULT_CMD);
92 if (!$this->editable) {
93 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'cannot_edit_marks'));
98 if ($add_mark_modal ===
null) {
107 $this->action_parameter_token,
116 $this->tpl->setContent(
117 $this->ui_renderer->render([
118 $mark_schema_table->getTable()->withRequest($this->request),
130 $data = $modal->getData();
132 $this->
showMarkSchema($modal->withOnLoad($modal->getShowSignal()));
136 $mark_steps = $this->mark_schema->getMarkSteps();
137 $mark_steps[
$data[
'index']] = $data[
'mark'];
139 if (is_string($new_schema)) {
140 $this->tpl->setOnScreenMessage(
'failure', $new_schema);
144 $this->mark_schema = $new_schema;
145 $this->test->storeMarkSchema(
148 $this->test->onMarkSchemaSaved();
149 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'),
true);
151 if ($this->
logger->isLoggingEnabled()) {
152 $this->
logger->logTestAdministrationInteraction(
153 $this->
logger->getInteractionFactory()->buildTestAdministrationInteraction(
154 $this->test->getRefId(),
155 $this->active_user->getId(),
156 TestAdministrationInteractionTypes::MARK_SCHEMA_MODIFIED,
157 $this->mark_schema->toLog($this->
logger->getAdditionalInformationGenerator())
169 $this->mark_schema = $this->mark_schema->createSimpleSchema(
170 $this->
lng->txt(
'failed_short'),
171 $this->
lng->txt(
'failed_official'),
174 $this->
lng->txt(
'passed_short'),
175 $this->
lng->txt(
'passed_official'),
179 $this->test->storeMarkSchema($this->mark_schema);
180 if ($this->
logger->isLoggingEnabled()) {
181 $this->
logger->logTestAdministrationInteraction(
182 $this->
logger->getInteractionFactory()->buildTestAdministrationInteraction(
183 $this->test->getRefId(),
184 $this->active_user->getId(),
185 TestAdministrationInteractionTypes::MARK_SCHEMA_RESET,
197 if (!$this->post_wrapper->has(
'interruptive_items')) {
202 $marks_to_be_deleted = $this->post_wrapper->retrieve(
203 'interruptive_items',
208 if (is_string($new_schema)) {
209 $this->tpl->setOnScreenMessage(
'failure', $new_schema);
214 $this->mark_schema = $new_schema;
215 $this->test->storeMarkSchema($new_schema);
217 if ($this->
logger->isLoggingEnabled()) {
218 $this->
logger->logTestAdministrationInteraction(
219 $this->
logger->getInteractionFactory()->buildTestAdministrationInteraction(
220 $this->test->getRefId(),
221 $this->active_user->getId(),
222 TestAdministrationInteractionTypes::MARK_SCHEMA_MODIFIED,
223 $this->mark_schema->toLog($this->
logger->getAdditionalInformationGenerator())
233 return $this->ui_factory->modal()->interruptive(
234 $this->
lng->txt(
'tst_mark_reset_to_simple_mark_schema'),
235 $this->
lng->txt(
'tst_mark_reset_to_simple_mark_schema_confirmation'),
236 $this->
ctrl->getFormActionByClass(MarkSchemaGUI::class,
'resetToSimpleMarkSchema')
237 )->withActionButtonLabel($this->
lng->txt(
'tst_mark_reset_to_simple_mark_schema'));
242 $title_lng_var =
'edit';
243 if ($mark ===
null) {
244 $title_lng_var =
'create';
247 return $this->ui_factory->modal()->roundtrip(
248 $this->
lng->txt($title_lng_var),
251 'mark' => $mark->toForm(
253 $this->ui_factory->input()->field(),
257 'index' => $this->ui_factory->input()->field()->hidden()
258 ->withValue($mark_index)
260 $this->
ctrl->getFormActionByClass(MarkSchemaGUI::class,
'saveMark')
264 private function editMark(array $affected_marks): void
268 $affected_mark = current($affected_marks);
269 $mark_steps = $this->mark_schema->getMarkSteps();
270 $this->response_handler->sendAsync(
271 $this->ui_renderer->renderAsync(
272 $this->buildMarkModal($mark_steps[$affected_mark], $affected_mark)
279 if (!$this->editable) {
282 $create_simple_schema_button = $this->ui_factory->button()->standard(
283 $this->
lng->txt(
'tst_mark_reset_to_simple_mark_schema'),
284 $confirmation_modal->getShowSignal()
286 $this->
toolbar->addComponent($create_simple_schema_button);
288 $add_mark_button = $this->ui_factory->button()->standard(
289 $this->
lng->txt(
'tst_mark_create_new_mark_step'),
290 $add_mark_modal->getShowSignal()
292 $this->
toolbar->addComponent($add_mark_button);
298 if (!$this->editable || $action ===
null) {
303 if ($affected_marks ===
null) {
304 $this->response_handler->sendAsync(
305 $this->ui_renderer->renderAsync(
306 $this->ui_factory->modal()->roundtrip(
307 $this->
lng->txt(
'error'),
308 $this->ui_factory->messageBox()->failure($this->
lng->txt(
'tst_delete_missing_mark'))
330 $confirm_delete_modal = $this->ui_factory->modal()->interruptive(
331 $this->
lng->txt(
'confirm'),
332 $this->
lng->txt(
'delete_mark_confirmation'),
333 $this->
ctrl->getFormActionByClass(MarkSchemaGUI::class,
'deleteMarkSteps')
334 )->withActionButtonLabel($this->
lng->txt(
'delete'))
337 $this->response_handler->sendAsync(
338 $this->ui_renderer->renderAsync($confirm_delete_modal)
344 $mark_steps = $this->mark_schema->getMarkSteps();
345 $marks_to_be_deleted = [];
346 foreach ($affected_marks as $affected_mark) {
347 $marks_to_be_deleted[] = $this->ui_factory->modal()->interruptiveItem()->standard(
348 (
string) $affected_mark,
349 $mark_steps[$affected_mark]->getOfficialName()
352 return $marks_to_be_deleted;
357 $param = $this->action_parameter_token->getName();
358 if (!$this->request_wrapper->has(
$param)) {
361 $trafo = $this->
refinery->byTrying([
362 $this->
refinery->kindlyTo()->null(),
363 $this->
refinery->kindlyTo()->string()
365 return $this->request_wrapper->retrieve(
$param, $trafo);
370 $affected_marks = $this->request_wrapper->retrieve(
371 $this->row_id_token->getName(),
374 $this->
refinery->container()->mapValues(
381 if (is_int($affected_marks)) {
382 $affected_marks = [$affected_marks];
385 return $affected_marks;
390 if ($this->editable) {
394 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'permission_denied'),
true);
395 $this->
ctrl->redirect($this,
'showMarkSchema');
400 if ($this->editable) {
404 $this->response_handler->sendAsync(
405 $this->ui_renderer->renderAsync(
406 $this->ui_factory->modal()->roundtrip(
407 $this->
lng->txt(
'error'),
408 $this->ui_factory->messageBox()->failure($this->
lng->txt(
'permission_denied'))
418 foreach ($marks_to_delete as $mark) {
419 unset($new_marks[$mark]);
423 $this->mark_schema->withMarkSteps(array_values($new_marks))
429 if (!is_string($checked_value)) {
430 return $checked_value;
433 $this->response_handler->sendAsync(
434 $this->ui_renderer->render(
435 $this->ui_factory->modal()->roundtrip(
436 $this->
lng->txt(
'error'),
437 $this->ui_factory->messageBox()->failure($checked_value)
453 $messages[] = $this->
lng->txt(
'no_passed_after_failed');
TestAdministrationInteractionTypes
URLBuilderToken $action_parameter_token
A class defining mark schemas for assessment test objects.
checkSchemaForErrors(MarkSchema $new_schema)
showMarkSchema(?RoundTripModal $add_mark_modal=null)
A class defining marks for assessment test objects.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
acquireParameters(array $namespace, string ... $names)
exitOnMarkSchemaNotEditable()
removeMarksAndCheckNewSchema(array $marks_to_delete)
buildResetConfirmationModal()
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
buildInteruptiveItems(array $affected_marks)
URLBuilderToken $row_id_token
populateToolbar(InterruptiveModal $confirmation_modal, RoundTripModal $add_mark_modal)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
checkForFailedAfterPassed()
resetToSimpleMarkSchema()
confirmMarkDeletion(array $marks_to_delete)
getTableActionQueryString()
checkForMissingZeroPercentage()
getTableAffectedItemsFromQuery()
__construct(private \ilObjTest $test, private \ilObjUser $active_user, private \ilLanguage $lng, private \ilCtrlInterface $ctrl, private \ilGlobalTemplateInterface $tpl, private \ilToolbarGUI $toolbar, private TestLogger $logger, private RequestWrapper $post_wrapper, private RequestWrapper $request_wrapper, private ResponseHandler $response_handler, private Request $request, private Refinery $refinery, private UIFactory $ui_factory, private UIRenderer $ui_renderer)
editMark(array $affected_marks)
redirectOnMarkSchemaNotEditable()
exitOnSchemaError(MarkSchema|string $checked_value)
buildMarkModal(?Mark $mark=null, int $mark_index=-1)