70 private readonly
ilCtrl $ctrl,
77 private readonly UIFactory $ui_factory,
78 private readonly UIRenderer $ui_renderer,
80 private readonly HTTP
$http,
84 $this->data_factory =
new DataFactory();
99 $this->assignment_configuration_hint_message = $assignmentConfigurationHintMessage;
123 $this->question_list = $questionList;
139 $this->question_container_id = $questionContainerId;
155 $this->assignment_editing_enabled = $assignmentEditingEnabled;
160 $nextClass = $this->
ctrl->getNextClass();
162 $command = $this->
ctrl->getCmd(self::CMD_SHOW_SKILL_QUEST_ASSIGNS);
165 $this->
ctrl->redirect($this, self::CMD_SHOW_SKILL_QUEST_ASSIGNS);
170 if (in_array($command, [self::CMD_EDIT_SKILL_QUEST_ASSIGNS])) {
174 switch ($nextClass) {
175 case strtolower(__CLASS__):
190 $this->
tabs->clearTargets();
191 $this->
tabs->setBackTarget(
192 $this->
lng->txt(
'back'),
193 $this->ctrl->getLinkTargetByClass(
194 ilAssQuestionSkillAssignmentsGUI::class,
199 strtolower(ilAssQuestionSkillAssignmentsGUI::class),
200 $this->
lng->txt(
'qpl_skl_sub_tab_quest_assign'),
201 $this->ctrl->getLinkTargetByClass(
202 ilAssQuestionSkillAssignmentsGUI::class,
206 $this->
tabs->activateTab(strtolower(ilAssQuestionSkillAssignmentsGUI::class));
228 $skill_points = $this->request_data_collector->raw(
'skill_points');
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];
241 if (!$assignment->isValidSkillPoint($skill_point)) {
249 $assignment->setQuestionId($questionId);
250 $assignment->setSkillBaseId($skillBaseId);
251 $assignment->setSkillTrefId($skillTrefId);
253 if ($assignment->dbRecordExists()) {
254 $assignment->loadFromDb();
256 if (!$assignment->hasEvalModeBySolution()) {
257 $assignment->setSkillPoints($skill_point);
258 $assignment->saveToDb();
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);
275 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'tst_msg_skl_qst_assign_points_not_saved'));
276 $this->showSkillQuestionAssignmentsCmd(
true);
282 $question_id = $this->request_data_collector->getQuestionId();
287 $assignmentList->loadFromDb();
292 $skillIds = $sgui->getSelectedSkills();
294 foreach ($skillIds as $skillId) {
295 $skill = explode(
':', $skillId);
296 $skillBaseId = (
int) $skill[0];
297 $skillTrefId = (
int) $skill[1];
300 if (!$assignmentList->isAssignedToQuestionId($skillBaseId, $skillTrefId, $question_id)) {
304 $assignment->setQuestionId($question_id);
305 $assignment->setSkillBaseId($skillBaseId);
306 $assignment->setSkillTrefId($skillTrefId);
310 $assignment->saveToDb();
316 $handledSkills[$skillId] = $skill;
320 foreach ($assignmentList->getAssignmentsByQuestionId($question_id) as $assignment) {
321 if (isset($handledSkills[
"{$assignment->getSkillBaseId()}:{$assignment->getSkillTrefId()}"])) {
325 $assignment->deleteFromDb();
328 if (!$assignment->isSkillUsed()) {
329 $this->skill_usage_service->removeUsage(
330 $assignment->getParentObjId(),
331 $assignment->getSkillBaseId(),
332 $assignment->getSkillTrefId()
337 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'qpl_qst_skl_assigns_updated'),
true);
341 $this->
ctrl->redirect($this, self::CMD_SHOW_SYNC_ORIGINAL_CONFIRMATION);
351 $question_id = $this->request_data_collector->getQuestionId();
355 $assignmentList->loadFromDb();
358 $assignmentList->getAssignmentsByQuestionId($question_id)
361 if (!$skillSelectorExplorerGUI->handleCommand()) {
362 $tpl =
new ilTemplate(
'tpl.qpl_qst_skl_assign_selection.html',
false,
false,
'components/ILIAS/TestQuestionPool');
368 $skillSelectorToolbarGUI->setOpenFormTag(
true);
369 $skillSelectorToolbarGUI->setCloseFormTag(
false);
371 $tpl->setVariable(
'SKILL_SELECTOR_TOOLBAR_TOP', $this->
ctrl->getHTML($skillSelectorToolbarGUI));
373 $tpl->setVariable(
'SKILL_SELECTOR_EXPLORER', $this->
ctrl->getHTML($skillSelectorExplorerGUI));
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));
380 $this->tpl->setContent($tpl->get());
393 $question_id = $this->request_data_collector->getQuestionId();
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);
402 $this->tpl->setContent($form->getHTML() .
'<br />' . $this->buildQuestionPage($question_gui));
407 $question_id = $this->request_data_collector->getQuestionId();
409 if ($this->isTestQuestion($question_id)) {
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);
416 $this->keepAssignmentParameters();
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);
424 $form->setValuesByPost();
426 if ($form->getItemByPostVar(
'eval_mode')) {
427 $assignment->setEvalMode($form->getItemByPostVar(
'eval_mode')->getValue());
432 if ($assignment->hasEvalModeBySolution()) {
433 $sol_cmp_expr_input = $form->getItemByPostVar(
'solution_compare_expressions');
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);
441 $assignment->initSolutionComparisonExpressionList();
442 $assignment->getSolutionComparisonExpressionList()->reset();
444 foreach ($sol_cmp_expr_input->getValues() as $expression) {
445 $assignment->getSolutionComparisonExpressionList()->add($expression);
448 $assignment->setSkillPoints($form->getItemByPostVar(
'q_res_skill_points')->getValue());
451 $assignment->saveToDb();
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')
460 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'qpl_qst_skl_assign_properties_modified'),
true);
462 if ($this->isSyncOriginalPossibleAndAllowed($question_id)) {
463 $this->
ctrl->redirect($this, self::CMD_SHOW_SYNC_ORIGINAL_CONFIRMATION);
467 $this->
ctrl->redirect($this, self::CMD_EDIT_SKILL_QUEST_ASSIGNS);
476 $form->setAssignment($assignment);
477 $form->setManipulationEnabled($this->isAssignmentEditingEnabled());
483 private function showSkillQuestionAssignmentsCmd(
bool $load_skill_points_from_request =
false): void
485 $this->handleAssignmentConfigurationHintMessage();
487 $assignment_list = $this->buildSkillQuestionAssignmentList();
488 $assignment_list->loadFromDb();
489 $assignment_list->loadAdditionalSkillData();
492 $mode = $this->
http->wrapper()->query()->retrieve(
493 SkillsByQuestionOverviewTable::VIEW_CONTROL_QUERY_PARAM,
495 $this->refinery->kindlyTo()->string(),
500 $edit_uri = $this->data_factory->uri(
501 ILIAS_HTTP_PATH .
'/' . $this->
ctrl->getLinkTargetByClass(
503 self::CMD_EDIT_SKILL_QUEST_ASSIGNS
507 $this->tpl->setContent($this->ui_renderer->render(
509 $this->question_list,
523 $assignment_list = $this->buildSkillQuestionAssignmentList();
524 $assignment_list->loadFromDb();
525 $assignment_list->loadAdditionalSkillData();
527 $this->keepAssignmentParameters();
529 $edit_uri = $this->data_factory->uri(
530 ILIAS_HTTP_PATH .
'/' . $this->
ctrl->getLinkTargetByClass(
532 self::CMD_SHOW_SKILL_QUEST_ASSIGN_PROPERTIES_FORM
536 $this->
ctrl->setParameterByClass(
537 ilAssQuestionSkillAssignmentsGUI::class,
539 $this->request_data_collector->getQuestionId()
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
548 )->withUnavailableAction(!$this->isAssignmentEditingEnabled())
550 $this->
ctrl->setParameterByClass(ilAssQuestionSkillAssignmentsGUI::class,
'q_id',
null);
553 $this->request_data_collector,
563 $this->isAssignmentEditingEnabled()
569 $this->tpl->setContent($this->ui_renderer->render(
$components));
574 $questionData = $this->question_list->getDataArrayForQuestionId($questionId);
576 if (!$questionData[
'original_id']) {
582 if ($parentObjId ===
null || !$this->doesObjectTypeMatch($parentObjId)) {
587 if ($this->
access->checkAccess(
'write',
'', $parentRefId)) {
598 $confirmation->setHeaderText($this->
lng->txt(
'qpl_sync_quest_skl_assigns_confirmation'));
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);
605 $this->tpl->setContent($this->
ctrl->getHTML($confirmation));
610 $question_id = $this->request_data_collector->getQuestionId();
611 if ($this->isTestQuestion($question_id) && $this->isSyncOriginalPossibleAndAllowed($question_id)) {
621 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'qpl_qst_skl_assign_synced_to_orig'),
true);
624 $this->
ctrl->redirect($this, self::CMD_EDIT_SKILL_QUEST_ASSIGNS);
630 $assignmentList->setParentObjId($this->getQuestionContainerId());
632 return $assignmentList;
642 self::CMD_SHOW_SKILL_SELECT,
644 self::CMD_UPDATE_SKILL_QUEST_ASSIGNS,
645 self::PARAM_SKILL_SELECTION
648 $skillSelectorExplorerGUI->setSelectMode(self::PARAM_SKILL_SELECTION,
true);
654 foreach ($assignments as $assignment) {
655 $id =
"{$assignment->getSkillBaseId()}:{$assignment->getSkillTrefId()}";
657 $skillSelectorExplorerGUI->setSkillSelected(
$id);
660 return $skillSelectorExplorerGUI;
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);
674 return $skillSelectorToolbarGUI;
679 $this->tpl->addCss(
'./assets/css/content.css');
683 $page_gui->setOutputMode(
"presentation");
684 $page_gui->setRenderPageContainer(
true);
686 $page_gui->setPresentationTitle($question_gui->
getObject()->getTitleForHTMLOutput());
691 $page_gui->setQuestionHTML([
695 return preg_replace(
"/src=\"\\.\\//ims",
"src=\"" . ILIAS_HTTP_PATH .
"/", $page_gui->presentation());
722 return $this->question_list->isInList($questionId);
729 foreach ($input->getValues() as $expression) {
730 $result = $this->validateSolutionCompareExpression($expression, $question);
732 if ($result !==
true) {
733 $errors[] =
"{$this->lng->txt('ass_lac_expression')} {$expression->getOrderIndex()}: {$result}";
737 if (count($errors)) {
738 $alert = $this->
lng->txt(
'ass_lac_validation_error');
739 $alert .=
'<br />' . implode(
'<br />', $errors);
740 $input->setAlert($alert);
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
754 if ($points_result == (
int) $points_result
755 && $invalid_values_solution === []) {
758 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'numeric_only'));
766 $question_provider->setQuestion($question);
772 return $e->getFormAlert($this->
lng);
783 $this->
ctrl->saveParameter($this,
'q_id');
784 $this->
ctrl->saveParameter($this,
'skill_base_id');
785 $this->
ctrl->saveParameter($this,
'skill_tref_id');
790 if ($this->getAssignmentConfigurationHintMessage()) {
791 $this->tpl->setOnScreenMessage(
'info', $this->getAssignmentConfigurationHintMessage());
798 $this->
lng->txt(
'qpl_qst_skl_selection_for_question_header'),
799 $this->question_list->getDataArrayForQuestionId($questionId)[
'title']
805 $flags = SORT_REGULAR;
807 if (defined(
'SORT_NATURAL')) {
808 $flags = SORT_NATURAL;
809 } elseif (defined(
'SORT_STRING')) {
810 $flags = SORT_STRING;
813 if (defined(
'SORT_FLAG_CASE')) {
814 $flags = $flags | SORT_FLAG_CASE;
817 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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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)
__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)
showSyncOriginalConfirmationCmd()
buildSkillQuestionAssignmentList()
const CMD_SHOW_SKILL_QUEST_ASSIGN_PROPERTIES_FORM
setQuestionOrderSequence($questionOrderSequence)
handleAssignmentConfigurationHintMessage()
isSyncOriginalPossibleAndAllowed(int $questionId)
const CMD_SHOW_SYNC_ORIGINAL_CONFIRMATION
array $questionOrderSequence
const CMD_UPDATE_SKILL_QUEST_ASSIGNS
buildQuestionPage(assQuestionGUI $question_gui)
const CMD_SAVE_SKILL_POINTS
getSkillSelectorHeader(int $questionId)
bool $assignment_editing_enabled
checkSolutionCompareExpressionInput($input, assQuestion $question)
setQuestionContainerId($questionContainerId)
updateSkillQuestionAssignmentsCmd()
setAssignmentConfigurationHintMessage(?string $assignmentConfigurationHintMessage)
showSkillQuestionAssignmentPropertiesFormCmd(?assQuestionGUI $question_gui=null, ?ilAssQuestionSkillAssignment $assignment=null, ?ilPropertyFormGUI $form=null)
isAvoidManipulationRedirectRequired($command)
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()
validateSolutionCompareExpression(ilAssQuestionSolutionComparisonExpression $expression, $question)
saveSkillQuestionAssignmentPropertiesFormCmd()
isAssignmentEditingEnabled()
string $assignment_configuration_hint_message
buildSkillSelectorExplorerGUI($assignments)
getAssignmentConfigurationHintMessage()
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.
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