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

Method constructor

app/views/user/CertificatesView.js:48–123  ·  view source on GitHub ↗
(options, userID)

Source from the content-addressed store, hash-verified

46 }
47
48 constructor (options, userID) {
49 super(options)
50 this.userID = userID
51 this.utils = utils
52 this.callOz = utils.getQueryVariable('callOz')
53 if (this.userID === me.id) {
54 this.user = me
55 if (utils.isCodeCombat && !utils.showOzaria()) {
56 this.setHero()
57 }
58 } else {
59 this.user = new User({ _id: this.userID })
60 this.user.fetch()
61 this.supermodel.trackModel(this.user)
62 if (utils.isCodeCombat && !utils.showOzaria()) {
63 this.listenToOnce(this.user, 'sync', () => (typeof this.setHero === 'function' ? this.setHero() : undefined))
64 }
65 this.user.fetchNameForClassmate({
66 success: data => {
67 this.studentName = User.broadName(data)
68 return (typeof this.render === 'function' ? this.render() : undefined)
69 },
70 })
71 }
72 const classroomID = utils.getQueryVariable('class')
73 if (classroomID) {
74 this.classroom = new Classroom({ _id: classroomID })
75 this.classroom.fetch()
76 this.supermodel.trackModel(this.classroom)
77 this.listenToOnce(this.classroom, 'sync', this.onClassroomLoaded)
78 }
79 const courseID = utils.getQueryVariable('course')
80 if (courseID) {
81 this.course = new Course({ _id: courseID })
82 this.course.fetch({ callOz: this.callOz })
83 this.supermodel.trackModel(this.course)
84 }
85 const campaignId = utils.getQueryVariable('campaign-id')
86 if (campaignId) {
87 this.campaign = new Campaign({ _id: campaignId })
88 this.campaign.fetch()
89 this.supermodel.trackModel(this.campaign)
90 }
91 this.courseInstanceID = utils.getQueryVariable('course-instance')
92 // TODO: anonymous loading of classrooms and courses with just enough info to generate cert, or cert route on server
93 // TODO: handle when we don't have classroom & course
94 // TODO: add a check here that the course is completed
95
96 this.sessions = new LevelSessions()
97 if (this.courseInstanceID) {
98 this.supermodel.trackRequest(this.sessions.fetchForCourseInstance(this.courseInstanceID, { userID: this.userID, data: { project: 'state.complete,level.original,playtime,changed,code,codeLanguage,team' } }))
99 this.listenToOnce(this.sessions, 'sync', this.calculateStats)
100 } else if (campaignId) {
101 this.supermodel.trackRequest(this.sessions.fetchForCampaign(campaignId, { data: { userId: this.userID, noLanguageFilter: true } }))
102 this.listenToOnce(this.sessions, 'sync', this.calculateCampaignStats)
103 } else if (courseID && this.userID) {
104 this.supermodel.trackRequest(this.sessions.fetchForCourse({ courseId: courseID, userId: this.userID }, { callOz: this.callOz }))
105 this.listenToOnce(this.sessions, 'sync', this.calculateCourseStats)

Callers

nothing calls this directly

Calls 11

setHeroMethod · 0.95
hashStringMethod · 0.95
fetchNameForClassmateMethod · 0.80
broadNameMethod · 0.80
fetchForCourseMethod · 0.80
fetchMethod · 0.45
renderMethod · 0.45
fetchForCampaignMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected