You are here

private function MultichoiceQuestion::insertAlternative in Quiz 8.4

Helper function. Saves new alternatives

Parameters

$i: The alternative index

1 call to MultichoiceQuestion::insertAlternative()
MultichoiceQuestion::saveNodeProperties in question_types/multichoice/lib/Drupal/multichoice/MultichoiceQuestion.php
Implementation of save

File

question_types/multichoice/lib/Drupal/multichoice/MultichoiceQuestion.php, line 212
The main classes for the multichoice question type.

Class

MultichoiceQuestion
Extension of QuizQuestion.

Namespace

Drupal\multichoice

Code

private function insertAlternative($i) {
  $alternatives = $this->node->alternatives[$i];
  db_insert('quiz_multichoice_answers')
    ->fields(array(
    'answer' => $alternatives['answer']['value'],
    'answer_format' => $alternatives['answer']['format'],
    'feedback_if_chosen' => $alternatives['feedback_if_chosen']['value'],
    'feedback_if_chosen_format' => $alternatives['feedback_if_chosen']['format'],
    'feedback_if_not_chosen' => $alternatives['feedback_if_not_chosen']['value'],
    'feedback_if_not_chosen_format' => $alternatives['feedback_if_not_chosen']['format'],
    'score_if_chosen' => $alternatives['score_if_chosen'],
    'score_if_not_chosen' => $alternatives['score_if_not_chosen'],
    'question_nid' => $this->node
      ->id(),
    'question_vid' => $this->node
      ->getRevisionId(),
  ))
    ->execute();
}