-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblock_studyprogress.php
More file actions
43 lines (33 loc) · 1.15 KB
/
Copy pathblock_studyprogress.php
File metadata and controls
43 lines (33 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
class block_studyprogress extends block_base {
public function init() {
$this->title = get_string('pluginname', 'block_studyprogress');
}
public function get_css_class() {
return 'block_studyprogress';
}
public function get_content() {
global $USER;
if ($this->content !== null) {
return $this->content;
}
$this->content = new stdClass();
$this->content->footer = '';
$courses = enrol_get_users_courses($USER->id, true);
if (empty($courses)) {
$this->content->text = get_string('nocourses', 'block_studyprogress');
return $this->content;
}
$output = html_writer::start_tag('ul');
foreach ($courses as $course) {
$url = new moodle_url('/course/view.php', ['id' => $course->id]);
$output .= html_writer::tag('li', html_writer::link($url, format_string($course->fullname)));
}
$output .= html_writer::end_tag('ul');
$this->content->text = $output;
return $this->content;
}
public function applicable_formats() {
return ['all' => true];
}
}