()
| 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 () { |
no test coverage detected