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