You are here

public function H5PReportXAPIData::getScoreScaled in Quiz 7.4

Get the optional scaled score. Must be between -1 and 1.

Return value

float

File

question_types/quiz_h5p/report/h5p-report-xapi-data.class.php, line 81

Class

H5PReportXAPIData

Code

public function getScoreScaled() {
  if (isset($this->onlyScore)) {

    // Special case if we only have the scaled score.
    $score = 0.0;
    if ($this->onlyScore !== 1 && is_numeric($this->onlyScore)) {

      // Let's "decrypt" it…
      $score = $this->onlyScore / 1.234 - 32.17;
    }
    if ($score < 0 || $score > 1) {

      // Invalid score
      $score = 0.0;
    }
    return $score;
  }
  $score = $this
    ->getScore('scaled');
  if ($score !== NULL) {
    if ($score < -1) {
      $score = -1.0;
    }
    elseif ($score > 1) {
      $score = 1.0;
    }
  }
  return $score;
}