(options)
| 135 | } |
| 136 | |
| 137 | getLevels (options) { |
| 138 | // options: courseID, withoutLadderLevels, projectLevels, assessmentLevels, levelsCollection |
| 139 | // TODO: find a way to get the i18n in here so that level names can be translated (Courses don't include in their denormalized copy of levels) |
| 140 | if (options == null) { options = {} } |
| 141 | const Levels = require('collections/Levels') |
| 142 | const courses = this.get('courses') |
| 143 | if (!courses) { return new Levels() } |
| 144 | const levelObjects = [] |
| 145 | for (const course of Array.from(courses)) { |
| 146 | if (options.courseID && (options.courseID !== course._id)) { |
| 147 | continue |
| 148 | } |
| 149 | if (options.levelsCollection) { |
| 150 | for (const level of Array.from(course.levels)) { |
| 151 | const matchedLevel = options.levelsCollection.findWhere({ original: level.original }) |
| 152 | levelObjects.push((matchedLevel != null ? matchedLevel.attributes : undefined) || matchedLevel) |
| 153 | } |
| 154 | } else { |
| 155 | levelObjects.push(course.levels) |
| 156 | } |
| 157 | } |
| 158 | const levels = new Levels(_.flatten(levelObjects)) |
| 159 | const language = __guard__(this.get('aceConfig'), x => x.language) |
| 160 | if (language) { levels.remove(levels.filter(level => level.get('primerLanguage') === language)) } |
| 161 | if (options.withoutLadderLevels) { |
| 162 | levels.remove(levels.filter(level => level.isLadder())) |
| 163 | } |
| 164 | if (options.projectLevels) { |
| 165 | levels.remove(levels.filter(level => level.get('shareable') !== 'project')) |
| 166 | } |
| 167 | if (options.assessmentLevels) { |
| 168 | levels.remove(levels.filter(level => !level.get('assessment'))) |
| 169 | } |
| 170 | return levels |
| 171 | } |
| 172 | |
| 173 | getLevelsByModules () { |
| 174 | const courseModuleLevelsMap = {} |
no test coverage detected