Last active
November 30, 2016 05:44
-
-
Save guillaumewuip/aa5764c92c80efce1873f9f01cadf0d3 to your computer and use it in GitHub Desktop.
Moodle files access
This file contains hidden or 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
DROP PROCEDURE IF EXISTS getLogsForModule; | |
DELIMITER $$ | |
CREATE PROCEDURE getLogsForModule(module VARCHAR(255)) | |
BEGIN | |
-- on doit passer par un concat car le nom d'une table doit être statique | |
SET @request = CONCAT("SELECT l.*, i.*, c.*, category_path(c.category) as category_path, u.* | |
FROM mdl_logstore_standard_log l | |
LEFT OUTER JOIN mdl_", module, " i ON i.id = l.objectid | |
LEFT OUTER JOIN mdl_course c ON c.id = l.courseid | |
LEFT OUTER JOIN mdl_user u ON u.id = l.userid | |
WHERE l.eventname LIKE '%", module, "%' | |
AND l.eventname LIKE '%course_module_viewed%';"); | |
PREPARE stmt FROM @request; | |
EXECUTE stmt; | |
DEALLOCATE PREPARE stmt; | |
END $$ | |
DELIMITER ; | |
-- | |
call getLogsForModule('resource') | |
call getLogsForModule('forum') | |
-- etc. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment