private function MultichoiceQuestion::forgive in Quiz 7
Same name and namespace in other branches
- 6.4 question_types/multichoice/multichoice.classes.inc \MultichoiceQuestion::forgive()
- 7.6 question_types/multichoice/multichoice.classes.inc \MultichoiceQuestion::forgive()
- 7.4 question_types/multichoice/multichoice.classes.inc \MultichoiceQuestion::forgive()
- 7.5 question_types/multichoice/multichoice.classes.inc \MultichoiceQuestion::forgive()
Forgive some possible logical flaws in the user input.
1 call to MultichoiceQuestion::forgive()
- MultichoiceQuestion::saveNodeProperties in question_types/
multichoice/ multichoice.classes.inc - Implementation of save
File
- question_types/
multichoice/ multichoice.classes.inc, line 29 - The main classes for the multichoice question type.
Class
- MultichoiceQuestion
- Extension of QuizQuestion.
Code
private function forgive() {
if ($this->node->choice_multi == 1) {
for ($i = 0; isset($this->node->alternatives[$i]); $i++) {
$short =& $this->node->alternatives[$i];
// If the scoring data doesn't make sense, use the data from the "correct" checkbox to set the score data
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 {
if (variable_get('multichoice_def_scoring', 0) == 0) {
$short['score_if_chosen'] = -1;
$short['score_if_not_chosen'] = 0;
}
elseif (variable_get('multichoice_def_scoring', 0) == 1) {
$short['score_if_chosen'] = 0;
$short['score_if_not_chosen'] = 1;
}
}
}
}
}
else {
// For questions with one, and only one, correct answer, there will be no points awarded for alternatives
// not chosen.
for ($i = 0; isset($this->node->alternatives[$i]); $i++) {
$short =& $this->node->alternatives[$i];
$short['score_if_not_chosen'] = 0;
if ($short['correct'] == 1 && !_quiz_is_int($short['score_if_chosen'], 1)) {
$short['score_if_chosen'] = 1;
}
}
}
}