Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 19... Línea 19...
19
 *
19
 *
20
 * @package    block_social_activities
20
 * @package    block_social_activities
21
 * @copyright  1999 onwards Martin Dougiamas (http://dougiamas.com)
21
 * @copyright  1999 onwards Martin Dougiamas (http://dougiamas.com)
22
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
22
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
23
 */
24
 
-
 
25
class block_social_activities extends block_list {
24
class block_social_activities extends block_base {
26
    function init(){
25
    function init(){
27
        $this->title = get_string('pluginname', 'block_social_activities');
26
        $this->title = get_string('pluginname', 'block_social_activities');
28
    }
27
    }
Línea 29... Línea 28...
29
 
28
 
30
    function applicable_formats() {
29
    function applicable_formats() {
31
        return array('course-view-social' => true);
30
        return array('course-view-social' => true);
Línea 32... Línea 31...
32
    }
31
    }
33
 
-
 
34
    function get_content() {
-
 
35
        global $USER, $CFG, $DB, $OUTPUT;
32
 
36
 
33
    function get_content() {
37
        if ($this->content !== NULL) {
34
        if ($this->content !== NULL) {
Línea 38... Línea 35...
38
            return $this->content;
35
            return $this->content;
39
        }
36
        }
40
 
-
 
41
        $this->content = new stdClass();
37
 
Línea 42... Línea 38...
42
        $this->content->items = array();
38
        $this->content = new stdClass();
43
        $this->content->icons = array();
39
        $this->content->text = '';
44
        $this->content->footer = '';
40
        $this->content->footer = '';
Línea 45... Línea 41...
45
 
41
 
46
        if (empty($this->instance)) {
-
 
47
            return $this->content;
-
 
48
        }
-
 
49
 
-
 
50
        $course = $this->page->course;
-
 
51
        $format = course_get_format($course);
-
 
52
        $courserenderer = $format->get_renderer($this->page);
-
 
53
 
-
 
54
        require_once($CFG->dirroot.'/course/lib.php');
-
 
55
 
-
 
56
        $context = context_course::instance($course->id);
-
 
57
        $isediting = $this->page->user_is_editing() && has_capability('moodle/course:manageactivities', $context);
-
 
58
        $modinfo = get_fast_modinfo($course);
-
 
59
 
-
 
60
        // Output classes.
-
 
61
        $cmnameclass = $format->get_output_classname('content\\cm\\cmname');
-
 
62
        $controlmenuclass = $format->get_output_classname('content\\cm\\controlmenu');
-
 
63
 
-
 
64
        $badgeattributes = [
-
 
65
            'class' => 'badge rounded-pill bg-warning text-dark mt-2',
-
 
66
            'data-region' => 'visibility'
-
 
67
        ];
-
 
68
 
-
 
69
        // Extra fast view mode.
-
 
70
        if (!$isediting) {
-
 
71
            if (!empty($modinfo->sections[0])) {
-
 
72
                foreach($modinfo->sections[0] as $cmid) {
-
 
73
                    $cm = $modinfo->cms[$cmid];
-
 
74
                    if (!$cm->uservisible || !$cm->is_visible_on_course_page()) {
-
 
75
                        continue;
-
 
76
                    }
-
 
77
 
-
 
78
                    $badges = '';
-
 
79
                    if (!$cm->visible) {
-
 
80
                        $badges = html_writer::tag(
-
 
81
                            'span',
-
 
82
                            get_string('hiddenfromstudents'),
-
 
83
                            $badgeattributes
-
 
84
                        );
-
 
85
                    }
-
 
86
 
-
 
87
                    if ($cm->is_stealth()) {
-
 
88
                        $badges = html_writer::tag(
-
 
89
                            'span',
-
 
90
                            get_string('hiddenoncoursepage'),
-
 
91
                            $badgeattributes
-
 
92
                        );
-
 
93
                    }
-
 
94
 
-
 
95
                    if (!$cm->url) {
-
 
96
                        $activitybasis = html_writer::div(
-
 
97
                            $cm->get_formatted_content(['overflowdiv' => true, 'noclean' => true]),
-
 
98
                            'activity-basis d-flex align-items-center'
-
 
99
                        );
-
 
100
                        $content = html_writer::div(
-
 
101
                            $activitybasis . $badges,
-
 
102
                            'contentwithoutlink activity-item activity',
-
 
103
                            ['data-activityname' => $cm->name]
-
 
104
                        );
-
 
105
                        $this->content->items[] = $content;
-
 
106
                        $this->content->icons[] = '';
-
 
107
                    } else {
-
 
108
                        $cmname = new $cmnameclass($format, $cm->get_section_info(), $cm);
-
 
109
                        $activitybasis = html_writer::div(
-
 
110
                            $courserenderer->render($cmname),
-
 
111
                            'activity-basis d-flex align-items-center');
-
 
112
                        $content = html_writer::div(
-
 
113
                            $activitybasis . $badges,
-
 
114
                            'activity-item activity',
-
 
115
                            ['data-activityname' => $cm->name]
-
 
116
                        );
-
 
117
                        $this->content->items[] = $content;
-
 
Línea -... Línea 42...
-
 
42
        if (empty($this->instance)) {
118
                    }
43
            return $this->content;
119
                }
44
        }
120
            }
45
 
Línea 121... Línea 46...
121
            return $this->content;
46
        $course = $this->page->course;
122
        }
-
 
123
 
-
 
124
        // Slow & hacky editing mode.
-
 
125
        $ismoving = ismoving($course->id);
47
 
126
        $section = $modinfo->get_section_info(0);
-
 
127
 
-
 
128
        if ($ismoving) {
-
 
129
            $strmovefull = strip_tags(get_string('movefull', '', "'$USER->activitycopyname'"));
-
 
130
            $strcancel= get_string('cancel');
-
 
131
        } else {
-
 
132
            $strmove = get_string('move');
48
        course_create_sections_if_missing($course, 0);
Línea 133... Línea -...
133
        }
-
 
134
 
-
 
135
        if ($ismoving) {
-
 
136
            $this->content->icons[] = ' ' . $OUTPUT->pix_icon('t/move', get_string('move'));
-
 
137
            $cancelurl = new moodle_url('/course/mod.php', array('cancelcopy' => 'true', 'sesskey' => sesskey()));
-
 
138
            $this->content->items[] = $USER->activitycopyname . '&nbsp;(<a href="' . $cancelurl . '">' . $strcancel . '</a>)';
-
 
139
        }
-
 
140
 
-
 
141
        if (!empty($modinfo->sections[0])) {
-
 
142
            foreach ($modinfo->sections[0] as $modnumber) {
-
 
143
                $mod = $modinfo->cms[$modnumber];
-
 
144
                if (!$mod->uservisible || !$mod->is_visible_on_course_page()) {
-
 
145
                    continue;
-
 
146
                }
-
 
147
                if (!$ismoving) {
-
 
148
 
49
        $format = course_get_format($course);
149
                    $controlmenu = new $controlmenuclass(
-
 
150
                        $format,
-
 
151
                        $mod->get_section_info(),
-
 
152
                        $mod,
-
 
153
                        ['disableindentation' => true]
-
 
154
                    );
-
 
155
 
-
 
156
                    $menu = $controlmenu->get_action_menu($OUTPUT);
-
 
157
 
-
 
158
                    // Add a move primary action.
-
 
159
                    $moveaction = html_writer::link(
-
 
160
                        new moodle_url('/course/mod.php', ['sesskey' => sesskey(), 'copy' => $mod->id]),
-
 
161
                        $OUTPUT->pix_icon('i/dragdrop', $strmove),
-
 
162
                        ['class' => 'editing_move_activity']
-
 
163
                    );
-
 
164
 
-
 
165
                    $editbuttons = html_writer::tag('div',
-
 
166
                        $courserenderer->render($controlmenu),
-
 
167
                        ['class' => 'buttons activity-actions ml-auto']
-
 
168
                    );
-
 
169
                } else {
-
 
170
                    $editbuttons = '';
-
 
171
                    $moveaction = '';
-
 
172
                }
-
 
173
                if ($mod->visible || has_capability('moodle/course:viewhiddenactivities', $mod->context)) {
-
 
174
                    if ($ismoving) {
-
 
175
                        if ($mod->id == $USER->activitycopy) {
-
 
176
                            continue;
-
 
177
                        }
-
 
178
                        $movingurl = new moodle_url('/course/mod.php', array('moveto' => $mod->id, 'sesskey' => sesskey()));
-
 
179
                        $this->content->items[] = html_writer::link($movingurl, '', array('title' => $strmovefull,
-
 
180
                            'class' => 'movehere'));
-
 
181
                        $this->content->icons[] = '';
-
 
182
                    }
-
 
183
 
-
 
184
                    $badges = '';
-
 
185
                    if (!$mod->visible) {
-
 
186
                        $badges = html_writer::tag(
-
 
187
                            'span',
-
 
188
                            get_string('hiddenfromstudents'),
-
 
189
                            $badgeattributes
-
 
190
                        );
-
 
191
                    }
-
 
192
 
-
 
193
                    if ($mod->is_stealth()) {
-
 
194
                        $badges = html_writer::tag(
-
 
195
                            'span',
-
 
196
                            get_string('hiddenoncoursepage'),
-
 
197
                            $badgeattributes
-
 
198
                        );
-
 
199
                    }
-
 
200
 
-
 
201
                    if (!$mod->url) {
-
 
202
                        $activitybasis = html_writer::div(
-
 
203
                            $mod->get_formatted_content(['overflowdiv' => true, 'noclean' => true]) .
-
 
204
                            $editbuttons,
-
 
205
                            'activity-basis d-flex align-items-center');
-
 
206
                        $content = html_writer::div(
-
 
207
                            $moveaction .
-
 
208
                            $activitybasis .
-
 
209
                            $badges,
-
 
210
                            'contentwithoutlink activity-item activity',
-
 
211
                            ['data-activityname' => $mod->name]
-
 
212
                        );
-
 
213
                        $this->content->items[] = $content;
-
 
214
                        $this->content->icons[] = '';
-
 
215
                    } else {
-
 
216
                        $cmname = new $cmnameclass($format, $mod->get_section_info(), $mod);
-
 
217
                        $activitybasis = html_writer::div(
-
 
218
                            $courserenderer->render($cmname) .
-
 
219
                            $editbuttons,
-
 
220
                            'activity-basis d-flex align-items-center');
-
 
221
                        $content = html_writer::div(
-
 
222
                            $moveaction .
-
 
223
                            $activitybasis .
-
 
224
                            $badges,
-
 
Línea 225... Línea -...
225
                            'activity-item activity',
-
 
226
                            ['data-activityname' => $mod->name]
50
        $modinfo = $format->get_modinfo();
227
                        );
-
 
228
                        $this->content->items[] = $content;
-
 
229
                    }
-
 
Línea 230... Línea 51...
230
                }
51
        $section = $modinfo->get_section_info(0);
231
            }
-
 
Línea -... Línea 52...
-
 
52
 
-
 
53
        if ($format->supports_ajax()) {
-
 
54
            include_course_ajax($course);
-
 
55
        }
-
 
56
 
-
 
57
        $courserenderer = $format->get_renderer($this->page);
232
        }
58
 
233
 
59
        $output = new block_social_activities\output\blocksection($format, $section);
234
        if ($ismoving) {
60