From 6826bb831eb32d8a3e89ede0b2611c4be47f16d6 Mon Sep 17 00:00:00 2001 From: Dan Marsden Date: Fri, 27 Jul 2018 14:12:05 +1200 Subject: [PATCH] Fix #196 Thanks to @antonio-c-mariani for this code. --- classes/page_with_filter_controls.php | 1 + classes/structure.php | 24 ++++++++++++++++++++++++ lang/en/attendance.php | 2 +- renderables.php | 10 +++------- renderer.php | 3 ++- tests/behat/attendance_mod.feature | 4 ++-- 6 files changed, 33 insertions(+), 11 deletions(-) diff --git a/classes/page_with_filter_controls.php b/classes/page_with_filter_controls.php index b88ff57..22f7ab5 100644 --- a/classes/page_with_filter_controls.php +++ b/classes/page_with_filter_controls.php @@ -154,6 +154,7 @@ class mod_attendance_page_with_filter_controls { $this->enddate = time(); break; case ATT_VIEW_ALL: + case ATT_VIEW_NOTPRESENT: $this->startdate = 0; $this->enddate = 0; break; diff --git a/classes/structure.php b/classes/structure.php index 7a29187..2863bf6 100644 --- a/classes/structure.php +++ b/classes/structure.php @@ -96,6 +96,10 @@ class mod_attendance_structure { /** @var array of sessionid. */ private $sessioninfo = array(); + /** @var float number [0..1], the threshold for student to be shown at low grade report */ + private $lowgradethreshold; + + /** * Initializes the attendance API instance using the data from DB * @@ -1271,4 +1275,24 @@ class mod_attendance_structure { } return; } + + /** + * Gets the lowgrade threshold to use. + * + */ + public function get_lowgrade_threshold() { + if (!isset($this->lowgradethreshold)) { + $this->lowgradethreshold = 1; + + if ($this->grade > 0) { + $gradeitem = grade_item::fetch(array('courseid' => $this->course->id, 'itemtype' => 'mod', + 'itemmodule' => 'attendance', 'iteminstance' => $this->id)); + if ($gradeitem->gradepass > 0 && $gradeitem->grademax != $gradeitem->grademin) { + $this->lowgradethreshold = ($gradeitem->gradepass - $gradeitem->grademin) / ($gradeitem->grademax - $gradeitem->grademin); + } + } + } + + return $this->lowgradethreshold; + } } diff --git a/lang/en/attendance.php b/lang/en/attendance.php index 7d85379..a1243f0 100644 --- a/lang/en/attendance.php +++ b/lang/en/attendance.php @@ -247,7 +247,7 @@ $string['invalidsessionendtime'] = 'The end time must be greater than start time $string['invalidstatus'] = 'You have selected an invalid status, please try again'; $string['iptimemissing'] = 'Invalid minutes to release'; $string['jumpto'] = 'Jump to'; -$string['lowgrade'] = 'Low grade'; +$string['below'] = 'Below {$a}%'; $string['maxpossible'] = 'Maximum possible'; $string['maxpossible_help'] = 'Shows the score each user can reach if they receive the maximum points in each session not yet taken (past and future):