public function ShortAnswerResponse::save in Quiz 6.5
Same name and namespace in other branches
- 6.6 question_types/short_answer/short_answer.classes.inc \ShortAnswerResponse::save()
- 6.3 question_types/short_answer/short_answer.classes.inc \ShortAnswerResponse::save()
- 6.4 question_types/short_answer/short_answer.classes.inc \ShortAnswerResponse::save()
- 7.6 question_types/short_answer/short_answer.classes.inc \ShortAnswerResponse::save()
- 7 question_types/short_answer/short_answer.classes.inc \ShortAnswerResponse::save()
- 7.4 question_types/short_answer/short_answer.classes.inc \ShortAnswerResponse::save()
- 7.5 question_types/short_answer/short_answer.classes.inc \ShortAnswerResponse::save()
File
- question_types/
short_answer/ short_answer.classes.inc, line 306 - The main classes for the short answer question type.
Class
- ShortAnswerResponse
- The short answer question response class.
Code
public function save() {
// We need to set is_evaluated depending on whether the type requires evaluation.
// Unfortunately, when score() is called, we don't yet have the record to modify (since
// score() is called before save()), so we have to set the param here.
$this->is_evaluated = (int) ($this->question->correct_answer_evaluation != ShortAnswerQuestion::ANSWER_MANUAL);
$sql = "INSERT INTO {quiz_short_answer_user_answers}\n (answer, question_nid, question_vid, result_id, score, is_evaluated)\n VALUES ('%s', %d, %d, %d, %d, %d)";
db_query($sql, $this->answer, $this->question->nid, $this->question->vid, $this->rid, $this->score, $this->is_evaluated);
$this->answer_id = db_last_insert_id('quiz_long_answer_user_answers', 'answer_id');
}