Beispiel #1
0
 /**
  * Mark answer as correct
  *
  * @return bool
  */
 public function markCorrect()
 {
     if (questions_close_on_marked_answer()) {
         $this->getQuestion()->setStatus('closed');
     }
     return add_entity_relationship($this->getQuestion()->guid, "correctAnswer", $this->guid);
 }
Beispiel #2
0
 /**
  * Get the current status of the question.
  *
  * This can be
  * - 'open'
  * - 'closed'
  *
  * @return string the current status
  */
 public function getStatus()
 {
     $result = 'open';
     // do we even support status
     if (questions_close_on_marked_answer()) {
         // make sure the status is correct
         switch ($this->status) {
             case 'open':
                 // is it still open, so no marked answer
                 if ($this->getMarkedAnswer()) {
                     $result = 'closed';
                 }
                 break;
             case 'closed':
                 $result = 'closed';
                 // is it still open, so no marked answer
                 if (!$this->getMarkedAnswer()) {
                     $result = 'open';
                 }
                 break;
             default:
                 // no setting yet
                 if ($this->getMarkedAnswer()) {
                     $result = 'closed';
                 }
                 break;
         }
     }
     return $result;
 }
Beispiel #3
0
 /**
  * Mark an answer as the correct answer for this question
  */
 public function markAsCorrect()
 {
     // first set the mark
     $this->correct_answer = true;
     // depending of the plugin settings, we also need to close the question
     if (questions_close_on_marked_answer()) {
         $question = $this->getContainerEntity();
         $question->close();
     }
 }
Beispiel #4
0
 /**
  * Mark an answer as the correct answer for this question
  *
  * @return void
  */
 public function markAsCorrect()
 {
     // first set the mark
     $this->correct_answer = true;
     // trigger event for notifications
     elgg_trigger_event('correct', 'object', $this);
     // depending of the plugin settings, we also need to close the question
     if (questions_close_on_marked_answer()) {
         $question = $this->getContainerEntity();
         $question->close();
     }
 }