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

Method updateClassroomSessions

app/views/play/CampaignView.js:654–685  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

652 }
653
654 updateClassroomSessions () {
655 if (this.classroom) {
656 const classroomLevels = this.classroom.getLevels()
657 this.classroomLevelMap = Object.fromEntries(classroomLevels.map(l => [l.get('original'), l]))
658 const defaultLanguage = this.classroom.get('aceConfig')?.language || 'python'
659 for (const session of this.sessions.slice()) {
660 const classroomLevel = this.classroomLevelMap[session.get('level').original]
661 if (!classroomLevel) {
662 continue
663 }
664 const expectedLanguage = classroomLevel.get('primerLanguage') || defaultLanguage
665 if (session.get('codeLanguage') !== expectedLanguage) {
666 this.sessions.remove(session)
667 continue
668 }
669 }
670 if (!this.editorMode) {
671 for (const session of this.sessions.models) {
672 if (this.levelStatusMap[session.get('levelID')] !== COMPLETE_STATUS) { // Don't overwrite a complete session with an incomplete one
673 this.levelStatusMap[session.get('levelID')] = session.get('state')?.complete ? COMPLETE_STATUS : STARTED_STATUS
674 }
675 const levelOriginal = session.get('level')?.original
676 if (levelOriginal && this.levelOriginalStatusMap[levelOriginal] !== COMPLETE_STATUS) {
677 this.levelOriginalStatusMap[levelOriginal] = session.get('state')?.complete ? COMPLETE_STATUS : STARTED_STATUS
678 }
679 if (session.get('state')?.difficulty) {
680 this.levelDifficultyMap[session.get('levelID')] = session.get('state').difficulty
681 }
682 }
683 }
684 }
685 }
686
687 buildLevelScoreMap () {
688 for (const session of this.sessions.models) {

Callers 2

constructorMethod · 0.95
onLoadedMethod · 0.95

Calls 2

getLevelsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected