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):
diff --git a/renderables.php b/renderables.php
index eedaed6..a463906 100644
--- a/renderables.php
+++ b/renderables.php
@@ -548,11 +548,6 @@ class attendance_report_data implements renderable {
* @param mod_attendance_structure $att
*/
public function __construct(mod_attendance_structure $att) {
- $currenttime = time();
- if ($att->pageparams->view == ATT_VIEW_NOTPRESENT) {
- $att->pageparams->enddate = $currenttime;
- }
-
$this->pageparams = $att->pageparams;
$this->users = $att->get_users($att->pageparams->group, $att->pageparams->page);
@@ -582,8 +577,9 @@ class attendance_report_data implements renderable {
foreach ($this->users as $key => $user) {
$usersummary = $this->summary->get_taken_sessions_summary_for($user->id);
if ($att->pageparams->view != ATT_VIEW_NOTPRESENT ||
- $usersummary->takensessionspoints < $usersummary->takensessionsmaxpoints ||
- $usersummary->takensessionsmaxpoints == 0) {
+ attendance_calc_fraction($usersummary->takensessionspoints, $usersummary->takensessionsmaxpoints) <
+ $att->get_lowgrade_threshold()) {
+
$this->usersgroups[$user->id] = groups_get_all_groups($att->course->id, $user->id);
$this->sessionslog[$user->id] = $att->get_user_filtered_sessions_log($user->id);
diff --git a/renderer.php b/renderer.php
index a2d76c2..7e21ced 100644
--- a/renderer.php
+++ b/renderer.php
@@ -206,7 +206,8 @@ class mod_attendance_renderer extends plugin_renderer_base {
$views[ATT_VIEW_WEEKS] = get_string('weeks', 'attendance');
$views[ATT_VIEW_DAYS] = get_string('days', 'attendance');
if ($fcontrols->reportcontrol && $fcontrols->att->grade > 0) {
- $views[ATT_VIEW_NOTPRESENT] = get_string('lowgrade', 'attendance');
+ $a = $fcontrols->att->get_lowgrade_threshold() * 100;
+ $views[ATT_VIEW_NOTPRESENT] = get_string('below', 'attendance', $a);
}
if ($fcontrols->reportcontrol) {
$views[ATT_VIEW_SUMMARY] = get_string('summary', 'attendance');
diff --git a/tests/behat/attendance_mod.feature b/tests/behat/attendance_mod.feature
index 027bc9f..5d582db 100644
--- a/tests/behat/attendance_mod.feature
+++ b/tests/behat/attendance_mod.feature
@@ -78,7 +78,7 @@ Feature: Teachers and Students can record session attendance
And I click on "Get these logs" "button"
Then "Attendance taken by student" "link" should exist
- Scenario: Teachers can view low grade report and send a message
+ Scenario: Teachers can view below % report and send a message
Given I log in as "teacher1"
And I am on "Course 1" course homepage
And I follow "Attendance"
@@ -88,7 +88,7 @@ Feature: Teachers and Students can record session attendance
| id_sestime_endhour | 02 |
And I click on "id_submitbutton" "button"
And I follow "Report"
- And I follow "Low grade"
+ And I follow "Below"
And I set the field "cb_selector" to "1"
And I click on "Send a message" "button"
And I should see "Message body"