You are here

private function ChoiceQuestion::forgive in Quiz 6.6

1 call to ChoiceQuestion::forgive()
ChoiceQuestion::save in question_types/choice/choice.classes.inc
Implementation of save

File

question_types/choice/choice.classes.inc, line 48
The main classes for the choice question type.

Class

ChoiceQuestion
Implementation of QuizQuestion.

Code

private function forgive() {
  if ($this->node->choice_multi == 1) {
    for ($i = 0; is_array($this->node->alternatives[$i]); $i++) {
      $short =& $this->node->alternatives[$i];
      if ($short['score_if_chosen'] == $short['score_if_not_chosen'] || !is_numeric($short['score_if_chosen'] || !is_numeric($short['score_if_not_chosen']))) {
        if ($short['correct'] == 1) {
          $short['score_if_chosen'] = 1;
          $short['score_if_not_chosen'] = 0;
        }
        else {
          $short['score_if_chosen'] = 0;
          $short['score_if_not_chosen'] = 1;
        }
      }
    }
  }
  else {
    for ($i = 0; is_array($this->node->alternatives[$i]); $i++) {
      $short = $this->node->alternatives[$i];
      $short['score_if_chosen'] = $short['correct'];
      $short['score_if_not_chosen'] = 0;
    }
  }
}