MCPcopy Create free account
hub / github.com/codecombat/codecombat / constructor

Method constructor

app/views/courses/CourseDetailsView.js:45–96  ·  view source on GitHub ↗
(options, courseID, courseInstanceID)

Source from the content-addressed store, hash-verified

43 }
44
45 constructor (options, courseID, courseInstanceID) {
46 super(options)
47 this.courseID = courseID
48 this.courseInstanceID = courseInstanceID
49 this.courses = new Courses()
50 this.course = new Course()
51 this.levelSessions = new LevelSessions()
52 this.courseInstance = new CourseInstance({ _id: this.courseInstanceID })
53 this.owner = new User()
54 this.classroom = new Classroom()
55 this.levels = new Levels()
56 this.courseInstances = new CourseInstances()
57
58 this.supermodel.trackRequest(this.courses.fetch().then(() => {
59 return this.course = this.courses.get(this.courseID)
60 }))
61 const sessionsLoaded = this.supermodel.trackRequest(this.levelSessions.fetchForCourseInstance(this.courseInstanceID, { cache: false }))
62
63 this.supermodel.trackRequest(this.courseInstance.fetch().then(() => {
64 if (this.destroyed) { return }
65 this.owner = new User({ _id: this.courseInstance.get('ownerID') })
66 this.supermodel.trackRequest(this.owner.fetch())
67
68 const classroomID = this.courseInstance.get('classroomID')
69 this.classroom = new Classroom({ _id: classroomID })
70 this.supermodel.trackRequest(this.classroom.fetch())
71
72 const levelsLoaded = this.supermodel.trackRequest(this.levels.fetchForClassroomAndCourse(classroomID, this.courseID, {
73 data: { project: 'concepts,practice,primerLanguage,type,slug,name,original,description,shareable,i18n' }
74 }))
75
76 return this.supermodel.trackRequest($.when(levelsLoaded, sessionsLoaded).then(() => {
77 this.buildSessionStats()
78 if (this.destroyed) { return }
79 if ((this.memberStats[me.id] != null ? this.memberStats[me.id].totalLevelsCompleted : undefined) >= (this.levels.size() - 1)) { // Don't need to complete arena
80 // need to figure out the next course instance
81 this.courseComplete = true
82 this.courseInstances.comparator = 'courseID'
83 // TODO: make this logic use locked course content to figure out the next course, then fetch the
84 // course instance for that
85 this.supermodel.trackRequest(this.courseInstances.fetchForClassroom(classroomID).then(() => {
86 this.nextCourseInstance = _.find(this.courseInstances.models, ci => ci.get('courseID') > this.courseID)
87 if (this.nextCourseInstance) {
88 const nextCourseID = this.nextCourseInstance.get('courseID')
89 return this.nextCourse = this.courses.get(nextCourseID)
90 }
91 }))
92 }
93 return this.promptForSchool = this.courseComplete && !me.isAnonymous() && !me.get('schoolName') && !storage.load('no-school')
94 }))
95 }))
96 }
97
98 initialize (options) {
99 if (window.tracker != null) {

Callers

nothing calls this directly

Calls 8

buildSessionStatsMethod · 0.95
isAnonymousMethod · 0.80
fetchMethod · 0.45
getMethod · 0.45
fetchForClassroomMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected