I found this php code at http://www.alt-php-faq.org/local/25/
which calculates (I think!) the total size of a directory. I thought this would be useful hack to calculate the size of individual Moodle courses (in the moodledata directory).
Any suggestions as to what Moodle screen would best accommodate such information for the admin and for the course instructors?
<?php
$totalsize=0;
function show_dir($dir, $pos=2){
global $totalsize;
if($pos == 2)
echo "<hr><pre>";
$handle = @opendir($dir);
while ($file = @readdir ($handle)){
if (eregi("^\.{1,2}$",$file))
continue;
if(is_dir($dir.$file)){
echo "|- ".$pos."s <b>$file</b>\n";
show_dir("$dir.$file/", $pos+3);
}else{
$size=filesize($dir.$file);
echo "|- ".$pos."s $file ";
echo("$size <br>");
$totalsize=$totalsize+$size;
}
}
@closedir($handle);
if($pos == 2) echo "</pre><hr>";
return($totalsize);
}
$totalsize = show_dir("c:/winnt/system32/");
echo($totalsize);
?>
Thanks for any ideas.
-Tom
You mean something like this?
So the admin can see 'dangerously overenthusiastic' teachers, filling up serverspace?
So the admin can see 'dangerously overenthusiastic' teachers, filling up serverspace?
Exactly. I think that's a great place for it, too.
(Maybe at the course category level, as well?)
Perhaps the size should be printed in the course settings screen, too, as reference?
Thanks for the nice picture!
a dangerously enthusiastic humanities teacher,
Tom
(Maybe at the course category level, as well?)
Perhaps the size should be printed in the course settings screen, too, as reference?
Thanks for the nice picture!
a dangerously enthusiastic humanities teacher,
Tom
Hi Tom & Koen,
Koen,
WP1
Koen,
- Is the file size measurement indicative of just teacher files or teacher and student files?
- Can you share the code with other Moodlers.
WP1
The idea is totaly Tom's, and, I'm sorry WP, the screenshot is just a dummy
It would surely be a nice adition to the administration pages, especially for poor guys like me with a very limited serverspace and teachers, sharing their slideshows with pictures and spoken texts in mp3-format
It would surely be a nice adition to the administration pages, especially for poor guys like me with a very limited serverspace and teachers, sharing their slideshows with pictures and spoken texts in mp3-format
That's what I was thinking, too, Koen. Just a quick way to check on server resources. I know it doesn't weigh what is in the database, but it could figure out the bulk of files in the moodledata folders.
W.P., we're just playing at functionality and ideas. What's your rationale/purpose for separating the two?
-Tom
W.P., we're just playing at functionality and ideas. What's your rationale/purpose for separating the two?
-Tom
Great idea,
I think I've got it working the way Koen suggested, by adding some lines in course/category.php
I only tried this on my local copy of moodle, hope it doesn't break anything when uploaded to a webserver...
I used strange names for the function ans for the variables, just to make sure they don't interfere with existing code. Feel free to change them...
WP1, I don't know of an easy way to separate student / teacher files. Sorry!
Hi Jan,
Is your script for v1.3.x, 1.4 Dev or both?
WP1
Is your script for v1.3.x, 1.4 Dev or both?
WP1
Hi Tom,
This would be a good administrator's tool. However, I also think it would be good to know what the numbers mean in relationship to instructor and student.
Just my thoughts about it.
WP1
This would be a good administrator's tool. However, I also think it would be good to know what the numbers mean in relationship to instructor and student.
- Allow an admin to allocate disk space more carefully. Also, it would allow teachers to determine their use of the space and manage student response and input (uploads) better.
- A teacher who has 50MB vs 25MB to use for their courses I think will approach things a bit differently for themselves and students. For example, they will probably have to determine how they will archive student's work as the term goes by.
- If you are a NYC teacher with 5 classes a day and a total of 125 to 140 students in different classes (about 30 - 35 students) in each class and only 200MB of space alloted for you course, what do you do? Gotta have some kind of Archival policy or procedure.
- A teacher who has 50MB vs 25MB to use for their courses I think will approach things a bit differently for themselves and students. For example, they will probably have to determine how they will archive student's work as the term goes by.
- Provide proof of use. Some school administrators only respond if they feel students and not teachers need something. This would be a way to demonsytrate that students are using the site and that teachers are not just archiving material on the space. Might even help the teacher get more space so they can upload meaningful video clips etc.
- Just for fun.
Just my thoughts about it.
WP1
Note there is already a function in Moodle to do this (in lib/moodlelib.php):
get_directory_size($rootdir);
(Sorry for the previous message which I've deleted ... I accidentally posted as Gerald Lendow after doing some testing here on moodle.org).
get_directory_size($rootdir);
(Sorry for the previous message which I've deleted ... I accidentally posted as Gerald Lendow after doing some testing here on moodle.org).
Hi Martin,
WP1
- Is this function applicable only when obtaining the total size of the Moodle install or can it be applied when obtaining the space used by each course, teacher and student in the course.?
- Can it work with the coming DMS?
WP1
This sort of stuff is one of the things that the DMS is supposed to solve (ie disk quotas).