public function H5PReportXAPIData::getScoreScaled in Opigno module 3.x
Same name and namespace in other branches
- 8 ActivityTypes/opigno_h5p/src/H5PReportXAPIData.php \Drupal\opigno_h5p\H5PReportXAPIData::getScoreScaled()
Get the optional scaled score.
Must be between -1 and 1.
Return value
float Scaled score.
File
- ActivityTypes/
opigno_h5p/ src/ H5PReportXAPIData.php, line 89
Class
- H5PReportXAPIData
- Class H5PReportXAPIData.
Namespace
Drupal\opigno_h5pCode
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;
}