77 private \ILIAS\TestQuestionPool\InternalRequestService
$request;
94 $this->request = $DIC->testQuestionPool()->internal()->request();
173 $nextClass = $this->
ctrl->getNextClass();
175 $command = $this->
ctrl->getCmd(self::CMD_SHOW_SKILL_QUEST_ASSIGNS);
178 $this->
ctrl->redirect($this, self::CMD_SHOW_SKILL_QUEST_ASSIGNS);
181 switch ($nextClass) {
182 case strtolower(__CLASS__):
202 case self::CMD_SAVE_SKILL_QUEST_ASSIGN_PROPERTIES_FORM:
203 case self::CMD_UPDATE_SKILL_QUEST_ASSIGNS:
215 if (is_array($_POST[
'skill_points'])) {
216 for (
$i = 0;
$i < 2;
$i++) {
217 foreach ($_POST[
'skill_points'] as $assignmentKey => $skillPoints) {
218 $assignmentKey = explode(
':', $assignmentKey);
219 $skillBaseId = (
int) $assignmentKey[0];
220 $skillTrefId = (
int) $assignmentKey[1];
221 $questionId = (
int) $assignmentKey[2];
227 if (!$assignment->isValidSkillPoint($skillPoints)) {
235 $assignment->setQuestionId($questionId);
236 $assignment->setSkillBaseId($skillBaseId);
237 $assignment->setSkillTrefId($skillTrefId);
239 if ($assignment->dbRecordExists()) {
240 $assignment->loadFromDb();
242 if (!$assignment->hasEvalModeBySolution()) {
243 $assignment->setSkillPoints((
int) $skillPoints);
244 $assignment->saveToDb();
256 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'tst_msg_skl_qst_assign_points_saved'),
true);
257 $this->
ctrl->redirect($this, self::CMD_SHOW_SKILL_QUEST_ASSIGNS);
259 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'tst_msg_skl_qst_assign_points_not_saved'));
266 $questionId = (
int) $this->request->raw(
'question_id');
271 $assignmentList->loadFromDb();
273 $handledSkills = array();
277 $skillIds = $sgui->getSelectedSkills();
279 foreach ($skillIds as $skillId) {
280 $skill = explode(
':', $skillId);
281 $skillBaseId = (
int) $skill[0];
282 $skillTrefId = (
int) $skill[1];
285 if (!$assignmentList->isAssignedToQuestionId($skillBaseId, $skillTrefId, $questionId)) {
289 $assignment->setQuestionId($questionId);
290 $assignment->setSkillBaseId($skillBaseId);
291 $assignment->setSkillTrefId($skillTrefId);
295 $assignment->saveToDb();
301 $handledSkills[$skillId] = $skill;
305 foreach ($assignmentList->getAssignmentsByQuestionId($questionId) as $assignment) {
306 if (isset($handledSkills[
"{$assignment->getSkillBaseId()}:{$assignment->getSkillTrefId()}"])) {
310 $assignment->deleteFromDb();
313 if (!$assignment->isSkillUsed()) {
315 $assignment->getParentObjId(),
316 $assignment->getSkillBaseId(),
317 $assignment->getSkillTrefId(),
323 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'qpl_qst_skl_assigns_updated'),
true);
327 $this->
ctrl->redirect($this, self::CMD_SHOW_SYNC_ORIGINAL_CONFIRMATION);
331 $this->
ctrl->redirect($this, self::CMD_SHOW_SKILL_QUEST_ASSIGNS);
336 $this->
ctrl->saveParameter($this,
'question_id');
337 $questionId = (
int) $this->request->raw(
'question_id');
341 $assignmentList->loadFromDb();
344 $assignmentList->getAssignmentsByQuestionId($questionId)
347 if (!$skillSelectorExplorerGUI->handleCommand()) {
348 $tpl =
new ilTemplate(
'tpl.qpl_qst_skl_assign_selection.html',
false,
false,
'Modules/TestQuestionPool');
354 $skillSelectorToolbarGUI->setOpenFormTag(
true);
355 $skillSelectorToolbarGUI->setCloseFormTag(
false);
357 $tpl->
setVariable(
'SKILL_SELECTOR_TOOLBAR_TOP', $this->
ctrl->getHTML($skillSelectorToolbarGUI));
359 $tpl->
setVariable(
'SKILL_SELECTOR_EXPLORER', $this->
ctrl->getHTML($skillSelectorExplorerGUI));
361 $skillSelectorToolbarGUI->setOpenFormTag(
false);
362 $skillSelectorToolbarGUI->setCloseFormTag(
true);
364 $tpl->
setVariable(
'SKILL_SELECTOR_TOOLBAR_BOTTOM', $this->
ctrl->getHTML($skillSelectorToolbarGUI));
366 $this->tpl->setContent($tpl->
get());
379 if ($questionGUI === null) {
383 if ($assignment === null) {
385 (
int) $this->request->raw(
'question_id'),
386 (
int) $this->request->raw(
'skill_base_id'),
387 (
int) $this->request->raw(
'skill_tref_id')
391 if ($form === null) {
397 $this->tpl->setContent($this->
ctrl->getHTML($form) .
'<br />' . $questionPageHTML);
402 $questionId = (
int) $this->request->raw(
'question_id');
408 (
int) $this->request->raw(
'question_id'),
409 (
int) $this->request->raw(
'skill_base_id'),
410 (
int) $this->request->raw(
'skill_tref_id')
415 if (!$form->checkInput()) {
416 $form->setValuesByPost();
420 $form->setValuesByPost();
422 if ($form->getItemByPostVar(
'eval_mode')) {
423 $assignment->setEvalMode($form->getItemByPostVar(
'eval_mode')->getValue());
428 if ($assignment->hasEvalModeBySolution()) {
429 $solCmpExprInput = $form->getItemByPostVar(
'solution_compare_expressions');
432 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"form_input_not_valid"));
437 $assignment->initSolutionComparisonExpressionList();
438 $assignment->getSolutionComparisonExpressionList()->reset();
440 foreach ($solCmpExprInput->getValues() as $expression) {
441 $assignment->getSolutionComparisonExpressionList()->add($expression);
444 $assignment->setSkillPoints($form->getItemByPostVar(
'q_res_skill_points')->getValue());
447 $assignment->saveToDb();
452 (
int) $this->request->raw(
'skill_base_id'),
453 (
int) $this->request->raw(
'skill_tref_id')
456 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'qpl_qst_skl_assign_properties_modified'),
true);
459 $this->
ctrl->redirect($this, self::CMD_SHOW_SYNC_ORIGINAL_CONFIRMATION);
463 $this->
ctrl->redirect($this, self::CMD_SHOW_SKILL_QUEST_ASSIGNS);
470 $form->setQuestion($question);
471 $form->setAssignment($assignment);
484 $table->loadSkillPointsFromRequest($loadSkillPointsFromRequest);
487 $assignmentList->loadFromDb();
488 $assignmentList->loadAdditionalSkillData();
489 $table->setSkillQuestionAssignmentList($assignmentList);
490 $table->setData($this->
orderQuestionData($this->questionList->getQuestionDataArray()));
492 $this->tpl->setContent($this->
ctrl->getHTML($table));
497 $questionData = $this->questionList->getDataArrayForQuestionId($questionId);
499 if (!$questionData[
'original_id']) {
510 if ($this->
access->checkAccess(
'write',
'', $parentRefId)) {
520 $questionId = (
int) $this->request->raw(
'question_id');
524 $confirmation->setHeaderText($this->
lng->txt(
'qpl_sync_quest_skl_assigns_confirmation'));
526 $confirmation->setFormAction($this->
ctrl->getFormAction($this));
527 $confirmation->addHiddenItem(
'question_id', $questionId);
528 $confirmation->setConfirm($this->
lng->txt(
'yes'), self::CMD_SYNC_ORIGINAL);
529 $confirmation->setCancel($this->
lng->txt(
'no'), self::CMD_SHOW_SKILL_QUEST_ASSIGNS);
531 $this->tpl->setContent($this->
ctrl->getHTML($confirmation));
536 $questionId = (
int) $_POST[
'question_id'];
541 $question->syncSkillAssignments(
542 $question->getObjId(),
544 $question->lookupParentObjId($question->getOriginalId()),
545 $question->getOriginalId()
548 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'qpl_qst_skl_assign_synced_to_orig'),
true);
551 $this->
ctrl->redirect($this, self::CMD_SHOW_SKILL_QUEST_ASSIGNS);
568 return $assignmentList;
578 self::CMD_SHOW_SKILL_SELECT,
580 self::CMD_UPDATE_SKILL_QUEST_ASSIGNS,
581 self::PARAM_SKILL_SELECTION
584 $skillSelectorExplorerGUI->setSelectMode(self::PARAM_SKILL_SELECTION,
true);
590 foreach ($assignments as $assignment) {
591 $id =
"{$assignment->getSkillBaseId()}:{$assignment->getSkillTrefId()}";
593 $skillSelectorExplorerGUI->setSkillSelected(
$id);
596 return $skillSelectorExplorerGUI;
606 $skillSelectorToolbarGUI->setFormAction($this->
ctrl->getFormAction($this));
607 $skillSelectorToolbarGUI->addFormButton($this->
lng->txt(
'qpl_save_skill_assigns_update'), self::CMD_UPDATE_SKILL_QUEST_ASSIGNS);
608 $skillSelectorToolbarGUI->addFormButton($this->
lng->txt(
'qpl_cancel_skill_assigns_update'), self::CMD_SHOW_SKILL_QUEST_ASSIGNS);
610 return $skillSelectorToolbarGUI;
615 $this->tpl->addCss(
'Services/COPage/css/content.css');
620 $pageGUI->setRenderPageContainer(
true);
622 $pageGUI->setPresentationTitle($questionGUI->object->getTitleForHTMLOutput());
624 $questionGUI->object->setShuffle(
false);
625 $questionHTML = $questionGUI->
getSolutionOutput(0, 0,
false,
false,
true,
false,
true,
false,
true);
626 $pageGUI->setQuestionHTML(array($questionGUI->object->getId() => $questionHTML));
628 $pageHTML = $pageGUI->presentation();
629 $pageHTML = preg_replace(
"/src=\"\\.\\//ims",
"src=\"" . ILIAS_HTTP_PATH .
"/", $pageHTML);
642 $assignment->setQuestionId($questionId);
643 $assignment->setSkillBaseId($skillBaseId);
644 $assignment->setSkillTrefId($skillTrefId);
646 $assignment->loadFromDb();
647 $assignment->loadAdditionalSkillData();
654 return $this->questionList->isInList($questionId);
661 foreach ($input->getValues() as $expression) {
664 if ($result !==
true) {
665 $errors[] =
"{$this->lng->txt('ass_lac_expression')} {$expression->getOrderIndex()}: {$result}";
670 $alert = $this->
lng->txt(
'ass_lac_validation_error');
671 $alert .=
'<br />' . implode(
'<br />',
$errors);
672 $input->setAlert($alert);
683 $conditionComposite = $conditionParser->parse($expression->
getExpression());
685 $questionProvider->setQuestion($question);
687 $conditionValidator->validate($conditionComposite);
690 return $e->getFormAlert($this->
lng);
701 $this->
ctrl->saveParameter($this,
'question_id');
702 $this->
ctrl->saveParameter($this,
'skill_base_id');
703 $this->
ctrl->saveParameter($this,
'skill_tref_id');
708 $orderedQuestionsData = array();
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->questionList->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);
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()
static setUsage(int $a_obj_id, int $a_skill_id, int $a_tref_id, bool $a_use=true)
const CMD_SAVE_SKILL_QUEST_ASSIGN_PROPERTIES_FORM
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...
buildQuestionSkillAssignment($questionId, $skillBaseId, $skillTrefId)
setQuestionList($questionList)
setQuestionOrderSequence($questionOrderSequence)
ilGlobalTemplateInterface $tpl
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__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)
static _instantiateQuestion(int $question_id)
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
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...