Proyectos de Subversion Moodle

Rev

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