ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
ilAssQuestionSkillAssignmentsGUI Class Reference
+ Collaboration diagram for ilAssQuestionSkillAssignmentsGUI:

Public Member Functions

 __construct (private readonly ilCtrl $ctrl, private readonly ilAccessHandler $access, private readonly ilGlobalTemplateInterface $tpl, private readonly ilLanguage $lng, private readonly ilDBInterface $db, private readonly RequestDataCollectorInterface $request_data_collector, private readonly SkillUsageService $skill_usage_service, private readonly UIFactory $ui_factory, private readonly UIRenderer $ui_renderer, private readonly Refinery $refinery, private readonly HTTP $http, private readonly ilToolbarGUI $toolbar, private readonly ilTabsGUI $tabs)
 
 getQuestionOrderSequence ()
 
 getAssignmentConfigurationHintMessage ()
 
 setAssignmentConfigurationHintMessage (?string $assignmentConfigurationHintMessage)
 
 setQuestionOrderSequence ($questionOrderSequence)
 
 getQuestionList ()
 
 setQuestionList ($questionList)
 
 getQuestionContainerId ()
 
 setQuestionContainerId ($questionContainerId)
 
 isAssignmentEditingEnabled ()
 
 setAssignmentEditingEnabled ($assignmentEditingEnabled)
 
 executeCommand ()
 

Data Fields

const CMD_SHOW_SKILL_QUEST_ASSIGNS = 'showSkillQuestionAssignments'
 
const CMD_EDIT_SKILL_QUEST_ASSIGNS = 'editSkillQuestionAssignment'
 
const CMD_SHOW_SKILL_SELECT = 'showSkillSelection'
 
const CMD_UPDATE_SKILL_QUEST_ASSIGNS = 'updateSkillQuestionAssignments'
 
const CMD_SHOW_SKILL_QUEST_ASSIGN_PROPERTIES_FORM = 'showSkillQuestionAssignmentPropertiesForm'
 
const CMD_SAVE_SKILL_QUEST_ASSIGN_PROPERTIES_FORM = 'saveSkillQuestionAssignmentPropertiesForm'
 
const CMD_SAVE_SKILL_POINTS = 'saveSkillPoints'
 
const CMD_SHOW_SYNC_ORIGINAL_CONFIRMATION = 'showSyncOriginalConfirmation'
 
const CMD_SYNC_ORIGINAL = 'syncOriginal'
 
const PARAM_SKILL_SELECTION = 'skill_ids'
 

Protected Member Functions

 doesObjectTypeMatch ($objectId)
 

Private Member Functions

 modifyTabs ()
 
 isAvoidManipulationRedirectRequired ($command)
 
 saveSkillPointsCmd ()
 
 updateSkillQuestionAssignmentsCmd ()
 
 showSkillSelectionCmd ()
 
 showSkillQuestionAssignmentPropertiesFormCmd (?assQuestionGUI $question_gui=null, ?ilAssQuestionSkillAssignment $assignment=null, ?ilPropertyFormGUI $form=null)
 
 saveSkillQuestionAssignmentPropertiesFormCmd ()
 
 buildSkillQuestionAssignmentPropertiesForm (assQuestion $question, ilAssQuestionSkillAssignment $assignment)
 
 editSkillQuestionAssignmentCmd ()
 
 isSyncOriginalPossibleAndAllowed (int $questionId)
 
 showSyncOriginalConfirmationCmd ()
 
 syncOriginalCmd ()
 
 buildSkillQuestionAssignmentList ()
 
 buildSkillSelectorExplorerGUI ($assignments)
 
 buildSkillSelectorToolbarGUI ()
 
 buildQuestionPage (assQuestionGUI $question_gui)
 
 buildQuestionSkillAssignment (int $question_id, int $skill_base_id, int $skill_tref_id)
 
 isTestQuestion ($questionId)
 
 checkSolutionCompareExpressionInput ($input, assQuestion $question)
 
 checkPointsAreInt (ilPropertyFormGUI $form)
 
 validateSolutionCompareExpression (ilAssQuestionSolutionComparisonExpression $expression, $question)
 
 keepAssignmentParameters ()
 
 handleAssignmentConfigurationHintMessage ()
 
 getSkillSelectorHeader (int $questionId)
 
 sortAlphabetically ($array)
 

Private Attributes

ilAssQuestionList $question_list
 
int $question_container_id
 
bool $assignment_editing_enabled
 
string $assignment_configuration_hint_message = null
 
array $questionOrderSequence
 
DataFactory $data_factory
 

Detailed Description

Definition at line 46 of file class.ilAssQuestionSkillAssignmentsGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilAssQuestionSkillAssignmentsGUI::__construct ( private readonly ilCtrl  $ctrl,
private readonly ilAccessHandler  $access,
private readonly ilGlobalTemplateInterface  $tpl,
private readonly ilLanguage  $lng,
private readonly ilDBInterface  $db,
private readonly RequestDataCollectorInterface  $request_data_collector,
private readonly SkillUsageService  $skill_usage_service,
private readonly UIFactory  $ui_factory,
private readonly UIRenderer  $ui_renderer,
private readonly Refinery  $refinery,
private readonly HTTP  $http,
private readonly ilToolbarGUI  $toolbar,
private readonly ilTabsGUI  $tabs 
)

Definition at line 69 of file class.ilAssQuestionSkillAssignmentsGUI.php.

83 {
84 $this->data_factory = new DataFactory();
85 }

Member Function Documentation

◆ buildQuestionPage()

ilAssQuestionSkillAssignmentsGUI::buildQuestionPage ( assQuestionGUI  $question_gui)
private

Definition at line 677 of file class.ilAssQuestionSkillAssignmentsGUI.php.

678 {
679 $this->tpl->addCss('./assets/css/content.css');
680
681 $page_gui = new ilAssQuestionPageGUI($question_gui->getObject()->getId());
682 $page_gui->setFileDownloadLink($question_gui->buildFileDownloadLink());
683 $page_gui->setOutputMode("presentation");
684 $page_gui->setRenderPageContainer(true);
685
686 $page_gui->setPresentationTitle($question_gui->getObject()->getTitleForHTMLOutput());
687
688 $question = $question_gui->getObject();
689 $question->setShuffle(false); // dirty, but works ^^
690 $question_gui->setObject($question);
691 $page_gui->setQuestionHTML([
692 $question_gui->getObject()->getId() => $question_gui->getSolutionOutput(0, 0, false, false, true, false, true, false, true)
693 ]);
694
695 return preg_replace("/src=\"\\.\\//ims", "src=\"" . ILIAS_HTTP_PATH . "/", $page_gui->presentation());
696
697 }
setObject(assQuestion $question)
getSolutionOutput(int $active_id, ?int $pass=null, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_inline_feedback=true)
Question page GUI class.

References assQuestionGUI\buildFileDownloadLink(), assQuestionGUI\getObject(), assQuestionGUI\getSolutionOutput(), assQuestionGUI\setObject(), and assQuestion\setShuffle().

+ Here is the call graph for this function:

◆ buildQuestionSkillAssignment()

ilAssQuestionSkillAssignmentsGUI::buildQuestionSkillAssignment ( int  $question_id,
int  $skill_base_id,
int  $skill_tref_id 
)
private
Returns
ilAssQuestionSkillAssignment

Definition at line 702 of file class.ilAssQuestionSkillAssignmentsGUI.php.

707 $assignment = new ilAssQuestionSkillAssignment($this->db);
708
709 $assignment->setParentObjId($this->getQuestionContainerId());
710 $assignment->setQuestionId($question_id);
711 $assignment->setSkillBaseId($skill_base_id);
712 $assignment->setSkillTrefId($skill_tref_id);
713
714 $assignment->loadFromDb();
715 $assignment->loadAdditionalSkillData();
716
717 return $assignment;
718 }

◆ buildSkillQuestionAssignmentList()

ilAssQuestionSkillAssignmentsGUI::buildSkillQuestionAssignmentList ( )
private

Definition at line 627 of file class.ilAssQuestionSkillAssignmentsGUI.php.

628 {
629 $assignmentList = new ilAssQuestionSkillAssignmentList($this->db);
630 $assignmentList->setParentObjId($this->getQuestionContainerId());
631
632 return $assignmentList;
633 }

◆ buildSkillQuestionAssignmentPropertiesForm()

ilAssQuestionSkillAssignmentsGUI::buildSkillQuestionAssignmentPropertiesForm ( assQuestion  $question,
ilAssQuestionSkillAssignment  $assignment 
)
private

Definition at line 470 of file class.ilAssQuestionSkillAssignmentsGUI.php.

475 $form->setQuestion($question);
476 $form->setAssignment($assignment);
477 $form->setManipulationEnabled($this->isAssignmentEditingEnabled());
478 $form->build();
479
480 return $form;
481 }

◆ buildSkillSelectorExplorerGUI()

ilAssQuestionSkillAssignmentsGUI::buildSkillSelectorExplorerGUI (   $assignments)
private
Returns
ilSkillSelectorGUI

Definition at line 638 of file class.ilAssQuestionSkillAssignmentsGUI.php.

639 {
640 $skillSelectorExplorerGUI = new ilSkillSelectorGUI(
641 $this,
642 self::CMD_SHOW_SKILL_SELECT,
643 $this,
644 self::CMD_UPDATE_SKILL_QUEST_ASSIGNS,
645 self::PARAM_SKILL_SELECTION
646 );
647
648 $skillSelectorExplorerGUI->setSelectMode(self::PARAM_SKILL_SELECTION, true);
649 //$skillSelectorExplorerGUI->setNodeOnclickEnabled(false);
650
651 // parameter name for skill selection is actually taken from value passed to constructor,
652 // but passing a non empty name to setSelectMode is neccessary to keep input fields enabled
653
654 foreach ($assignments as $assignment) {
655 $id = "{$assignment->getSkillBaseId()}:{$assignment->getSkillTrefId()}";
656 //$skillSelectorExplorerGUI->setNodeSelected($id);
657 $skillSelectorExplorerGUI->setSkillSelected($id);
658 }
659
660 return $skillSelectorExplorerGUI;
661 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Explorer class that works on tree objects (Services/Tree)

References $id.

Referenced by showSkillSelectionCmd(), and updateSkillQuestionAssignmentsCmd().

+ Here is the caller graph for this function:

◆ buildSkillSelectorToolbarGUI()

ilAssQuestionSkillAssignmentsGUI::buildSkillSelectorToolbarGUI ( )
private
Returns
ilToolbarGUI

Definition at line 666 of file class.ilAssQuestionSkillAssignmentsGUI.php.

667 {
668 $skillSelectorToolbarGUI = new ilToolbarGUI();
669
670 $skillSelectorToolbarGUI->setFormAction($this->ctrl->getFormAction($this));
671 $skillSelectorToolbarGUI->addFormButton($this->lng->txt('qpl_save_skill_assigns_update'), self::CMD_UPDATE_SKILL_QUEST_ASSIGNS);
672 $skillSelectorToolbarGUI->addFormButton($this->lng->txt('qpl_cancel_skill_assigns_update'), self::CMD_EDIT_SKILL_QUEST_ASSIGNS);
673
674 return $skillSelectorToolbarGUI;
675 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

Referenced by showSkillSelectionCmd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkPointsAreInt()

ilAssQuestionSkillAssignmentsGUI::checkPointsAreInt ( ilPropertyFormGUI  $form)
private

Definition at line 747 of file class.ilAssQuestionSkillAssignmentsGUI.php.

747 : bool
748 {
749 $points_result = $form->getInput('q_res_skill_points');
750 $invalid_values_solution = array_filter(
751 $form->getInput('solution_compare_expressions')['points'],
752 fn(string $v): bool => $v != (int) $v
753 );
754 if ($points_result == (int) $points_result
755 && $invalid_values_solution === []) {
756 return true;
757 }
758 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('numeric_only'));
759 return false;
760 }
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...

References ilPropertyFormGUI\getInput(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ checkSolutionCompareExpressionInput()

ilAssQuestionSkillAssignmentsGUI::checkSolutionCompareExpressionInput (   $input,
assQuestion  $question 
)
private

Definition at line 725 of file class.ilAssQuestionSkillAssignmentsGUI.php.

725 : bool
726 {
727 $errors = [];
728
729 foreach ($input->getValues() as $expression) {
730 $result = $this->validateSolutionCompareExpression($expression, $question);
731
732 if ($result !== true) {
733 $errors[] = "{$this->lng->txt('ass_lac_expression')} {$expression->getOrderIndex()}: {$result}";
734 }
735 }
736
737 if (count($errors)) {
738 $alert = $this->lng->txt('ass_lac_validation_error');
739 $alert .= '<br />' . implode('<br />', $errors);
740 $input->setAlert($alert);
741 return false;
742 }
743
744 return true;
745 }
validateSolutionCompareExpression(ilAssQuestionSolutionComparisonExpression $expression, $question)

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ doesObjectTypeMatch()

ilAssQuestionSkillAssignmentsGUI::doesObjectTypeMatch (   $objectId)
protected

Definition at line 822 of file class.ilAssQuestionSkillAssignmentsGUI.php.

822 : bool
823 {
824 return ilObject::_lookupType($objectId) == 'qpl';
825 }
static _lookupType(int $id, bool $reference=false)

References ilObject\_lookupType().

+ Here is the call graph for this function:

◆ editSkillQuestionAssignmentCmd()

ilAssQuestionSkillAssignmentsGUI::editSkillQuestionAssignmentCmd ( )
private

Definition at line 521 of file class.ilAssQuestionSkillAssignmentsGUI.php.

521 : void
522 {
523 $assignment_list = $this->buildSkillQuestionAssignmentList();
524 $assignment_list->loadFromDb();
525 $assignment_list->loadAdditionalSkillData();
526
528
529 $edit_uri = $this->data_factory->uri(
530 ILIAS_HTTP_PATH . '/' . $this->ctrl->getLinkTargetByClass(
531 self::class,
532 self::CMD_SHOW_SKILL_QUEST_ASSIGN_PROPERTIES_FORM
533 )
534 );
535
536 $this->ctrl->setParameterByClass(
537 ilAssQuestionSkillAssignmentsGUI::class,
538 'q_id',
539 $this->request_data_collector->getQuestionId()
540 );
541 $this->toolbar->addComponent(
542 $this->ui_factory->button()->standard(
543 $this->lng->txt('tst_manage_competence_select_skills'),
544 $this->ctrl->getLinkTargetByClass(
545 [ilAssQuestionSkillAssignmentsGUI::class],
546 self::CMD_SHOW_SKILL_SELECT
547 )
548 )->withUnavailableAction(!$this->isAssignmentEditingEnabled())
549 );
550 $this->ctrl->setParameterByClass(ilAssQuestionSkillAssignmentsGUI::class, 'q_id', null);
551
553 $this->request_data_collector,
554 $assignment_list,
555 $this->ui_factory,
556 $this->lng,
558 $this->tpl,
559 [
560 EditSkillsOfQuestionTableEditAction::ACTION_ID => new EditSkillsOfQuestionTableEditAction(
561 $this->ui_factory,
562 $this->lng,
564 )
565 ]
566 ))
567 ))->getComponents(new URLBuilder($edit_uri));
568
569 $this->tpl->setContent($this->ui_renderer->render($components));
570 }
$components

References $components, ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ILIAS\Repository\toolbar().

Referenced by updateSkillQuestionAssignmentsCmd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilAssQuestionSkillAssignmentsGUI::executeCommand ( )

Definition at line 158 of file class.ilAssQuestionSkillAssignmentsGUI.php.

158 : void
159 {
160 $nextClass = $this->ctrl->getNextClass();
161
162 $command = $this->ctrl->getCmd(self::CMD_SHOW_SKILL_QUEST_ASSIGNS);
163
164 if ($this->isAvoidManipulationRedirectRequired($command)) {
165 $this->ctrl->redirect($this, self::CMD_SHOW_SKILL_QUEST_ASSIGNS);
166 }
167
169
170 if (in_array($command, [self::CMD_EDIT_SKILL_QUEST_ASSIGNS])) {
171 $this->modifyTabs();
172 }
173
174 switch ($nextClass) {
175 case strtolower(__CLASS__):
176 case '':
177
178 $command .= 'Cmd';
179 $this->$command();
180 break;
181
182 default:
183
184 throw new ilTestQuestionPoolException('unsupported next class in ctrl flow');
185 }
186 }

References ILIAS\Repository\ctrl(), isAvoidManipulationRedirectRequired(), keepAssignmentParameters(), and modifyTabs().

+ Here is the call graph for this function:

◆ getAssignmentConfigurationHintMessage()

ilAssQuestionSkillAssignmentsGUI::getAssignmentConfigurationHintMessage ( )

◆ getQuestionContainerId()

ilAssQuestionSkillAssignmentsGUI::getQuestionContainerId ( )
Returns
int

Definition at line 129 of file class.ilAssQuestionSkillAssignmentsGUI.php.

References $question_container_id.

Referenced by saveSkillPointsCmd(), showSkillSelectionCmd(), and updateSkillQuestionAssignmentsCmd().

+ Here is the caller graph for this function:

◆ getQuestionList()

ilAssQuestionSkillAssignmentsGUI::getQuestionList ( )

◆ getQuestionOrderSequence()

ilAssQuestionSkillAssignmentsGUI::getQuestionOrderSequence ( )

◆ getSkillSelectorHeader()

ilAssQuestionSkillAssignmentsGUI::getSkillSelectorHeader ( int  $questionId)
private

Definition at line 795 of file class.ilAssQuestionSkillAssignmentsGUI.php.

795 : string
796 {
797 return sprintf(
798 $this->lng->txt('qpl_qst_skl_selection_for_question_header'),
799 $this->question_list->getDataArrayForQuestionId($questionId)['title']
800 );
801 }

References ILIAS\Repository\lng().

Referenced by showSkillSelectionCmd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleAssignmentConfigurationHintMessage()

ilAssQuestionSkillAssignmentsGUI::handleAssignmentConfigurationHintMessage ( )
private

Definition at line 788 of file class.ilAssQuestionSkillAssignmentsGUI.php.

788 : void
789 {
791 $this->tpl->setOnScreenMessage('info', $this->getAssignmentConfigurationHintMessage());
792 }
793 }

◆ isAssignmentEditingEnabled()

ilAssQuestionSkillAssignmentsGUI::isAssignmentEditingEnabled ( )
Returns
bool

Definition at line 145 of file class.ilAssQuestionSkillAssignmentsGUI.php.

References $assignment_editing_enabled.

Referenced by isAvoidManipulationRedirectRequired().

+ Here is the caller graph for this function:

◆ isAvoidManipulationRedirectRequired()

ilAssQuestionSkillAssignmentsGUI::isAvoidManipulationRedirectRequired (   $command)
private

Definition at line 209 of file class.ilAssQuestionSkillAssignmentsGUI.php.

209 : bool
210 {
211 if ($this->isAssignmentEditingEnabled()) {
212 return false;
213 }
214
215 switch ($command) {
218
219 return true;
220 }
221
222 return false;
223 }

References CMD_SAVE_SKILL_QUEST_ASSIGN_PROPERTIES_FORM, CMD_UPDATE_SKILL_QUEST_ASSIGNS, and isAssignmentEditingEnabled().

Referenced by executeCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isSyncOriginalPossibleAndAllowed()

ilAssQuestionSkillAssignmentsGUI::isSyncOriginalPossibleAndAllowed ( int  $questionId)
private

Definition at line 572 of file class.ilAssQuestionSkillAssignmentsGUI.php.

572 : bool
573 {
574 $questionData = $this->question_list->getDataArrayForQuestionId($questionId);
575
576 if (!$questionData['original_id']) {
577 return false;
578 }
579
580 $parentObjId = assQuestion::lookupParentObjId($questionData['original_id']);
581
582 if ($parentObjId === null || !$this->doesObjectTypeMatch($parentObjId)) {
583 return false;
584 }
585
586 foreach (ilObject::_getAllReferences($parentObjId) as $parentRefId) {
587 if ($this->access->checkAccess('write', '', $parentRefId)) {
588 return true;
589 }
590 }
591
592 return false;
593 }
static lookupParentObjId(int $question_id)
static _getAllReferences(int $id)
get all reference ids for object ID

References ilObject\_getAllReferences(), ILIAS\Repository\access(), and assQuestion\lookupParentObjId().

Referenced by updateSkillQuestionAssignmentsCmd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isTestQuestion()

ilAssQuestionSkillAssignmentsGUI::isTestQuestion (   $questionId)
private

Definition at line 720 of file class.ilAssQuestionSkillAssignmentsGUI.php.

720 : bool
721 {
722 return $this->question_list->isInList($questionId);
723 }

Referenced by saveSkillPointsCmd(), and updateSkillQuestionAssignmentsCmd().

+ Here is the caller graph for this function:

◆ keepAssignmentParameters()

ilAssQuestionSkillAssignmentsGUI::keepAssignmentParameters ( )
private

Definition at line 781 of file class.ilAssQuestionSkillAssignmentsGUI.php.

781 : void
782 {
783 $this->ctrl->saveParameter($this, 'q_id');
784 $this->ctrl->saveParameter($this, 'skill_base_id');
785 $this->ctrl->saveParameter($this, 'skill_tref_id');
786 }

References ILIAS\Repository\ctrl().

Referenced by executeCommand(), showSkillSelectionCmd(), and updateSkillQuestionAssignmentsCmd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ modifyTabs()

ilAssQuestionSkillAssignmentsGUI::modifyTabs ( )
private

Definition at line 188 of file class.ilAssQuestionSkillAssignmentsGUI.php.

188 : void
189 {
190 $this->tabs->clearTargets();
191 $this->tabs->setBackTarget(
192 $this->lng->txt('back'),
193 $this->ctrl->getLinkTargetByClass(
194 ilAssQuestionSkillAssignmentsGUI::class,
196 )
197 );
198 $this->tabs->addTab(
199 strtolower(ilAssQuestionSkillAssignmentsGUI::class),
200 $this->lng->txt('qpl_skl_sub_tab_quest_assign'),
201 $this->ctrl->getLinkTargetByClass(
202 ilAssQuestionSkillAssignmentsGUI::class,
204 )
205 );
206 $this->tabs->activateTab(strtolower(ilAssQuestionSkillAssignmentsGUI::class));
207 }

References CMD_EDIT_SKILL_QUEST_ASSIGNS, CMD_SHOW_SKILL_QUEST_ASSIGNS, ILIAS\Repository\lng(), and ILIAS\Repository\tabs().

Referenced by executeCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveSkillPointsCmd()

ilAssQuestionSkillAssignmentsGUI::saveSkillPointsCmd ( )
private

Definition at line 225 of file class.ilAssQuestionSkillAssignmentsGUI.php.

225 : void
226 {
227 $success = true;
228 $skill_points = $this->request_data_collector->raw('skill_points');
229
230 for ($i = 0; $i < 2; $i++) {
231 foreach ($skill_points as $assignment_key => $skill_point) {
232 $assignment_key = explode(':', $assignment_key);
233 $skillBaseId = (int) $assignment_key[0];
234 $skillTrefId = (int) $assignment_key[1];
235 $questionId = (int) $assignment_key[2];
236
237 if ($this->isTestQuestion($questionId)) {
238 $assignment = new ilAssQuestionSkillAssignment($this->db);
239
240 if ($i === 0) {
241 if (!$assignment->isValidSkillPoint($skill_point)) {
242 $success = false;
243 break 2;
244 }
245 continue;
246 }
247
248 $assignment->setParentObjId($this->getQuestionContainerId());
249 $assignment->setQuestionId($questionId);
250 $assignment->setSkillBaseId($skillBaseId);
251 $assignment->setSkillTrefId($skillTrefId);
252
253 if ($assignment->dbRecordExists()) {
254 $assignment->loadFromDb();
255
256 if (!$assignment->hasEvalModeBySolution()) {
257 $assignment->setSkillPoints($skill_point);
258 $assignment->saveToDb();
259
260 // add skill usage
261 $this->skill_usage_service->addUsage($this->getQuestionContainerId(), $skillBaseId, $skillTrefId);
262 }
263 }
264 }
265
266 }
267 }
268
269 if ($success) {
270 $this->tpl->setOnScreenMessage('success', $this->lng->txt('tst_msg_skl_qst_assign_points_saved'), true);
271 $this->ctrl->redirect($this, self::CMD_SHOW_SKILL_QUEST_ASSIGNS);
272 return;
273 }
274
275 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('tst_msg_skl_qst_assign_points_not_saved'));
276 $this->showSkillQuestionAssignmentsCmd(true);
277 }

References ILIAS\Repository\ctrl(), getQuestionContainerId(), ILIAS\Repository\int(), isTestQuestion(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ saveSkillQuestionAssignmentPropertiesFormCmd()

ilAssQuestionSkillAssignmentsGUI::saveSkillQuestionAssignmentPropertiesFormCmd ( )
private

Definition at line 405 of file class.ilAssQuestionSkillAssignmentsGUI.php.

405 : void
406 {
407 $question_id = $this->request_data_collector->getQuestionId();
408
409 if ($this->isTestQuestion($question_id)) {
410 $question_gui = assQuestionGUI::_getQuestionGUI('', $question_id);
411
412 $row_id_parameter = $this->request_data_collector->getRowIdParameter(EditSkillsOfQuestionTableActions::FULL_ROW_ID_PARAMETER);
413 [1 => $skill_base_id, 2 => $skill_tref_id] = explode('_', $row_id_parameter);
414 $assignment = $this->buildQuestionSkillAssignment($question_id, (int) $skill_base_id, (int) $skill_tref_id);
415
417 $form = $this->buildSkillQuestionAssignmentPropertiesForm($question_gui->getObject(), $assignment);
418 if (!$form->checkInput()
419 || !$this->checkPointsAreInt($form)) {
420 $form->setValuesByPost();
421 $this->showSkillQuestionAssignmentPropertiesFormCmd($question_gui, $assignment, $form);
422 return;
423 }
424 $form->setValuesByPost();
425
426 if ($form->getItemByPostVar('eval_mode')) {
427 $assignment->setEvalMode($form->getItemByPostVar('eval_mode')->getValue());
428 } else {
430 }
431
432 if ($assignment->hasEvalModeBySolution()) {
433 $sol_cmp_expr_input = $form->getItemByPostVar('solution_compare_expressions');
434
435 if (!$this->checkSolutionCompareExpressionInput($sol_cmp_expr_input, $question_gui->getObject())) {
436 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('form_input_not_valid'));
437 $this->showSkillQuestionAssignmentPropertiesFormCmd($question_gui, $assignment, $form);
438 return;
439 }
440
441 $assignment->initSolutionComparisonExpressionList();
442 $assignment->getSolutionComparisonExpressionList()->reset();
443
444 foreach ($sol_cmp_expr_input->getValues() as $expression) {
445 $assignment->getSolutionComparisonExpressionList()->add($expression);
446 }
447 } else {
448 $assignment->setSkillPoints($form->getItemByPostVar('q_res_skill_points')->getValue());
449 }
450
451 $assignment->saveToDb();
452
453 // add skill usage
454 $this->skill_usage_service->addUsage(
455 $this->getQuestionContainerId(),
456 $this->request_data_collector->int('skill_base_id'),
457 $this->request_data_collector->int('skill_tref_id')
458 );
459
460 $this->tpl->setOnScreenMessage('success', $this->lng->txt('qpl_qst_skl_assign_properties_modified'), true);
461
462 if ($this->isSyncOriginalPossibleAndAllowed($question_id)) {
463 $this->ctrl->redirect($this, self::CMD_SHOW_SYNC_ORIGINAL_CONFIRMATION);
464 }
465 }
466
467 $this->ctrl->redirect($this, self::CMD_EDIT_SKILL_QUEST_ASSIGNS);
468 }
static _getQuestionGUI(string $question_type='', int $question_id=-1)
Creates a question gui representation and returns the alias to the question gui.
checkSolutionCompareExpressionInput($input, assQuestion $question)
showSkillQuestionAssignmentPropertiesFormCmd(?assQuestionGUI $question_gui=null, ?ilAssQuestionSkillAssignment $assignment=null, ?ilPropertyFormGUI $form=null)
buildQuestionSkillAssignment(int $question_id, int $skill_base_id, int $skill_tref_id)
buildSkillQuestionAssignmentPropertiesForm(assQuestion $question, ilAssQuestionSkillAssignment $assignment)

References assQuestionGUI\_getQuestionGUI(), ILIAS\Repository\ctrl(), ilAssQuestionSkillAssignment\EVAL_MODE_BY_QUESTION_RESULT, and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ setAssignmentConfigurationHintMessage()

ilAssQuestionSkillAssignmentsGUI::setAssignmentConfigurationHintMessage ( ?string  $assignmentConfigurationHintMessage)

Definition at line 97 of file class.ilAssQuestionSkillAssignmentsGUI.php.

97 : void
98 {
99 $this->assignment_configuration_hint_message = $assignmentConfigurationHintMessage;
100 }

◆ setAssignmentEditingEnabled()

ilAssQuestionSkillAssignmentsGUI::setAssignmentEditingEnabled (   $assignmentEditingEnabled)
Parameters
bool$assignmentEditingEnabled

Definition at line 153 of file class.ilAssQuestionSkillAssignmentsGUI.php.

153 : void
154 {
155 $this->assignment_editing_enabled = $assignmentEditingEnabled;
156 }

◆ setQuestionContainerId()

ilAssQuestionSkillAssignmentsGUI::setQuestionContainerId (   $questionContainerId)
Parameters
int$questionContainerId

Definition at line 137 of file class.ilAssQuestionSkillAssignmentsGUI.php.

137 : void
138 {
139 $this->question_container_id = $questionContainerId;
140 }

◆ setQuestionList()

ilAssQuestionSkillAssignmentsGUI::setQuestionList (   $questionList)
Parameters
ilAssQuestionList$questionList

Definition at line 121 of file class.ilAssQuestionSkillAssignmentsGUI.php.

121 : void
122 {
123 $this->question_list = $questionList;
124 }

◆ setQuestionOrderSequence()

ilAssQuestionSkillAssignmentsGUI::setQuestionOrderSequence (   $questionOrderSequence)
Parameters
array$questionOrderSequence

Definition at line 105 of file class.ilAssQuestionSkillAssignmentsGUI.php.

105 : void
106 {
107 $this->questionOrderSequence = $questionOrderSequence;
108 }

References $questionOrderSequence.

◆ showSkillQuestionAssignmentPropertiesFormCmd()

ilAssQuestionSkillAssignmentsGUI::showSkillQuestionAssignmentPropertiesFormCmd ( ?assQuestionGUI  $question_gui = null,
?ilAssQuestionSkillAssignment  $assignment = null,
?ilPropertyFormGUI  $form = null 
)
private

Definition at line 384 of file class.ilAssQuestionSkillAssignmentsGUI.php.

388 : void {
390
392
393 $question_id = $this->request_data_collector->getQuestionId();
394 $question_gui ??= assQuestionGUI::_getQuestionGUI('', $question_id);
395
396 $row_id_parameter = $this->request_data_collector->getRowIdParameter(EditSkillsOfQuestionTableActions::FULL_ROW_ID_PARAMETER);
397 [1 => $skill_base_id, 2 => $skill_tref_id] = explode('_', $row_id_parameter);
398 $assignment ??= $this->buildQuestionSkillAssignment($question_id, (int) $skill_base_id, (int) $skill_tref_id);
399
400 $form ??= $this->buildSkillQuestionAssignmentPropertiesForm($question_gui->getObject(), $assignment);
401
402 $this->tpl->setContent($form->getHTML() . '<br />' . $this->buildQuestionPage($question_gui));
403 }

◆ showSkillSelectionCmd()

ilAssQuestionSkillAssignmentsGUI::showSkillSelectionCmd ( )
private

Definition at line 348 of file class.ilAssQuestionSkillAssignmentsGUI.php.

348 : void
349 {
351 $question_id = $this->request_data_collector->getQuestionId();
352
353 $assignmentList = new ilAssQuestionSkillAssignmentList($this->db);
354 $assignmentList->setParentObjId($this->getQuestionContainerId());
355 $assignmentList->loadFromDb();
356
357 $skillSelectorExplorerGUI = $this->buildSkillSelectorExplorerGUI(
358 $assignmentList->getAssignmentsByQuestionId($question_id)
359 );
360
361 if (!$skillSelectorExplorerGUI->handleCommand()) {
362 $tpl = new ilTemplate('tpl.qpl_qst_skl_assign_selection.html', false, false, 'components/ILIAS/TestQuestionPool');
363
364 $tpl->setVariable('SKILL_SELECTOR_HEADER', $this->getSkillSelectorHeader($question_id));
365
366 $skillSelectorToolbarGUI = $this->buildSkillSelectorToolbarGUI();
367
368 $skillSelectorToolbarGUI->setOpenFormTag(true);
369 $skillSelectorToolbarGUI->setCloseFormTag(false);
370 $skillSelectorToolbarGUI->setLeadingImage(ilUtil::getImagePath("nav/arrow_upright.svg"), " ");
371 $tpl->setVariable('SKILL_SELECTOR_TOOLBAR_TOP', $this->ctrl->getHTML($skillSelectorToolbarGUI));
372
373 $tpl->setVariable('SKILL_SELECTOR_EXPLORER', $this->ctrl->getHTML($skillSelectorExplorerGUI));
374
375 $skillSelectorToolbarGUI->setOpenFormTag(false);
376 $skillSelectorToolbarGUI->setCloseFormTag(true);
377 $skillSelectorToolbarGUI->setLeadingImage(ilUtil::getImagePath("nav/arrow_downright.svg"), " ");
378 $tpl->setVariable('SKILL_SELECTOR_TOOLBAR_BOTTOM', $this->ctrl->getHTML($skillSelectorToolbarGUI));
379
380 $this->tpl->setContent($tpl->get());
381 }
382 }
special template class to simplify handling of ITX/PEAR
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)

References buildSkillSelectorExplorerGUI(), buildSkillSelectorToolbarGUI(), ILIAS\Repository\ctrl(), ilUtil\getImagePath(), getQuestionContainerId(), getSkillSelectorHeader(), and keepAssignmentParameters().

+ Here is the call graph for this function:

◆ showSyncOriginalConfirmationCmd()

ilAssQuestionSkillAssignmentsGUI::showSyncOriginalConfirmationCmd ( )
private

Definition at line 595 of file class.ilAssQuestionSkillAssignmentsGUI.php.

595 : void
596 {
597 $confirmation = new ilConfirmationGUI();
598 $confirmation->setHeaderText($this->lng->txt('qpl_sync_quest_skl_assigns_confirmation'));
599
600 $confirmation->setFormAction($this->ctrl->getFormAction($this));
601 $confirmation->addHiddenItem('q_id', $this->request_data_collector->getQuestionId());
602 $confirmation->setConfirm($this->lng->txt('yes'), self::CMD_SYNC_ORIGINAL);
603 $confirmation->setCancel($this->lng->txt('no'), self::CMD_EDIT_SKILL_QUEST_ASSIGNS);
604
605 $this->tpl->setContent($this->ctrl->getHTML($confirmation));
606 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ sortAlphabetically()

ilAssQuestionSkillAssignmentsGUI::sortAlphabetically (   $array)
private

Definition at line 803 of file class.ilAssQuestionSkillAssignmentsGUI.php.

804 {
805 $flags = SORT_REGULAR;
806
807 if (defined('SORT_NATURAL')) {
808 $flags = SORT_NATURAL;
809 } elseif (defined('SORT_STRING')) {
810 $flags = SORT_STRING;
811 }
812
813 if (defined('SORT_FLAG_CASE')) {
814 $flags = $flags | SORT_FLAG_CASE;
815 }
816
817 asort($array, $flags);
818
819 return $array;
820 }

◆ syncOriginalCmd()

ilAssQuestionSkillAssignmentsGUI::syncOriginalCmd ( )
private

Definition at line 608 of file class.ilAssQuestionSkillAssignmentsGUI.php.

608 : void
609 {
610 $question_id = $this->request_data_collector->getQuestionId();
611 if ($this->isTestQuestion($question_id) && $this->isSyncOriginalPossibleAndAllowed($question_id)) {
612 $question = assQuestion::instantiateQuestion($question_id);
613
614 $question->syncSkillAssignments(
615 $question->getObjId(),
616 $question->getId(),
617 $question->lookupParentObjId($question->getOriginalId()),
618 $question->getOriginalId()
619 );
620
621 $this->tpl->setOnScreenMessage('success', $this->lng->txt('qpl_qst_skl_assign_synced_to_orig'), true);
622 }
623
624 $this->ctrl->redirect($this, self::CMD_EDIT_SKILL_QUEST_ASSIGNS);
625 }
static instantiateQuestion(int $question_id)

References ILIAS\Repository\ctrl(), assQuestion\getId(), assQuestion\getObjId(), assQuestion\getOriginalId(), assQuestion\instantiateQuestion(), ILIAS\Repository\lng(), assQuestion\lookupParentObjId(), and assQuestion\syncSkillAssignments().

+ Here is the call graph for this function:

◆ updateSkillQuestionAssignmentsCmd()

ilAssQuestionSkillAssignmentsGUI::updateSkillQuestionAssignmentsCmd ( )
private

Definition at line 279 of file class.ilAssQuestionSkillAssignmentsGUI.php.

279 : void
280 {
282 $question_id = $this->request_data_collector->getQuestionId();
283
284 if ($this->isTestQuestion($question_id)) {
285 $assignmentList = new ilAssQuestionSkillAssignmentList($this->db);
286 $assignmentList->setParentObjId($this->getQuestionContainerId());
287 $assignmentList->loadFromDb();
288
289 $handledSkills = [];
290
291 $sgui = $this->buildSkillSelectorExplorerGUI([]);
292 $skillIds = $sgui->getSelectedSkills();
293
294 foreach ($skillIds as $skillId) {
295 $skill = explode(':', $skillId);
296 $skillBaseId = (int) $skill[0];
297 $skillTrefId = (int) $skill[1];
298
299 if ($skillBaseId) {
300 if (!$assignmentList->isAssignedToQuestionId($skillBaseId, $skillTrefId, $question_id)) {
301 $assignment = new ilAssQuestionSkillAssignment($this->db);
302
303 $assignment->setParentObjId($this->getQuestionContainerId());
304 $assignment->setQuestionId($question_id);
305 $assignment->setSkillBaseId($skillBaseId);
306 $assignment->setSkillTrefId($skillTrefId);
307
310 $assignment->saveToDb();
311
312 // add skill usage
313 $this->skill_usage_service->addUsage($this->getQuestionContainerId(), $skillBaseId, $skillTrefId);
314 }
315
316 $handledSkills[$skillId] = $skill;
317 }
318 }
319
320 foreach ($assignmentList->getAssignmentsByQuestionId($question_id) as $assignment) {
321 if (isset($handledSkills["{$assignment->getSkillBaseId()}:{$assignment->getSkillTrefId()}"])) {
322 continue;
323 }
324
325 $assignment->deleteFromDb();
326
327 // remove skill usage
328 if (!$assignment->isSkillUsed()) {
329 $this->skill_usage_service->removeUsage(
330 $assignment->getParentObjId(),
331 $assignment->getSkillBaseId(),
332 $assignment->getSkillTrefId()
333 );
334 }
335 }
336
337 $this->tpl->setOnScreenMessage('success', $this->lng->txt('qpl_qst_skl_assigns_updated'), true);
338
339 if ($this->isSyncOriginalPossibleAndAllowed($question_id)) {
341 $this->ctrl->redirect($this, self::CMD_SHOW_SYNC_ORIGINAL_CONFIRMATION);
342 }
343 }
344
346 }

References buildSkillSelectorExplorerGUI(), ILIAS\Repository\ctrl(), ilAssQuestionSkillAssignment\DEFAULT_COMPETENCE_POINTS, editSkillQuestionAssignmentCmd(), ilAssQuestionSkillAssignment\EVAL_MODE_BY_QUESTION_RESULT, getQuestionContainerId(), ILIAS\Repository\int(), isSyncOriginalPossibleAndAllowed(), isTestQuestion(), keepAssignmentParameters(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ validateSolutionCompareExpression()

ilAssQuestionSkillAssignmentsGUI::validateSolutionCompareExpression ( ilAssQuestionSolutionComparisonExpression  $expression,
  $question 
)
private

Definition at line 762 of file class.ilAssQuestionSkillAssignmentsGUI.php.

762 : bool
763 {
764 try {
765 $question_provider = new ilAssLacQuestionProvider();
766 $question_provider->setQuestion($question);
767 (new ilAssLacCompositeValidator($question_provider))->validate(
768 (new ilAssLacConditionParser())->parse($expression->getExpression())
769 );
770 } catch (ilAssLacException $e) {
771 if ($e instanceof ilAssLacFormAlertProvider) {
772 return $e->getFormAlert($this->lng);
773 }
774
775 throw $e;
776 }
777
778 return true;
779 }
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...

References Vendor\Package\$e, ilAssQuestionSolutionComparisonExpression\getExpression(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

Field Documentation

◆ $assignment_configuration_hint_message

string ilAssQuestionSkillAssignmentsGUI::$assignment_configuration_hint_message = null
private

◆ $assignment_editing_enabled

bool ilAssQuestionSkillAssignmentsGUI::$assignment_editing_enabled
private

◆ $data_factory

DataFactory ilAssQuestionSkillAssignmentsGUI::$data_factory
private

Definition at line 67 of file class.ilAssQuestionSkillAssignmentsGUI.php.

◆ $question_container_id

int ilAssQuestionSkillAssignmentsGUI::$question_container_id
private

Definition at line 61 of file class.ilAssQuestionSkillAssignmentsGUI.php.

Referenced by getQuestionContainerId().

◆ $question_list

ilAssQuestionList ilAssQuestionSkillAssignmentsGUI::$question_list
private

Definition at line 60 of file class.ilAssQuestionSkillAssignmentsGUI.php.

Referenced by getQuestionList().

◆ $questionOrderSequence

array ilAssQuestionSkillAssignmentsGUI::$questionOrderSequence
private

◆ CMD_EDIT_SKILL_QUEST_ASSIGNS

const ilAssQuestionSkillAssignmentsGUI::CMD_EDIT_SKILL_QUEST_ASSIGNS = 'editSkillQuestionAssignment'

◆ CMD_SAVE_SKILL_POINTS

const ilAssQuestionSkillAssignmentsGUI::CMD_SAVE_SKILL_POINTS = 'saveSkillPoints'

Definition at line 54 of file class.ilAssQuestionSkillAssignmentsGUI.php.

◆ CMD_SAVE_SKILL_QUEST_ASSIGN_PROPERTIES_FORM

const ilAssQuestionSkillAssignmentsGUI::CMD_SAVE_SKILL_QUEST_ASSIGN_PROPERTIES_FORM = 'saveSkillQuestionAssignmentPropertiesForm'

◆ CMD_SHOW_SKILL_QUEST_ASSIGN_PROPERTIES_FORM

const ilAssQuestionSkillAssignmentsGUI::CMD_SHOW_SKILL_QUEST_ASSIGN_PROPERTIES_FORM = 'showSkillQuestionAssignmentPropertiesForm'

◆ CMD_SHOW_SKILL_QUEST_ASSIGNS

◆ CMD_SHOW_SKILL_SELECT

const ilAssQuestionSkillAssignmentsGUI::CMD_SHOW_SKILL_SELECT = 'showSkillSelection'

Definition at line 50 of file class.ilAssQuestionSkillAssignmentsGUI.php.

◆ CMD_SHOW_SYNC_ORIGINAL_CONFIRMATION

const ilAssQuestionSkillAssignmentsGUI::CMD_SHOW_SYNC_ORIGINAL_CONFIRMATION = 'showSyncOriginalConfirmation'

Definition at line 55 of file class.ilAssQuestionSkillAssignmentsGUI.php.

◆ CMD_SYNC_ORIGINAL

const ilAssQuestionSkillAssignmentsGUI::CMD_SYNC_ORIGINAL = 'syncOriginal'

Definition at line 56 of file class.ilAssQuestionSkillAssignmentsGUI.php.

◆ CMD_UPDATE_SKILL_QUEST_ASSIGNS

const ilAssQuestionSkillAssignmentsGUI::CMD_UPDATE_SKILL_QUEST_ASSIGNS = 'updateSkillQuestionAssignments'

◆ PARAM_SKILL_SELECTION

const ilAssQuestionSkillAssignmentsGUI::PARAM_SKILL_SELECTION = 'skill_ids'

Definition at line 58 of file class.ilAssQuestionSkillAssignmentsGUI.php.


The documentation for this class was generated from the following file: