Skip to content

Commit

Permalink
feat: remove rounding in student competencies export
Browse files Browse the repository at this point in the history
  • Loading branch information
nbey committed Sep 22, 2021
1 parent ad8a272 commit 04211aa
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
22 changes: 6 additions & 16 deletions data-exporters/slate-cbl/student-competencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,6 @@

while ($record = $result->fetch_assoc()) {
$StudentCompetency = Slate\CBL\StudentCompetency::instantiateRecord($record);
$demonstrationsComplete = $StudentCompetency->getDemonstrationsComplete();
$demonstrationsRequired = $StudentCompetency->getDemonstrationsRequired();
$demonstrationsAverage = round(
$StudentCompetency->getDemonstrationsAverage(),
Slate\CBL\StudentCompetency::$averagePrecision
);
$growth = round(
$StudentCompetency->getGrowth(),
Slate\CBL\StudentCompetency::$averagePrecision
);

yield [
'ID' => $StudentCompetency->ID,
Expand All @@ -149,12 +139,12 @@
'StudentFullName' => $Student->FullName,
'CompetencyCode' => $StudentCompetency->Competency->Code,
'Level' => $StudentCompetency->Level,
'BaselineRating' => round($StudentCompetency->BaselineRating, 1),
'DemonstrationsAverage' => $demonstrationsAverage ?: null,
'Growth' => $growth ?: null,
'Progress' => round($demonstrationsRequired ? $demonstrationsComplete/$demonstrationsRequired : 1, 2),
'DemonstrationsRequired' => $demonstrationsRequired,
'DemonstrationsComplete' => $demonstrationsComplete,
'BaselineRating' => $StudentCompetency->getBaselineRating(),
'DemonstrationsAverage' => $StudentCompetency->getDemonstrationsAverage() ?: null,
'Growth' => $StudentCompetency->getGrowth() ?: null,
'Progress' => $StudentCompetency->getProgress() ?: null,
'DemonstrationsRequired' => $StudentCompetency->getDemonstrationsRequired(),
'DemonstrationsComplete' => $StudentCompetency->getDemonstrationsComplete(),
'DemonstrationsMissed' => $StudentCompetency->getDemonstrationsMissed(),
'DemonstrationOpportunities' => $StudentCompetency->getDemonstrationOpportunities()
];
Expand Down
18 changes: 17 additions & 1 deletion php-classes/Slate/CBL/StudentCompetency.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class StudentCompetency extends \ActiveRecord
public static $isLevelComplete;
public static $growthCalculatorClass = Calculators\Growth\MostRecentMinusFirst::class;
public static $averagePrecision = 1;
public static $progressPrecision = 2;


// ActiveRecord configuration
Expand Down Expand Up @@ -117,6 +118,9 @@ class StudentCompetency extends \ActiveRecord
'growth' => [
'getter' => 'getGrowth'
],
'progress' => [
'getter' => 'getProgress'
],
'next' => [
'getter' => 'getNext'
]
Expand Down Expand Up @@ -524,7 +528,19 @@ public function getGrowth()
$this->competencyGrowth = $growthCalculationClass::calculateGrowth($this);
}

return $this->competencyGrowth === false ? null : $this->competencyGrowth;
return $this->competencyGrowth === false ? null : round($this->competencyGrowth, static::$averagePrecision);
}

private $competencyProgress;
public function getProgress()
{
if ($this->competencyProgress === null) {
$required = $this->getDemonstrationsRequired();
$complete = $this->getDemonstrationsComplete();
$this->competencyProgress = $required ? $complete / $required : 1;
}

return $this->competencyProgress === false ? null : round($this->competencyProgress, static::$progressPrecision);
}

private $previous;
Expand Down

0 comments on commit 04211aa

Please sign in to comment.