Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 1441
Línea 24... Línea 24...
24
 */
24
 */
Línea 25... Línea 25...
25
 
25
 
Línea 26... Línea 26...
26
namespace core_completion;
26
namespace core_completion;
-
 
27
 
-
 
28
use core\context;
27
 
29
use core\output\local\properties\iconsize;
28
use core\context;
30
use core_course\output\activity_icon;
29
use stdClass;
31
use stdClass;
30
use context_course;
-
 
31
use cm_info;
-
 
32
use tabobject;
32
use context_course;
33
use lang_string;
-
 
Línea 34... Línea 33...
34
use moodle_url;
33
use cm_info;
35
defined('MOODLE_INTERNAL') || die;
34
use moodle_url;
36
 
35
 
37
/**
36
/**
Línea 103... Línea 102...
103
     * @param array $cmids list of course module ids
102
     * @param array $cmids list of course module ids
104
     * @param bool $withcompletiondetails include completion details
103
     * @param bool $withcompletiondetails include completion details
105
     * @return array
104
     * @return array
106
     */
105
     */
107
    public function get_activities($cmids, $withcompletiondetails = false) {
106
    public function get_activities($cmids, $withcompletiondetails = false) {
-
 
107
        $output = \core\di::get(\core\output\renderer_helper::class)->get_core_renderer();
108
        $moduleinfo = get_fast_modinfo($this->courseid);
108
        $moduleinfo = get_fast_modinfo($this->courseid);
109
        $activities = [];
109
        $activities = [];
110
        foreach ($cmids as $cmid) {
110
        foreach ($cmids as $cmid) {
111
            $mod = $moduleinfo->get_cm($cmid);
111
            $mod = $moduleinfo->get_cm($cmid);
112
            if (!$mod->uservisible) {
112
            if (!$mod->uservisible) {
113
                continue;
113
                continue;
114
            }
114
            }
-
 
115
 
-
 
116
            $icon = activity_icon::from_cm_info($mod)
-
 
117
                ->set_icon_size(iconsize::SIZE5);
-
 
118
 
115
            $moduleobject = new stdClass();
119
            $moduleobject = new stdClass();
116
            $moduleobject->cmid = $cmid;
120
            $moduleobject->cmid = $cmid;
117
            $moduleobject->modname = $mod->get_formatted_name();
121
            $moduleobject->modname = $mod->get_formatted_name();
118
            $moduleobject->icon = $mod->get_icon_url()->out();
122
            $moduleobject->icon = $mod->get_icon_url()->out();
119
            $moduleobject->url = $mod->url;
123
            $moduleobject->url = $mod->url;
-
 
124
            $moduleobject->activityicon = $icon->export_for_template($output);
120
            $moduleobject->canmanage = $withcompletiondetails && self::can_edit_bulk_completion($this->courseid, $mod);
125
            $moduleobject->canmanage = $withcompletiondetails && self::can_edit_bulk_completion($this->courseid, $mod);
Línea 121... Línea 126...
121
 
126
 
122
            // Get activity completion information.
127
            // Get activity completion information.
123
            if ($moduleobject->canmanage) {
128
            if ($moduleobject->canmanage) {
Línea 242... Línea 247...
242
        foreach ($data->modules as $module) {
247
        foreach ($data->modules as $module) {
243
            $libfile = "$CFG->dirroot/mod/$module->name/lib.php";
248
            $libfile = "$CFG->dirroot/mod/$module->name/lib.php";
244
            if (!file_exists($libfile)) {
249
            if (!file_exists($libfile)) {
245
                continue;
250
                continue;
246
            }
251
            }
-
 
252
            if (!plugin_supports('mod', $module->name, FEATURE_MODEDIT_DEFAULT_COMPLETION, true)) {
-
 
253
                continue;
-
 
254
            }
247
            $module->icon = $OUTPUT->image_url('monologo', $module->name)->out();
255
            $module->icon = $OUTPUT->image_url('monologo', $module->name)->out();
248
            $module->formattedname = format_string(get_string('modulename', 'mod_' . $module->name),
256
            $module->formattedname = format_string(get_string('modulename', 'mod_' . $module->name),
249
                true, ['context' => $context]);
257
                true, ['context' => $context]);
250
            $module->canmanage = $canmanage && course_allowed_module($course, $module->name);
258
            $module->canmanage = $canmanage && course_allowed_module($course, $module->name);
251
            if ($includedefaults) {
259
            if ($includedefaults) {
Línea 271... Línea 279...
271
     * @param \cm_info|null $cm if specified capability for a given coursemodule will be check,
279
     * @param \cm_info|null $cm if specified capability for a given coursemodule will be check,
272
     *     if not specified capability to edit at least one activity is checked.
280
     *     if not specified capability to edit at least one activity is checked.
273
     */
281
     */
274
    public static function can_edit_bulk_completion($courseorid, $cm = null) {
282
    public static function can_edit_bulk_completion($courseorid, $cm = null) {
275
        if ($cm) {
283
        if ($cm) {
-
 
284
            if (!plugin_supports('mod', $cm->modname, FEATURE_COMPLETION, true)) {
-
 
285
                return false;
-
 
286
            }
276
            return $cm->uservisible && has_capability('moodle/course:manageactivities', $cm->context);
287
            return $cm->uservisible && has_capability('moodle/course:manageactivities', $cm->context);
277
        }
288
        }
278
        $coursecontext = context_course::instance(is_object($courseorid) ? $courseorid->id : $courseorid);
289
        $coursecontext = context_course::instance(is_object($courseorid) ? $courseorid->id : $courseorid);
279
        if (has_capability('moodle/course:manageactivities', $coursecontext)) {
290
        if (has_capability('moodle/course:manageactivities', $coursecontext)) {
280
            return true;
291
            return true;
Línea 287... Línea 298...
287
        }
298
        }
288
        return false;
299
        return false;
289
    }
300
    }
Línea 290... Línea 301...
290
 
301
 
291
    /**
-
 
292
     * @deprecated since Moodle 4.0
-
 
293
     */
-
 
294
    public static function get_available_completion_tabs() {
-
 
295
        throw new \coding_exception(__FUNCTION__ . '() has been removed.');
-
 
296
    }
-
 
297
 
-
 
298
    /**
302
    /**
299
     * Returns an array with the available completion options (url => name) for the current course and user.
303
     * Returns an array with the available completion options (url => name) for the current course and user.
300
     *
304
     *
301
     * @param int $courseid The course id.
305
     * @param int $courseid The course id.
302
     * @return array
306
     * @return array