function QuizController::manageQuestions in Quiz 8.6
Same name and namespace in other branches
- 8.5 src/Controller/QuizController.php \Drupal\quiz\Controller\QuizController::manageQuestions()
- 6.x src/Controller/QuizController.php \Drupal\quiz\Controller\QuizController::manageQuestions()
Creates a form for quiz questions.
Handles the manage questions tab.
Parameters
$node: The quiz node we are managing questions for.
Return value
??? String containing the form.
1 string reference to 'QuizController::manageQuestions'
File
- src/
Controller/ QuizController.php, line 103
Class
Namespace
Drupal\quiz\ControllerCode
function manageQuestions(Quiz $quiz) {
if ($quiz
->get('randomization')
->getString() < 3) {
$manage_questions = Drupal::formBuilder()
->getForm(\Drupal\quiz\Form\QuizQuestionsForm::class, $quiz);
return $manage_questions;
$question_bank = Views::getView('quiz_question_bank')
->preview();
// Insert into vert tabs.
$form['vert_tabs'] = array(
'#type' => 'x',
// @todo wtf?
'#weight' => 0,
'#default_tab' => 'edit-questions',
);
$form['vert_tabs']['questions'] = array(
'#type' => 'details',
'#title' => t('Manage questions'),
'#group' => 'vert_tabs',
'questions' => $manage_questions,
);
$form['vert_tabs']['bank'] = array(
'#type' => 'details',
'#title' => t('Question bank'),
'#group' => 'vert_tabs',
'bank' => $question_bank,
);
return $manage_questions;
}
else {
$form = \Drupal::service('entity.manager')
->getFormObject('quiz', 'default')
->setEntity($quiz);
$form = \Drupal::formBuilder()
->getForm($form);
}
foreach (\Drupal\Core\Render\Element::children($form) as $key) {
if (in_array($key, array_keys($quiz
->getFieldDefinitions())) || $form[$key]['#type'] == 'details') {
if (!in_array($key, [
'quiz_terms',
'random',
'quiz',
])) {
$form[$key]['#access'] = FALSE;
}
}
}
return $form;
}