counting number of files uploaded in Moodle

counting number of files uploaded in Moodle

by m question -
Number of replies: 4

Hi, 


this report in Moodle ad hoc reports for Moodle 3.1 count number of files, however if teacher used folder resource and uploaded the files in folder, the report does not count those files which give not accurate results.


how to change the report to include ALL files even uploaded in folder resource.


Thanks

Average of ratings: -
In reply to m question

Re: counting number of files uploaded in Moodle

by m question -

I still have the same question

there are 3 tables that I think I need to use to calculate the number of files (either uploaded to course page or uploaded to folder) :

mdl_resource

mdl_files

mdl_folder


but I can't calculate number of files IN folders, I don't see common field between two relation mdl_files and mdl_folder

I am using this report from ad hoc report page

==================================

SELECT COUNT(*) AS COUNT ,r.course ,c.shortname shortname ,c.fullname coursename 

,( SELECT DISTINCT CONCAT(u.firstname,' ',u.lastname) FROM prefix_role_assignments AS ra JOIN prefix_user AS u ON ra.userid = u.id JOIN prefix_context AS ctx ON ctx.id = ra.contextid 

WHERE ra.roleid = 3 AND ctx.instanceid = r.course AND ctx.contextlevel = 50 LIMIT 1) AS Teacher 


FROM prefix_resource r JOIN prefix_course c ON r.course = c.id WHERE c.category IN (10,13,28,18,26) GROUP BY r.course ORDER BY COUNT(*) DESC


In reply to m question

Re: counting number of files uploaded in Moodle

by m question -
relation  mdl_files_reference is empty , is that normal?


In reply to m question

Re: counting number of files uploaded in Moodle

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Yes.

In reply to Tim Hunt

Re: counting number of files uploaded in Moodle

by Dario Roig Garcia -

Hello, you can try this SQL. You can obtain the sum of files in all folders that belong to one courseid. In the example 47255.

select sum(filesize) from mdl_files f, (select ctx.id from mdl_course_modules AS cm INNER JOIN mdl_context AS ctx ON ctx.contextlevel = 70 AND ctx.instanceid = cm.id INNER JOIN mdl_modules AS mdl ON cm.module = mdl.id LEFT JOIN mdl_folder AS  d ON cm.instance = d.id  where d.course = 47255 and cm.course = 47255) folder where f.contextid = folder.id;

Regards