Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing data in custom SQL report #243

Open
VOOM108 opened this issue Jan 18, 2024 · 0 comments
Open

Missing data in custom SQL report #243

VOOM108 opened this issue Jan 18, 2024 · 0 comments

Comments

@VOOM108
Copy link

VOOM108 commented Jan 18, 2024

I wrote an SQL query that works on all Moodle platforms I support, except one. The strange thing is, that out of 1800 users that are enrolled in a course, only 1200 show up in the report. There is a similar effect with all courses using this report. There is no obvious reason for that discrepancy.

Any idea what may be going on here? What factors could be at play here?

SELECT 
 c.shortname as "Kurs",
 u.lastname as "Nachname", 
 u.firstname as "Vorname", 
 u.institution as "Firma",
 u.department as "Abteilung",
 FROM_UNIXTIME(ue.timecreated) as "Eingeschrieben",
   (
    CASE 
      WHEN cmp.timecompleted IS NULL THEN 'ungueltig' 
      ELSE 'gueltig' 
    END
  ) as "Zertifikat",
 FROM_UNIXTIME(cmp.timecompleted) as "Aktueller Abschluss",
  (
    SELECT 
      GROUP_CONCAT(FROM_UNIXTIME(cc_hist.timecompleted) SEPARATOR ', ') 
    FROM 
      prefix_local_recompletion_cc cc_hist 
    WHERE 
      cc_hist.course = cmp.course 
      AND cc_hist.userid = cmp.userid 
  ) as "Archivierte Abschluesse, Komma-sep."
FROM 
  prefix_user u
  LEFT JOIN prefix_user_enrolments ue ON u.id = ue.userid
  LEFT JOIN prefix_course_completions cmp ON cmp.userid = u.id 
  LEFT JOIN prefix_course c ON c.id = cmp.course
WHERE 
  cmp.course = %%COURSEID%%
  AND u.suspended = 0
GROUP BY 
  u.id, 
  cmp.course

It's not the u.suspended = 0, this filters out only very few as intended.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant