ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilAssQuestionSkillAssignmentsGUI Class Reference
+ Collaboration diagram for ilAssQuestionSkillAssignmentsGUI:

Public Member Functions

 __construct (private ilCtrl $ctrl, private ilAccessHandler $access, private ilGlobalTemplateInterface $tpl, private ilLanguage $lng, private ilDBInterface $db)
 
 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_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

 isAvoidManipulationRedirectRequired ($command)
 
 saveSkillPointsCmd ()
 
 updateSkillQuestionAssignmentsCmd ()
 
 showSkillSelectionCmd ()
 
 showSkillQuestionAssignmentPropertiesFormCmd (?assQuestionGUI $question_gui=null, ?ilAssQuestionSkillAssignment $assignment=null, ?ilPropertyFormGUI $form=null)
 
 saveSkillQuestionAssignmentPropertiesFormCmd ()
 
 buildSkillQuestionAssignmentPropertiesForm (assQuestion $question, ilAssQuestionSkillAssignment $assignment)
 
 showSkillQuestionAssignmentsCmd ($loadSkillPointsFromRequest=false)
 
 isSyncOriginalPossibleAndAllowed ($questionId)
 
 showSyncOriginalConfirmationCmd ()
 
 syncOriginalCmd ()
 
 buildTableGUI ()
 
 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 ()
 
 orderQuestionData ($questionData)
 
 handleAssignmentConfigurationHintMessage ()
 
 getSkillSelectorHeader ($questionId)
 
 sortAlphabetically ($array)
 

Private Attributes

ilAssQuestionList $question_list
 
int $question_container_id
 
bool $assignment_editing_enabled
 
string $assignment_configuration_hint_message = null
 
 $questionOrderSequence
 
RequestDataCollector $request_data_collector
 
SkillUsageService $skillUsageService
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilAssQuestionSkillAssignmentsGUI::__construct ( private ilCtrl  $ctrl,
private ilAccessHandler  $access,
private ilGlobalTemplateInterface  $tpl,
private ilLanguage  $lng,
private ilDBInterface  $db 
)
Parameters
ilCtrl$ctrl
ilAccessHandler$access
ilGlobalTemplateInterface$tpl
ilLanguage$lng
ilDBInterface$db

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

78 {
79
80 $local_dic = QuestionPoolDIC::dic();
81 $this->request_data_collector = $local_dic['request_data_collector'];
82
83 global $DIC;
84 $this->skillUsageService = $DIC->skills()->usage();
85 }
global $DIC
Definition: shib_login.php:26

References $DIC.

Member Function Documentation

◆ buildQuestionPage()

ilAssQuestionSkillAssignmentsGUI::buildQuestionPage ( assQuestionGUI  $question_gui)
private

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

595 {
596 $this->tpl->addCss('./assets/css/content.css');
597
598 $page_gui = new ilAssQuestionPageGUI($question_gui->getObject()->getId());
599 $page_gui->setFileDownloadLink($question_gui->buildFileDownloadLink());
600 $page_gui->setOutputMode("presentation");
601 $page_gui->setRenderPageContainer(true);
602
603 $page_gui->setPresentationTitle($question_gui->getObject()->getTitleForHTMLOutput());
604
605 $question = $question_gui->getObject();
606 $question->setShuffle(false); // dirty, but works ^^
607 $question_gui->setObject($question);
608 $page_gui->setQuestionHTML([
609 $question_gui->getObject()->getId() => $question_gui->getSolutionOutput(0, 0, false, false, true, false, true, false, true)
610 ]);
611
612 return preg_replace("/src=\"\\.\\//ims", "src=\"" . ILIAS_HTTP_PATH . "/", $page_gui->presentation());
613
614 }
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 619 of file class.ilAssQuestionSkillAssignmentsGUI.php.

624 $assignment = new ilAssQuestionSkillAssignment($this->db);
625
626 $assignment->setParentObjId($this->getQuestionContainerId());
627 $assignment->setQuestionId($question_id);
628 $assignment->setSkillBaseId($skill_base_id);
629 $assignment->setSkillTrefId($skill_tref_id);
630
631 $assignment->loadFromDb();
632 $assignment->loadAdditionalSkillData();
633
634 return $assignment;
635 }

◆ buildSkillQuestionAssignmentList()

ilAssQuestionSkillAssignmentsGUI::buildSkillQuestionAssignmentList ( )
private

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

545 {
546 $assignmentList = new ilAssQuestionSkillAssignmentList($this->db);
547 $assignmentList->setParentObjId($this->getQuestionContainerId());
548
549 return $assignmentList;
550 }

◆ buildSkillQuestionAssignmentPropertiesForm()

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

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

456 $form->setQuestion($question);
457 $form->setAssignment($assignment);
458 $form->setManipulationEnabled($this->isAssignmentEditingEnabled());
459 $form->build();
460
461 return $form;
462 }

◆ buildSkillSelectorExplorerGUI()

ilAssQuestionSkillAssignmentsGUI::buildSkillSelectorExplorerGUI (   $assignments)
private
Returns
ilSkillSelectorGUI

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

556 {
557 $skillSelectorExplorerGUI = new ilSkillSelectorGUI(
558 $this,
559 self::CMD_SHOW_SKILL_SELECT,
560 $this,
561 self::CMD_UPDATE_SKILL_QUEST_ASSIGNS,
562 self::PARAM_SKILL_SELECTION
563 );
564
565 $skillSelectorExplorerGUI->setSelectMode(self::PARAM_SKILL_SELECTION, true);
566 //$skillSelectorExplorerGUI->setNodeOnclickEnabled(false);
567
568 // parameter name for skill selection is actually taken from value passed to constructor,
569 // but passing a non empty name to setSelectMode is neccessary to keep input fields enabled
570
571 foreach ($assignments as $assignment) {
572 $id = "{$assignment->getSkillBaseId()}:{$assignment->getSkillTrefId()}";
573 //$skillSelectorExplorerGUI->setNodeSelected($id);
574 $skillSelectorExplorerGUI->setSkillSelected($id);
575 }
576
577 return $skillSelectorExplorerGUI;
578 }
$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 583 of file class.ilAssQuestionSkillAssignmentsGUI.php.

584 {
585 $skillSelectorToolbarGUI = new ilToolbarGUI();
586
587 $skillSelectorToolbarGUI->setFormAction($this->ctrl->getFormAction($this));
588 $skillSelectorToolbarGUI->addFormButton($this->lng->txt('qpl_save_skill_assigns_update'), self::CMD_UPDATE_SKILL_QUEST_ASSIGNS);
589 $skillSelectorToolbarGUI->addFormButton($this->lng->txt('qpl_cancel_skill_assigns_update'), self::CMD_SHOW_SKILL_QUEST_ASSIGNS);
590
591 return $skillSelectorToolbarGUI;
592 }
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:

◆ buildTableGUI()

ilAssQuestionSkillAssignmentsGUI::buildTableGUI ( )
private

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

536 {
537 $table = new ilAssQuestionSkillAssignmentsTableGUI($this, self::CMD_SHOW_SKILL_QUEST_ASSIGNS, $this->ctrl, $this->lng);
538 $table->setManipulationsEnabled($this->isAssignmentEditingEnabled());
539 $table->init();
540
541 return $table;
542 }

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

+ Here is the call graph for this function:

◆ checkPointsAreInt()

ilAssQuestionSkillAssignmentsGUI::checkPointsAreInt ( ilPropertyFormGUI  $form)
private

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

664 : bool
665 {
666 $points_result = $form->getInput('q_res_skill_points');
667 $invalid_values_solution = array_filter(
668 $form->getInput('solution_compare_expressions')['points'],
669 fn(string $v): bool => $v != (int) $v
670 );
671 if ($points_result == (int) $points_result
672 && $invalid_values_solution === []) {
673 return true;
674 }
675 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('numeric_only'));
676 return false;
677 }
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 642 of file class.ilAssQuestionSkillAssignmentsGUI.php.

642 : bool
643 {
644 $errors = [];
645
646 foreach ($input->getValues() as $expression) {
647 $result = $this->validateSolutionCompareExpression($expression, $question);
648
649 if ($result !== true) {
650 $errors[] = "{$this->lng->txt('ass_lac_expression')} {$expression->getOrderIndex()}: {$result}";
651 }
652 }
653
654 if (count($errors)) {
655 $alert = $this->lng->txt('ass_lac_validation_error');
656 $alert .= '<br />' . implode('<br />', $errors);
657 $input->setAlert($alert);
658 return false;
659 }
660
661 return true;
662 }
validateSolutionCompareExpression(ilAssQuestionSolutionComparisonExpression $expression, $question)

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ doesObjectTypeMatch()

ilAssQuestionSkillAssignmentsGUI::doesObjectTypeMatch (   $objectId)
protected

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

763 : bool
764 {
765 return ilObject::_lookupType($objectId) == 'qpl';
766 }
static _lookupType(int $id, bool $reference=false)

References ilObject\_lookupType().

+ Here is the call 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
168 switch ($nextClass) {
169 case strtolower(__CLASS__):
170 case '':
171
172 $command .= 'Cmd';
173 $this->$command();
174 break;
175
176 default:
177
178 throw new ilTestQuestionPoolException('unsupported next class in ctrl flow');
179 }
180 }

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

+ 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 (   $questionId)
private

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

737 : string
738 {
739 $questionData = $this->question_list->getDataArrayForQuestionId($questionId);
740
741 return sprintf($this->lng->txt('qpl_qst_skl_selection_for_question_header'), $questionData['title']);
742 }

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 730 of file class.ilAssQuestionSkillAssignmentsGUI.php.

730 : void
731 {
733 $this->tpl->setOnScreenMessage('info', $this->getAssignmentConfigurationHintMessage());
734 }
735 }

◆ 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 182 of file class.ilAssQuestionSkillAssignmentsGUI.php.

182 : bool
183 {
184 if ($this->isAssignmentEditingEnabled()) {
185 return false;
186 }
187
188 switch ($command) {
191
192 return true;
193 }
194
195 return false;
196 }

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 (   $questionId)
private

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

480 : bool
481 {
482 $questionData = $this->question_list->getDataArrayForQuestionId($questionId);
483
484 if (!$questionData['original_id']) {
485 return false;
486 }
487
488 $parentObjId = assQuestion::lookupParentObjId($questionData['original_id']);
489
490 if ($parentObjId === null || !$this->doesObjectTypeMatch($parentObjId)) {
491 return false;
492 }
493
494 foreach (ilObject::_getAllReferences($parentObjId) as $parentRefId) {
495 if ($this->access->checkAccess('write', '', $parentRefId)) {
496 return true;
497 }
498 }
499
500 return false;
501 }
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 637 of file class.ilAssQuestionSkillAssignmentsGUI.php.

637 : bool
638 {
639 return $this->question_list->isInList($questionId);
640 }

Referenced by saveSkillPointsCmd(), and updateSkillQuestionAssignmentsCmd().

+ Here is the caller graph for this function:

◆ keepAssignmentParameters()

ilAssQuestionSkillAssignmentsGUI::keepAssignmentParameters ( )
private

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

698 : void
699 {
700 $this->ctrl->saveParameter($this, 'q_id');
701 $this->ctrl->saveParameter($this, 'skill_base_id');
702 $this->ctrl->saveParameter($this, 'skill_tref_id');
703 }

References ILIAS\Repository\ctrl().

Referenced by updateSkillQuestionAssignmentsCmd().

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

◆ orderQuestionData()

ilAssQuestionSkillAssignmentsGUI::orderQuestionData (   $questionData)
private

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

706 {
707 $orderedQuestionsData = [];
708
709 if ($this->getQuestionOrderSequence()) {
710 foreach ($this->getQuestionOrderSequence() as $questionId) {
711 $orderedQuestionsData[$questionId] = $questionData[$questionId];
712 }
713
714 return $orderedQuestionsData;
715 }
716
717 foreach ($questionData as $questionId => $data) {
718 $orderedQuestionsData[$questionId] = $data['title'];
719 }
720
721 $orderedQuestionsData = $this->sortAlphabetically($orderedQuestionsData);
722
723 foreach ($orderedQuestionsData as $questionId => $questionTitle) {
724 $orderedQuestionsData[$questionId] = $questionData[$questionId];
725 }
726
727 return $orderedQuestionsData;
728 }

References $data.

◆ saveSkillPointsCmd()

ilAssQuestionSkillAssignmentsGUI::saveSkillPointsCmd ( )
private

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

198 : void
199 {
200 $success = true;
201 $skill_points = $this->request_data_collector->raw('skill_points');
202
203 for ($i = 0; $i < 2; $i++) {
204 foreach ($skill_points as $assignment_key => $skill_point) {
205 $assignment_key = explode(':', $assignment_key);
206 $skillBaseId = (int) $assignment_key[0];
207 $skillTrefId = (int) $assignment_key[1];
208 $questionId = (int) $assignment_key[2];
209
210 if ($this->isTestQuestion($questionId)) {
211 $assignment = new ilAssQuestionSkillAssignment($this->db);
212
213 if ($i === 0) {
214 if (!$assignment->isValidSkillPoint($skill_point)) {
215 $success = false;
216 break 2;
217 }
218 continue;
219 }
220
221 $assignment->setParentObjId($this->getQuestionContainerId());
222 $assignment->setQuestionId($questionId);
223 $assignment->setSkillBaseId($skillBaseId);
224 $assignment->setSkillTrefId($skillTrefId);
225
226 if ($assignment->dbRecordExists()) {
227 $assignment->loadFromDb();
228
229 if (!$assignment->hasEvalModeBySolution()) {
230 $assignment->setSkillPoints($skill_point);
231 $assignment->saveToDb();
232
233 // add skill usage
234 $this->skillUsageService->addUsage($this->getQuestionContainerId(), $skillBaseId, $skillTrefId);
235 }
236 }
237 }
238
239 }
240 }
241
242 if ($success) {
243 $this->tpl->setOnScreenMessage('success', $this->lng->txt('tst_msg_skl_qst_assign_points_saved'), true);
244 $this->ctrl->redirect($this, self::CMD_SHOW_SKILL_QUEST_ASSIGNS);
245 return;
246 }
247
248 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('tst_msg_skl_qst_assign_points_not_saved'));
250 }
showSkillQuestionAssignmentsCmd($loadSkillPointsFromRequest=false)

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

+ Here is the call graph for this function:

◆ saveSkillQuestionAssignmentPropertiesFormCmd()

ilAssQuestionSkillAssignmentsGUI::saveSkillQuestionAssignmentPropertiesFormCmd ( )
private

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

384 : void
385 {
386 $question_id = $this->request_data_collector->getQuestionId();
387
388 if ($this->isTestQuestion($question_id)) {
389 $question_gui = assQuestionGUI::_getQuestionGUI('', $question_id);
390
391 $assignment = $this->buildQuestionSkillAssignment(
392 $question_id,
393 $this->request_data_collector->int('skill_base_id'),
394 $this->request_data_collector->int('skill_tref_id')
395 );
396
398 $form = $this->buildSkillQuestionAssignmentPropertiesForm($question_gui->getObject(), $assignment);
399 if (!$form->checkInput()
400 || !$this->checkPointsAreInt($form)) {
401 $form->setValuesByPost();
402 $this->showSkillQuestionAssignmentPropertiesFormCmd($question_gui, $assignment, $form);
403 return;
404 }
405 $form->setValuesByPost();
406
407 if ($form->getItemByPostVar('eval_mode')) {
408 $assignment->setEvalMode($form->getItemByPostVar('eval_mode')->getValue());
409 } else {
411 }
412
413 if ($assignment->hasEvalModeBySolution()) {
414 $sol_cmp_expr_input = $form->getItemByPostVar('solution_compare_expressions');
415
416 if (!$this->checkSolutionCompareExpressionInput($sol_cmp_expr_input, $question_gui->getObject())) {
417 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('form_input_not_valid'));
418 $this->showSkillQuestionAssignmentPropertiesFormCmd($question_gui, $assignment, $form);
419 return;
420 }
421
422 $assignment->initSolutionComparisonExpressionList();
423 $assignment->getSolutionComparisonExpressionList()->reset();
424
425 foreach ($sol_cmp_expr_input->getValues() as $expression) {
426 $assignment->getSolutionComparisonExpressionList()->add($expression);
427 }
428 } else {
429 $assignment->setSkillPoints($form->getItemByPostVar('q_res_skill_points')->getValue());
430 }
431
432 $assignment->saveToDb();
433
434 // add skill usage
435 $this->skillUsageService->addUsage(
436 $this->getQuestionContainerId(),
437 $this->request_data_collector->int('skill_base_id'),
438 $this->request_data_collector->int('skill_tref_id')
439 );
440
441 $this->tpl->setOnScreenMessage('success', $this->lng->txt('qpl_qst_skl_assign_properties_modified'), true);
442
443 if ($this->isSyncOriginalPossibleAndAllowed($question_id)) {
444 $this->ctrl->redirect($this, self::CMD_SHOW_SYNC_ORIGINAL_CONFIRMATION);
445 }
446 }
447
448 $this->ctrl->redirect($this, self::CMD_SHOW_SKILL_QUEST_ASSIGNS);
449 }
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 356 of file class.ilAssQuestionSkillAssignmentsGUI.php.

360 : void {
362
364
365 if ($question_gui === null) {
366 $question_gui = assQuestionGUI::_getQuestionGUI('', $this->request_data_collector->getQuestionId());
367 }
368
369 if ($assignment === null) {
370 $assignment = $this->buildQuestionSkillAssignment(
371 $this->request_data_collector->getQuestionId(),
372 $this->request_data_collector->int('skill_base_id'),
373 $this->request_data_collector->int('skill_tref_id')
374 );
375 }
376
377 if ($form === null) {
378 $form = $this->buildSkillQuestionAssignmentPropertiesForm($question_gui->getObject(), $assignment);
379 }
380
381 $this->tpl->setContent($form->getHTML() . '<br />' . $this->buildQuestionPage($question_gui));
382 }

◆ showSkillQuestionAssignmentsCmd()

ilAssQuestionSkillAssignmentsGUI::showSkillQuestionAssignmentsCmd (   $loadSkillPointsFromRequest = false)
private

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

464 : void
465 {
467
468 $table = $this->buildTableGUI();
469 $table->loadSkillPointsFromRequest($loadSkillPointsFromRequest);
470
471 $assignmentList = $this->buildSkillQuestionAssignmentList();
472 $assignmentList->loadFromDb();
473 $assignmentList->loadAdditionalSkillData();
474 $table->setSkillQuestionAssignmentList($assignmentList);
475 $table->setData($this->orderQuestionData($this->question_list->getQuestionDataArray()));
476
477 $this->tpl->setContent($table->getHTML());
478 }

Referenced by saveSkillPointsCmd().

+ Here is the caller graph for this function:

◆ showSkillSelectionCmd()

ilAssQuestionSkillAssignmentsGUI::showSkillSelectionCmd ( )
private

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

320 : void
321 {
322 $this->ctrl->saveParameter($this, 'q_id');
323 $question_id = $this->request_data_collector->getQuestionId();
324
325 $assignmentList = new ilAssQuestionSkillAssignmentList($this->db);
326 $assignmentList->setParentObjId($this->getQuestionContainerId());
327 $assignmentList->loadFromDb();
328
329 $skillSelectorExplorerGUI = $this->buildSkillSelectorExplorerGUI(
330 $assignmentList->getAssignmentsByQuestionId($question_id)
331 );
332
333 if (!$skillSelectorExplorerGUI->handleCommand()) {
334 $tpl = new ilTemplate('tpl.qpl_qst_skl_assign_selection.html', false, false, 'components/ILIAS/TestQuestionPool');
335
336 $tpl->setVariable('SKILL_SELECTOR_HEADER', $this->getSkillSelectorHeader($question_id));
337
338 $skillSelectorToolbarGUI = $this->buildSkillSelectorToolbarGUI();
339
340 $skillSelectorToolbarGUI->setOpenFormTag(true);
341 $skillSelectorToolbarGUI->setCloseFormTag(false);
342 $skillSelectorToolbarGUI->setLeadingImage(ilUtil::getImagePath("nav/arrow_upright.svg"), " ");
343 $tpl->setVariable('SKILL_SELECTOR_TOOLBAR_TOP', $this->ctrl->getHTML($skillSelectorToolbarGUI));
344
345 $tpl->setVariable('SKILL_SELECTOR_EXPLORER', $this->ctrl->getHTML($skillSelectorExplorerGUI));
346
347 $skillSelectorToolbarGUI->setOpenFormTag(false);
348 $skillSelectorToolbarGUI->setCloseFormTag(true);
349 $skillSelectorToolbarGUI->setLeadingImage(ilUtil::getImagePath("nav/arrow_downright.svg"), " ");
350 $tpl->setVariable('SKILL_SELECTOR_TOOLBAR_BOTTOM', $this->ctrl->getHTML($skillSelectorToolbarGUI));
351
352 $this->tpl->setContent($tpl->get());
353 }
354 }
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(), and getSkillSelectorHeader().

+ Here is the call graph for this function:

◆ showSyncOriginalConfirmationCmd()

ilAssQuestionSkillAssignmentsGUI::showSyncOriginalConfirmationCmd ( )
private

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

503 : void
504 {
505 $confirmation = new ilConfirmationGUI();
506 $confirmation->setHeaderText($this->lng->txt('qpl_sync_quest_skl_assigns_confirmation'));
507
508 $confirmation->setFormAction($this->ctrl->getFormAction($this));
509 $confirmation->addHiddenItem('q_id', $this->request_data_collector->getQuestionId());
510 $confirmation->setConfirm($this->lng->txt('yes'), self::CMD_SYNC_ORIGINAL);
511 $confirmation->setCancel($this->lng->txt('no'), self::CMD_SHOW_SKILL_QUEST_ASSIGNS);
512
513 $this->tpl->setContent($this->ctrl->getHTML($confirmation));
514 }
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 744 of file class.ilAssQuestionSkillAssignmentsGUI.php.

745 {
746 $flags = SORT_REGULAR;
747
748 if (defined('SORT_NATURAL')) {
749 $flags = SORT_NATURAL;
750 } elseif (defined('SORT_STRING')) {
751 $flags = SORT_STRING;
752 }
753
754 if (defined('SORT_FLAG_CASE')) {
755 $flags = $flags | SORT_FLAG_CASE;
756 }
757
758 asort($array, $flags);
759
760 return $array;
761 }

◆ syncOriginalCmd()

ilAssQuestionSkillAssignmentsGUI::syncOriginalCmd ( )
private

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

516 : void
517 {
518 $question_id = $this->request_data_collector->getQuestionId();
519 if ($this->isTestQuestion($question_id) && $this->isSyncOriginalPossibleAndAllowed($question_id)) {
520 $question = assQuestion::instantiateQuestion($question_id);
521
522 $question->syncSkillAssignments(
523 $question->getObjId(),
524 $question->getId(),
525 $question->lookupParentObjId($question->getOriginalId()),
526 $question->getOriginalId()
527 );
528
529 $this->tpl->setOnScreenMessage('success', $this->lng->txt('qpl_qst_skl_assign_synced_to_orig'), true);
530 }
531
532 $this->ctrl->redirect($this, self::CMD_SHOW_SKILL_QUEST_ASSIGNS);
533 }
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 252 of file class.ilAssQuestionSkillAssignmentsGUI.php.

252 : void
253 {
254 $question_id = $this->request_data_collector->getQuestionId();
255
256 if ($this->isTestQuestion($question_id)) {
257 $assignmentList = new ilAssQuestionSkillAssignmentList($this->db);
258 $assignmentList->setParentObjId($this->getQuestionContainerId());
259 $assignmentList->loadFromDb();
260
261 $handledSkills = [];
262
263 $sgui = $this->buildSkillSelectorExplorerGUI([]);
264 $skillIds = $sgui->getSelectedSkills();
265
266 foreach ($skillIds as $skillId) {
267 $skill = explode(':', $skillId);
268 $skillBaseId = (int) $skill[0];
269 $skillTrefId = (int) $skill[1];
270
271 if ($skillBaseId) {
272 if (!$assignmentList->isAssignedToQuestionId($skillBaseId, $skillTrefId, $question_id)) {
273 $assignment = new ilAssQuestionSkillAssignment($this->db);
274
275 $assignment->setParentObjId($this->getQuestionContainerId());
276 $assignment->setQuestionId($question_id);
277 $assignment->setSkillBaseId($skillBaseId);
278 $assignment->setSkillTrefId($skillTrefId);
279
282 $assignment->saveToDb();
283
284 // add skill usage
285 $this->skillUsageService->addUsage($this->getQuestionContainerId(), $skillBaseId, $skillTrefId);
286 }
287
288 $handledSkills[$skillId] = $skill;
289 }
290 }
291
292 foreach ($assignmentList->getAssignmentsByQuestionId($question_id) as $assignment) {
293 if (isset($handledSkills["{$assignment->getSkillBaseId()}:{$assignment->getSkillTrefId()}"])) {
294 continue;
295 }
296
297 $assignment->deleteFromDb();
298
299 // remove skill usage
300 if (!$assignment->isSkillUsed()) {
301 $this->skillUsageService->removeUsage(
302 $assignment->getParentObjId(),
303 $assignment->getSkillBaseId(),
304 $assignment->getSkillTrefId()
305 );
306 }
307 }
308
309 $this->tpl->setOnScreenMessage('success', $this->lng->txt('qpl_qst_skl_assigns_updated'), true);
310
311 if ($this->isSyncOriginalPossibleAndAllowed($question_id)) {
313 $this->ctrl->redirect($this, self::CMD_SHOW_SYNC_ORIGINAL_CONFIRMATION);
314 }
315 }
316
317 $this->ctrl->redirect($this, self::CMD_SHOW_SKILL_QUEST_ASSIGNS);
318 }

References buildSkillSelectorExplorerGUI(), ILIAS\Repository\ctrl(), ilAssQuestionSkillAssignment\DEFAULT_COMPETENCE_POINTS, 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 679 of file class.ilAssQuestionSkillAssignmentsGUI.php.

679 : bool
680 {
681 try {
682 $question_provider = new ilAssLacQuestionProvider();
683 $question_provider->setQuestion($question);
684 (new ilAssLacCompositeValidator($question_provider))->validate(
685 (new ilAssLacConditionParser())->parse($expression->getExpression())
686 );
687 } catch (ilAssLacException $e) {
688 if ($e instanceof ilAssLacFormAlertProvider) {
689 return $e->getFormAlert($this->lng);
690 }
691
692 throw $e;
693 }
694
695 return true;
696 }
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

◆ $question_container_id

int ilAssQuestionSkillAssignmentsGUI::$question_container_id
private

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

Referenced by getQuestionContainerId().

◆ $question_list

ilAssQuestionList ilAssQuestionSkillAssignmentsGUI::$question_list
private

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

Referenced by getQuestionList().

◆ $questionOrderSequence

ilAssQuestionSkillAssignmentsGUI::$questionOrderSequence
private

◆ $request_data_collector

RequestDataCollector ilAssQuestionSkillAssignmentsGUI::$request_data_collector
private

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

◆ $skillUsageService

SkillUsageService ilAssQuestionSkillAssignmentsGUI::$skillUsageService
private

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

◆ CMD_SAVE_SKILL_POINTS

const ilAssQuestionSkillAssignmentsGUI::CMD_SAVE_SKILL_POINTS = 'saveSkillPoints'

Definition at line 44 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

const ilAssQuestionSkillAssignmentsGUI::CMD_SHOW_SKILL_QUEST_ASSIGNS = 'showSkillQuestionAssignments'

◆ CMD_SHOW_SKILL_SELECT

const ilAssQuestionSkillAssignmentsGUI::CMD_SHOW_SKILL_SELECT = 'showSkillSelection'

◆ CMD_SHOW_SYNC_ORIGINAL_CONFIRMATION

const ilAssQuestionSkillAssignmentsGUI::CMD_SHOW_SYNC_ORIGINAL_CONFIRMATION = 'showSyncOriginalConfirmation'

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

◆ CMD_SYNC_ORIGINAL

const ilAssQuestionSkillAssignmentsGUI::CMD_SYNC_ORIGINAL = 'syncOriginal'

Definition at line 46 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 48 of file class.ilAssQuestionSkillAssignmentsGUI.php.


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