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

Method onLoaded

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

Source from the content-addressed store, hash-verified

451 }
452
453 onLoaded () {
454 let left
455 super.onLoaded()
456 if (this.classCodeQueryVar && !me.isAnonymous()) {
457 if (window.tracker != null) {
458 window.tracker.trackEvent('Students Join Class Link', { category: 'Students', classCode: this.classCodeQueryVar })
459 }
460 this.joinClass()
461 } else if (this.classCodeQueryVar && me.isAnonymous()) {
462 this.openModalView(new CreateAccountModal())
463 }
464 const ownerIDs = (left = _.map(this.classrooms.models, c => c.get('ownerID'))) != null ? left : []
465 Promise.resolve($.ajax(NameLoader.loadNames(ownerIDs)))
466 .then(() => {
467 this.ownerNameMap = {}
468 for (const ownerID of Array.from(ownerIDs)) { this.ownerNameMap[ownerID] = NameLoader.getName(ownerID) }
469 return this.renderSelectors('.teacher-name')
470 })
471 if (utils.useWebsocket) {
472 this.useWebsocket = true
473 const {
474 wsBus,
475 } = application
476 const uniqueOwnerIDs = Array.from(new Set(ownerIDs))
477 const teacherTopics = uniqueOwnerIDs.map(teacher => {
478 wsBus.addFriend(teacher, { role: 'teacher' })
479 return `user-${teacher}`
480 })
481 wsBus.ws.subscribe(teacherTopics)
482 me.fetchOnlineTeachers(uniqueOwnerIDs).then(onlineTeachers => {
483 wsBus.updateOnlineFriends(onlineTeachers)
484 return this.renderSelectors('.teacher-icon')
485 })
486 }
487
488 if (utils.isCodeCombat) {
489 const academicaCS1CourseInstance = _.find(this.courseInstances.models != null ? this.courseInstances.models : [], ci => ci.get('_id') === '610047c74bc544001e26ea12')
490 if (academicaCS1CourseInstance) {
491 const academicaGlobalClassroom = _.find(this.classrooms.models != null ? this.classrooms.models : [], c => c.get('_id') === '610047c673801a001f85fd43')
492 if (!academicaGlobalClassroom && (utils.getQueryVariable('autorefresh') !== true)) {
493 // Refresh so that we make sure we get this loaded
494 window.location.href = '/students?autorefresh=true'
495 }
496 }
497
498 if (!this.classrooms.models.length) {
499 me.setLastClassroomItems(true) // Default players to being able to see classroom items if they aren't in any classrooms
500 this.nextLevelInfo = { courseAcronym: 'CS1' } // Don't both trying to figure out the next level for edge case of student with no classrooms
501 this.allCompleted = false
502 return
503 }
504
505 if (this.classrooms.models.length === 1) {
506 // If we're in only one classroom, we can use its classroom item setting
507 me.setLastClassroomItems(this.classrooms.models[0].get('classroomItems', true))
508 }
509
510 this.calculateAllCompleted()

Callers

nothing calls this directly

Calls 14

joinClassMethod · 0.95
calculateAllCompletedMethod · 0.95
showHocProgressMethod · 0.95
calculateHocStatsMethod · 0.95
isAnonymousMethod · 0.80
addFriendMethod · 0.80
updateOnlineFriendsMethod · 0.80
setLastClassroomItemsMethod · 0.80
trackEventMethod · 0.45
getMethod · 0.45
loadNamesMethod · 0.45
getNameMethod · 0.45

Tested by

no test coverage detected