[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 /** 2 * A collection of utility classes for use with course modules. 3 * 4 * @module moodle-course-util 5 * @submodule moodle-course-util-cm 6 */ 7 8 Y.namespace('Moodle.core_course.util.cm'); 9 10 /** 11 * A collection of utility classes for use with course modules. 12 * 13 * @class Moodle.core_course.util.cm 14 * @static 15 */ 16 Y.Moodle.core_course.util.cm = { 17 CONSTANTS: { 18 MODULEIDPREFIX: 'module-' 19 }, 20 SELECTORS: { 21 COURSEMODULE: '.activity', 22 INSTANCENAME: '.instancename' 23 }, 24 25 /** 26 * Retrieve the course module item from one of it's child Nodes. 27 * 28 * @method getCourseModuleNodeFromComponent 29 * @param coursemodulecomponent {Node} The component Node. 30 * @return {Node|null} The Course Module Node. 31 */ 32 getCourseModuleFromComponent: function(coursemodulecomponent) { 33 return Y.one(coursemodulecomponent).ancestor(this.SELECTORS.COURSEMODULE, true); 34 }, 35 36 /** 37 * Determines the section ID for the provided section. 38 * 39 * @method getId 40 * @param coursemodule {Node} The course module to find an ID for. 41 * @return {Number|false} The ID of the course module in question or false if no ID was found. 42 */ 43 getId: function(coursemodule) { 44 // We perform a simple substitution operation to get the ID. 45 var id = coursemodule.get('id').replace( 46 this.CONSTANTS.MODULEIDPREFIX, ''); 47 48 // Attempt to validate the ID. 49 id = parseInt(id, 10); 50 if (typeof id === 'number' && isFinite(id)) { 51 return id; 52 } 53 return false; 54 }, 55 56 /** 57 * Determines the section ID for the provided section. 58 * 59 * @method getName 60 * @param coursemodule {Node} The course module to find an ID for. 61 * @return {Number|false} The ID of the course module in question or false if no ID was found. 62 */ 63 getName: function(coursemodule) { 64 var instance = coursemodule.one(this.SELECTORS.INSTANCENAME); 65 if (instance) { 66 return instance.get('firstChild').get('data'); 67 } 68 return null; 69 } 70 };
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |