You are here

public function ScaleResponse::__construct in Quiz 6.6

Same name and namespace in other branches
  1. 8.6 question_types/quiz_scale/src/Plugin/quiz/QuizQuestion/ScaleResponse.php \ScaleResponse::__construct()
  2. 8.5 question_types/quiz_scale/src/Plugin/quiz/QuizQuestion/ScaleResponse.php \ScaleResponse::__construct()
  3. 6.4 question_types/scale/scale.classes.inc \ScaleResponse::__construct()
  4. 7.6 question_types/scale/scale.classes.inc \ScaleResponse::__construct()
  5. 7 question_types/scale/scale.classes.inc \ScaleResponse::__construct()
  6. 7.4 question_types/scale/scale.classes.inc \ScaleResponse::__construct()
  7. 7.5 question_types/scale/scale.classes.inc \ScaleResponse::__construct()

Constructor

Parameters

$rid - response_id:

$question - as an object:

$answer - answer_id:

File

question_types/scale/scale.classes.inc, line 497
The main classes for the scale question type.

Class

ScaleResponse
The short answer question response class.

Code

public function __construct($rid, $question, $answer = NULL) {
  $this->rid = $rid;
  $this->question = $question;
  if (isset($answer)) {
    $this->answer_id = $answer;
  }
  else {
    $sql = 'SELECT answer_id
              FROM {quiz_scale_user_answers}
              WHERE result_id = %d AND question_nid = %d AND question_vid = %d';
    $res = db_query($sql, $rid, $this->question->nid, $this->question->vid);
    $res_o = db_fetch_object($res);
    $this->answer_id = $res_o->answer_id;
  }
  $sql = 'SELECT answer
            FROM {quiz_scale_answer}
            WHERE id = %d';
  $res = db_query($sql, $this->answer_id);
  $res_o = db_fetch_object($res);
  $this->answer = check_plain($res_o->answer);
}