public function getNextRequestableHint()
 {
     $query = "\n\t\t\tSELECT\t\tqht_hint_id\n\t\t\t\n\t\t\tFROM\t\tqpl_hints\n\t\t\t\n\t\t\tWHERE\t\tqht_question_fi = %s\n\t\t\t\n\t\t\tORDER BY\tqht_hint_index ASC\n\t\t";
     $res = $this->db->queryF($query, array('integer'), array($this->previewSession->getQuestionId()));
     while ($row = $this->db->fetchAssoc($res)) {
         if (!$this->isRequested($row['qht_hint_id'])) {
             return ilAssQuestionHint::getInstanceById($row['qht_hint_id']);
         }
     }
     throw new ilTestException("no next hint found for questionId={$this->previewSession->getQuestionId()}, userId={$this->previewSession->getUserId()}");
 }
 /**
  * inits the notification telling the user,
  * that a hint is stored to hint ordering clipboard
  * 
  * @access	private
  * @global	ilLanguage	$lng
  */
 private function initHintOrderingClipboardNotification()
 {
     global $lng;
     if (!$this->hintOrderingClipboard->hasStored()) {
         return;
     }
     $questionHint = ilAssQuestionHint::getInstanceById($this->hintOrderingClipboard->getStored());
     ilUtil::sendInfo(sprintf($lng->txt('tst_question_hints_item_stored_in_ordering_clipboard'), $questionHint->getIndex()));
 }
 /**
  * Returns the next requestable hint for given question
  * relating to given testactive and testpass
  *
  * @access	public
  * @global	ilDB				$ilDB
  * @return	ilAssQuestionHint	$nextRequestableHint
  * @throws	ilTestException
  */
 public function getNextRequestableHint()
 {
     global $ilDB;
     $query = "\n\t\t\tSELECT\t\tqht_hint_id\n\t\t\t\n\t\t\tFROM\t\tqpl_hints\n\t\t\t\n\t\t\tLEFT JOIN\tqpl_hint_tracking\n\t\t\tON\t\t\tqhtr_hint_fi = qht_hint_id\n\t\t\tAND\t\t\tqhtr_active_fi = %s\n\t\t\tAND\t\t\tqhtr_pass = %s\n\t\t\t\n\t\t\tWHERE\t\tqht_question_fi = %s\n\t\t\tAND\t\t\tqhtr_track_id IS NULL\n\t\t\t\n\t\t\tORDER BY\tqht_hint_index ASC\n\t\t";
     $ilDB->setLimit(1);
     $res = $ilDB->queryF($query, array('integer', 'integer', 'integer'), array($this->getActiveId(), $this->getPass(), $this->getQuestionId()));
     while ($row = $ilDB->fetchAssoc($res)) {
         $nextHint = ilAssQuestionHint::getInstanceById($row['qht_hint_id']);
         return $nextHint;
     }
     throw new ilTestException("no next hint found for questionId={$this->getQuestionId()}, activeId={$this->getActiveId()}, pass={$this->getPass()}");
 }
 /**
  * shows an allready requested hint
  * 
  * @access	private
  * @global	ilCtrl $ilCtrl
  * @global	ilTemplate $tpl
  * @global	ilLanguage $lng
  */
 private function showHintCmd()
 {
     global $ilCtrl, $tpl, $lng;
     if (!isset($_GET['hintId']) || !(int) $_GET['hintId']) {
         throw new ilTestException('no hint id given');
     }
     $isRequested = $this->questionHintTracking->isRequested((int) $_GET['hintId']);
     if (!$isRequested) {
         throw new ilTestException('hint with given id is not yet requested for given testactive and testpass');
     }
     $questionHint = ilAssQuestionHint::getInstanceById((int) $_GET['hintId']);
     require_once 'Services/Utilities/classes/class.ilUtil.php';
     require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
     require_once 'Services/Form/classes/class.ilNonEditableValueGUI.php';
     // build form
     $form = new ilPropertyFormGUI();
     $form->setFormAction($ilCtrl->getFormAction($this));
     $form->setTableWidth('100%');
     $form->setTitle(sprintf($lng->txt('tst_question_hints_form_header_edit'), $questionHint->getIndex(), $this->questionOBJ->getTitle()));
     $form->addCommandButton(self::CMD_BACK_TO_QUESTION, $lng->txt('tst_question_hints_back_to_question'));
     $numExistingRequests = $this->questionHintTracking->getNumExistingRequests();
     if ($numExistingRequests > 1) {
         $form->addCommandButton(self::CMD_SHOW_LIST, $lng->txt('button_show_requested_question_hints'));
     }
     // form input: hint text
     $nonEditableHintText = new ilNonEditableValueGUI($lng->txt('tst_question_hints_form_label_hint_text'), 'hint_text', true);
     $nonEditableHintText->setValue(ilUtil::prepareTextareaOutput($questionHint->getText(), true));
     $form->addItem($nonEditableHintText);
     // form input: hint points
     $nonEditableHintPoints = new ilNonEditableValueGUI($lng->txt('tst_question_hints_form_label_hint_points'), 'hint_points');
     $nonEditableHintPoints->setValue($questionHint->getPoints());
     $form->addItem($nonEditableHintPoints);
     $this->populateContent($ilCtrl->getHtml($form));
 }