Prompt for school name on course completion

This commit is contained in:
Nick Winter 2015-12-02 10:59:55 -08:00
parent 866900615f
commit a0e5126ab7
3 changed files with 44 additions and 4 deletions

View file

@ -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

View file

@ -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 Youre 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

View file

@ -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')