Sql Query for Course Size

Sql Query for Course Size

by Mr Blue -
Number of replies: 7

Hey,

I am trying to create a query which will report on the sizes of my course based within a certain time frame..

any ideas ?

Average of ratings: -
In reply to Mr Blue

Re: Sql Query for Course Size

by Darko Miletić -

What is course size?

In reply to Darko Miletić

Re: Sql Query for Course Size

by Mr Blue -

Hey 


Thanks for the reply, ideally i would like to know the files that have contributed to the course, which would generate the size (mb) of the course.



In reply to Mr Blue

Re: Sql Query for Course Size

by Colin Fraser -
Picture of Documentation writers Picture of Testers

AFAIK, currently, this can only be done via a backup, but I don't think that this is what you are after. My thought is that you can ask the database, via an SQL query. I suspect, though, it will not likely be worth the time required to build the query to get the result you are looking for. A basic outline of that query would be something along the lines of 

select files.name, files.size, ....from myMoodledb where files.contextid="%*"  and so on, 

The issue is that while this might tell you the name, filesize and whatever other information you want of any file you use in any course, it will still not be accurate if you have a page resource, a forum, glossaries, grades etc. I don't think that the byte size of any other resource or activity types are recorded anywhere - well, I haven't found them yet.

  

In reply to Colin Fraser

Re: Sql Query for Course Size

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators

The Course size report might give you a few ideas too:

https://moodle.org/plugins/report_coursesize


the report is built by the sql queries here:

https://github.com/danmarsden/moodle-report_coursesize/blob/master/index.php#L63

Average of ratings: Useful (3)
In reply to Dan Marsden

Re: Sql Query for Course Size

by Mr Blue -

Hi,


Thank you all for the responses.. 

I am trying to install the plugin.. but it doesnt get recognised when check for updates ?

Which folder directory does it install into ?

Regards

In reply to Mr Blue

Re: Sql Query for Course Size

by Mr Blue -

Hi..

Managed to solve that last issue.


Thanks again.

In reply to Mr Blue

Re: Sql Query for Course Size

by Arvind Dubey -

If you are looking size of uploaded files in a course then below query can help you.


"SELECT sum(filesize) as filesize FROM `mdl_files` f INNER JOIN mdl_context cn ON cn.id = f.contextid INNER JOIN mdl_course c ON c.id = cn.instanceid AND cn.contextlevel = 50 where c.id = ?";


But if you are looking entire course size including text stored in database, then create a course back up and check size of back up data.


Average of ratings: Useful (1)