[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 // This file is part of Moodle - http://moodle.org/ 2 // 3 // Moodle is free software: you can redistribute it and/or modify 4 // it under the terms of the GNU General Public License as published by 5 // the Free Software Foundation, either version 3 of the License, or 6 // (at your option) any later version. 7 // 8 // Moodle is distributed in the hope that it will be useful, 9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 // GNU General Public License for more details. 12 // 13 // You should have received a copy of the GNU General Public License 14 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 15 16 /** 17 * Competency rule config. 18 * 19 * @package tool_lp 20 * @copyright 2015 Frédéric Massart - FMCorz.net 21 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 22 */ 23 24 define(['jquery', 25 'core/str'], 26 function($, Str) { 27 28 var OUTCOME_NONE = 0, 29 OUTCOME_EVIDENCE = 1, 30 OUTCOME_COMPLETE = 2, 31 OUTCOME_RECOMMEND = 3; 32 33 return /** @alias module:tool_lp/competency_outcomes */ { 34 35 NONE: OUTCOME_NONE, 36 EVIDENCE: OUTCOME_EVIDENCE, 37 COMPLETE: OUTCOME_COMPLETE, 38 RECOMMEND: OUTCOME_RECOMMEND, 39 40 /** 41 * Get all the outcomes. 42 * 43 * @return {Object} Indexed by outcome code, contains code and name. 44 * @method getAll 45 */ 46 getAll: function() { 47 var self = this; 48 return Str.get_strings([ 49 {key: 'competencyoutcome_none', component: 'tool_lp'}, 50 {key: 'competencyoutcome_evidence', component: 'tool_lp'}, 51 {key: 'competencyoutcome_recommend', component: 'tool_lp'}, 52 {key: 'competencyoutcome_complete', component: 'tool_lp'}, 53 ]).then(function(strings) { 54 var outcomes = {}; 55 outcomes[self.NONE] = {code: self.NONE, name: strings[0]}; 56 outcomes[self.EVIDENCE] = {code: self.EVIDENCE, name: strings[1]}; 57 outcomes[self.RECOMMEND] = {code: self.RECOMMEND, name: strings[2]}; 58 outcomes[self.COMPLETE] = {code: self.COMPLETE, name: strings[3]}; 59 return outcomes; 60 }); 61 }, 62 63 /** 64 * Get the string for an outcome. 65 * 66 * @param {Number} id The outcome code. 67 * @return {Promise} Resolved with the string. 68 * @method getString 69 */ 70 getString: function(id) { 71 var self = this, 72 all = self.getAll(); 73 74 return all.then(function(outcomes) { 75 if (typeof outcomes[id] === 'undefined') { 76 return $.Deferred().reject().promise(); 77 } 78 return outcomes[id].name; 79 }); 80 } 81 }; 82 83 });
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 |