public function MatchingResponse::save in Quiz 7.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()
- 6.5 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()
Implementation of save().
Overrides QuizQuestionResponse::save
See also
File
- question_types/
matching/ matching.classes.inc, line 453 - Matching classes.
Class
- MatchingResponse
- Extension of QuizQuestionResponse
Code
public function save() {
$this
->delete();
$insert = db_insert('quiz_matching_user_answers')
->fields(array(
'match_id',
'result_answer_id',
'answer',
'score',
));
foreach ($this->answer as $key => $value) {
$insert
->values(array(
'match_id' => $key,
'result_answer_id' => $this->result_answer_id,
'answer' => (int) $value,
'score' => $key == $value ? 1 : 0,
));
}
$insert
->execute();
}