79 private \ILIAS\TestQuestionPool\InternalRequestService
$request;
98 $this->request = $DIC->testQuestionPool()->internal()->request();
99 $this->skillUsageService = $DIC->skills()->usage();
178 $nextClass = $this->
ctrl->getNextClass();
180 $command = $this->
ctrl->getCmd(self::CMD_SHOW_SKILL_QUEST_ASSIGNS);
183 $this->
ctrl->redirect($this, self::CMD_SHOW_SKILL_QUEST_ASSIGNS);
186 switch ($nextClass) {
187 case strtolower(__CLASS__):
207 case self::CMD_SAVE_SKILL_QUEST_ASSIGN_PROPERTIES_FORM:
208 case self::CMD_UPDATE_SKILL_QUEST_ASSIGNS:
220 if (is_array($_POST[
'skill_points'])) {
221 for ($i = 0; $i < 2; $i++) {
222 foreach ($_POST[
'skill_points'] as $assignmentKey => $skillPoints) {
223 $assignmentKey = explode(
':', $assignmentKey);
224 $skillBaseId = (
int) $assignmentKey[0];
225 $skillTrefId = (
int) $assignmentKey[1];
226 $questionId = (
int) $assignmentKey[2];
232 if (!$assignment->isValidSkillPoint($skillPoints)) {
240 $assignment->setQuestionId($questionId);
241 $assignment->setSkillBaseId($skillBaseId);
242 $assignment->setSkillTrefId($skillTrefId);
244 if ($assignment->dbRecordExists()) {
245 $assignment->loadFromDb();
247 if (!$assignment->hasEvalModeBySolution()) {
248 $assignment->setSkillPoints((
int) $skillPoints);
249 $assignment->saveToDb();
261 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'tst_msg_skl_qst_assign_points_saved'),
true);
262 $this->
ctrl->redirect($this, self::CMD_SHOW_SKILL_QUEST_ASSIGNS);
264 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'tst_msg_skl_qst_assign_points_not_saved'));
271 $questionId = (
int) $this->request->raw(
'question_id');
276 $assignmentList->loadFromDb();
278 $handledSkills = array();
282 $skillIds = $sgui->getSelectedSkills();
284 foreach ($skillIds as $skillId) {
285 $skill = explode(
':', $skillId);
286 $skillBaseId = (
int) $skill[0];
287 $skillTrefId = (
int) $skill[1];
290 if (!$assignmentList->isAssignedToQuestionId($skillBaseId, $skillTrefId, $questionId)) {
294 $assignment->setQuestionId($questionId);
295 $assignment->setSkillBaseId($skillBaseId);
296 $assignment->setSkillTrefId($skillTrefId);
300 $assignment->saveToDb();
306 $handledSkills[$skillId] = $skill;
310 foreach ($assignmentList->getAssignmentsByQuestionId($questionId) as $assignment) {
311 if (isset($handledSkills[
"{$assignment->getSkillBaseId()}:{$assignment->getSkillTrefId()}"])) {
315 $assignment->deleteFromDb();
318 if (!$assignment->isSkillUsed()) {
319 $this->skillUsageService->removeUsage(
320 $assignment->getParentObjId(),
321 $assignment->getSkillBaseId(),
322 $assignment->getSkillTrefId()
327 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'qpl_qst_skl_assigns_updated'),
true);
331 $this->
ctrl->redirect($this, self::CMD_SHOW_SYNC_ORIGINAL_CONFIRMATION);
335 $this->
ctrl->redirect($this, self::CMD_SHOW_SKILL_QUEST_ASSIGNS);
340 $this->
ctrl->saveParameter($this,
'question_id');
341 $questionId = (
int) $this->request->raw(
'question_id');
345 $assignmentList->loadFromDb();
348 $assignmentList->getAssignmentsByQuestionId($questionId)
351 if (!$skillSelectorExplorerGUI->handleCommand()) {
352 $tpl =
new ilTemplate(
'tpl.qpl_qst_skl_assign_selection.html',
false,
false,
'Modules/TestQuestionPool');
358 $skillSelectorToolbarGUI->setOpenFormTag(
true);
359 $skillSelectorToolbarGUI->setCloseFormTag(
false);
361 $tpl->
setVariable(
'SKILL_SELECTOR_TOOLBAR_TOP', $this->
ctrl->getHTML($skillSelectorToolbarGUI));
363 $tpl->
setVariable(
'SKILL_SELECTOR_EXPLORER', $this->
ctrl->getHTML($skillSelectorExplorerGUI));
365 $skillSelectorToolbarGUI->setOpenFormTag(
false);
366 $skillSelectorToolbarGUI->setCloseFormTag(
true);
367 $skillSelectorToolbarGUI->setLeadingImage(
ilUtil::getImagePath(
"nav/arrow_downright.svg"),
" ");
368 $tpl->
setVariable(
'SKILL_SELECTOR_TOOLBAR_BOTTOM', $this->
ctrl->getHTML($skillSelectorToolbarGUI));
370 $this->tpl->setContent($tpl->
get());
383 if ($questionGUI === null) {
387 if ($assignment === null) {
389 (
int) $this->request->raw(
'question_id'),
390 (
int) $this->request->raw(
'skill_base_id'),
391 (
int) $this->request->raw(
'skill_tref_id')
395 if ($form === null) {
401 $this->tpl->setContent($this->
ctrl->getHTML($form) .
'<br />' . $questionPageHTML);
406 $questionId = (
int) $this->request->raw(
'question_id');
412 (
int) $this->request->raw(
'question_id'),
413 (
int) $this->request->raw(
'skill_base_id'),
414 (
int) $this->request->raw(
'skill_tref_id')
419 if (!$form->checkInput()) {
420 $form->setValuesByPost();
424 $form->setValuesByPost();
426 if ($form->getItemByPostVar(
'eval_mode')) {
427 $assignment->setEvalMode($form->getItemByPostVar(
'eval_mode')->getValue());
432 if ($assignment->hasEvalModeBySolution()) {
433 $solCmpExprInput = $form->getItemByPostVar(
'solution_compare_expressions');
436 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"form_input_not_valid"));
441 $assignment->initSolutionComparisonExpressionList();
442 $assignment->getSolutionComparisonExpressionList()->reset();
444 foreach ($solCmpExprInput->getValues() as $expression) {
445 $assignment->getSolutionComparisonExpressionList()->add($expression);
448 $assignment->setSkillPoints($form->getItemByPostVar(
'q_res_skill_points')->getValue());
451 $assignment->saveToDb();
454 $this->skillUsageService->addUsage(
456 (
int) $this->request->raw(
'skill_base_id'),
457 (
int) $this->request->raw(
'skill_tref_id')
460 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'qpl_qst_skl_assign_properties_modified'),
true);
463 $this->
ctrl->redirect($this, self::CMD_SHOW_SYNC_ORIGINAL_CONFIRMATION);
467 $this->
ctrl->redirect($this, self::CMD_SHOW_SKILL_QUEST_ASSIGNS);
474 $form->setQuestion($question);
475 $form->setAssignment($assignment);
488 $table->loadSkillPointsFromRequest($loadSkillPointsFromRequest);
491 $assignmentList->loadFromDb();
492 $assignmentList->loadAdditionalSkillData();
493 $table->setSkillQuestionAssignmentList($assignmentList);
494 $table->setData($this->
orderQuestionData($this->questionList->getQuestionDataArray()));
496 $this->tpl->setContent($this->
ctrl->getHTML($table));
501 $questionData = $this->questionList->getDataArrayForQuestionId($questionId);
503 if (!$questionData[
'original_id']) {
514 if ($this->
access->checkAccess(
'write',
'', $parentRefId)) {
524 $questionId = (
int) $this->request->raw(
'question_id');
528 $confirmation->setHeaderText($this->
lng->txt(
'qpl_sync_quest_skl_assigns_confirmation'));
530 $confirmation->setFormAction($this->
ctrl->getFormAction($this));
531 $confirmation->addHiddenItem(
'question_id', $questionId);
532 $confirmation->setConfirm($this->
lng->txt(
'yes'), self::CMD_SYNC_ORIGINAL);
533 $confirmation->setCancel($this->
lng->txt(
'no'), self::CMD_SHOW_SKILL_QUEST_ASSIGNS);
535 $this->tpl->setContent($this->
ctrl->getHTML($confirmation));
540 $questionId = (
int) $_POST[
'question_id'];
545 $question->syncSkillAssignments(
546 $question->getObjId(),
548 $question->lookupParentObjId($question->getOriginalId()),
549 $question->getOriginalId()
552 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'qpl_qst_skl_assign_synced_to_orig'),
true);
555 $this->
ctrl->redirect($this, self::CMD_SHOW_SKILL_QUEST_ASSIGNS);
572 return $assignmentList;
582 self::CMD_SHOW_SKILL_SELECT,
584 self::CMD_UPDATE_SKILL_QUEST_ASSIGNS,
585 self::PARAM_SKILL_SELECTION
588 $skillSelectorExplorerGUI->setSelectMode(self::PARAM_SKILL_SELECTION,
true);
594 foreach ($assignments as $assignment) {
595 $id =
"{$assignment->getSkillBaseId()}:{$assignment->getSkillTrefId()}";
597 $skillSelectorExplorerGUI->setSkillSelected(
$id);
600 return $skillSelectorExplorerGUI;
610 $skillSelectorToolbarGUI->setFormAction($this->
ctrl->getFormAction($this));
611 $skillSelectorToolbarGUI->addFormButton($this->
lng->txt(
'qpl_save_skill_assigns_update'), self::CMD_UPDATE_SKILL_QUEST_ASSIGNS);
612 $skillSelectorToolbarGUI->addFormButton($this->
lng->txt(
'qpl_cancel_skill_assigns_update'), self::CMD_SHOW_SKILL_QUEST_ASSIGNS);
614 return $skillSelectorToolbarGUI;
619 $this->tpl->addCss(
'Services/COPage/css/content.css');
624 $pageGUI->setRenderPageContainer(
true);
626 $pageGUI->setPresentationTitle($questionGUI->object->getTitle());
628 $questionGUI->object->setShuffle(
false);
629 $questionHTML = $questionGUI->
getSolutionOutput(0, 0,
false,
false,
true,
false,
true,
false,
true);
630 $pageGUI->setQuestionHTML(array($questionGUI->object->getId() => $questionHTML));
632 $pageHTML = $pageGUI->presentation();
633 $pageHTML = preg_replace(
"/src=\"\\.\\//ims",
"src=\"" . ILIAS_HTTP_PATH .
"/", $pageHTML);
646 $assignment->setQuestionId($questionId);
647 $assignment->setSkillBaseId($skillBaseId);
648 $assignment->setSkillTrefId($skillTrefId);
650 $assignment->loadFromDb();
651 $assignment->loadAdditionalSkillData();
658 return $this->questionList->isInList($questionId);
665 foreach ($input->getValues() as $expression) {
668 if ($result !==
true) {
669 $errors[] =
"{$this->lng->txt('ass_lac_expression')} {$expression->getOrderIndex()}: {$result}";
673 if (count($errors)) {
674 $alert = $this->
lng->txt(
'ass_lac_validation_error');
675 $alert .=
'<br />' . implode(
'<br />', $errors);
676 $input->setAlert($alert);
687 $conditionComposite = $conditionParser->parse($expression->
getExpression());
689 $questionProvider->setQuestion($question);
691 $conditionValidator->validate($conditionComposite);
694 return $e->getFormAlert($this->
lng);
705 $this->
ctrl->saveParameter($this,
'question_id');
706 $this->
ctrl->saveParameter($this,
'skill_base_id');
707 $this->
ctrl->saveParameter($this,
'skill_tref_id');
712 $orderedQuestionsData = array();
716 $orderedQuestionsData[$questionId] = $questionData[$questionId];
719 return $orderedQuestionsData;
722 foreach ($questionData as $questionId =>
$data) {
723 $orderedQuestionsData[$questionId] =
$data[
'title'];
728 foreach ($orderedQuestionsData as $questionId => $questionTitle) {
729 $orderedQuestionsData[$questionId] = $questionData[$questionId];
732 return $orderedQuestionsData;
744 $questionData = $this->questionList->getDataArrayForQuestionId($questionId);
746 return sprintf($this->
lng->txt(
'qpl_qst_skl_selection_for_question_header'), $questionData[
'title']);
751 $flags = SORT_REGULAR;
753 if (defined(
'SORT_NATURAL')) {
754 $flags = SORT_NATURAL;
755 } elseif (defined(
'SORT_STRING')) {
756 $flags = SORT_STRING;
759 if (defined(
'SORT_FLAG_CASE')) {
760 $flags = $flags | SORT_FLAG_CASE;
763 asort($array, $flags);
const CMD_UPDATE_SKILL_QUEST_ASSIGNS
const CMD_SHOW_SKILL_SELECT
setAssignmentConfigurationHintMessage($assignmentConfigurationHintMessage)
sortAlphabetically($array)
setQuestionContainerId($questionContainerId)
const PARAM_SKILL_SELECTION
saveSkillQuestionAssignmentPropertiesFormCmd()
setOutputMode(string $a_mode=self::PRESENTATION)
keepAssignmentParameters()
Abstract basic class which is to be extended by the concrete assessment question type classes...
isSyncOriginalPossibleAndAllowed($questionId)
doesObjectTypeMatch($objectId)
static _getAllReferences(int $id)
get all reference ids for object ID
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
isAssignmentEditingEnabled()
setAssignmentEditingEnabled($assignmentEditingEnabled)
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.
getSkillSelectorHeader($questionId)
static lookupParentObjId(int $questionId)
$assignmentConfigurationHintMessage
showSyncOriginalConfirmationCmd()
const CMD_SAVE_SKILL_QUEST_ASSIGN_PROPERTIES_FORM
SkillUsageService $skillUsageService
setVariable(string $variable, $value='')
Sets the given variable to the given value.
$assignmentEditingEnabled
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.
buildSkillQuestionAssignmentPropertiesForm(assQuestion $question, ilAssQuestionSkillAssignment $assignment)
showSkillQuestionAssignmentsCmd($loadSkillPointsFromRequest=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static instantiateQuestion(int $question_id)
buildQuestionSkillAssignment($questionId, $skillBaseId, $skillTrefId)
setQuestionList($questionList)
setQuestionOrderSequence($questionOrderSequence)
ilGlobalTemplateInterface $tpl
Basic GUI class for assessment questions.
__construct(ilCtrl $ctrl, ilAccessHandler $access, ilGlobalTemplateInterface $tpl, ilLanguage $lng, ilDBInterface $db)
getAssignmentConfigurationHintMessage()
getQuestionOrderSequence()
ILIAS TestQuestionPool InternalRequestService $request
checkSolutionCompareExpressionInput($input, assQuestion $question)
isAvoidManipulationRedirectRequired($command)
Explorer class that works on tree objects (Services/Tree)
const DEFAULT_COMPETENCE_POINTS
getSolutionOutput( $active_id, $pass=null, $graphicalOutput=false, $result_output=false, $show_question_only=true, $show_feedback=false, $show_correct_solution=false, $show_manual_scoring=false, $show_question_text=true)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
buildSkillSelectorExplorerGUI($assignments)
buildSkillSelectorToolbarGUI()
isTestQuestion($questionId)
showSkillQuestionAssignmentPropertiesFormCmd(assQuestionGUI $questionGUI=null, ilAssQuestionSkillAssignment $assignment=null, ilPropertyFormGUI $form=null)
const CMD_SHOW_SYNC_ORIGINAL_CONFIRMATION
static _lookupType(int $id, bool $reference=false)
buildSkillQuestionAssignmentList()
const EVAL_MODE_BY_QUESTION_RESULT
handleAssignmentConfigurationHintMessage()
updateSkillQuestionAssignmentsCmd()
const CMD_SHOW_SKILL_QUEST_ASSIGNS
orderQuestionData($questionData)
buildQuestionPage(assQuestionGUI $questionGUI)
const CMD_SHOW_SKILL_QUEST_ASSIGN_PROPERTIES_FORM