You are here

public function OpignoScormQuizResponse::score in Opigno 7

@copydoc QuizQuestionResponse::delete()

File

modules/scorm/quiz/includes/opigno_scorm_quiz.response.inc, line 98
Response type class definition.

Class

OpignoScormQuizResponse
@file Response type class definition.

Code

public function score() {
  $scaled = db_select('opigno_scorm_quiz_user_results', 'o')
    ->fields('o', array(
    'score_scaled',
  ))
    ->condition('question_nid', $this->question->nid)
    ->condition('question_vid', $this->question->vid)
    ->condition('result_id', $this->rid)
    ->execute()
    ->fetchField();
  $round_method = !empty($this->question->opigno_scorm_round_method[LANGUAGE_NONE][0]['value']) ? $this->question->opigno_scorm_round_method[LANGUAGE_NONE][0]['value'] : 'round';
  $scaled *= $this
    ->getMaxScore();
  switch ($round_method) {
    case 'ceil':
      $scaled = ceil($scaled);
      break;
    case 'floor':
      $scaled = floor($scaled);
      break;
    default:
      $scaled = round($scaled);
      break;
  }
  return $scaled;
}