You are here

function QuizQuestionsForm::getSubQuestions in Quiz 8.5

Same name and namespace in other branches
  1. 8.6 src/Form/QuizQuestionsForm.php \Drupal\quiz\Form\QuizQuestionsForm::getSubQuestions()
  2. 6.x src/Form/QuizQuestionsForm.php \Drupal\quiz\Form\QuizQuestionsForm::getSubQuestions()

Return value

array of QuizQuestion

1 call to QuizQuestionsForm::getSubQuestions()
QuizQuestionsForm::buildForm in src/Form/QuizQuestionsForm.php
Handles "manage questions" tab.

File

src/Form/QuizQuestionsForm.php, line 176

Class

QuizQuestionsForm
Form to manage questions in a quiz.

Namespace

Drupal\quiz\Form

Code

function getSubQuestions($root_question, $all_questions) {
  $append = [];
  foreach ($all_questions as $sub_question) {
    if ($root_question
      ->id() == $sub_question
      ->get('qqr_pid')
      ->getString()) {

      // Question is a leaf of this parent.
      $append[$sub_question
        ->id()] = $sub_question;
    }
  }
  return $append;
}