You are here

function QuizQuestionResponse::toBareObject in Quiz 8.4

Represent the response as a stdClass object.

Convert data to an object that has the following properties:

  • $score
  • $rid
  • $nid
  • $vid
  • $is_correct

File

question_types/quiz_question/lib/Drupal/quiz_question/QuizQuestionResponse.php, line 132

Class

QuizQuestionResponse

Namespace

Drupal\quiz_question

Code

function toBareObject() {
  $obj = new \stdClass();
  $obj->score = $this
    ->getScore();

  // This can be 0 for unscored.
  $obj->nid = $this->question
    ->id();
  $obj->vid = $this->question
    ->getRevisionId();
  $obj->rid = $this->rid;
  $obj->is_correct = (int) $this
    ->isCorrect();
  $obj->is_evaluated = $this
    ->isEvaluated();
  $obj->is_skipped = 0;
  $obj->is_doubtful = isset($_POST['is_doubtful']) ? $_POST['is_doubtful'] : 0;
  $obj->is_valid = $this
    ->isValid();
  return $obj;
}