Documente Academic
Documente Profesional
Documente Cultură
Jump to: navigation, search Main page Managing a Moodle site Site-wide reports ad-hoc contributed reports Site-wide reports
Contents
1 User and Role Report o 1.1 Detailed ACTIONs for each ROLE (TEACHER,NONE-EDITING TEACHER and STUDENT) o 1.2 Student (user) COUNT in each Course o 1.3 LIST of all site USERS by COURSE enrollment (Moodle 1.9.x) o 1.4 LIST of all site USERS by COURSE enrollment (Moodle 2.x) o 1.5 Enrolled users,which did not login into the Course, even once (Moodle 2) o 1.6 Permissions Overides on Categories o 1.7 Lists "Totally Opened Courses" (visible, opened to guests, with no password) o 1.8 Lists "loggedin users" from the last 120 days o 1.9 Lists the users who have only logged into the site once o 1.10 Students in all courses of some institute o 1.11 Full User info (for deleted users) o 1.12 User's courses o 1.13 Special Roles o 1.14 Courses without Teachers o 1.15 List of users who have been enrolled for more than 4 weeks 2 Log Acivity Reports o 2.1 Detailed "VIEW" ACTION for each ROLE (TEACHER,NONE-EDITING TEACHER and STUDENT) o 2.2 Total Activity of Roles:"Teacher" and "None-Editing Teacher" by Dates and by Hours o 2.3 How many LOGINs per user and user's Activity o 2.4 Total activity per course, per unique user on the last 24h 3 Course Reports o 3.1 Most Active courses o 3.2 Active courses, advanced o 3.3 RESOURCE count for each COURSE o 3.4 Detailed Resource COUNT by Teacher in each course o 3.5 Courses that are defined as using GROUPs o 3.6 List all Courses in and below a certain category o 3.7 List all Categories in one level below a certain category
3.8 Blog activity per Course (not including VIEW) 3.9 All Courses which uploaded a Syllabus file 3.10 Site-wide completed SCORM activities by Course name 4 Grade Reports o 4.1 Site-Wide Grade Report with All Items o 4.2 Site-Wide Grade Report with Just Course Totals o 4.3 Learner report by Learner with grades 5 Activity Module Reports o 5.1 How many SCORM activities are used in each Course o 5.2 Detailed ACTIONs for each MODULE o 5.3 Most popular ACTIVITY o 5.4 System wide use of ACTIVITIES and RESOURCES o 5.5 LOG file ACTIONS per MODULE per COURSE (IDs) o 5.6 System Wide usage count of various course Activities o 5.7 Course wiki usage/activity over the last 6 semesters o 5.8 Detailed WIKI activity (per wiki per course) o 5.9 Wiki usage, system wide o 5.10 Aggregated Teacher activity by "WEB2" Modules o 5.11 List all the certificates issued, sort by variables in the custom profile fields o 5.12 Counter Blog usage in Courses,system wide o 5.13 Elluminate (Blackboard Collaborate) - system wide usage 6 Assignment Module Reports o 6.1 All Ungraded Assignments o 6.2 All Ungraded Assignments w/ Link o 6.3 Assignments (and Quizzes) waiting to be graded o 6.4 Who is using "Single File Upload" assignment 7 Resource Module Reports o 7.1 List "Recently uploaded files" o 7.2 List Courses that loaded a specific file: "X" o 7.3 All resources that link to some specific external website o 7.4 "Compose Web Page" RESOURCE count o 7.5 Resource count in courses 8 Forum Module Reports o 8.1 print all User's post in course Forums o 8.2 FORUM use Count per COURSE -- not including NEWS Forum! o 8.3 FORUM use Count per COURSE by type -- not including NEWS Forum! o 8.4 Forum activity - system wide o 8.5 Activity In Forums o 8.6 All Forum type:NEWS o 8.7 All new forum NEWS items (discussions) from all my Courses o 8.8 News Forum - Discussions COUNT 9 Quiz Module Reports o 9.1 Generate a list of instructors and their email addresses for those courses that has "essay questions" in their quizzes o 9.2 Number of Quizes per Course o 9.3 List all MultiAnswer (Cloze) Questions
o o o
9.4 List courses with MANUAL grades 9.5 List the users that did not took the Quiz 10 SCORM Activity Reports o 10.1 Lists All completed SCORM activites by Course name
o o
,(SELECT name FROM prefix_role WHERE id=asg.roleid) FROM prefix_user AS USER, prefix_course AS course, prefix_role_assignments AS asg INNER JOIN prefix_context AS context ON asg.contextid=context.id WHERE context.contextlevel = 50 AND USER.id=asg.userid AND context.instanceid=course.id
Enrolled users,which did not login into the Course, even once (Moodle 2)
Designed forMoodle 2 table structure and uses special plugin filter : %%FILTER_SEARCHTEXT:table.field%%
SELECT user2.id AS ID, ul.timeaccess, user2.firstname AS Firstname, user2.lastname AS Lastname, user2.email AS Email, user2.city AS City, user2.idnumber AS IDNumber, user2.phone1 AS Phone, user2.institution AS Institution, IF (user2.lastaccess = 0,'never', DATE_FORMAT(FROM_UNIXTIME(user2.lastaccess),'%Y-%m-%d')) AS dLastAccess ,(SELECT DATE_FORMAT(FROM_UNIXTIME(timeaccess),'%Y-%m-%d') FROM prefix_user_lastaccess WHERE userid=user2.id AND courseid=c.id) AS CourseLastAccess ,(SELECT r.name FROM prefix_user_enrolments AS uenrol
JOIN prefix_enrol AS e ON e.id = uenrol.enrolid JOIN prefix_role AS r ON e.id = r.id WHERE uenrol.userid=user2.id AND e.courseid = c.id) AS RoleName FROM prefix_user_enrolments AS ue JOIN prefix_enrol AS e ON e.id = ue.enrolid JOIN prefix_course AS c ON c.id = e.courseid JOIN prefix_user AS user2 ON user2 .id = ue.userid LEFT JOIN prefix_user_lastaccess AS ul ON ul.userid = user2.id WHERE c.id=16 AND ul.timeaccess IS NULL %%FILTER_SEARCHTEXT:user2.firstname%%
Lists the users who have only logged into the site once
SELECT id, username, firstname, lastname, idnumber FROM prefix_user WHERE prefix_user.deleted = 0
User's courses
change "u.id = 2" with a new user id
SELECT u.firstname, u.lastname, c.id, c.fullname FROM prefix_course AS c 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 u.id = 2
Special Roles
SELECT ra.roleid,r.name ,concat('<a target="_new" href="%%WWWROOT%%/course/user.php?id=1&user=',ra.userid,'">',u.firstname ,' ',u.lastname,'</a>') AS Username ,concat('<a target="_new" href="%%WWWROOT%%/course/view.php?id=',c.id,'">',c.fullname,'</a>') AS Course FROM prefix_role_assignments AS ra JOIN prefix_role AS r ON r.id = ra.roleid JOIN prefix_user AS u ON u.id = ra.userid JOIN prefix_context AS ctx ON (ctx.id = ra.contextid AND ctx.contextlevel = 50)
List of users who have been enrolled for more than 4 weeks
For Moodle 2.2 , by Isuru Madushanka Weerarathna
SELECT uenr.userid AS USER, IF(enr.courseid=enr.courseid ,'Y','N') AS Enrolled, IF(DATEDIFF(NOW(), FROM_UNIXTIME(uenr.timecreated))>=28,'Y','N') AS EnrolledMoreThan4Weeks FROM mdl_enrol AS enr, mdl_user_enrolments AS uenr WHERE enr.id = uenr.enrolid AND enr.STATUS = uenr.statu
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,grptimeh
Total activity per course, per unique user on the last 24h
SELECT COUNT(DISTINCT userid) AS countUsers , COUNT(course) AS countVisits , concat('<a target="_new" href="%%WWWROOT%%/course/view.php?id=',c.id,'">',c.fullname,'</a>') AS Course FROM prefix_log AS l JOIN prefix_course AS c ON c.id = l.course WHERE course > 0 AND FROM_UNIXTIME(TIME) >= DATE_SUB(NOW(), INTERVAL 1 DAY) AND c.fullname LIKE '%%' GROUP BY course ORDER BY countVisits DESC
Course Reports
Most Active courses
SELECT COUNT(l.id) hits, l.course courseId, c.fullname coursename FROM prefix_log l INNER JOIN prefix_course c ON l.course = c.id GROUP BY courseId ORDER BY hits DESC
,(SELECT CONCAT(u.firstname,' ', u.lastname) AS Teacher FROM prefix_role_assignments AS ra JOIN prefix_context AS ctx ON ra.contextid = ctx.id JOIN prefix_user AS u ON u.id = ra.userid WHERE ra.roleid = 3 AND ctx.instanceid = c.id LIMIT 1) AS Teacher ,CASE WHEN WHEN WHEN END AS c.fullname LIKE '% 'THEN '' c.fullname LIKE '% 'THEN '' c.fullname LIKE '% 'THEN '' YEAR
,(SELECT COUNT(*) FROM prefix_course_modules cm WHERE cm.course = l.course) Modules ,(SELECT COUNT( ra.userid ) AS Users FROM prefix_role_assignments AS ra JOIN prefix_context AS ctx ON ra.contextid = ctx.id WHERE ra.roleid = 5 AND ctx.instanceid = c.id) AS Students FROM prefix_log l INNER JOIN prefix_course c ON l.course = c.id GROUP BY c.id HAVING Modules > 2 ORDER BY YEAR DESC, hits DESC
WHEN c.fullname LIKE '% %' THEN 'Semester C' END ) AS Semester ,COUNT(c.id) AS Total ,(SELECT COUNT(*) FROM prefix_course_modules AS cm WHERE cm.course = c.id AND cm.module= 20) AS TABs ,(SELECT COUNT(*) FROM prefix_course_modules AS cm WHERE cm.course = c.id AND cm.module= 33) AS BOOKs FROM `prefix_resource` AS r JOIN `prefix_course` AS c ON c.id = r.course #WHERE TYPE= 'file' AND reference NOT LIKE 'http://%' #WHERE 1=1 #%%FILTER_YEARS:c.fullname%% #AND c.fullname LIKE '%2013%' GROUP BY course ORDER BY COUNT(c.id) DESC
$parent_id = $s; $categories= array(); $categories = get_categories($parent_id); echo '<ol>'; foreach ($categories as $category) { echo '<li><a href="'.$CFG>wwwroot.'/course/category.php?id='.$category->id.'">'.$category>name.'</a></li>'; } echo '</ol>'; ?>
JOIN prefix_user AS u ON u.id = ra.userid WHERE ra.roleid = 3 AND ctx.instanceid = c.id LIMIT 1) AS Teacher FROM prefix_resource AS r JOIN prefix_course AS c ON r.course = c.id WHERE ( r.name LIKE '%%' OR r.name LIKE '%%' OR r.name LIKE '%syllabus%' OR r.name LIKE '% %' ) AND c.category IN (10,18,26,13,28)
Grade Reports
Site-Wide Grade Report with All Items
Shows grades for all course items along with course totals for each student.
SELECT u.firstname AS 'First' , u.lastname AS 'Last', u.firstname + ' ' + u.lastname AS 'Display Name', c.fullname AS 'Course', cc.name AS 'Category', CASE WHEN gi.itemtype = 'course' THEN c.fullname + ' Course Total' ELSE gi.itemname END AS 'Item Name', ROUND(gg.finalgrade,2) AS Grade, DATEADD(ss,gi.timemodified,'1970-01-01') AS TIME FROM JOIN JOIN JOIN JOIN JOIN JOIN prefix_course AS c prefix_context AS ctx ON c.id = ctx.instanceid prefix_role_assignments AS ra ON ra.contextid = ctx.id prefix_user AS u ON u.id = ra.userid prefix_grade_grades AS gg ON gg.userid = u.id prefix_grade_items AS gi ON gi.id = gg.itemid prefix_course_categories AS cc ON cc.id = c.category
For MySQL users, you'll need to use the MySQL DATE_ADD function instead of DATEADD:
DATE_ADD('1970-01-01', INTERVAL gi.timemodified SECONDS) AS Time
ORDER BY lastname
For MySQL users, you'll need to use the MySQL DATE_ADD function instead of DATEADD:
DATE_ADD('1970-01-01', INTERVAL gi.timemodified SECONDS) AS Time
JOIN prefix_grade_items AS gi ON gi.id = gg.itemid JOIN prefix_course_categories AS cc ON cc.id = c.category WHERE gi.courseid = c.id AND gi.itemname != 'Attendance' ORDER BY `Name` ASC
,(SELECT COUNT( m.name ) AS COUNT FROM prefix_course_modules AS cm JOIN prefix_modules AS m ON cm.module = m.id WHERE cm.course = c.id AND m.name LIKE '%forum%') AS Forums ,(SELECT COUNT( m.name ) AS COUNT FROM prefix_course_modules AS cm JOIN prefix_modules AS m ON cm.module = m.id WHERE cm.course = c.id AND m.name LIKE '%data%') AS Databses ,(SELECT COUNT( m.name ) AS COUNT FROM prefix_course_modules AS cm JOIN prefix_modules AS m ON cm.module = m.id WHERE cm.course = c.id AND m.name LIKE '%assignment%') AS Assignments ,(SELECT COUNT( ra.userid ) AS Users FROM prefix_role_assignments AS ra JOIN prefix_context AS ctx ON ra.contextid = ctx.id WHERE ra.roleid = 5 AND ctx.instanceid = c.id) AS Students FROM prefix_course AS c WHERE c.category IN ( 18) ORDER BY Wikis DESC,Blogs DESC, Forums DESC
JOIN prefix_course AS c ON c.id = cm.course WHERE cm.course = c.id AND m.name LIKE '%wiki%' AND c.fullname LIKE CONCAT('%','2010','%') AND c.fullname LIKE '%Semester A%') AS '2010 <br/> Semester A' ,(SELECT COUNT( m.name ) AS COUNT FROM prefix_course_modules AS cm JOIN prefix_modules AS m ON cm.module = m.id JOIN prefix_course AS c ON c.id = cm.course WHERE cm.course = c.id AND m.name LIKE '%wiki%' AND c.fullname LIKE CONCAT('%','2010','%') AND c.fullname LIKE '%Semester B%') AS '2010 <br/> Semester B' ,(SELECT COUNT( m.name ) AS COUNT FROM prefix_course_modules AS cm JOIN prefix_modules AS m ON cm.module = m.id JOIN prefix_course AS c ON c.id = cm.course WHERE cm.course = c.id AND m.name LIKE '%wiki%' AND c.fullname LIKE CONCAT('%','','%') AND c.fullname LIKE '% %') AS '< br/> ' ,(SELECT COUNT( m.name ) AS COUNT FROM prefix_course_modules AS cm JOIN prefix_modules AS m ON cm.module = m.id JOIN prefix_course AS c ON c.id = cm.course WHERE cm.course = c.id AND m.name LIKE '%wiki%' AND c.fullname LIKE CONCAT('%','','%') AND c.fullname LIKE '% %') AS '< br/> ' ,(SELECT COUNT( m.name ) AS COUNT FROM prefix_course_modules AS cm JOIN prefix_modules AS m ON cm.module = m.id JOIN prefix_course AS c ON c.id = cm.course WHERE cm.course = c.id AND m.name LIKE '%wiki%' AND c.fullname LIKE CONCAT('%','','%') AND c.fullname LIKE '% %') AS '< br/> ' ,(SELECT COUNT( m.name ) AS COUNT FROM prefix_course_modules AS cm JOIN prefix_modules AS m ON cm.module = m.id JOIN prefix_course AS c ON c.id = cm.course WHERE cm.course = c.id AND m.name LIKE '%wiki%' AND c.fullname LIKE CONCAT('%','','%') AND c.fullname LIKE '% %') AS '< br/> ' ,(SELECT COUNT( m.name ) AS COUNT FROM prefix_course_modules AS cm JOIN prefix_modules AS m ON cm.module = m.id JOIN prefix_course AS c ON c.id = cm.course WHERE cm.course = c.id AND m.name LIKE '%wiki%' AND c.fullname LIKE CONCAT('%','','%') AND c.fullname LIKE '% %') AS '< br/> ' ,(SELECT COUNT( m.name ) AS COUNT FROM prefix_course_modules AS cm JOIN prefix_modules AS m ON cm.module = m.id JOIN prefix_course AS c ON c.id = cm.course
WHERE cm.course = c.id AND m.name LIKE '%wiki%' AND c.fullname LIKE CONCAT('%','','%') AND c.fullname LIKE '% %') AS '< br/> '
LIKE '%wiki%' AND l.action LIKE '%edit%' ) AS 'WikiActivity<br/>EDIT' ,(SELECT COUNT(*) FROM prefix_log AS l WHERE l.course = c.id AND l.module LIKE '%wiki%' AND l.action LIKE '%annotate%' ) AS 'WikiActivity<br/>ANNOTATE' ,(SELECT COUNT(*) FROM prefix_log AS l WHERE l.course = c.id AND l.module LIKE '%wiki%' AND l.action LIKE '%comments%' ) AS 'WikiActivity<br/>Comments' ,(SELECT COUNT( ra.userid ) AS Users FROM prefix_role_assignments AS ra JOIN prefix_context AS ctx ON ra.contextid = ctx.id WHERE ra.roleid = 5 AND ctx.instanceid = c.id) AS Students ,(SELECT COUNT(*) FROM prefix_ouwiki_pages AS ouwp JOIN prefix_ouwiki AS ouw ON ouw.id = ouwp.subwikiid WHERE ouw.course = c.id GROUP BY ouw.course ) AS OUWikiPages ,(SELECT COUNT( DISTINCT nwp.pagename ) FROM prefix_wiki_pages AS nwp JOIN prefix_wiki AS nw ON nw.id = nwp.dfwiki WHERE nw.course = c.id ) AS NWikiPages FROM prefix_course AS c WHERE c.category IN ( 8,13,15) HAVING Wikis > 0 ORDER BY 'WikiActivity<br/>ALL' DESC
List all the certificates issued, sort by variables in the custom profile fields
Note: The SQL queries look intimidating at first, but isn't really that difficult to learn. I've seen in the forums that users wanted to do 'site-wide' groups in 1.9x. This is sort of the idea. It pulls all the certificates issued to all users sorted by the custom profile fields, which in my case is the Units or Depts (i.e. my site wide groups). Why certificates? I've explored with both grades and quizzes, the course admins are not really interested in the actual grades but whether the learner received a certificate (i.e. passed the course with x, y, z activities). It also saves me from creating groups and assigning them into the right groups. Even assigning in bulk is not efficient, since I have upward of 25 groups per course and constantly new learners enrolling in courses. The limitation is something to do with the server? as it only pull 5000 rows of data. If anyone figured out how to change this, please let me know. In the meantime, the work around is to pull only a few units/depts at a time to limit the number of rows. This is fine at the moment, since each course admin are only responsible for certain units/depts.
SELECT DATE_FORMAT( FROM_UNIXTIME(prefix_certificate_issues.timecreated), '%Y/%m/%d' ) AS DATE, prefix_certificate_issues.classname AS Topic, prefix_certificate.name AS Certificate, prefix_certificate_issues.studentname AS Name, prefix_user_info_data.DATA AS Units FROM prefix_certificate_issues INNER JOIN prefix_user_info_data ON prefix_certificate_issues.userid = prefix_user_info_data.userid INNER JOIN prefix_certificate ON prefix_certificate_issues.certificateid = prefix_certificate.id WHERE prefix_user_info_data.DATA='Unit 1' OR prefix_user_info_data.DATA='Unit 2' OR prefix_user_info_data.DATA='Unit 3' ORDER BY Units, Name, Topic ASC
WHERE cm.course = c.id AND m.name LIKE '%blog%') AS Blogs ,(SELECT COUNT( ra.userid ) AS Users FROM prefix_role_assignments AS ra JOIN prefix_context AS ctx ON ra.contextid = ctx.id WHERE ra.roleid = 5 AND ctx.instanceid = c.id) AS Students FROM prefix_course AS c, (SELECT @counter := 0) AS s_init WHERE c.category IN ( 8,13,15) HAVING Blogs > 0 ORDER BY Blogs DESC
WHERE asb.grade < 0 AND cm.instance = a.id AND cm.module = 1 ORDER BY c.fullname, a.name, u.lastname
Returns all the submitted assignments that still need grading, along with a link that goes directly to the submission to grade it. The links work if you view the report within Moodle.
SELECT u.firstname AS "First", u.lastname AS "Last", c.fullname AS "Course", a.name AS "Assignment", '<a href="http://education.varonis.com/mod/assignment/submissions.php' + CHAR(63) + + 'id=' + CAST(cm.id AS VARCHAR) + '&userid=' + CAST(u.id AS VARCHAR) + '&mode=single&filter=0&offset=2">' + a.name + '</a>' AS "Assignmentlink" FROM JOIN JOIN JOIN JOIN prefix_assignment_submissions AS asb prefix_assignment AS a ON a.id = asb.assignment prefix_user AS u ON u.id = asb.userid prefix_course AS c ON c.id = a.course prefix_course_modules AS cm ON c.id = cm.course
WHERE asb.grade < 0 AND cm.instance = a.id AND cm.module = 1 ORDER BY c.fullname, a.name, u.lastname
number of quizzes unFinished Quiz attempts Finished Quiz attempts number of students number of Assignments number of submitted answers by students number of unchecked assignments (waiting for the Teacher) in a Course.
SELECT concat('<a target="_new" href="%%WWWROOT%%/course/view.php?id=',c.id,'">',c.fullname,'</a>') AS Course ,(SELECT CONCAT(u.firstname,' ', u.lastname) AS Teacher FROM prefix_role_assignments AS ra JOIN prefix_context AS ctx ON ra.contextid = ctx.id JOIN prefix_user AS u ON u.id = ra.userid WHERE ra.roleid = 3 AND ctx.instanceid = c.id LIMIT 1) AS Teacher
,concat('<a target="_new" href="%%WWWROOT%%/mod/assignment/index.php?id=',c.id,'"></a>' ) AS Assignments ,concat('<a target="_new" href="%%WWWROOT%%/mod/quiz/index.php?id=',c.id,'"></a>' ) AS 'Quizzes' ,(SELECT COUNT(*) FROM prefix_course_modules cm JOIN prefix_modules AS m ON m.id = cm.module WHERE m.name LIKE 'quiz' AND cm.course = c.id GROUP BY cm.course ) AS 'nQuizzes' ,(SELECT COUNT(*) FROM prefix_quiz_attempts AS qa JOIN prefix_quiz AS q ON q.id = qa.quiz WHERE q.course = c.id AND qa.timefinish = 0 GROUP BY q.course) AS 'unFinished Quiz attempts' ,(SELECT COUNT(*) FROM prefix_quiz_attempts AS qa JOIN prefix_quiz AS q ON q.id = qa.quiz WHERE q.course = c.id AND qa.timefinish > 0 GROUP BY q.course) AS 'finished quiz attempts' ,(SELECT COUNT( ra.userid ) AS Users FROM prefix_role_assignments AS ra JOIN prefix_context AS ctx ON ra.contextid = ctx.id WHERE ra.roleid = 5 AND ctx.instanceid = c.id ) AS nStudents ,( SELECT COUNT(a.id) FROM prefix_assignment AS a JOIN prefix_course_modules AS cm ON a.course = cm.course WHERE cm.instance = a.id AND cm.module = 1 AND a.course = c.id ) nAssignments ,( SELECT COUNT(*) FROM prefix_assignment AS a WHERE a.course = c.id AND FROM_UNIXTIME(a.timedue) > NOW() GROUP BY a.course ) 'Open <br/>Assignments' , CONCAT(ROUND( (100 / iAssignments ) * iOpenAssignments ) ,'%') 'unFinished <br/>Assignments <br/>(percent)' ,( SELECT COUNT(asb.id) FROM prefix_assignment_submissions AS asb JOIN prefix_assignment AS a ON a.id = asb.assignment
JOIN prefix_course_modules AS cm ON a.course = cm.course WHERE asb.grade < 0 AND cm.instance = a.id AND cm.module = 1 AND a.course = c.id ) 'unChecked <br/>Submissions' ,( SELECT COUNT(asb.id) FROM prefix_assignment_submissions AS asb JOIN prefix_assignment AS a ON a.id = asb.assignment JOIN prefix_course_modules AS cm ON a.course = cm.course WHERE cm.instance = a.id AND cm.module = 1 AND a.course = c.id ) 'Submitted <br/>Assignments' FROM prefix_course AS c LEFT JOIN ( SELECT course, COUNT(*) AS iAssignments FROM prefix_assignment AS a GROUP BY a.course ) AS tblAssignmentsCount ON tblAssignmentsCount.course = c.id LEFT JOIN ( SELECT course, COUNT(*) AS iOpenAssignments FROM prefix_assignment AS a WHERE FROM_UNIXTIME(a.timedue) > NOW() GROUP BY a.course ) AS tblOpenAssignmentsCount ON tblOpenAssignmentsCount.course = c.id WHERE 1=1 #AND c.fullname LIKE '%%' %%FILTER_YEARS:c.fullname%% ## You can enable the SEMESTER FILTER AS well, ## BY uncommenting the following line: ## %%FILTER_SEMESTERS:c.fullname%% ORDER BY 'Open <br/>Assignments' DESC
ON prefix_course.id = prefix_forum.course WHERE NOT(prefix_forum.TYPE = 'news') GROUP BY prefix_forum.course ORDER BY total DESC
FORUM use Count per COURSE by type -- not including NEWS Forum!
SELECT prefix_course.fullname, prefix_forum.course, prefix_forum.TYPE, COUNT(*) AS total FROM prefix_forum INNER JOIN prefix_course ON prefix_course.id = prefix_forum.course WHERE NOT(prefix_forum.TYPE = 'news') GROUP BY prefix_forum.course,prefix_forum.TYPE ORDER BY total DESC
Activity In Forums
Trying to figure out how much real activity we have in Forums by aggregating: Users in Course, Number of Posts, Number of Discussions, Unique student post, Unique student discussions, Number of Teachers , Number of Students, ratio between unique Student posts and the number of students in the Course...
SELECT c.fullname,f.name,f.TYPE ,(SELECT COUNT(id) FROM prefix_forum_discussions AS fd WHERE f.id = fd.forum) AS Discussions ,(SELECT COUNT(DISTINCT fd.userid) FROM prefix_forum_discussions AS fd WHERE fd.forum = f.id) AS UniqueUsersDiscussions ,(SELECT COUNT(fp.id) FROM prefix_forum_discussions fd JOIN prefix_forum_posts AS fp ON fd.id = fp.discussion WHERE f.id = fd.forum) AS Posts ,(SELECT COUNT(DISTINCT fp.userid) FROM prefix_forum_discussions fd JOIN prefix_forum_posts AS fp ON fd.id = fp.discussion WHERE f.id = fd.forum) AS UniqueUsersPosts ,(SELECT COUNT( ra.userid ) AS Students FROM prefix_role_assignments AS ra JOIN prefix_context AS ctx ON ra.contextid = ctx.id WHERE ra.roleid =5 AND ctx.instanceid = c.id ) AS StudentsCount ,(SELECT COUNT( ra.userid ) AS Teachers FROM prefix_role_assignments AS ra JOIN prefix_context AS ctx ON ra.contextid = ctx.id WHERE ra.roleid =3 AND ctx.instanceid = c.id ) AS 'Teacher<br/>Count' ,(SELECT COUNT( ra.userid ) AS Users FROM prefix_role_assignments AS ra JOIN prefix_context AS ctx ON ra.contextid = ctx.id WHERE ra.roleid IN (3,5) AND ctx.instanceid = c.id ) AS UserCount , (SELECT (UniqueUsersDiscussions / StudentsCount )) AS StudentDissUsage , (SELECT (UniqueUsersPosts /StudentsCount)) AS StudentPostUsage FROM prefix_forum AS f JOIN prefix_course AS c ON f.course = c.id WHERE `type` != 'news' ORDER BY StudentPostUsage DESC
WHERE fd.timemodified > ul.timeaccess AND fd.forum IN (SELECT f.id FROM prefix_course_modules AS cm JOIN prefix_modules AS m ON cm.module = m.id JOIN prefix_forum AS f ON cm.instance = f.id WHERE m.name = 'forum' AND f.TYPE = 'news') AND c.id IN (SELECT c.id FROM prefix_course AS c 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 u.id = 26) ORDER BY `fd`.`timemodified` DESC
qu.course = co.id AND co.id = ct.instanceid AND ra.roleid = re.id AND re.name = 'Teacher' AND ra.contextid = ct.id AND ra.userid = u.id SELECT COUNT('x') AS NumOfStudents FROM mdl_role_assignments a JOIN mdl_user u ON userid = u.id WHERE roleid = 5 AND contextid = (SELECT id FROM mdl_context WHERE instanceid = 668 AND contextlevel = 50)
Do not forget to change "c.id = 14" and q.name LIKE '%quiz name goes here%'
SELECT user2.id AS ID, ul.timeaccess, user2.firstname AS Firstname, user2.lastname AS Lastname, user2.email AS Email, user2.username AS IDNumber, user2.institution AS Institution, IF (user2.lastaccess = 0,'never', DATE_FORMAT(FROM_UNIXTIME(user2.lastaccess),'%Y-%m-%d')) AS dLastAccess ,(SELECT DATE_FORMAT(FROM_UNIXTIME(timeaccess),'%Y-%m-%d') FROM prefix_user_lastaccess WHERE userid=user2.id AND courseid=c.id) AS CourseLastAccess ,(SELECT r.name FROM prefix_user_enrolments AS uenrol JOIN prefix_enrol AS e ON e.id = uenrol.enrolid JOIN prefix_role AS r ON e.id = r.id WHERE uenrol.userid=user2.id AND e.courseid = c.id) AS RoleName FROM prefix_user_enrolments AS ue JOIN prefix_enrol AS e ON e.id = ue.enrolid JOIN prefix_course AS c ON c.id = e.courseid JOIN prefix_user AS user2 ON user2 .id = ue.userid LEFT JOIN prefix_user_lastaccess AS ul ON ul.userid = user2.id WHERE c.id=14 AND ue.userid NOT IN (SELECT qa.userid FROM prefix_quiz_attempts AS qa JOIN prefix_quiz AS q ON qa.quiz = q.id JOIN prefix_course AS c ON q.course = c.id WHERE c.id = 14 AND q.name LIKE '%quiz name goes here%')