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

Method constructor

app/views/courses/CoursesView.js:93–162  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

91 }
92
93 constructor () {
94 super()
95 this.moreAILeagueTiles = false
96 this.renderStats = this.renderStats.bind(this)
97 this.utils = utils
98 this.classCodeQueryVar = utils.getQueryVariable('_cc', false)
99 this.courseInstances = new CocoCollection([], { url: `/db/user/${me.id}/course-instances`, model: CourseInstance })
100
101 this.classroomsLoaded = false
102 this.courseInstancesLoaded = false
103 this.courseInstances.comparator = ci => parseInt(ci.get('classroomID').substr(0, 8), 16) + utils.orderedCourseIDs.indexOf(ci.get('courseID'))
104 this.listenToOnce(this.courseInstances, 'sync', function () {
105 this.courseInstancesLoaded = true
106 this.onCourseInstancesLoaded()
107 })
108 this.supermodel.loadCollection(this.courseInstances, { cache: false })
109 this.classrooms = new CocoCollection([], { url: '/db/classroom', model: Classroom })
110 this.classrooms.comparator = (a, b) => b.id.localeCompare(a.id)
111 this.supermodel.loadCollection(this.classrooms, { data: { memberID: me.id }, cache: false })
112 this.supermodel.addPromiseResource(store.dispatch('courses/fetchReleased'))
113 this.hourOfCodeOptions = utils.hourOfCodeOptions
114 this.hocCodeLanguage = (me.get('hourOfCodeOptions') || {}).hocCodeLanguage || 'python'
115 this.hocStats = {}
116 this.listenTo(this.classrooms, 'sync', function () {
117 if (utils.isOzaria && this.showHocProgress()) {
118 const campaign = this.hourOfCodeOptions.campaignId
119 const sessionFetchOptions = {
120 language: this.hocCodeLanguage,
121 project: 'state.complete,level.original,playtime,changed',
122 }
123 this.supermodel.addPromiseResource(store.dispatch('levelSessions/fetchLevelSessionsForCampaign', { campaignHandle: campaign, options: { data: sessionFetchOptions } }))
124 this.campaignLevels = new Levels()
125 this.supermodel.trackRequest(this.campaignLevels.fetchForCampaign(this.hourOfCodeOptions.campaignId, { data: { project: `original,primerLanguage,slug,i18n.${me.get('preferredLanguage', true)}` } }))
126 }
127 this.classroomsLoaded = true
128 this.onCourseInstancesLoaded()
129 })
130 this.store = store
131 this.originalLevelMap = {}
132 this.urls = require('core/urls')
133
134 this.wsBus = globalVar.application.wsBus // shortcut
135 if (utils.isCodeCombat) {
136 this.ladderImageMap = {}
137 this.ladders = this.supermodel.loadCollection(new LadderCollection()).model
138 this.listenToOnce(this.ladders, 'sync', this.onLaddersLoaded)
139
140 if (me.get('role') === 'student') {
141 const tournaments = new CocoCollection([], { url: `/db/tournaments?memberId=${me.id}`, model: Tournament })
142 this.reversedTournaments = []
143 this.listenToOnce(tournaments, 'sync', () => {
144 this.tournaments = (Array.from(tournaments.models).map((t) => t.toJSON()))
145 this.reversedTournaments = this.tournaments.slice().reverse()
146 this.tournamentsByState = _.groupBy(this.tournaments, 'state')
147 return this.renderSelectors('.custom-tournaments-area')
148 })
149 tournaments.fetch({ cache: false })
150 }

Callers

nothing calls this directly

Calls 7

showHocProgressMethod · 0.95
fetchMethod · 0.95
loadAILeagueStatsMethod · 0.95
__guard__Function · 0.70
getMethod · 0.45
fetchForCampaignMethod · 0.45

Tested by

no test coverage detected