(options, classroomID)
| 52 | } |
| 53 | |
| 54 | constructor (options, classroomID) { |
| 55 | super(...arguments) |
| 56 | if (me.isAnonymous()) { return } |
| 57 | this.classroom = new Classroom({ _id: classroomID }) |
| 58 | this.supermodel.loadModel(this.classroom) |
| 59 | this.courses = new CocoCollection([], { url: '/db/course', model: Course }) |
| 60 | this.courses.comparator = '_id' |
| 61 | this.supermodel.loadCollection(this.courses) |
| 62 | this.courses.comparator = '_id' |
| 63 | this.courseInstances = new CocoCollection([], { url: '/db/course_instance', model: CourseInstance }) |
| 64 | this.courseInstances.comparator = 'courseID' |
| 65 | this.supermodel.loadCollection(this.courseInstances, { data: { classroomID } }) |
| 66 | this.prepaids = new Prepaids() |
| 67 | this.prepaids.comparator = '_id' |
| 68 | this.prepaids.fetchByCreator(me.id) |
| 69 | this.supermodel.loadCollection(this.prepaids) |
| 70 | this.users = new CocoCollection([], { url: `/db/classroom/${classroomID}/members?memberLimit=100`, model: User }) |
| 71 | this.users.comparator = user => user.broadName().toLowerCase() |
| 72 | this.supermodel.loadCollection(this.users) |
| 73 | this.listenToOnce(this.courseInstances, 'sync', this.onCourseInstancesSync) |
| 74 | this.sessions = new CocoCollection([], { model: LevelSession }) |
| 75 | this.ownedClassrooms = new Classrooms() |
| 76 | this.ownedClassrooms.fetchMine({ data: { project: '_id' } }) |
| 77 | this.supermodel.trackCollection(this.ownedClassrooms) |
| 78 | this.levels = new Levels() |
| 79 | this.levels.fetchForClassroom(classroomID, { data: { project: 'name,original,practice,slug' } }) |
| 80 | this.levels.on('add', function (model) { return this._byId[model.get('original')] = model }) // so you can 'get' them |
| 81 | this.supermodel.trackCollection(this.levels) |
| 82 | if (window.tracker) { |
| 83 | window.tracker.trackEvent('Students Class Loaded', { category: 'Students', classroomID }) |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | onCourseInstancesSync () { |
| 88 | let courseInstance, sessions |
nothing calls this directly
no test coverage detected