80 $local_dic = QuestionPoolDIC::dic();
81 $this->request_data_collector = $local_dic[
'request_data_collector'];
84 $this->skillUsageService = $DIC->skills()->usage();
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);
168 switch ($nextClass) {
169 case strtolower(__CLASS__):
189 case self::CMD_SAVE_SKILL_QUEST_ASSIGN_PROPERTIES_FORM:
190 case self::CMD_UPDATE_SKILL_QUEST_ASSIGNS:
201 $skill_points = $this->request_data_collector->raw(
'skill_points');
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];
214 if (!$assignment->isValidSkillPoint($skill_point)) {
222 $assignment->setQuestionId($questionId);
223 $assignment->setSkillBaseId($skillBaseId);
224 $assignment->setSkillTrefId($skillTrefId);
226 if ($assignment->dbRecordExists()) {
227 $assignment->loadFromDb();
229 if (!$assignment->hasEvalModeBySolution()) {
230 $assignment->setSkillPoints($skill_point);
231 $assignment->saveToDb();
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);
248 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'tst_msg_skl_qst_assign_points_not_saved'));
254 $question_id = $this->request_data_collector->getQuestionId();
259 $assignmentList->loadFromDb();
264 $skillIds = $sgui->getSelectedSkills();
266 foreach ($skillIds as $skillId) {
267 $skill = explode(
':', $skillId);
268 $skillBaseId = (
int) $skill[0];
269 $skillTrefId = (
int) $skill[1];
272 if (!$assignmentList->isAssignedToQuestionId($skillBaseId, $skillTrefId, $question_id)) {
276 $assignment->setQuestionId($question_id);
277 $assignment->setSkillBaseId($skillBaseId);
278 $assignment->setSkillTrefId($skillTrefId);
282 $assignment->saveToDb();
288 $handledSkills[$skillId] = $skill;
292 foreach ($assignmentList->getAssignmentsByQuestionId($question_id) as $assignment) {
293 if (isset($handledSkills[
"{$assignment->getSkillBaseId()}:{$assignment->getSkillTrefId()}"])) {
297 $assignment->deleteFromDb();
300 if (!$assignment->isSkillUsed()) {
301 $this->skillUsageService->removeUsage(
302 $assignment->getParentObjId(),
303 $assignment->getSkillBaseId(),
304 $assignment->getSkillTrefId()
309 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'qpl_qst_skl_assigns_updated'),
true);
313 $this->
ctrl->redirect($this, self::CMD_SHOW_SYNC_ORIGINAL_CONFIRMATION);
317 $this->
ctrl->redirect($this, self::CMD_SHOW_SKILL_QUEST_ASSIGNS);
322 $this->
ctrl->saveParameter($this,
'q_id');
323 $question_id = $this->request_data_collector->getQuestionId();
327 $assignmentList->loadFromDb();
330 $assignmentList->getAssignmentsByQuestionId($question_id)
333 if (!$skillSelectorExplorerGUI->handleCommand()) {
334 $tpl =
new ilTemplate(
'tpl.qpl_qst_skl_assign_selection.html',
false,
false,
'components/ILIAS/TestQuestionPool');
340 $skillSelectorToolbarGUI->setOpenFormTag(
true);
341 $skillSelectorToolbarGUI->setCloseFormTag(
false);
343 $tpl->setVariable(
'SKILL_SELECTOR_TOOLBAR_TOP', $this->
ctrl->getHTML($skillSelectorToolbarGUI));
345 $tpl->setVariable(
'SKILL_SELECTOR_EXPLORER', $this->
ctrl->getHTML($skillSelectorExplorerGUI));
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));
352 $this->tpl->setContent($tpl->get());
365 if ($question_gui ===
null) {
369 if ($assignment ===
null) {
371 $this->request_data_collector->getQuestionId(),
372 $this->request_data_collector->int(
'skill_base_id'),
373 $this->request_data_collector->int(
'skill_tref_id')
377 if ($form ===
null) {
381 $this->tpl->setContent($form->getHTML() .
'<br />' . $this->
buildQuestionPage($question_gui));
386 $question_id = $this->request_data_collector->getQuestionId();
393 $this->request_data_collector->int(
'skill_base_id'),
394 $this->request_data_collector->int(
'skill_tref_id')
399 if (!$form->checkInput()
401 $form->setValuesByPost();
405 $form->setValuesByPost();
407 if ($form->getItemByPostVar(
'eval_mode')) {
408 $assignment->setEvalMode($form->getItemByPostVar(
'eval_mode')->getValue());
413 if ($assignment->hasEvalModeBySolution()) {
414 $sol_cmp_expr_input = $form->getItemByPostVar(
'solution_compare_expressions');
417 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'form_input_not_valid'));
422 $assignment->initSolutionComparisonExpressionList();
423 $assignment->getSolutionComparisonExpressionList()->reset();
425 foreach ($sol_cmp_expr_input->getValues() as $expression) {
426 $assignment->getSolutionComparisonExpressionList()->add($expression);
429 $assignment->setSkillPoints($form->getItemByPostVar(
'q_res_skill_points')->getValue());
432 $assignment->saveToDb();
435 $this->skillUsageService->addUsage(
437 $this->request_data_collector->int(
'skill_base_id'),
438 $this->request_data_collector->int(
'skill_tref_id')
441 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'qpl_qst_skl_assign_properties_modified'),
true);
444 $this->
ctrl->redirect($this, self::CMD_SHOW_SYNC_ORIGINAL_CONFIRMATION);
448 $this->
ctrl->redirect($this, self::CMD_SHOW_SKILL_QUEST_ASSIGNS);
456 $form->setQuestion($question);
457 $form->setAssignment($assignment);
469 $table->loadSkillPointsFromRequest($loadSkillPointsFromRequest);
472 $assignmentList->loadFromDb();
473 $assignmentList->loadAdditionalSkillData();
474 $table->setSkillQuestionAssignmentList($assignmentList);
475 $table->setData($this->
orderQuestionData($this->question_list->getQuestionDataArray()));
477 $this->tpl->setContent($table->getHTML());
482 $questionData = $this->question_list->getDataArrayForQuestionId($questionId);
484 if (!$questionData[
'original_id']) {
495 if ($this->
access->checkAccess(
'write',
'', $parentRefId)) {
506 $confirmation->setHeaderText($this->
lng->txt(
'qpl_sync_quest_skl_assigns_confirmation'));
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);
513 $this->tpl->setContent($this->
ctrl->getHTML($confirmation));
518 $question_id = $this->request_data_collector->getQuestionId();
522 $question->syncSkillAssignments(
523 $question->getObjId(),
525 $question->lookupParentObjId($question->getOriginalId()),
526 $question->getOriginalId()
529 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'qpl_qst_skl_assign_synced_to_orig'),
true);
532 $this->
ctrl->redirect($this, self::CMD_SHOW_SKILL_QUEST_ASSIGNS);
549 return $assignmentList;
559 self::CMD_SHOW_SKILL_SELECT,
561 self::CMD_UPDATE_SKILL_QUEST_ASSIGNS,
562 self::PARAM_SKILL_SELECTION
565 $skillSelectorExplorerGUI->setSelectMode(self::PARAM_SKILL_SELECTION,
true);
571 foreach ($assignments as $assignment) {
572 $id =
"{$assignment->getSkillBaseId()}:{$assignment->getSkillTrefId()}";
574 $skillSelectorExplorerGUI->setSkillSelected(
$id);
577 return $skillSelectorExplorerGUI;
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);
591 return $skillSelectorToolbarGUI;
596 $this->tpl->addCss(
'./assets/css/content.css');
601 $pageGUI->setRenderPageContainer(
true);
603 $pageGUI->setPresentationTitle($question_gui->
getObject()->getTitleForHTMLOutput());
606 $question->setShuffle(
false);
608 $questionHTML = $question_gui->
getSolutionOutput(0, 0,
false,
false,
true,
false,
true,
false,
true);
609 $pageGUI->setQuestionHTML([$question_gui->
getObject()->getId() => $questionHTML]);
611 $pageHTML = $pageGUI->presentation();
612 $pageHTML = preg_replace(
"/src=\"\\.\\//ims",
"src=\"" . ILIAS_HTTP_PATH .
"/", $pageHTML);
628 $assignment->setQuestionId($question_id);
629 $assignment->setSkillBaseId($skill_base_id);
630 $assignment->setSkillTrefId($skill_tref_id);
632 $assignment->loadFromDb();
633 $assignment->loadAdditionalSkillData();
640 return $this->question_list->isInList($questionId);
647 foreach ($input->getValues() as $expression) {
650 if ($result !==
true) {
651 $errors[] =
"{$this->lng->txt('ass_lac_expression')} {$expression->getOrderIndex()}: {$result}";
655 if (count($errors)) {
656 $alert = $this->
lng->txt(
'ass_lac_validation_error');
657 $alert .=
'<br />' . implode(
'<br />', $errors);
658 $input->setAlert($alert);
667 $points_result = $form->
getInput(
'q_res_skill_points');
668 $invalid_values_solution = array_filter(
669 $form->
getInput(
'solution_compare_expressions')[
'points'],
670 fn(
string $v):
bool => $v != (
int) $v
672 if ($points_result == (
int) $points_result
673 && $invalid_values_solution === []) {
676 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'numeric_only'));
684 $question_provider->setQuestion($question);
690 return $e->getFormAlert($this->
lng);
701 $this->
ctrl->saveParameter($this,
'q_id');
702 $this->
ctrl->saveParameter($this,
'skill_base_id');
703 $this->
ctrl->saveParameter($this,
'skill_tref_id');
708 $orderedQuestionsData = [];
712 $orderedQuestionsData[$questionId] = $questionData[$questionId];
715 return $orderedQuestionsData;
718 foreach ($questionData as $questionId =>
$data) {
719 $orderedQuestionsData[$questionId] =
$data[
'title'];
724 foreach ($orderedQuestionsData as $questionId => $questionTitle) {
725 $orderedQuestionsData[$questionId] = $questionData[$questionId];
728 return $orderedQuestionsData;
740 $questionData = $this->question_list->getDataArrayForQuestionId($questionId);
742 return sprintf($this->
lng->txt(
'qpl_qst_skl_selection_for_question_header'), $questionData[
'title']);
747 $flags = SORT_REGULAR;
749 if (defined(
'SORT_NATURAL')) {
750 $flags = SORT_NATURAL;
751 } elseif (defined(
'SORT_STRING')) {
752 $flags = SORT_STRING;
755 if (defined(
'SORT_FLAG_CASE')) {
756 $flags = $flags | SORT_FLAG_CASE;
759 asort($array, $flags);
bool $assignment_editing_enabled
showSkillQuestionAssignmentPropertiesFormCmd(?assQuestionGUI $question_gui=null, ?ilAssQuestionSkillAssignment $assignment=null, ?ilPropertyFormGUI $form=null)
const CMD_UPDATE_SKILL_QUEST_ASSIGNS
const CMD_SHOW_SKILL_SELECT
sortAlphabetically($array)
setQuestionContainerId($questionContainerId)
const PARAM_SKILL_SELECTION
saveSkillQuestionAssignmentPropertiesFormCmd()
setOutputMode(string $a_mode=self::PRESENTATION)
keepAssignmentParameters()
isSyncOriginalPossibleAndAllowed($questionId)
doesObjectTypeMatch($objectId)
static _getAllReferences(int $id)
get all reference ids for object ID
buildQuestionPage(assQuestionGUI $question_gui)
isAssignmentEditingEnabled()
setAssignmentEditingEnabled($assignmentEditingEnabled)
getSkillSelectorHeader($questionId)
setObject(assQuestion $question)
showSyncOriginalConfirmationCmd()
const CMD_SAVE_SKILL_QUEST_ASSIGN_PROPERTIES_FORM
SkillUsageService $skillUsageService
const CMD_SAVE_SKILL_POINTS
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
validateSolutionCompareExpression(ilAssQuestionSolutionComparisonExpression $expression, $question)
static _getQuestionGUI(string $question_type='', int $question_id=-1)
Creates a question gui representation and returns the alias to the question gui.
checkPointsAreInt(ilPropertyFormGUI $form)
buildSkillQuestionAssignmentPropertiesForm(assQuestion $question, ilAssQuestionSkillAssignment $assignment)
showSkillQuestionAssignmentsCmd($loadSkillPointsFromRequest=false)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static instantiateQuestion(int $question_id)
RequestDataCollector $request_data_collector
setQuestionList($questionList)
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
setQuestionOrderSequence($questionOrderSequence)
ilAssQuestionList $question_list
getAssignmentConfigurationHintMessage()
getQuestionOrderSequence()
checkSolutionCompareExpressionInput($input, assQuestion $question)
isAvoidManipulationRedirectRequired($command)
buildQuestionSkillAssignment(int $question_id, int $skill_base_id, int $skill_tref_id)
__construct(private ilCtrl $ctrl, private ilAccessHandler $access, private ilGlobalTemplateInterface $tpl, private ilLanguage $lng, private ilDBInterface $db)
Explorer class that works on tree objects (Services/Tree)
setAssignmentConfigurationHintMessage(?string $assignmentConfigurationHintMessage)
static lookupParentObjId(int $question_id)
const DEFAULT_COMPETENCE_POINTS
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
int $question_container_id
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
string $assignment_configuration_hint_message
buildSkillSelectorExplorerGUI($assignments)
buildSkillSelectorToolbarGUI()
isTestQuestion($questionId)
const CMD_SHOW_SYNC_ORIGINAL_CONFIRMATION
static _lookupType(int $id, bool $reference=false)
buildSkillQuestionAssignmentList()
const EVAL_MODE_BY_QUESTION_RESULT
handleAssignmentConfigurationHintMessage()
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)
updateSkillQuestionAssignmentsCmd()
const CMD_SHOW_SKILL_QUEST_ASSIGNS
orderQuestionData($questionData)
const CMD_SHOW_SKILL_QUEST_ASSIGN_PROPERTIES_FORM