0% found this document useful (0 votes)
28 views

Moodle Request

moodle

Uploaded by

ByPass Pass
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
28 views

Moodle Request

moodle

Uploaded by

ByPass Pass
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 17
User and Role Report Count number of distinct learners and teachers enrolled per category {including all its sub categories) -ECT COUNT(DISTINCT Ira.userid) AS learners, COUNT(DISTINCT tr OM prefix_course AS ¢ #, mdl_course_categories AS cats T JOIN prefix_context AS ctx ON c.id = ctx. instanceid IN prefix_role_assignments AS Ira ON Ira.contextid = ctx.id IN prefix_role_assignments AS tra ON tra.contextid = ctx.id IN prefix_course_categories AS cats ON c.category = cats.id IRE c.category = cats.id r>¢ cats.path LIKE '%/CATEGORYID/X" #Replace CATEGORYID with OR cats.path LIKE '%/CATEGORYID" Detailed ACTIONs for each ROLE (TEACHER, NON-EDITING TEACHER and STUDENT) SELECT r.name, l.action, COUNT( l.userid ) AS counter FROM prefix_log AS 1 JOIN prefix_context AS context ON context.instanceid = 1.cour JOIN prefix_role_assignments AS ra ON l.userid = ra.userid AN JOIN prefix_role AS r ON ra.roleid = r.id WHERE ra.roleid IN (3, 4, 5) GROUP BY roleid, 1.action Student (user) COUNT in each Course Including (optional) filter by: year (if included in course fullname), " hre SELECT concat(‘ @ Students in all courses of some institute What isthe status (deleted or not) of all Students (roleid = 5) in all courses of some Institure SELECT c.id, c.fullname, u.firstname, u.lastname, u.deleted FROM prefix_course AS ¢ JOIN prefix_context AS ctx ON c.id = ctx.instanceid JOIN prefix_role_assignments AS ra ON ra.contextid = ctx.id JOIN prefix_user AS u ON u.id = ra.userid WHERE ra.roleid =! AND ctx.instanceid = c.id AND u.institution = ‘please enter school name here’ Full User info (for deleted users) Including extra custom profile fields (from prefix_user_info_data) SELECT * FROM prefix_user as u JOIN prefix_user_info_data as uid ON uid.userid = u.id JOIN prefix_user_info_field as uif ON (uid.fieldid = uif.id A WHERE “deleted and “institution’="your school name" an User's courses change “u.id = 2" with a new user id SELECT u.firstname, u.lastname, c.id, ¢.fullname FROM prefix_course AS ¢ JOIN prefix_context AS ctx ON c.id = ctx.instanceid JOIN prefix_role_assignments AS ra ON ra.contextid = ctx.id JOIN prefix_user AS u ON u.id = ra.userid WHERE uid = 2 List Users with extra info (email) in current course blocks/configurable_reports replaces %%COURSEID%%6 with course id. SELECT u.firstname, u.lastname, u.email FROM prefix_role_assignments AS ra JOIN prefix_context AS context ON context. JOIN prefix_course AS ¢ ON c.id = context. JOIN prefix_user AS u ON u.id = ra.userid id = ra.contextid A nstanceid AND c.id Special Roles SELECT ra.roleid,r.name yconcat(‘=28,'Y"," FROM prefix_enrol As enr, prefix_user_enrolments AS uenr WHERE enr.id = uenr.enrolid AND enr.status = uenr.status List of users with language Contributed by: Randy Thornton (nttps//moodle.org/user/profle php?id=88992) ‘An issue with systems that do not have their default language set up properly isthe need to do a mass change for al users to a localization. A common case is changing default English to American English. This will show you the language setting forall users: SELECT username, lang from prefix_user NOTE: UPDATE commands require the ability o alter the database directly via tools like Adminer or PHPMyAdmin or other db tools. This code will change the setting from ‘en’ to ‘en_us' forall users: UPDATE prefix_user SET lang = ‘en_us' WHERE lang = ‘en’ To do this for only users who have a particular country set, use this as an example: UPDATE prefix_user SET lang = ‘en_us' WHERE country = ‘US’ AN » List of users with Authentication Contributed by: Randy Thornton (https://moodle.org/user/profle php?id=88992) ‘Sometimes you need to do mass changes of authentication methods. A common case is changing default manual to LDAP. This will show you the Authentication setting forall users: SELECT username, auth from prefix_user NOTE: UPDATE commands require the ability o alter the database directly via tools like Adminer or PHPMyAdmin or other db tools This code will change the setting from ‘manuat'to ldap" for all users except for the first ewo accounts which are Guest and Admin. (WARNING: itis bad practice to change your admin account from manual to an external method as failure of that external method will lock you out of Moodle as admin.) UPDATE prefix_user SET auth = ‘ldap’ WHERE auth = ‘manual’ AN » Compare role capability and permissions SELECT DISTINCT mrc.capability (SELECT rc.permission FROM “md)_role_capabilities’ AS rc WHE AND rc.roleid = '1' AND rc.contextid = ‘1') AS Manager . (SELECT rc.permission FROM “mdl_role_capabilities’ AS rc WHE AND rc.roleid = '2' AND rc.contextid = ‘1') AS CourseCreato ) (SELECT rc.permission FROM “mdl_role_capabilities’ AS rc WHE AND rc.roleid = '3' AND rc.contextid = ‘1') AS Teacher , (SELECT rc.permission FROM “mdl_role_capabilities” AS rc WHE AND rc.roleid = '4' AND rc.contextid = ‘1') AS AssistantTea (SELECT rc.permission FROM “mdl_role_capabilities’ AS rc WHE AND rc.roleid = 'S' AND rc.contextid = ‘1') AS Student , (SELECT rc.permission FROM “mdl_role_capabilities” AS rc WHE AND rc.roleid = '6' AND rc.contextid = ‘1') AS Guest FROM “mdl_role capabilities’ AS mrc User's accumulative 1e spent in course ‘A sum up of the time delta between logstore_standard_log user's records, consider- ing the @ 2 hour session limit. Uses: current users id S69KUSERIDIGH6 and current course's id 8%¢COURSEIDIEK ‘And also using a date filter (which can be ignored) The extra “User field is used as a dummy field for the Line chart Series field, in which | use X-id, Series=Type, Y=delta SELECT Lid, 1.timecreated, DATE_FORMAT(FROM_UNIXTINE(1.timecreated), '%d-%m-KV") AS dTime @prevtime := (SELECT max(timecreated) FROM ndl_logstore_stand WHERE userid = %XUSERTD%% and id < 1.id ORDER BY IF (1.timecreated - @prevtime < 7200, @delta := @delta + (1.t L.timecreated-@prevtime AS delta, "user" as type FROM prefix_logstore_standard_log as 1, (SELECT @delta := @) AS s_init # Change UserID WHERE 1.userid = %XUSERIDX% AND 1.courseid = XXCOURSEIDXX SMPILTER_STARTTINE:1.timecreated: >%% %%FILTER_ENDTINE:1.timec Log Activity Reports Count all Active Users by ROLE in a course category (including all of its sub-categories) SELECT COUNT(DISTINCT l.userid) as active FROM mdl_course as ¢ JOIN mdl_context AS ctx ON ctx.instanceid=c.id JOIN mdl_role_assignments AS ra ON ra.contextid = ctx.id JOIN mdl_user_lastaccess as 1 ON ra.userid = l.userid JOIN mdl_course_categories AS cats ON c.category = cats.id WHERE c.category=cats.id AND ( cats.path LIKE '%/80/%' OR cats.path LIKE '%/80" ) AND ra.roleid=3 AND ctx.contextlevel=50 #ra.roleid= TEACHER AND 1.timeaccess > (unix_timestamp() - ((60%69*24)*NO_OF_DAY » Detailed "VIEW" ACTION for each ROLE (TEACHER,NONE-EDITING TEACHER and STUDENT) SELECT 1.action, count( l.userid ) as counter , r.name FROM *prefix_log’ as 1 JOIN * prefix_role_assignments’ AS ra on l.userid = ra.userid JOIN *prefix_role AS r ON ra.roleid = r.id WHERE (ra.roleid IN (3,4,5)) AND (1.action LIKE '%view%' ) GROUP BY roleid,1.action order by r.name, counter desc Total Activity of Roles: and by Hours ‘eacher” and “None-Editing Teacher” by Dates The output columns of this report table can be used as base for a Pivot-Table which will show the amount of activity per hour per days in 3D graph view. SELECT DATE_FORMAT( FROM_UNIXTIME( 1.time ) , '%Y-Xm-%d' ) AS DATE_FORMAT( FROM_UNIXTIME( 1.time ) , ‘Xk’ ) AS grptimeh , FROM ~prefix_log” AS 1 JOIN prefix_user AS u ON u.id = l.userid JOIN prefix_role_assignments AS ra ON l.userid = ra.userid JOIN prefix_role AS r ON r.id = ra.roleid WHERE ra.roleid IN (3,4) GROUP BY grptimed, grptimeh ORDER BY grptimed, erptimeh How many LOGINs per user and user's Activity + link username to a user activity graph report

You might also like