public function MatchingResponse::save in Quiz 6.5
Same name and namespace in other branches
- 6.6 question_types/matching/matching.classes.inc \MatchingResponse::save()
- 6.3 question_types/matching/matching.classes.inc \MatchingResponse::save()
- 6.4 question_types/matching/matching.classes.inc \MatchingResponse::save()
- 7.6 question_types/matching/matching.classes.inc \MatchingResponse::save()
- 7 question_types/matching/matching.classes.inc \MatchingResponse::save()
- 7.4 question_types/matching/matching.classes.inc \MatchingResponse::save()
- 7.5 question_types/matching/matching.classes.inc \MatchingResponse::save()
File
- question_types/
matching/ matching.classes.inc, line 220 - quiz_directions.classes
Class
- MatchingResponse
- Class that describes a "Directions question response". For the most part, no real scoring takes place for a direction node. However, there are a few behind-the-scenes tricks that are done here to make the quiz-taking process a little easier.
Code
public function save() {
$user_answers = isset($this->answer) ? $this->answer : array();
// to prevent warning : Invalid argument supplied for foreach()
foreach ($user_answers as $key => $value) {
$score = $key == $value ? 1 : 0;
$sql = "INSERT INTO {quiz_matching_user_answers} (match_id, result_id, answer, score) VALUES (%d, %d, %d, %d)";
// This is expensive need to be changed
db_query($sql, $key, $this->rid, (int) $value, $score);
}
}