You are here

public function MatchingResponse::save in Quiz 6.3

Same name and namespace in other branches
  1. 6.6 question_types/matching/matching.classes.inc \MatchingResponse::save()
  2. 6.4 question_types/matching/matching.classes.inc \MatchingResponse::save()
  3. 6.5 question_types/matching/matching.classes.inc \MatchingResponse::save()
  4. 7.6 question_types/matching/matching.classes.inc \MatchingResponse::save()
  5. 7 question_types/matching/matching.classes.inc \MatchingResponse::save()
  6. 7.4 question_types/matching/matching.classes.inc \MatchingResponse::save()
  7. 7.5 question_types/matching/matching.classes.inc \MatchingResponse::save()

Save the current response.

Overrides QuizQuestionResponse::save

File

question_types/matching/matching.classes.inc, line 226
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 = $this->answer;
  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);
  }
}