private function MultichoiceQuestion::insertAlternative in Quiz 8.5
Same name and namespace in other branches
- 8.6 question_types/quiz_multichoice/src/Plugin/quiz/QuizQuestion/MultichoiceQuestion.php \Drupal\quiz_multichoice\Plugin\quiz\QuizQuestion\MultichoiceQuestion::insertAlternative()
Helper function. Saves new alternatives.
Parameters
int $i: The alternative index.
1 call to MultichoiceQuestion::insertAlternative()
- MultichoiceQuestion::saveNodeProperties in question_types/
quiz_multichoice/ src/ Plugin/ quiz/ QuizQuestion/ MultichoiceQuestion.php - Implementation of saveNodeProperties().
File
- question_types/
quiz_multichoice/ src/ Plugin/ quiz/ QuizQuestion/ MultichoiceQuestion.php, line 238
Class
- MultichoiceQuestion
- @QuizQuestion ( id = "multichoice", label = Plugin annotation @Translation("Multiple choice question"), handlers = { "response" = "\Drupal\quiz_multichoice\Plugin\quiz\QuizQuestion\MultichoiceResponse" } )
Namespace
Drupal\quiz_multichoice\Plugin\quiz\QuizQuestionCode
private function insertAlternative($i) {
$alternatives = $this
->_normalizeAlternative($this->node->alternatives[$i]);
db_insert('quiz_multichoice_answers')
->fields(array(
'answer' => $alternatives['answer'],
'answer_format' => $alternatives['answer_format'],
'feedback_if_chosen' => $alternatives['feedback_if_chosen'],
'feedback_if_chosen_format' => $alternatives['feedback_if_chosen_format'],
'feedback_if_not_chosen' => $alternatives['feedback_if_not_chosen'],
'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->nid,
'question_vid' => $this->node->vid,
'weight' => isset($alternatives['weight']) ? $alternatives['weight'] : $i,
))
->execute();
}