You are here

function MultichoiceQuestion::_normalizeAlternative in Quiz 7.4

Same name and namespace in other branches
  1. 7.6 question_types/multichoice/multichoice.classes.inc \MultichoiceQuestion::_normalizeAlternative()
  2. 7.5 question_types/multichoice/multichoice.classes.inc \MultichoiceQuestion::_normalizeAlternative()
2 calls to MultichoiceQuestion::_normalizeAlternative()
MultichoiceQuestion::insertAlternative in question_types/multichoice/multichoice.classes.inc
Helper function. Saves new alternatives
MultichoiceQuestion::updateAlternative in question_types/multichoice/multichoice.classes.inc
Helper function. Updates existing alternatives

File

question_types/multichoice/multichoice.classes.inc, line 200
The main classes for the multichoice question type.

Class

MultichoiceQuestion
Extension of QuizQuestion.

Code

function _normalizeAlternative($alternatives) {
  $copy = $alternatives;

  // answer
  if (is_array($alternatives['answer']) && isset($alternatives['answer']['value'])) {
    $copy['answer'] = $alternatives['answer']['value'];
  }

  // answer format
  if (is_array($alternatives['answer']) && isset($alternatives['answer']['format'])) {
    $copy['answer_format'] = $alternatives['answer']['format'];
  }

  // feedback if choosen
  if (is_array($alternatives['feedback_if_chosen']) && isset($alternatives['feedback_if_chosen']['value'])) {
    $copy['feedback_if_chosen'] = $alternatives['feedback_if_chosen']['value'];
  }

  // feedback if choosen foramt
  if (is_array($alternatives['feedback_if_chosen']) && isset($alternatives['feedback_if_chosen']['format'])) {
    $copy['feedback_if_chosen_format'] = $alternatives['feedback_if_chosen']['format'];
  }

  // feedback if not chosen
  if (is_array($alternatives['feedback_if_not_chosen']) && isset($alternatives['feedback_if_not_chosen']['value'])) {
    $copy['feedback_if_not_chosen'] = $alternatives['feedback_if_not_chosen']['value'];
  }

  // feedback if not chosen foramt
  if (is_array($alternatives['feedback_if_not_chosen']) && isset($alternatives['feedback_if_not_chosen']['format'])) {
    $copy['feedback_if_not_chosen_format'] = $alternatives['feedback_if_not_chosen']['format'];
  }
  return $copy;
}