70 private readonly
ilCtrl $ctrl,
77 private readonly UIFactory $ui_factory,
78 private readonly UIRenderer $ui_renderer,
80 private readonly HTTP
$http,
83 private readonly ?
ilObjTest $test_object =
null
85 $this->data_factory =
new DataFactory();
100 $this->assignment_configuration_hint_message = $assignmentConfigurationHintMessage;
124 $this->question_list = $questionList;
140 $this->question_container_id = $questionContainerId;
156 $this->assignment_editing_enabled = $assignmentEditingEnabled;
161 $nextClass = $this->
ctrl->getNextClass();
163 $command = $this->
ctrl->getCmd(self::CMD_SHOW_SKILL_QUEST_ASSIGNS);
166 $this->
ctrl->redirect($this, self::CMD_SHOW_SKILL_QUEST_ASSIGNS);
171 if (in_array($command, [self::CMD_EDIT_SKILL_QUEST_ASSIGNS])) {
175 switch ($nextClass) {
176 case strtolower(__CLASS__):
191 $this->
tabs->clearTargets();
192 $this->
tabs->setBackTarget(
193 $this->
lng->txt(
'back'),
194 $this->ctrl->getLinkTargetByClass(
195 ilAssQuestionSkillAssignmentsGUI::class,
200 strtolower(ilAssQuestionSkillAssignmentsGUI::class),
201 $this->
lng->txt(
'qpl_skl_sub_tab_quest_assign'),
202 $this->ctrl->getLinkTargetByClass(
203 ilAssQuestionSkillAssignmentsGUI::class,
207 $this->
tabs->activateTab(strtolower(ilAssQuestionSkillAssignmentsGUI::class));
229 $skill_points = $this->request_data_collector->raw(
'skill_points');
231 for ($i = 0; $i < 2; $i++) {
232 foreach ($skill_points as $assignment_key => $skill_point) {
233 $assignment_key = explode(
':', $assignment_key);
234 $skillBaseId = (
int) $assignment_key[0];
235 $skillTrefId = (
int) $assignment_key[1];
236 $questionId = (
int) $assignment_key[2];
242 if (!$assignment->isValidSkillPoint($skill_point)) {
250 $assignment->setQuestionId($questionId);
251 $assignment->setSkillBaseId($skillBaseId);
252 $assignment->setSkillTrefId($skillTrefId);
254 if ($assignment->dbRecordExists()) {
255 $assignment->loadFromDb();
257 if (!$assignment->hasEvalModeBySolution()) {
258 $assignment->setSkillPoints($skill_point);
259 $assignment->saveToDb();
271 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'tst_msg_skl_qst_assign_points_saved'),
true);
272 $this->
ctrl->redirect($this, self::CMD_SHOW_SKILL_QUEST_ASSIGNS);
276 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'tst_msg_skl_qst_assign_points_not_saved'));
277 $this->showSkillQuestionAssignmentsCmd(
true);
283 $question_id = $this->request_data_collector->getQuestionId();
288 $assignmentList->loadFromDb();
293 $skillIds = $sgui->getSelectedSkills();
295 foreach ($skillIds as $skillId) {
296 $skill = explode(
':', $skillId);
297 $skillBaseId = (
int) $skill[0];
298 $skillTrefId = (
int) $skill[1];
301 if (!$assignmentList->isAssignedToQuestionId($skillBaseId, $skillTrefId, $question_id)) {
305 $assignment->setQuestionId($question_id);
306 $assignment->setSkillBaseId($skillBaseId);
307 $assignment->setSkillTrefId($skillTrefId);
311 $assignment->saveToDb();
317 $handledSkills[$skillId] = $skill;
321 foreach ($assignmentList->getAssignmentsByQuestionId($question_id) as $assignment) {
322 if (isset($handledSkills[
"{$assignment->getSkillBaseId()}:{$assignment->getSkillTrefId()}"])) {
326 $assignment->deleteFromDb();
329 if (!$assignment->isSkillUsed()) {
330 $this->skill_usage_service->removeUsage(
331 $assignment->getParentObjId(),
332 $assignment->getSkillBaseId(),
333 $assignment->getSkillTrefId()
338 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'qpl_qst_skl_assigns_updated'),
true);
342 $this->
ctrl->redirect($this, self::CMD_SHOW_SYNC_ORIGINAL_CONFIRMATION);
352 $question_id = $this->request_data_collector->getQuestionId();
356 $assignmentList->loadFromDb();
359 $assignmentList->getAssignmentsByQuestionId($question_id)
362 if (!$skillSelectorExplorerGUI->handleCommand()) {
363 $tpl =
new ilTemplate(
'tpl.qpl_qst_skl_assign_selection.html',
false,
false,
'components/ILIAS/TestQuestionPool');
369 $skillSelectorToolbarGUI->setOpenFormTag(
true);
370 $skillSelectorToolbarGUI->setCloseFormTag(
false);
372 $tpl->setVariable(
'SKILL_SELECTOR_TOOLBAR_TOP', $this->
ctrl->getHTML($skillSelectorToolbarGUI));
374 $tpl->setVariable(
'SKILL_SELECTOR_EXPLORER', $this->
ctrl->getHTML($skillSelectorExplorerGUI));
376 $skillSelectorToolbarGUI->setOpenFormTag(
false);
377 $skillSelectorToolbarGUI->setCloseFormTag(
true);
378 $skillSelectorToolbarGUI->setLeadingImage(
ilUtil::getImagePath(
"nav/arrow_downright.svg"),
" ");
379 $tpl->setVariable(
'SKILL_SELECTOR_TOOLBAR_BOTTOM', $this->
ctrl->getHTML($skillSelectorToolbarGUI));
381 $this->tpl->setContent($tpl->get());
394 $question_id = $this->request_data_collector->getQuestionId();
397 $row_id_parameter = $this->request_data_collector->getRowIdParameter(EditSkillsOfQuestionTableActions::FULL_ROW_ID_PARAMETER);
398 [1 => $skill_base_id, 2 => $skill_tref_id] = explode(
'_', $row_id_parameter);
403 $this->tpl->setContent($form->getHTML() .
'<br />' . $this->buildQuestionPage($question_gui));
406 private function saveSkillQuestionAssignmentPropertiesFormCmd(): void
408 $question_id = $this->request_data_collector->getQuestionId();
410 if ($this->isTestQuestion($question_id)) {
413 $row_id_parameter = $this->request_data_collector->getRowIdParameter(EditSkillsOfQuestionTableActions::FULL_ROW_ID_PARAMETER);
414 [1 => $skill_base_id, 2 => $skill_tref_id] = explode(
'_', $row_id_parameter);
415 $assignment = $this->buildQuestionSkillAssignment($question_id, (
int) $skill_base_id, (
int) $skill_tref_id);
417 $this->keepAssignmentParameters();
418 $form = $this->buildSkillQuestionAssignmentPropertiesForm($question_gui->getObject(), $assignment);
419 if (!$form->checkInput()
420 || !$this->checkPointsAreInt($form)) {
421 $form->setValuesByPost();
422 $this->showSkillQuestionAssignmentPropertiesFormCmd($question_gui, $assignment, $form);
425 $form->setValuesByPost();
427 if ($form->getItemByPostVar(
'eval_mode')) {
428 $assignment->setEvalMode($form->getItemByPostVar(
'eval_mode')->getValue());
433 if ($assignment->hasEvalModeBySolution()) {
435 $sol_cmp_expr_input = $form->getItemByPostVar(
'solution_compare_expressions');
439 && !$this->checkSolutionCompareExpressionInput($sol_cmp_expr_input, $question_gui->getObject())
441 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'form_input_not_valid'));
442 $this->showSkillQuestionAssignmentPropertiesFormCmd($question_gui, $assignment, $form);
446 $assignment->initSolutionComparisonExpressionList();
447 $assignment->getSolutionComparisonExpressionList()->reset();
449 foreach ($sol_cmp_expr_input?->getValues() ?? [] as $expression) {
450 $assignment->getSolutionComparisonExpressionList()->add($expression);
453 $assignment->setSkillPoints($form->getItemByPostVar(
'q_res_skill_points')->getValue());
456 $assignment->saveToDb();
459 $this->skill_usage_service->addUsage(
460 $this->getQuestionContainerId(),
461 $this->request_data_collector->int(
'skill_base_id'),
462 $this->request_data_collector->int(
'skill_tref_id')
465 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'qpl_qst_skl_assign_properties_modified'),
true);
467 if ($this->isSyncOriginalPossibleAndAllowed($question_id)) {
468 $this->
ctrl->redirect($this, self::CMD_SHOW_SYNC_ORIGINAL_CONFIRMATION);
472 $this->
ctrl->redirect($this, self::CMD_EDIT_SKILL_QUEST_ASSIGNS);
481 $form->setAssignment($assignment);
482 $form->setManipulationEnabled($this->isAssignmentEditingEnabled());
488 private function showSkillQuestionAssignmentsCmd(
bool $load_skill_points_from_request =
false): void
490 $this->handleAssignmentConfigurationHintMessage();
492 $assignment_list = $this->buildSkillQuestionAssignmentList();
493 $assignment_list->loadFromDb();
494 $assignment_list->loadAdditionalSkillData();
497 $mode = $this->
http->wrapper()->query()->retrieve(
498 SkillsByQuestionOverviewTable::VIEW_CONTROL_QUERY_PARAM,
500 $this->refinery->kindlyTo()->string(),
505 $edit_uri = $this->data_factory->uri(
506 ILIAS_HTTP_PATH .
'/' . $this->
ctrl->getLinkTargetByClass(
508 self::CMD_EDIT_SKILL_QUEST_ASSIGNS
512 $this->tpl->setContent($this->ui_renderer->render(
514 $this->question_list,
528 && $this->hasFixedQuestionSetSkillAssignsLowerThanBarrier()
530 $this->tpl->setOnScreenMessage(
'info', $this->getSkillAssignBarrierInfo());
536 if (!$this->test_object?->isFixedTest()) {
541 $assignmentList->setParentObjId($this->test_object->getId());
542 $assignmentList->loadFromDb();
544 return $assignmentList->hasSkillsAssignedLowerThanBarrier();
549 return !$this->test_object instanceof
ilObjTest
552 $this->
lng->txt(
'tst_skill_triggerings_num_req_answers_not_reached_warn'),
553 $this->test_object->getGlobalSettings()->getSkillTriggeringNumberOfAnswers()
560 $assignment_list = $this->buildSkillQuestionAssignmentList();
561 $assignment_list->loadFromDb();
562 $assignment_list->loadAdditionalSkillData();
564 $this->keepAssignmentParameters();
566 $edit_uri = $this->data_factory->uri(
567 ILIAS_HTTP_PATH .
'/' . $this->
ctrl->getLinkTargetByClass(
569 self::CMD_SHOW_SKILL_QUEST_ASSIGN_PROPERTIES_FORM
573 $this->
ctrl->setParameterByClass(
574 ilAssQuestionSkillAssignmentsGUI::class,
576 $this->request_data_collector->getQuestionId()
579 $this->ui_factory->button()->standard(
580 $this->lng->txt(
'tst_manage_competence_select_skills'),
581 $this->ctrl->getLinkTargetByClass(
582 [ilAssQuestionSkillAssignmentsGUI::class],
583 self::CMD_SHOW_SKILL_SELECT
585 )->withUnavailableAction(!$this->isAssignmentEditingEnabled())
587 $this->
ctrl->setParameterByClass(ilAssQuestionSkillAssignmentsGUI::class,
'q_id',
null);
590 $this->request_data_collector,
600 $this->isAssignmentEditingEnabled()
606 $this->tpl->setContent($this->ui_renderer->render(
$components));
611 $questionData = $this->question_list->getDataArrayForQuestionId($questionId);
613 if (!$questionData[
'original_id']) {
619 if ($parentObjId ===
null || !$this->doesObjectTypeMatch($parentObjId)) {
624 if ($this->
access->checkAccess(
'write',
'', $parentRefId)) {
635 $confirmation->setHeaderText($this->
lng->txt(
'qpl_sync_quest_skl_assigns_confirmation'));
637 $confirmation->setFormAction($this->
ctrl->getFormAction($this));
638 $confirmation->addHiddenItem(
'q_id', $this->request_data_collector->getQuestionId());
639 $confirmation->setConfirm($this->
lng->txt(
'yes'), self::CMD_SYNC_ORIGINAL);
640 $confirmation->setCancel($this->
lng->txt(
'no'), self::CMD_EDIT_SKILL_QUEST_ASSIGNS);
642 $this->tpl->setContent($this->
ctrl->getHTML($confirmation));
647 $question_id = $this->request_data_collector->getQuestionId();
648 if ($this->isTestQuestion($question_id) && $this->isSyncOriginalPossibleAndAllowed($question_id)) {
658 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'qpl_qst_skl_assign_synced_to_orig'),
true);
661 $this->
ctrl->redirect($this, self::CMD_EDIT_SKILL_QUEST_ASSIGNS);
667 $assignmentList->setParentObjId($this->getQuestionContainerId());
669 return $assignmentList;
679 self::CMD_SHOW_SKILL_SELECT,
681 self::CMD_UPDATE_SKILL_QUEST_ASSIGNS,
682 self::PARAM_SKILL_SELECTION
685 $skillSelectorExplorerGUI->setSelectMode(self::PARAM_SKILL_SELECTION,
true);
691 foreach ($assignments as $assignment) {
692 $id =
"{$assignment->getSkillBaseId()}:{$assignment->getSkillTrefId()}";
694 $skillSelectorExplorerGUI->setSkillSelected(
$id);
697 return $skillSelectorExplorerGUI;
707 $skillSelectorToolbarGUI->setFormAction($this->
ctrl->getFormAction($this));
708 $skillSelectorToolbarGUI->addFormButton($this->
lng->txt(
'qpl_save_skill_assigns_update'), self::CMD_UPDATE_SKILL_QUEST_ASSIGNS);
709 $skillSelectorToolbarGUI->addFormButton($this->
lng->txt(
'qpl_cancel_skill_assigns_update'), self::CMD_EDIT_SKILL_QUEST_ASSIGNS);
711 return $skillSelectorToolbarGUI;
716 $this->tpl->addCss(
'./assets/css/content.css');
720 $page_gui->setOutputMode(
"presentation");
721 $page_gui->setRenderPageContainer(
true);
723 $page_gui->setPresentationTitle($question_gui->
getObject()->getTitleForHTMLOutput());
728 $page_gui->setQuestionHTML([
732 return preg_replace(
"/src=\"\\.\\//ims",
"src=\"" . ILIAS_HTTP_PATH .
"/", $page_gui->presentation());
759 return $this->question_list->isInList($questionId);
768 foreach ($input->
getValues() as $expression) {
769 $result = $this->validateSolutionCompareExpression($expression, $question);
771 if ($result !==
true) {
772 $errors[] =
"{$this->lng->txt('ass_lac_expression')} {$expression->getOrderIndex()}: {$result}";
776 if ($errors !== []) {
777 $input->
setAlert($this->
lng->txt(
'ass_lac_validation_error') .
'<br />' . implode(
'<br />', $errors));
786 $points_result = $form->
getInput(
'q_res_skill_points');
787 $invalid_values_solution = array_filter(
788 $form->
getInput(
'solution_compare_expressions')[
'points'],
789 fn(
string $v):
bool => $v != (
int) $v
791 if ($points_result == (
int) $points_result
792 && $invalid_values_solution === []) {
795 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'numeric_only'));
821 $this->
ctrl->saveParameter($this,
'q_id');
822 $this->
ctrl->saveParameter($this,
'skill_base_id');
823 $this->
ctrl->saveParameter($this,
'skill_tref_id');
828 if ($this->getAssignmentConfigurationHintMessage()) {
829 $this->tpl->setOnScreenMessage(
'info', $this->getAssignmentConfigurationHintMessage());
836 $this->
lng->txt(
'qpl_qst_skl_selection_for_question_header'),
837 $this->question_list->getDataArrayForQuestionId($questionId)[
'title']
843 $flags = SORT_REGULAR;
845 if (defined(
'SORT_NATURAL')) {
846 $flags = SORT_NATURAL;
847 } elseif (defined(
'SORT_STRING')) {
848 $flags = SORT_STRING;
851 if (defined(
'SORT_FLAG_CASE')) {
852 $flags = $flags | SORT_FLAG_CASE;
855 asort($array, $flags);
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Builds a Color from either hex- or rgb values.
static _getQuestionGUI(string $question_type='', int $question_id=-1)
Creates a question gui representation and returns the alias to the question gui.
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)
static lookupParentObjId(int $question_id)
syncSkillAssignments(int $srcParentId, int $srcQuestionId, int $trgParentId, int $trgQuestionId)
setShuffle(?bool $shuffle=true)
static instantiateQuestion(int $question_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilParserQuestionProvider.
setQuestion(assQuestion $question)
setQuestionId(int $questionId)
setParentObjId(int $parentObjId)
loadAdditionalSkillData()
setSkillTrefId(int $skillTrefId)
setSkillBaseId(int $skillBaseId)
const int DEFAULT_COMPETENCE_POINTS
const string EVAL_MODE_BY_QUESTION_RESULT
isTestQuestion($questionId)
showSyncOriginalConfirmationCmd()
buildSkillQuestionAssignmentList()
checkSolutionCompareExpressionInput(ilLogicalAnswerComparisonExpressionInputGUI $input, assQuestion $question)
const CMD_SHOW_SKILL_QUEST_ASSIGN_PROPERTIES_FORM
setQuestionOrderSequence($questionOrderSequence)
handleAssignmentConfigurationHintMessage()
__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, private readonly ?ilObjTest $test_object=null)
isSyncOriginalPossibleAndAllowed(int $questionId)
const CMD_SHOW_SYNC_ORIGINAL_CONFIRMATION
array $questionOrderSequence
const CMD_UPDATE_SKILL_QUEST_ASSIGNS
buildQuestionPage(assQuestionGUI $question_gui)
validateSolutionCompareExpression(ilAssQuestionSolutionComparisonExpression $expression, assQuestion $question)
const CMD_SAVE_SKILL_POINTS
getSkillSelectorHeader(int $questionId)
bool $assignment_editing_enabled
setQuestionContainerId($questionContainerId)
updateSkillQuestionAssignmentsCmd()
setAssignmentConfigurationHintMessage(?string $assignmentConfigurationHintMessage)
showSkillQuestionAssignmentPropertiesFormCmd(?assQuestionGUI $question_gui=null, ?ilAssQuestionSkillAssignment $assignment=null, ?ilPropertyFormGUI $form=null)
isAvoidManipulationRedirectRequired($command)
hasFixedQuestionSetSkillAssignsLowerThanBarrier()
setAssignmentEditingEnabled($assignmentEditingEnabled)
const CMD_SAVE_SKILL_QUEST_ASSIGN_PROPERTIES_FORM
keepAssignmentParameters()
ilAssQuestionList $question_list
const CMD_SHOW_SKILL_SELECT
checkPointsAreInt(ilPropertyFormGUI $form)
buildQuestionSkillAssignment(int $question_id, int $skill_base_id, int $skill_tref_id)
buildSkillSelectorToolbarGUI()
isAssignmentEditingEnabled()
string $assignment_configuration_hint_message
buildSkillSelectorExplorerGUI($assignments)
getAssignmentConfigurationHintMessage()
getSkillAssignBarrierInfo()
int $question_container_id
const PARAM_SKILL_SELECTION
setQuestionList($questionList)
DataFactory $data_factory
const CMD_EDIT_SKILL_QUEST_ASSIGNS
editSkillQuestionAssignmentCmd()
doesObjectTypeMatch($objectId)
buildSkillQuestionAssignmentPropertiesForm(assQuestion $question, ilAssQuestionSkillAssignment $assignment)
getQuestionOrderSequence()
const CMD_SHOW_SKILL_QUEST_ASSIGNS
sortAlphabetically($array)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilCtrl provides processing control methods.
isSkillServiceToBeConsidered()
Returns whether this test must consider skills, usually by providing appropriate extensions in the us...
static _lookupType(int $id, bool $reference=false)
static _getAllReferences(int $id)
get all reference ids for object ID
Explorer class that works on tree objects (Services/Tree)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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)
@ ALL
event string being used if
An entity that renders components to a string output.
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
static http()
Fetches the global http state from ILIAS.
SkillAssignmentViewControlMode