Comments (9)
comment copied from tracker:
Thanks for the report - the way the attendance module obtains the user list isn't great - it also tries to display information about suspended users as well
The core piece of the code that affects this is in attendance/locallib.php get_users()
if you aren't using groups you could modify the existing calls to get_enrolled_users and add "true" as the 8th param but this won't solve it for the cases where groups are being used.
The more I look at the get_users() function the more I see areas that could do with re-factoring.
Unfortunately my volunteer time is in very high demand so it's unlikely I'll get to this in the short-term so if you have someone that is able to work on it and provide a patch it would be really appreciated.
from moodle-mod_attendance.
We have an interesting variation on this.
We have a user that has access via multiple enrolment methods, 2 custom ones and a manual enrolment.
Our custom enrolment method suspends a user if they drop off the source list, and in this case we have 1 suspended enrolment, and two active ones:
The attendance taking screen displays this user as "Enrolment Suspend"
Which suggests that it isn't resolving all of the statuses or is taking a suspension as being higher precedence...?
from moodle-mod_attendance.
Thanks Michael, let us know if you track it down!
from moodle-mod_attendance.
I think the problem is in the get_users()
function. Around about line 1103 (CONTRIB-3549) there is a select statement against the user_enrolments
table.
In any case once the select is performed, the code then iterates over it's list of users, and looks for a matching $enrolments[]
record (an array indexed by $user->id
.
This presupposes that there is only a single enrolment for a given user, so should there be > 1 enrolment then this would be incomplete data to make the decision on.
I suspect the problem is that the get_records_sql()
will be using the 1st record as a unique ID, but as this is ue.userid
it isn't.
It probably needs changed to SELECT ue.id, ue.userid ...
, and then within the foreach($users as $user)
loop iterate the $enrolments array for each user.
Of course this wouldn't be terribly efficient, as you'd have to loop $enrolments for every $user.
Instead could loop $enrolments and "fill" $users
foreach($enrolments as $e) {
if (isset($users[$e->userid]) {
//Check that the user is in the class list
if ($e->status == 0) { //Active participant via *this* enrolment
if(!isset($users[$e->userid]->enrolmentstatus)) { //we haven't seen this user yet
$users[$e->userid]->enrolmentstatus = $e->status;
$users[$e->userid]->enrolmentstart = $e->mintime;
$users[$e->userid]->enrolmentend = $e->maxtime;
$users[$e->userid]->type = 'standard';
}
else { //we *have seen this user before
}
}
}
}
I guess you could end up with users that don't have enrolment information but I'd have thought it odd that $enrolment
s didn't hold 1 or more entry for each $user
.
Not tried this in code, but purely based on my reading of this section.
from moodle-mod_attendance.
thanks - there's a lot of hard-coded sql in the attendance module that should really be changed to using core functions to return enrolments but it might be quicker to fix it using the existing sql as you mention.
from moodle-mod_attendance.
I placed a fix for this in bug #118
from moodle-mod_attendance.
Thanks Dave - I've merged that into the master branch - would be good if someone else could verify this as well and I'll cherry pick into the other branches.
from moodle-mod_attendance.
I can confirm that this fixes the problem with multiple enrollments, some suspended, some not.
+1 to cherrypick
from moodle-mod_attendance.
great - thanks, I've cherry-picked that onto the 2.8 and 2.7 branches as well.
from moodle-mod_attendance.
Related Issues (20)
- "Save and show next page" looses sort parameter HOT 1
- More Explanation_Attandance HOT 1
- instructor name HOT 3
- Export does not include duration or end time of session in row headers HOT 1
- Unable to save custom session fields when editing sessions HOT 1
- Unable to add new sessions when a custom session field is locked HOT 1
- Automatically setting status after session end HOT 2
- Group statistics HOT 4
- Only profile picture linked to profile HOT 3
- Calendar language wrong when adding sessions HOT 2
- Breadcrumb navigation lists attendance twice HOT 2
- Keep session description empty when no description is set HOT 1
- Allow activity grade to use percentage based on Over All Sessions calculation. HOT 3
- Student recording - error (rotating QR code) HOT 1
- Inconsistency in Automark functionality after changing default status in attendance module HOT 1
- Inconsistency in "On activity completion" automark option when course completion tracking is disabled HOT 1
- debugging warning in 4.4 HOT 1
- icon a bit large in comparison to others in 4.4 HOT 1
- Acronyms with special characters cause error when using Attendance as datasource in Report Builder HOT 1
- preconfigured Timeslots HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from moodle-mod_attendance.