You are here

function QuizQuestionResponse::toBareObject in OG Quiz 7

Represent the response as a stdClass object.

Convert data to an object that has the following properties:

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

File

includes/og_quiz_question.php, line 936
Classes used in the Quiz Question module.

Class

QuizQuestionResponse
Each question type must store its own response data and be able to calculate a score for that data.

Code

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

  // This can be 0 for unscored.
  $obj->nid = $this->question->nid;
  $obj->vid = $this->question->vid;
  $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;
}