Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 1441
Línea 198... Línea 198...
198
 
198
 
199
                // reset $sectioncontents
199
                // reset $sectioncontents
200
                $sectionvalues = array();
200
                $sectionvalues = array();
201
                $sectionvalues['id'] = $section->id;
201
                $sectionvalues['id'] = $section->id;
-
 
202
                $sectionvalues['name'] = get_section_name($course, $section);
-
 
203
                // Temporary hack to be able to hide the subsections in certain app versions.
-
 
204
                if (!empty($section->component) && \core_useragent::is_moodle_app()) {
-
 
205
                    $sectionvalues['name'] = html_writer::span($sectionvalues['name'], 'course-' . $section->component);
202
                $sectionvalues['name'] = get_section_name($course, $section);
206
                }
Línea 203... Línea 207...
203
                $sectionvalues['visible'] = $section->visible;
207
                $sectionvalues['visible'] = $section->visible;
204
 
208
 
205
                $options = (object) array('noclean' => true);
209
                $options = (object) array('noclean' => true);
Línea 210... Línea 214...
210
                $sectionvalues['hiddenbynumsections'] = $section->section > $coursenumsections ? 1 : 0;
214
                $sectionvalues['hiddenbynumsections'] = $section->section > $coursenumsections ? 1 : 0;
211
                $sectionvalues['uservisible'] = $section->uservisible;
215
                $sectionvalues['uservisible'] = $section->uservisible;
212
                if (!empty($section->availableinfo)) {
216
                if (!empty($section->availableinfo)) {
213
                    $sectionvalues['availabilityinfo'] = \core_availability\info::format_info($section->availableinfo, $course);
217
                    $sectionvalues['availabilityinfo'] = \core_availability\info::format_info($section->availableinfo, $course);
214
                }
218
                }
-
 
219
                $sectionvalues['component'] = $section->component;
-
 
220
                $sectionvalues['itemid'] = $section->itemid;
Línea 215... Línea 221...
215
 
221
 
Línea 216... Línea 222...
216
                $sectioncontents = array();
222
                $sectioncontents = array();
217
 
223
 
Línea 445... Línea 451...
445
                    'section' => new external_value(PARAM_INT, 'Section number inside the course', VALUE_OPTIONAL),
451
                    'section' => new external_value(PARAM_INT, 'Section number inside the course', VALUE_OPTIONAL),
446
                    'hiddenbynumsections' => new external_value(PARAM_INT, 'Whether is a section hidden in the course format',
452
                    'hiddenbynumsections' => new external_value(PARAM_INT, 'Whether is a section hidden in the course format',
447
                                                                VALUE_OPTIONAL),
453
                                                                VALUE_OPTIONAL),
448
                    'uservisible' => new external_value(PARAM_BOOL, 'Is the section visible for the user?', VALUE_OPTIONAL),
454
                    'uservisible' => new external_value(PARAM_BOOL, 'Is the section visible for the user?', VALUE_OPTIONAL),
449
                    'availabilityinfo' => new external_value(PARAM_RAW, 'Availability information.', VALUE_OPTIONAL),
455
                    'availabilityinfo' => new external_value(PARAM_RAW, 'Availability information.', VALUE_OPTIONAL),
-
 
456
                    'component' => new external_value(PARAM_COMPONENT, 'The delegate component of this section if any.',
-
 
457
                        VALUE_OPTIONAL),
-
 
458
                    'itemid' => new external_value(PARAM_INT,
-
 
459
                        'The optional item id delegate component can use to identify its instance.', VALUE_OPTIONAL),
450
                    'modules' => new external_multiple_structure(
460
                    'modules' => new external_multiple_structure(
451
                            new external_single_structure(
461
                            new external_single_structure(
452
                                array(
462
                                array(
453
                                    'id' => new external_value(PARAM_INT, 'activity id'),
463
                                    'id' => new external_value(PARAM_INT, 'activity id'),
454
                                    'url' => new external_value(PARAM_URL, 'activity url', VALUE_OPTIONAL),
464
                                    'url' => new external_value(PARAM_URL, 'activity url', VALUE_OPTIONAL),
Línea 884... Línea 894...
884
                                    'largest size of file that can be uploaded into the course',
894
                                    'largest size of file that can be uploaded into the course',
885
                                    VALUE_DEFAULT, $courseconfig->maxbytes),
895
                                    VALUE_DEFAULT, $courseconfig->maxbytes),
886
                            'showreports' => new external_value(PARAM_INT,
896
                            'showreports' => new external_value(PARAM_INT,
887
                                    'are activity report shown (yes = 1, no =0)', VALUE_DEFAULT,
897
                                    'are activity report shown (yes = 1, no =0)', VALUE_DEFAULT,
888
                                    $courseconfig->showreports),
898
                                    $courseconfig->showreports),
889
                            'visible' => new external_value(PARAM_INT,
899
                            'visible' => new external_value(
-
 
900
                                PARAM_INT,
890
                                    '1: available to student, 0:not available', VALUE_OPTIONAL),
901
                                '1: available to student, 0: not available',
-
 
902
                                VALUE_DEFAULT,
-
 
903
                                $courseconfig->visible,
-
 
904
                            ),
891
                            'hiddensections' => new external_value(PARAM_INT,
905
                            'hiddensections' => new external_value(PARAM_INT,
892
                                    '(deprecated, use courseformatoptions) How the hidden sections in the course are displayed to students',
906
                                    '(deprecated, use courseformatoptions) How the hidden sections in the course are displayed to students',
893
                                    VALUE_OPTIONAL),
907
                                    VALUE_OPTIONAL),
894
                            'groupmode' => new external_value(PARAM_INT, 'no group, separate, visible',
908
                            'groupmode' => new external_value(PARAM_INT, 'no group, separate, visible',
895
                                    VALUE_DEFAULT, $courseconfig->groupmode),
909
                                    VALUE_DEFAULT, $courseconfig->groupmode),
Línea 939... Línea 953...
939
        require_once($CFG->libdir . '/completionlib.php');
953
        require_once($CFG->libdir . '/completionlib.php');
Línea 940... Línea 954...
940
 
954
 
941
        $params = self::validate_parameters(self::create_courses_parameters(),
955
        $params = self::validate_parameters(self::create_courses_parameters(),
Línea -... Línea 956...
-
 
956
                        array('courses' => $courses));
-
 
957
 
942
                        array('courses' => $courses));
958
        $courseconfig = get_config('moodlecourse');
943
 
959
 
Línea 944... Línea 960...
944
        $availablethemes = core_component::get_plugin_list('theme');
960
        $availablethemes = core_component::get_plugin_list('theme');
Línea 965... Línea 981...
965
                throw new moodle_exception('errorinvalidparam', 'webservice', '', 'fullname');
981
                throw new moodle_exception('errorinvalidparam', 'webservice', '', 'fullname');
966
            } else if (trim($course['shortname']) === '') {
982
            } else if (trim($course['shortname']) === '') {
967
                throw new moodle_exception('errorinvalidparam', 'webservice', '', 'shortname');
983
                throw new moodle_exception('errorinvalidparam', 'webservice', '', 'shortname');
968
            }
984
            }
Línea -... Línea 985...
-
 
985
 
-
 
986
            // Make sure start/end date are correctly set.
-
 
987
            if (!array_key_exists('startdate', $course)) {
-
 
988
                $course['startdate'] = usergetmidnight(time());
-
 
989
            }
-
 
990
            if (!array_key_exists('enddate', $course) && $courseconfig->courseenddateenabled) {
-
 
991
                $course['enddate'] = $course['startdate'] + $courseconfig->courseduration;
-
 
992
            }
969
 
993
 
970
            // Make sure lang is valid
994
            // Make sure lang is valid
971
            if (array_key_exists('lang', $course)) {
995
            if (array_key_exists('lang', $course)) {
972
                if (empty($availablelangs[$course['lang']])) {
996
                if (empty($availablelangs[$course['lang']])) {
973
                    throw new moodle_exception('errorinvalidparam', 'webservice', '', 'lang');
997
                    throw new moodle_exception('errorinvalidparam', 'webservice', '', 'lang');
Línea 986... Línea 1010...
986
                        $course['theme'] = $course['forcetheme'];
1010
                        $course['theme'] = $course['forcetheme'];
987
                    }
1011
                    }
988
                }
1012
                }
989
            }
1013
            }
Línea -... Línea 1014...
-
 
1014
 
-
 
1015
            $course['showactivitydates'] = $courseconfig->showactivitydates;
990
 
1016
 
991
            //force visibility if ws user doesn't have the permission to set it
1017
            //force visibility if ws user doesn't have the permission to set it
992
            $category = $DB->get_record('course_categories', array('id' => $course['categoryid']));
1018
            $category = $DB->get_record('course_categories', array('id' => $course['categoryid']));
993
            if (!has_capability('moodle/course:visibility', $context)) {
1019
            if (!has_capability('moodle/course:visibility', $context)) {
994
                $course['visible'] = $category->visible;
1020
                $course['visible'] = $category->visible;
Línea 995... Línea 1021...
995
            }
1021
            }
996
 
-
 
997
            //set default value for completion
1022
 
998
            $courseconfig = get_config('moodlecourse');
1023
            //set default value for completion
999
            if (completion_info::is_enabled_for_site()) {
1024
            if (completion_info::is_enabled_for_site()) {
1000
                if (!array_key_exists('enablecompletion', $course)) {
1025
                if (!array_key_exists('enablecompletion', $course)) {
1001
                    $course['enablecompletion'] = $courseconfig->enablecompletion;
1026
                    $course['enablecompletion'] = $courseconfig->enablecompletion;
Línea 3230... Línea 3255...
3230
                    id: course id
3255
                    id: course id
3231
                    ids: comma separated course ids
3256
                    ids: comma separated course ids
3232
                    shortname: course short name
3257
                    shortname: course short name
3233
                    idnumber: course id number
3258
                    idnumber: course id number
3234
                    category: category id the course belongs to
3259
                    category: category id the course belongs to
-
 
3260
                    sectionid: section id that belongs to a course
3235
                ', VALUE_DEFAULT, ''),
3261
                ', VALUE_DEFAULT, ''),
3236
                'value' => new external_value(PARAM_RAW, 'The value to match', VALUE_DEFAULT, '')
3262
                'value' => new external_value(PARAM_RAW, 'The value to match', VALUE_DEFAULT, '')
3237
            )
3263
            )
3238
        );
3264
        );
3239
    }
3265
    }
Línea 3240... Línea -...
3240
 
-
 
3241
 
3266
 
3242
    /**
3267
    /**
3243
     * Get courses matching a specific field (id/s, shortname, idnumber, category)
3268
     * Get courses matching a specific field (id/s, shortname, idnumber, category)
3244
     *
3269
     *
3245
     * @param  string $field field name to search, or empty for all courses
3270
     * @param  string $field field name to search, or empty for all courses
Línea 3265... Línea 3290...
3265
            $courses = $DB->get_records('course', null, 'id ASC');
3290
            $courses = $DB->get_records('course', null, 'id ASC');
3266
        } else {
3291
        } else {
3267
            switch ($params['field']) {
3292
            switch ($params['field']) {
3268
                case 'id':
3293
                case 'id':
3269
                case 'category':
3294
                case 'category':
-
 
3295
                case 'sectionid':
3270
                    $value = clean_param($params['value'], PARAM_INT);
3296
                    $value = clean_param($params['value'], PARAM_INT);
3271
                    break;
3297
                    break;
3272
                case 'ids':
3298
                case 'ids':
3273
                    $value = clean_param($params['value'], PARAM_SEQUENCE);
3299
                    $value = clean_param($params['value'], PARAM_SEQUENCE);
3274
                    break;
3300
                    break;
Línea 3295... Línea 3321...
3295
 
3321
 
3296
                // Load and validate all courses. This is called because it loads the courses
3322
                // Load and validate all courses. This is called because it loads the courses
3297
                // more efficiently.
3323
                // more efficiently.
3298
                list ($courses, $warnings) = util::validate_courses($courseids, [],
3324
                list ($courses, $warnings) = util::validate_courses($courseids, [],
-
 
3325
                        false, true);
-
 
3326
            } else if ($params['field'] === 'sectionid') {
-
 
3327
                $courseid = $DB->get_field('course_sections', 'course', ['id' => $value]);
3299
                        false, true);
3328
                $courses = $courseid ? [$DB->get_record('course', ['id' => $courseid])] : [];
3300
            } else {
3329
            } else {
3301
                $courses = $DB->get_records('course', array($params['field'] => $value), 'id ASC');
3330
                $courses = $DB->get_records('course', array($params['field'] => $value), 'id ASC');
3302
            }
3331
            }
Línea 3606... Línea 3635...
3606
    public static function get_updates_since_returns() {
3635
    public static function get_updates_since_returns() {
3607
        return self::check_updates_returns();
3636
        return self::check_updates_returns();
3608
    }
3637
    }
Línea 3609... Línea 3638...
3609
 
3638
 
-
 
3639
    /**
-
 
3640
     * Mark the edit_module as deprecated.
-
 
3641
     * @todo Remove this method in Moodle 6.0 (MDL-83530).
-
 
3642
     * @return bool
-
 
3643
     */
-
 
3644
    public static function edit_module_is_deprecated() {
-
 
3645
        return true;
-
 
3646
    }
-
 
3647
 
3610
    /**
3648
    /**
3611
     * Parameters for function edit_module()
3649
     * Parameters for function edit_module()
3612
     *
3650
     *
-
 
3651
     * @deprecated since 5.0
3613
     * @since Moodle 3.3
3652
     * @todo Remove this method in Moodle 6.0 (MDL-83530).
3614
     * @return external_function_parameters
3653
     * @return external_function_parameters
3615
     */
3654
     */
3616
    public static function edit_module_parameters() {
3655
    public static function edit_module_parameters() {
3617
        return new external_function_parameters(
3656
        return new external_function_parameters(
Línea 3631... Línea 3670...
3631
     * - two modules html for "duplicate" action
3670
     * - two modules html for "duplicate" action
3632
     * - updated module html for everything else
3671
     * - updated module html for everything else
3633
     *
3672
     *
3634
     * Throws exception if operation is not permitted/possible
3673
     * Throws exception if operation is not permitted/possible
3635
     *
3674
     *
3636
     * @since Moodle 3.3
3675
     * @deprecated since 5.0
-
 
3676
     * @todo Remove this method in Moodle 6.0 (MDL-83530).
3637
     * @param string $action
3677
     * @param string $action
3638
     * @param int $id
3678
     * @param int $id
3639
     * @param null|int $sectionreturn
3679
     * @param null|int $sectionreturn
3640
     * @return string
3680
     * @return string
3641
     */
3681
     */
Línea 3737... Línea 3777...
3737
    }
3777
    }
Línea 3738... Línea 3778...
3738
 
3778
 
3739
    /**
3779
    /**
3740
     * Return structure for edit_module()
3780
     * Return structure for edit_module()
3741
     *
3781
     *
-
 
3782
     * @deprecated since 5.0
3742
     * @since Moodle 3.3
3783
     * @todo Remove this method in Moodle 6.0 (MDL-83530).
3743
     * @return \core_external\external_description
3784
     * @return \core_external\external_description
3744
     */
3785
     */
3745
    public static function edit_module_returns() {
3786
    public static function edit_module_returns() {
3746
        return new external_value(PARAM_RAW, 'html to replace the current module with');
3787
        return new external_value(PARAM_RAW, 'html to replace the current module with');
Línea 3747... Línea 3788...
3747
    }
3788
    }
-
 
3789
 
-
 
3790
    /**
-
 
3791
     * Mark the get_module as deprecated.
-
 
3792
     * @todo Remove this method in Moodle 6.0 (MDL-83530).
-
 
3793
     * @return bool
-
 
3794
     */
-
 
3795
    public static function get_module_is_deprecated() {
-
 
3796
        return true;
-
 
3797
    }
3748
 
3798
 
3749
    /**
3799
    /**
3750
     * Parameters for function get_module()
3800
     * Parameters for function get_module()
-
 
3801
     *
3751
     *
3802
     * @deprecated since 5.0
3752
     * @since Moodle 3.3
3803
     * @todo Remove this method in Moodle 6.0 (MDL-83530).
3753
     * @return external_function_parameters
3804
     * @return external_function_parameters
3754
     */
3805
     */
3755
    public static function get_module_parameters() {
3806
    public static function get_module_parameters() {
Línea 3761... Línea 3812...
3761
    }
3812
    }
Línea 3762... Línea 3813...
3762
 
3813
 
3763
    /**
3814
    /**
3764
     * Returns html for displaying one activity module on course page
3815
     * Returns html for displaying one activity module on course page
3765
     *
3816
     *
-
 
3817
     * @deprecated since 5.0
3766
     * @since Moodle 3.3
3818
     * @todo Remove this method in Moodle 6.0 (MDL-83530).
3767
     * @param int $id
3819
     * @param int $id
3768
     * @param null|int $sectionreturn
3820
     * @param null|int $sectionreturn
3769
     * @return string
3821
     * @return string
3770
     */
3822
     */
Línea 3803... Línea 3855...
3803
    }
3855
    }
Línea 3804... Línea 3856...
3804
 
3856
 
3805
    /**
3857
    /**
3806
     * Return structure for get_module()
3858
     * Return structure for get_module()
3807
     *
3859
     *
-
 
3860
     * @deprecated since 5.0
3808
     * @since Moodle 3.3
3861
     * @todo Remove this method in Moodle 6.0 (MDL-83530).
3809
     * @return \core_external\external_description
3862
     * @return \core_external\external_description
3810
     */
3863
     */
3811
    public static function get_module_returns() {
3864
    public static function get_module_returns() {
3812
        return new external_value(PARAM_RAW, 'html to replace the current module with');
3865
        return new external_value(PARAM_RAW, 'html to replace the current module with');
Línea 3813... Línea 3866...
3813
    }
3866
    }
-
 
3867
 
-
 
3868
    /**
-
 
3869
     * Mark the edit_section as deprecated.
-
 
3870
     * @todo Remove this method in Moodle 6.0 (MDL-83530).
-
 
3871
     * @return bool
-
 
3872
     */
-
 
3873
    public static function edit_section_is_deprecated() {
-
 
3874
        return true;
-
 
3875
    }
3814
 
3876
 
3815
    /**
3877
    /**
3816
     * Parameters for function edit_section()
3878
     * Parameters for function edit_section()
-
 
3879
     *
3817
     *
3880
     * @deprecated since 5.0
3818
     * @since Moodle 3.3
3881
     * @todo Remove this method in Moodle 6.0 (MDL-83530).
3819
     * @return external_function_parameters
3882
     * @return external_function_parameters
3820
     */
3883
     */
3821
    public static function edit_section_parameters() {
3884
    public static function edit_section_parameters() {
Línea 3828... Línea 3891...
3828
    }
3891
    }
Línea 3829... Línea 3892...
3829
 
3892
 
3830
    /**
3893
    /**
3831
     * Performs one of the edit section actions
3894
     * Performs one of the edit section actions
3832
     *
3895
     *
-
 
3896
     * @deprecated since 5.0
3833
     * @since Moodle 3.3
3897
     * @todo Remove this method in Moodle 6.0 (MDL-83530).
3834
     * @param string $action
3898
     * @param string $action
3835
     * @param int $id section id
3899
     * @param int $id section id
3836
     * @param int $sectionreturn section to return to
3900
     * @param int $sectionreturn section to return to
3837
     * @return string
3901
     * @return string
Línea 3858... Línea 3922...
3858
    }
3922
    }
Línea 3859... Línea 3923...
3859
 
3923
 
3860
    /**
3924
    /**
3861
     * Return structure for edit_section()
3925
     * Return structure for edit_section()
3862
     *
3926
     *
-
 
3927
     * @deprecated since 5.0
3863
     * @since Moodle 3.3
3928
     * @todo Remove this method in Moodle 6.0 (MDL-83530).
3864
     * @return \core_external\external_description
3929
     * @return \core_external\external_description
3865
     */
3930
     */
3866
    public static function edit_section_returns() {
3931
    public static function edit_section_returns() {
3867
        return new external_value(PARAM_RAW, 'Additional data for javascript (JSON-encoded string)');
3932
        return new external_value(PARAM_RAW, 'Additional data for javascript (JSON-encoded string)');
Línea 3920... Línea 3985...
3920
     */
3985
     */
3921
    public static function get_enrolled_courses_by_timeline_classification(
3986
    public static function get_enrolled_courses_by_timeline_classification(
3922
        string $classification,
3987
        string $classification,
3923
        int $limit = 0,
3988
        int $limit = 0,
3924
        int $offset = 0,
3989
        int $offset = 0,
3925
        string $sort = null,
3990
        ?string $sort = null,
3926
        string $customfieldname = null,
3991
        ?string $customfieldname = null,
3927
        string $customfieldvalue = null,
3992
        ?string $customfieldvalue = null,
3928
        string $searchvalue = null,
3993
        ?string $searchvalue = null,
3929
        array $requiredfields = []
3994
        array $requiredfields = []
3930
    ) {
3995
    ) {
3931
        global $CFG, $PAGE, $USER;
3996
        global $CFG, $PAGE, $USER;
3932
        require_once($CFG->dirroot . '/course/lib.php');
3997
        require_once($CFG->dirroot . '/course/lib.php');
Línea 4225... Línea 4290...
4225
     * @param int $offset Skip this number of records from the start of the result set
4290
     * @param int $offset Skip this number of records from the start of the result set
4226
     * @param string|null $sort SQL string for sorting
4291
     * @param string|null $sort SQL string for sorting
4227
     * @return array List of courses
4292
     * @return array List of courses
4228
     * @throws  invalid_parameter_exception
4293
     * @throws  invalid_parameter_exception
4229
     */
4294
     */
4230
    public static function get_recent_courses(int $userid = 0, int $limit = 0, int $offset = 0, string $sort = null) {
4295
    public static function get_recent_courses(int $userid = 0, int $limit = 0, int $offset = 0, ?string $sort = null) {
4231
        global $USER, $PAGE;
4296
        global $USER, $PAGE;
Línea 4232... Línea 4297...
4232
 
4297
 
4233
        if (empty($userid)) {
4298
        if (empty($userid)) {
4234
            $userid = $USER->id;
4299
            $userid = $USER->id;
Línea 4250... Línea 4315...
4250
 
4315
 
Línea 4251... Línea 4316...
4251
        $usercontext = context_user::instance($userid);
4316
        $usercontext = context_user::instance($userid);
Línea 4252... Línea 4317...
4252
 
4317
 
4253
        self::validate_context($usercontext);
4318
        self::validate_context($usercontext);
4254
 
4319
 
Línea 4255... Línea 4320...
4255
        if ($userid != $USER->id and !has_capability('moodle/user:viewdetails', $usercontext)) {
4320
        if ($userid != $USER->id && !has_capability('moodle/user:viewalldetails', $usercontext)) {
Línea 4300... Línea 4365...
4300
     *
4365
     *
4301
     * @param int $cmid Course Module id from which the users will be obtained
4366
     * @param int $cmid Course Module id from which the users will be obtained
4302
     * @param int $groupid Group id from which the users will be obtained
4367
     * @param int $groupid Group id from which the users will be obtained
4303
     * @param bool $onlyactive Whether to return only the active enrolled users or all enrolled users in the course.
4368
     * @param bool $onlyactive Whether to return only the active enrolled users or all enrolled users in the course.
4304
     * @return array List of users
4369
     * @return array List of users
4305
     * @throws invalid_parameter_exception
-
 
4306
     */
4370
     */
4307
    public static function get_enrolled_users_by_cmid(int $cmid, int $groupid = 0, bool $onlyactive = false) {
4371
    public static function get_enrolled_users_by_cmid(int $cmid, int $groupid = 0, bool $onlyactive = false) {
4308
    global $PAGE;
4372
        global $PAGE;
-
 
4373
 
4309
        $warnings = [];
4374
        $warnings = [];
Línea -... Línea 4375...
-
 
4375
 
-
 
4376
        [
-
 
4377
            'cmid' => $cmid,
-
 
4378
            'groupid' => $groupid,
4310
 
4379
            'onlyactive' => $onlyactive,
4311
        self::validate_parameters(self::get_enrolled_users_by_cmid_parameters(), [
4380
        ] = self::validate_parameters(self::get_enrolled_users_by_cmid_parameters(), [
4312
                'cmid' => $cmid,
4381
            'cmid' => $cmid,
4313
                'groupid' => $groupid,
4382
            'groupid' => $groupid,
4314
                'onlyactive' => $onlyactive,
4383
            'onlyactive' => $onlyactive,
Línea 4315... Línea 4384...
4315
        ]);
4384
        ]);
4316
 
4385
 
4317
        list($course, $cm) = get_course_and_cm_from_cmid($cmid);
4386
        list($course, $cm) = get_course_and_cm_from_cmid($cmid);
Línea -... Línea 4387...
-
 
4387
        $coursecontext = context_course::instance($course->id);
-
 
4388
        self::validate_context($coursecontext);
4318
        $coursecontext = context_course::instance($course->id);
4389
 
Línea 4319... Línea 4390...
4319
        self::validate_context($coursecontext);
4390
        course_require_view_participants($coursecontext);
4320
 
4391
 
4321
        $enrolledusers = get_enrolled_users($coursecontext, '', $groupid, 'u.*', null, 0, 0, $onlyactive);
4392
        $enrolledusers = get_enrolled_users($coursecontext, '', $groupid, 'u.*', null, 0, 0, $onlyactive);
Línea 4486... Línea 4557...
4486
     * @return external_function_parameters
4557
     * @return external_function_parameters
4487
     */
4558
     */
4488
    public static function get_course_content_items_parameters() {
4559
    public static function get_course_content_items_parameters() {
4489
        return new external_function_parameters([
4560
        return new external_function_parameters([
4490
            'courseid' => new external_value(PARAM_INT, 'ID of the course', VALUE_REQUIRED),
4561
            'courseid' => new external_value(PARAM_INT, 'ID of the course', VALUE_REQUIRED),
-
 
4562
            'sectionnum' => new external_value(PARAM_INT, 'Number of the section', VALUE_DEFAULT),
4491
        ]);
4563
        ]);
4492
    }
4564
    }
Línea 4493... Línea 4565...
4493
 
4565
 
4494
    /**
4566
    /**
4495
     * Given a course ID fetch all accessible modules for that course
4567
     * Given a course ID fetch all accessible modules for that course
4496
     *
4568
     *
-
 
4569
     * @param int $courseid The course we want to fetch the modules for
4497
     * @param int $courseid The course we want to fetch the modules for
4570
     * @param int|null $sectionnum The section we want to fetch the modules for
4498
     * @return array Contains array of modules and their metadata
4571
     * @return array Contains array of modules and their metadata
4499
     */
4572
     */
4500
    public static function get_course_content_items(int $courseid) {
4573
    public static function get_course_content_items(int $courseid, ?int $sectionnum = null) {
Línea 4501... Línea 4574...
4501
        global $USER;
4574
        global $USER;
4502
 
4575
 
-
 
4576
        [
4503
        [
4577
            'courseid' => $courseid,
4504
            'courseid' => $courseid,
4578
            'sectionnum' => $sectionnum,
-
 
4579
        ] = self::validate_parameters(self::get_course_content_items_parameters(), [
4505
        ] = self::validate_parameters(self::get_course_content_items_parameters(), [
4580
            'courseid' => $courseid,
Línea 4506... Línea 4581...
4506
            'courseid' => $courseid,
4581
            'sectionnum' => $sectionnum,
4507
        ]);
4582
        ]);
4508
 
4583
 
-
 
4584
        $coursecontext = context_course::instance($courseid);
-
 
4585
        self::validate_context($coursecontext);
Línea 4509... Línea 4586...
4509
        $coursecontext = context_course::instance($courseid);
4586
        $course = get_course($courseid);
Línea 4510... Línea 4587...
4510
        self::validate_context($coursecontext);
4587
        // Get section_info object with all delegation information.
4511
        $course = get_course($courseid);
4588
        $sectioninfo = get_fast_modinfo($course)->get_section_info($sectionnum);
4512
 
4589
 
Línea 4513... Línea 4590...
4513
        $contentitemservice = \core_course\local\factory\content_item_service_factory::get_content_item_service();
4590
        $contentitemservice = \core_course\local\factory\content_item_service_factory::get_content_item_service();
4514
 
4591
 
Línea 4594... Línea 4671...
4594
        ]);
4671
        ]);
Línea 4595... Línea 4672...
4595
 
4672
 
4596
        $coursecontext = context_course::instance($courseid);
4673
        $coursecontext = context_course::instance($courseid);
Línea -... Línea 4674...
-
 
4674
        self::validate_context($coursecontext);
-
 
4675
 
4597
        self::validate_context($coursecontext);
4676
        // The active plugin must be set, and be present on the site.
-
 
4677
        $activeplugin = clean_param(
-
 
4678
            get_config('core', 'activitychooseractivefooter'),
Línea -... Línea 4679...
-
 
4679
            PARAM_COMPONENT,
4598
 
4680
        );
-
 
4681
 
-
 
4682
        if (
-
 
4683
            $activeplugin !== COURSE_CHOOSER_FOOTER_NONE &&
4599
        $activeplugin = get_config('core', 'activitychooseractivefooter');
4684
            !empty($activeplugin) &&
4600
 
4685
            core_component::get_component_directory($activeplugin) !== null
4601
        if ($activeplugin !== COURSE_CHOOSER_FOOTER_NONE) {
4686
        ) {
4602
            $footerdata = component_callback($activeplugin, 'custom_chooser_footer', [$courseid, $sectionid]);
4687
            $footerdata = component_callback($activeplugin, 'custom_chooser_footer', [$courseid, $sectionid]);
4603
            return [
4688
            return [