'document.php','name' => get_lang('ToolDocument'));
// Title of the page
$nameTools = get_lang('DocumentQuota');
// Display the header
Display::display_header($nameTools,'Doc');
/* FUNCTIONS */
/**
* Here we count 1 kilobyte = 1000 byte, 12 megabyte = 1000 kilobyte.
*/
function display_quota($course_quota, $already_consumed_space) {
$course_quota_m = round($course_quota / 1000000);
$already_consumed_space_m = round($already_consumed_space / 1000000);
$message = get_lang('CourseCurrentlyUses') . ' ' . $already_consumed_space_m . ' megabyte.
'. get_lang('MaximumAllowedQuota') . ' '.$course_quota_m.' megabyte.
';
$percentage = $already_consumed_space / $course_quota * 100;
$percentage = round($percentage);
$other_percentage = $percentage < 100 ? 100 - $percentage : 0;
// Decide where to place percentage in graph
if ($percentage >= 50) {
$text_in_filled = ' '.$other_percentage.'%';
$text_in_unfilled = '';
} else {
$text_in_unfilled = ' '.$other_percentage.'%';
$text_in_filled = '';
}
// Decide the background colour of the graph
if ($percentage < 65) {
$colour = '#00BB00'; // Safe - green
} elseif ($percentage < 90) {
$colour = '#ffd400'; // Filling up - yelloworange
} else {
$colour = '#DD0000'; // Full - red
}
// This is used for the table width: a table of only 100 pixels looks too small
$visual_percentage = 4 * $percentage;
$visual_other_percentage = 4 * $other_percentage;
$message .= get_lang('PercentageQuotaInUse') . ': '.$percentage.'%.
' .
get_lang('PercentageQuotaFree') . ': '.$other_percentage.'%.
';
$show_percentage = $percentage >= 10 ? ' '.$percentage.'%' : '';
$message .= '
'.$show_percentage.' | '.$other_percentage.'% |