You are here

function QuizQuestionResponse::toBareObject in Quiz 7.4

Same name and namespace in other branches
  1. 6.6 question_types/quiz_question/quiz_question.core.inc \QuizQuestionResponse::toBareObject()
  2. 6.3 question_types/quiz_question/quiz_question.core.inc \QuizQuestionResponse::toBareObject()
  3. 6.4 question_types/quiz_question/quiz_question.core.inc \QuizQuestionResponse::toBareObject()
  4. 6.5 question_types/quiz_question/quiz_question.core.inc \QuizQuestionResponse::toBareObject()
  5. 7.6 question_types/quiz_question/quiz_question.core.inc \QuizQuestionResponse::toBareObject()
  6. 7 question_types/quiz_question/quiz_question.core.inc \QuizQuestionResponse::toBareObject()
  7. 7.5 question_types/quiz_question/quiz_question.core.inc \QuizQuestionResponse::toBareObject()

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/quiz_question.core.inc, line 773
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;
}