/**
  * 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);
 }
예제 #4
0
 /**
  * assigns the field elements of passed hint db row array to the
  * corresponding hint object properties of passed hint object instance
  *
  * @access	public
  * @static
  * @param	self	$questionHint
  * @param	array	$hintDbRow
  */
 public static function assignDbRow(self $questionHint, $hintDbRow)
 {
     foreach ($hintDbRow as $field => $value) {
         switch ($field) {
             case 'qht_hint_id':
                 $questionHint->setId($value);
                 break;
             case 'qht_question_fi':
                 $questionHint->setQuestionId($value);
                 break;
             case 'qht_hint_index':
                 $questionHint->setIndex($value);
                 break;
             case 'qht_hint_points':
                 $questionHint->setPoints($value);
                 break;
             case 'qht_hint_text':
                 $questionHint->setText($value);
                 break;
             default:
                 throw new ilTestQuestionPoolException("invalid db field identifier ({$field}) given!");
         }
     }
 }