Created
January 14, 2013 21:11
-
-
Save mikebuchanon/4533553 to your computer and use it in GitHub Desktop.
student vs faculty course views in Moodle by date, day of week, and hour
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select to_timestamp(ml.time)::date as date, | |
extract(dow from to_timestamp(ml.time)) as dow, | |
extract(hour from to_timestamp(ml.time)) as hour, | |
sum(case when mr.name='Student' then 1 else 0 end) as student_logins, | |
sum(case when mr.name='Teacher' then 1 else 0 end) as fac_staff_logins | |
from mdl_log ml | |
join mdl_context mcon on mcon.contextlevel=50 and mcon.instanceid=ml.course | |
join mdl_role_assignments mra on mra.contextid=mcon.id | |
join mdl_role mr on mr.id=mra.roleid | |
where to_timestamp(ml.time) > '1/14/2013' | |
and ml.action='view' and ml.module='course' | |
group by to_timestamp(ml.time)::date, | |
extract(dow from to_timestamp(ml.time)), | |
extract(hour from to_timestamp(ml.time)) | |
order by 1,3; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment