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

Method joinClass

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

Source from the content-addressed store, hash-verified

629 }
630
631 joinClass () {
632 if (this.state) { return }
633 this.state = 'enrolling'
634 this.errorMessage = null
635 this.classCode = this.$('#class-code-input').val() || this.classCodeQueryVar
636 if (!this.classCode) {
637 this.state = null
638 this.errorMessage = 'Please enter a code.'
639 this.renderSelectors('#join-class-form')
640 return
641 }
642 this.renderSelectors('#join-class-form')
643 if (me.get('emailVerified') || me.isStudent()) {
644 const newClassroom = new Classroom()
645 const jqxhr = newClassroom.joinWithCode(this.classCode)
646 this.listenTo(newClassroom, 'join:success', function () { return this.onJoinClassroomSuccess(newClassroom) })
647 return this.listenTo(newClassroom, 'join:error', function () { return this.onJoinClassroomError(newClassroom, jqxhr) })
648 } else {
649 const modal = new JoinClassModal({ classCode: this.classCode })
650 this.openModalView(modal)
651 this.listenTo(modal, 'error', this.onClassLoadError)
652 this.listenTo(modal, 'join:success', this.onJoinClassroomSuccess)
653 this.listenTo(modal, 'join:error', this.onJoinClassroomError)
654 this.listenToOnce(modal, 'hidden', function () {
655 if (!me.isStudent()) {
656 return this.onClassLoadError()
657 }
658 })
659 return this.listenTo(modal, 'hidden', function () {
660 this.state = null
661 return this.renderSelectors('#join-class-form')
662 })
663 }
664 }
665
666 // Super hacky way to patch users being able to join class while hiding /students from others
667 onClassLoadError () {

Callers 3

onLoadedMethod · 0.95
onSubmitJoinClassFormMethod · 0.95

Calls 6

joinWithCodeMethod · 0.95
onJoinClassroomErrorMethod · 0.95
onClassLoadErrorMethod · 0.95
isStudentMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected