MCPcopy Index your code
hub / github.com/codecombat/codecombat / constructor

Method constructor

app/views/courses/ClassroomView.js:54–85  ·  view source on GitHub ↗
(options, classroomID)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 7

isAnonymousMethod · 0.80
fetchByCreatorMethod · 0.80
broadNameMethod · 0.80
fetchMineMethod · 0.80
fetchForClassroomMethod · 0.45
getMethod · 0.45
trackEventMethod · 0.45

Tested by

no test coverage detected