1 |
efrain |
1 |
<?php
|
|
|
2 |
// This file is part of Moodle - http://moodle.org/
|
|
|
3 |
//
|
|
|
4 |
// Moodle is free software: you can redistribute it and/or modify
|
|
|
5 |
// it under the terms of the GNU General Public License as published by
|
|
|
6 |
// the Free Software Foundation, either version 3 of the License, or
|
|
|
7 |
// (at your option) any later version.
|
|
|
8 |
//
|
|
|
9 |
// Moodle is distributed in the hope that it will be useful,
|
|
|
10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
12 |
// GNU General Public License for more details.
|
|
|
13 |
//
|
|
|
14 |
// You should have received a copy of the GNU General Public License
|
|
|
15 |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
16 |
|
|
|
17 |
/**
|
|
|
18 |
* Completion Progress block runtime configured styles.
|
|
|
19 |
*
|
|
|
20 |
* @package block_completion_progress
|
|
|
21 |
* @copyright 2020 Jonathon Fowler
|
|
|
22 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
23 |
*/
|
|
|
24 |
|
|
|
25 |
define('NO_DEBUG_DISPLAY', true);
|
|
|
26 |
define('NO_MOODLE_COOKIES', true);
|
|
|
27 |
define('NO_UPGRADE_CHECK', true);
|
|
|
28 |
|
|
|
29 |
require_once(__DIR__ . '/../../config.php');
|
|
|
30 |
require_once($CFG->libdir.'/filelib.php');
|
|
|
31 |
|
|
|
32 |
$cachevalue = optional_param('v', -1, PARAM_INT);
|
|
|
33 |
|
|
|
34 |
$css = '';
|
|
|
35 |
|
|
|
36 |
// Emit colours configuration.
|
|
|
37 |
$colours = array(
|
|
|
38 |
'completed' => 'completed_colour',
|
|
|
39 |
'submittedNotComplete' => 'submittednotcomplete_colour',
|
|
|
40 |
'notCompleted' => 'notCompleted_colour',
|
|
|
41 |
'futureNotCompleted' => 'futureNotCompleted_colour'
|
|
|
42 |
);
|
|
|
43 |
foreach ($colours as $classname => $stringkey) {
|
|
|
44 |
$colour = get_config('block_completion_progress', $stringkey) ?:
|
|
|
45 |
get_string($stringkey, 'block_completion_progress');
|
|
|
46 |
$css .= ".block_completion_progress .progressBarCell.$classname { ";
|
|
|
47 |
$css .= "background-color: $colour;";
|
|
|
48 |
$css .= " }\n";
|
|
|
49 |
}
|
|
|
50 |
|
|
|
51 |
if ($cachevalue < 0) {
|
|
|
52 |
send_content_uncached($css, 'styles.css');
|
|
|
53 |
} else {
|
|
|
54 |
send_file($css, 'styles.css', null, 0, true, false, '', false, ['immutable' => true]);
|
|
|
55 |
}
|