/** * Constructor * * @access public * @param assQuestion $questionOBJ * @param ilCtrl $ctrl * @param ilTabsGUI $tabs * @param ilLanguage $lng */ public function __construct(assQuestion $questionOBJ, ilCtrl $ctrl, ilTabsGUI $tabs, ilLanguage $lng) { parent::__construct($questionOBJ, $ctrl, $tabs, $lng); $this->questionHint = new ilAssQuestionHint(); if (!isset($_GET['hint_id']) || !(int) $_GET['hint_id'] || !$this->questionHint->load((int) $_GET['hint_id'])) { ilUtil::sendFailure('invalid hint id given: ' . (int) $_GET['hint_id'], true); $this->ctrl->redirectByClass('ilAssQuestionHintsGUI', ilAssQuestionHintsGUI::CMD_SHOW_LIST); } }
/** * saves the form on successfull validation and redirects to showForm command * * @access private * @global ilCtrl $ilCtrl * @global ilLanguage $lng */ private function saveFormCmd() { global $ilCtrl, $lng; $form = $this->buildForm(); if ($form->checkInput()) { $questionHint = new ilAssQuestionHint(); if ((int) $form->getInput('hint_id')) { $questionHint->load((int) $form->getInput('hint_id')); } else { $questionHint->setQuestionId($this->questionOBJ->getId()); $questionHint->setIndex(ilAssQuestionHintList::getNextIndexByQuestionId($this->questionOBJ->getId())); } $questionHint->setText($form->getInput('hint_text')); $questionHint->setPoints($form->getInput('hint_points')); $questionHint->save(); ilUtil::sendSuccess($lng->txt('tst_question_hints_form_saved_msg'), true); $ilCtrl->redirectByClass('ilAssQuestionHintsGUI', ilAssQuestionHintsGUI::CMD_SHOW_LIST); } ilUtil::sendFailure($lng->txt('tst_question_hints_form_invalid_msg')); $this->showFormCmd($form); }
/** * saves the form on successfull validation and redirects to showForm command * * @access private * @global ilCtrl $ilCtrl * @global ilLanguage $lng */ private function saveFormCmd() { global $ilCtrl, $lng, $ilUser; $form = $this->buildForm(); if ($form->checkInput()) { $questionHint = new ilAssQuestionHint(); if ((int) $form->getInput('hint_id')) { $questionHint->load((int) $form->getInput('hint_id')); $hintJustCreated = false; } else { $questionHint->setQuestionId($this->questionOBJ->getId()); $questionHint->setIndex(ilAssQuestionHintList::getNextIndexByQuestionId($this->questionOBJ->getId())); $hintJustCreated = true; } $questionHint->setText($form->getInput('hint_text')); $questionHint->setPoints($form->getInput('hint_points')); $questionHint->save(); ilUtil::sendSuccess($lng->txt('tst_question_hints_form_saved_msg'), true); $originalexists = $this->questionOBJ->_questionExistsInPool($this->questionOBJ->original_id); include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php"; if ($_GET["calling_test"] && $originalexists && assQuestion::_isWriteable($this->questionOBJ->original_id, $ilUser->getId())) { $ilCtrl->redirectByClass('ilAssQuestionHintsGUI', ilAssQuestionHintsGUI::CMD_CONFIRM_SYNC); } if ($hintJustCreated && $this->questionOBJ->isAdditionalContentEditingModePageObject()) { $ilCtrl->setParameterByClass('ilasshintpagegui', 'hint_id', $questionHint->getId()); $ilCtrl->redirectByClass('ilasshintpagegui', 'edit'); } else { $ilCtrl->redirectByClass('ilAssQuestionHintsGUI', ilAssQuestionHintsGUI::CMD_SHOW_LIST); } } ilUtil::sendFailure($lng->txt('tst_question_hints_form_invalid_msg')); $this->showFormCmd($form); }
/** * saves the form on successfull validation and redirects to showForm command * * @access private * @global ilCtrl $ilCtrl * @global ilLanguage $lng */ private function saveFormCmd() { global $ilCtrl, $lng; $form = $this->buildForm(); if ($form->checkInput()) { $questionHint = new ilAssQuestionHint(); if ((int) $form->getInput('hint_id')) { $questionHint->load((int) $form->getInput('hint_id')); $hintJustCreated = false; } else { $questionHint->setQuestionId($this->questionOBJ->getId()); $questionHint->setIndex(ilAssQuestionHintList::getNextIndexByQuestionId($this->questionOBJ->getId())); $hintJustCreated = true; } $questionHint->setText($form->getInput('hint_text')); $questionHint->setPoints($form->getInput('hint_points')); $questionHint->save(); ilUtil::sendSuccess($lng->txt('tst_question_hints_form_saved_msg'), true); if ($hintJustCreated && $this->questionOBJ->isAdditionalContentEditingModePageObject()) { $ilCtrl->setParameterByClass('ilasshintpagegui', 'hint_id', $questionHint->getId()); $ilCtrl->redirectByClass('ilasshintpagegui', 'edit'); } else { $ilCtrl->redirectByClass('ilAssQuestionHintsGUI', ilAssQuestionHintsGUI::CMD_SHOW_LIST); } } ilUtil::sendFailure($lng->txt('tst_question_hints_form_invalid_msg')); $this->showFormCmd($form); }