Proyectos de Subversion Moodle

Rev

Rev 1 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
/**
2
 * A collection of utility classes for use with course sections.
3
 *
1441 ariadna 4
 * TODO: remove this module as part of MDL-83627.
5
 *
1 efrain 6
 * @module moodle-course-util
7
 * @submodule moodle-course-util-section
8
 */
9
 
10
Y.namespace('Moodle.core_course.util.section');
11
 
1441 ariadna 12
Y.log(
13
    'YUI Moodle.core_course.util.cm is deprecated. Please, add support_components to your course format.',
14
    'warn',
15
    'moodle-course-coursebase'
16
);
17
 
1 efrain 18
/**
19
 * A collection of utility classes for use with course sections.
20
 *
21
 * @class Moodle.core_course.util.section
22
 * @static
23
 */
24
Y.Moodle.core_course.util.section = {
25
    CONSTANTS: {
26
        SECTIONIDPREFIX: 'section-'
27
    },
28
 
29
    /**
30
     * Determines the section ID for the provided section.
31
     *
32
     * @method getId
33
     * @param section {Node} The section to find an ID for.
34
     * @return {Number|false} The ID of the section in question or false if no ID was found.
35
     */
36
    getId: function(section) {
37
        // We perform a simple substitution operation to get the ID.
38
        var id = section.get('id').replace(
39
                this.CONSTANTS.SECTIONIDPREFIX, '');
40
 
41
        // Attempt to validate the ID.
42
        id = parseInt(id, 10);
43
        if (typeof id === 'number' && isFinite(id)) {
44
            return id;
45
        }
46
        return false;
47
    }
48
};