Esempio n. 1
0
 /**
  * Builds a title for a question in format question x of n.
  *
  * @param \Drupal\quiz\QuestionInterface $question
  * @return string
  *  Returns title string.
  */
 public function addAnswerTitle(QuestionInterface $question)
 {
     $storage = static::entityTypeManager()->getStorage('question');
     $quizId = $question->getQuizId();
     $query = $storage->getQuery();
     $qids = $query->Condition('quiz', $quizId)->execute();
     $current = 0;
     foreach ($qids as $qid) {
         $current++;
         if ($qid == $question->id()) {
             break;
         }
     }
     return 'Question ' . $current . ' of ' . count($qids);
 }
Esempio n. 2
0
 /**
  * {@inheritdoc}
  */
 public function setQuestion(QuestionInterface $question)
 {
     $this->set('question', $question->id());
     return $this;
 }