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

Method classStats

app/views/courses/ClassroomView.js:230–255  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

228 }
229
230 classStats () {
231 const stats = {}
232
233 let playtime = 0
234 let total = 0
235 for (const session of Array.from(this.sessions.models)) {
236 const pt = session.get('playtime') || 0
237 playtime += pt
238 total += 1
239 }
240 stats.averagePlaytime = playtime && total ? moment.duration(playtime / total, 'seconds').humanize() : 0
241 stats.totalPlaytime = playtime ? moment.duration(playtime, 'seconds').humanize() : 0
242
243 const levelPracticeMap = {}
244 for (const level of Array.from(this.levels.models)) {
245 var left
246 levelPracticeMap[level.id] = (left = level.get('practice')) != null ? left : false
247 }
248 const completeSessions = this.sessions.filter(s => __guard__(s.get('state'), x => x.complete) && !levelPracticeMap[s.get('levelID')])
249 stats.averageLevelsComplete = this.users.size() ? (_.size(completeSessions) / this.users.size()).toFixed(1) : 'N/A' // '
250 stats.totalLevelsComplete = _.size(completeSessions)
251
252 const enrolledUsers = this.users.filter(user => user.isEnrolled())
253 stats.enrolledUsers = _.size(enrolledUsers)
254 return stats
255 }
256
257 onClickAddStudentsButton (e) {
258 const modal = new InviteToClassroomModal({ classroom: this.classroom })

Callers

nothing calls this directly

Calls 4

filterMethod · 0.80
isEnrolledMethod · 0.80
__guard__Function · 0.70
getMethod · 0.45

Tested by

no test coverage detected