-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrenderers.php
More file actions
127 lines (103 loc) · 4.89 KB
/
renderers.php
File metadata and controls
127 lines (103 loc) · 4.89 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot . '/course/renderer.php');
class theme_ktt_boost_child_som_core_course_renderer extends core_course_renderer {
/**
* Renders HTML to display one course module in a course section
*
* This includes link, content, availability, completion info and additional information
* that module type wants to display (i.e. number of unread forum posts)
*
* This function calls:
* {@link core_course_renderer::course_section_cm_name()}
* {@link core_course_renderer::course_section_cm_text()}
* {@link core_course_renderer::course_section_cm_availability()}
* {@link core_course_renderer::course_section_cm_completion()}
* {@link course_get_cm_edit_actions()}
* {@link core_course_renderer::course_section_cm_edit_actions()}
*
* @param stdClass $course
* @param completion_info $completioninfo
* @param cm_info $mod
* @param int|null $sectionreturn
* @param array $displayoptions
* @return string
*/
public function course_section_cm($course, &$completioninfo, cm_info $mod, $sectionreturn, $displayoptions = array()) {
$output = '';
// We return empty string (because course module will not be displayed at all)
// if:
// 1) The activity is not visible to users
// and
// 2) The 'availableinfo' is empty, i.e. the activity was
// hidden in a way that leaves no info, such as using the
// eye icon.
if (!$mod->is_visible_on_course_page()) {
return $output;
}
$indentclasses = 'mod-indent';
if (!empty($mod->indent)) {
$indentclasses .= ' mod-indent-'.$mod->indent;
if ($mod->indent > 15) {
$indentclasses .= ' mod-indent-huge';
}
}
$output .= html_writer::start_tag('div');
if ($this->page->user_is_editing()) {
$output .= course_get_cm_move($mod, $sectionreturn);
}
$output .= html_writer::start_tag('div', array('class' => 'mod-indent-outer w-100'));
// This div is used to indent the content.
$output .= html_writer::div('', $indentclasses);
// Start a wrapper for the actual content to keep the indentation consistent
$output .= html_writer::start_tag('div');
// Display the link to the module (or do nothing if module has no url)
$cmname = $this->course_section_cm_name($mod, $displayoptions);
if (!empty($cmname)) {
// Start the div for the activity title, excluding the edit icons.
$output .= html_writer::start_tag('div', array('class' => 'activityinstance'));
$output .= $cmname;
// Module can put text after the link (e.g. forum unread)
$output .= $mod->afterlink;
// Closing the tag which contains everything but edit icons. Content part of the module should not be part of this.
$output .= html_writer::end_tag('div'); // .activityinstance
}
// If there is content but NO link (eg label), then display the
// content here (BEFORE any icons). In this case cons must be
// displayed after the content so that it makes more sense visually
// and for accessibility reasons, e.g. if you have a one-line label
// it should work similarly (at least in terms of ordering) to an
// activity.
$contentpart = $this->course_section_cm_text($mod, $displayoptions);
$url = $mod->url;
if (empty($url)) {
$output .= $contentpart;
}
$modicons = '';
if ($this->page->user_is_editing()) {
$editactions = course_get_cm_edit_actions($mod, $mod->indent, $sectionreturn);
$modicons .= ' '. $this->course_section_cm_edit_actions($editactions, $mod, $displayoptions);
$modicons .= $mod->afterediticons;
}
$modicons .= $this->course_section_cm_completion($course, $completioninfo, $mod, $displayoptions);
if (!empty($modicons)) {
$output .= html_writer::div($modicons, 'actions');
}
// Show availability info (if module is not available).
$output .= $this->course_section_cm_availability($mod, $displayoptions);
// If there is content AND a link, then display the content here
// (AFTER any icons). Otherwise it was displayed before
if (!empty($url)) {
$output .= $contentpart;
}
$output .= 'Added on date: ';
$output .= html_writer::start_tag('strong');
$output .= date_format_string($mod->added, '%Y-%m');
$output .= html_writer::end_tag('strong');
$output .= html_writer::end_tag('div'); // $indentclasses
// End of indentation div.
$output .= html_writer::end_tag('div');
$output .= html_writer::end_tag('div');
return $output;
}
}