File tree Expand file tree Collapse file tree 9 files changed +8
-19
lines changed Expand file tree Collapse file tree 9 files changed +8
-19
lines changed Original file line number Diff line number Diff line change @@ -94,12 +94,7 @@ public function get_disk_usage() {
94
94
return get_string ('notcalculated ' , 'block_site_stats ' );
95
95
}
96
96
97
- $ unit = get_string ('sizemb ' , 'block_site_stats ' );
98
- if ($ diskusagecache > 1024 ) {
99
- $ unit = get_string ('sizegb ' , 'block_site_stats ' );
100
- }
101
-
102
- return $ diskusagecache . $ unit ;
97
+ return $ diskusagecache ;
103
98
}
104
99
/**
105
100
* Export the data for template
Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ public function execute() {
44
44
global $ CFG ;
45
45
$ cache = cache::make ('block_site_stats ' , 'sitestats ' );
46
46
$ diskusage = get_directory_size ($ CFG ->dataroot );
47
- $ disksize = number_format ( ceil ( $ diskusage / 1048576 ) );
47
+ $ disksize = display_size ( $ diskusage );
48
48
$ cache ->set ('diskusage ' , $ disksize );
49
49
return true ;
50
50
}
Original file line number Diff line number Diff line change 31
31
$ string ['privacy:metadata ' ] = 'The Site Statistics block only shows data stored in other locations. ' ;
32
32
$ string ['site_stats:myaddinstance ' ] = 'Add a new Site Statistics block to Dashboard ' ;
33
33
$ string ['site_stats:view ' ] = 'View Site Statistics block content ' ;
34
- $ string ['sizegb ' ] = ' GB ' ;
35
- $ string ['sizemb ' ] = ' MB ' ;
36
34
$ string ['users ' ] = 'Users ' ;
Original file line number Diff line number Diff line change 31
31
$ string ['privacy:metadata ' ] = 'साइट आँकड़े ब्लॉक केवल अन्य स्थानों में संग्रहित डेटा दिखाता है। ' ;
32
32
$ string ['site_stats:myaddinstance ' ] = 'डैशबोर्ड पर नया साइट आँकड़ा ब्लॉक जोड़ें ' ;
33
33
$ string ['site_stats:view ' ] = 'साइट आँकड़े ब्लॉक की सामग्री देखें ' ;
34
- $ string ['sizegb ' ] = ' जीबी ' ;
35
- $ string ['sizemb ' ] = ' एमबी ' ;
36
34
$ string ['users ' ] = 'उपयोगकर्ता ' ;
Original file line number Diff line number Diff line change 31
31
$ string ['privacy:metadata ' ] = 'साइट सांख्यिकी ब्लॉक फक्त इतर स्थानांतील डेटा दर्शवितो. ' ;
32
32
$ string ['site_stats:myaddinstance ' ] = 'डॅशबोर्डवर नविन साइट सांख्यिकी ब्लॉक जोडा ' ;
33
33
$ string ['site_stats:view ' ] = 'साइट सांख्यिकी ब्लॉक सामग्री पहा ' ;
34
- $ string ['sizegb ' ] = ' जीबी ' ;
35
- $ string ['sizemb ' ] = ' एमबी ' ;
36
34
$ string ['users ' ] = 'वापरकर्ते ' ;
Original file line number Diff line number Diff line change 13
13
//
14
14
// You should have received a copy of the GNU General Public License
15
15
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16
+
16
17
namespace block_site_stats \output ;
17
18
18
19
use advanced_testcase ;
@@ -95,20 +96,17 @@ public function test_get_activities_count(): void {
95
96
* @return void
96
97
*/
97
98
public function test_get_disk_usage (): void {
98
- global $ CFG ;
99
99
// Test when the diskusage scheduled task is not run.
100
100
$ diskusage = $ this ->main ->get_disk_usage ();
101
101
$ expected = get_string ('notcalculated ' , 'block_site_stats ' );
102
102
$ this ->assertEquals ($ expected , $ diskusage );
103
103
104
104
// Test when the diskusage scheduled task is run.
105
- $ diskusage = get_directory_size ($ CFG ->dataroot );
106
- $ disksize = number_format (ceil ($ diskusage / 1048576 ));
107
105
$ task = new diskusage ();
108
106
$ status = $ task ->execute ();
109
107
if ($ status ) {
110
108
$ diskusage = $ this ->main ->get_disk_usage ();
111
- $ this ->assertEquals ( $ disksize . ' MB ' , $ diskusage );
109
+ $ this ->assertNotEquals ( $ expected , $ diskusage );
112
110
}
113
111
}
114
112
}
Original file line number Diff line number Diff line change 13
13
//
14
14
// You should have received a copy of the GNU General Public License
15
15
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16
+
16
17
namespace block_site_stats \privacy ;
17
18
18
19
use advanced_testcase ;
Original file line number Diff line number Diff line change 13
13
//
14
14
// You should have received a copy of the GNU General Public License
15
15
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16
+
16
17
namespace block_site_stats ;
17
18
use advanced_testcase ;
18
19
use block_site_stats ;
Original file line number Diff line number Diff line change 24
24
25
25
defined ('MOODLE_INTERNAL ' ) || die ();
26
26
27
- $ plugin ->version = 2024050403 ; // The current plugin version (Date: YYYYMMDDXX).
28
- $ plugin ->release = '1.0.1 ' ;
27
+ $ plugin ->version = 2024050404 ; // The current plugin version (Date: YYYYMMDDXX).
28
+ $ plugin ->release = '1.0.2 ' ;
29
29
$ plugin ->requires = 2022111800 ; // Requires this Moodle version.
30
30
$ plugin ->component = 'block_site_stats ' ; // Full name of the plugin (used for diagnostics).
31
31
$ plugin ->maturity = MATURITY_STABLE ;
You can’t perform that action at this time.
0 commit comments