From a0e5126ab7f840cc74500c860517178245e5d776 Mon Sep 17 00:00:00 2001 From: Nick Winter Date: Wed, 2 Dec 2015 10:59:55 -0800 Subject: [PATCH] Prompt for school name on course completion --- app/styles/courses/course-details.sass | 16 +++++++++++++++- app/templates/courses/course-details.jade | 19 ++++++++++++++++--- app/views/courses/CourseDetailsView.coffee | 13 +++++++++++++ 3 files changed, 44 insertions(+), 4 deletions(-) diff --git a/app/styles/courses/course-details.sass b/app/styles/courses/course-details.sass index 933e2defa..5ee30de90 100644 --- a/app/styles/courses/course-details.sass +++ b/app/styles/courses/course-details.sass @@ -142,7 +142,21 @@ width: 50% .jumbotron - .btn + form + margin-top: -40px + margin-bottom: 20px + + .btn + margin-top: -15px + + .no-school + width: 30% + + .save-school + margin-left: 10% + width: 60% + + .btn:not(.btn-submit) white-space: normal min-height: 200px diff --git a/app/templates/courses/course-details.jade b/app/templates/courses/course-details.jade index 889a73e80..5a726d656 100644 --- a/app/templates/courses/course-details.jade +++ b/app/templates/courses/course-details.jade @@ -54,14 +54,27 @@ block content if view.courseComplete && !view.teacherMode .jumbotron + if promptForSchool + .row + .col-md-6.col-md-offset-3 + form.form#school-form + .form-group + label.control-label(for="course-complete-school-input") + span.spr(data-i18n="signup.school_name") School Name and City + em.optional-note + | ( + span(data-i18n="signup.optional") optional + | ): + .input-border + input#course-complete-school-input.input-large.form-control(name="schoolName", data-i18n="[placeholder]signup.school_name_placeholder") + button.btn.btn-primary.btn-submit.no-school(type="submit") None + button.btn.btn-info.btn-submit.save-school(type="submit") Save .row if view.singlePlayerMode && !me.isAnonymous() - .col-md-3 - .col-md-6 + .col-md-6.col-md-offset-3 a.btn.btn-lg.btn-success(href="/play") h1 Play the Campaign p You’re ready to take the next step! Explore hundreds of challenging levels, learn advanced programming skills, and compete in multiplayer arenas! - .col-md-3 else if view.singlePlayerMode && me.isAnonymous() .col-md-6 a.btn.btn-lg.btn-success.signup-button diff --git a/app/views/courses/CourseDetailsView.coffee b/app/views/courses/CourseDetailsView.coffee index 296d22f2a..875aa7be2 100644 --- a/app/views/courses/CourseDetailsView.coffee +++ b/app/views/courses/CourseDetailsView.coffee @@ -9,6 +9,7 @@ template = require 'templates/courses/course-details' User = require 'models/User' utils = require 'core/utils' Prepaid = require 'models/Prepaid' +storage = require 'core/storage' autoplayedOnce = false @@ -28,6 +29,7 @@ module.exports = class CourseDetailsView extends RootView 'click .progress-level-cell': 'onClickProgressLevelCell' 'mouseenter .progress-level-cell': 'onMouseEnterPoint' 'mouseleave .progress-level-cell': 'onMouseLeavePoint' + 'submit #school-form': 'onSubmitSchoolForm' constructor: (options, @courseID, @courseInstanceID) -> super options @@ -62,6 +64,7 @@ module.exports = class CourseDetailsView extends RootView context.userConceptStateMap = @userConceptStateMap ? {} context.userLevelStateMap = @userLevelStateMap ? {} context.document = document + context.promptForSchool = @courseComplete and not me.isAnonymous() and not me.get('schoolName') and not storage.load('no-school') context afterRender: -> @@ -368,3 +371,13 @@ module.exports = class CourseDetailsView extends RootView if @owner.get('firstName') and @owner.get('lastName') return "#{@owner.get('firstName')} #{@owner.get('lastName')}" @owner.get('name') or @owner.get('email') + + onSubmitSchoolForm: (e) -> + e.preventDefault() + schoolName = @$el.find('#course-complete-school-input').val().trim() + if schoolName and schoolName isnt me.get('schoolName') + me.set 'schoolName', schoolName + me.patch() + else + storage.save 'no-school', true + @$el.find('#school-form').slideUp('slow')