You are here

public function ShortAnswerResponse::save in Quiz 8.4

Implementation of save

Overrides QuizQuestionResponse::save

See also

QuizQuestionResponse#save()

File

question_types/short_answer/lib/Drupal/short_answer/ShortAnswerResponse.php, line 135
The main classes for the short answer response.

Class

ShortAnswerResponse
Extension of QuizQuestionResponse

Namespace

Drupal\short_answer

Code

public function save() {

  // We need to set is_evaluated depending on whether the type requires evaluation.
  $this->is_evaluated = (int) ($this->question->correct_answer_evaluation != ShortAnswerQuestion::ANSWER_MANUAL);
  $this->answer_id = db_insert('quiz_short_answer_user_answers')
    ->fields(array(
    'answer' => $this->answer,
    'question_nid' => $this->question
      ->id(),
    'question_vid' => $this->question
      ->getRevisionId(),
    'result_id' => $this->rid,
    'score' => $this
      ->getScore(FALSE),
    'is_evaluated' => $this->is_evaluated,
  ))
    ->execute();
}