mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-24 08:08:15 -05:00
Merge branch 'master' into production
This commit is contained in:
commit
a99b21c4f5
7 changed files with 93 additions and 10 deletions
|
@ -1,7 +1,8 @@
|
|||
#classroom-view
|
||||
|
||||
.enable-btn
|
||||
margin: 1px
|
||||
margin-top: 1px
|
||||
margin-bottom: 4px
|
||||
|
||||
#main-button-area
|
||||
.btn
|
||||
|
@ -16,6 +17,12 @@
|
|||
.progress-bar
|
||||
border-right: 1px solid grey
|
||||
|
||||
.progress-bar-complete
|
||||
background-color: #9DE257
|
||||
color: grey
|
||||
.progress-bar-started
|
||||
background-color: #FFF6A1
|
||||
color: grey
|
||||
.progress-bar-default
|
||||
background-color: white
|
||||
color: grey
|
||||
|
|
|
@ -3,3 +3,9 @@
|
|||
.enrollment-count
|
||||
font-size: 30px
|
||||
width: 120px
|
||||
|
||||
.not-enrolled
|
||||
line-height: 16px
|
||||
|
||||
.uppercase
|
||||
text-transform: uppercase
|
||||
|
|
|
@ -98,9 +98,9 @@ block content
|
|||
a(href=view.getLevelURL(level, course, courseInstance, session))
|
||||
- var content = view.levelPopoverContent(level, session, i);
|
||||
if session && session.get('state') && session.get('state').complete
|
||||
.progress-bar.progress-bar-success(style=css, data-content=content, data-toggle='popover')= i
|
||||
.progress-bar.progress-bar-complete(style=css, data-content=content, data-toggle='popover')= i
|
||||
else if session
|
||||
.progress-bar.progress-bar-warning(style=css, data-content=content, data-toggle='popover')= i
|
||||
.progress-bar.progress-bar-started(style=css, data-content=content, data-toggle='popover')= i
|
||||
else
|
||||
.progress-bar.progress-bar-default(style=css, data-content=content, data-toggle='popover')= i
|
||||
else if paidFor
|
||||
|
|
|
@ -24,13 +24,46 @@ block content
|
|||
if view.state === 'error'
|
||||
.alert.alert-danger= view.stateMessage
|
||||
|
||||
- var usedEnrollments = view.prepaids.totalRedeemers();
|
||||
- var totalEnrollments = view.prepaids.totalMaxRedeemers();
|
||||
- var remainingEnrollments = totalEnrollments - usedEnrollments;
|
||||
.row
|
||||
.col-md-4
|
||||
.col-md-3
|
||||
strong.uppercase unused paid enrollments
|
||||
.col-md-1
|
||||
strong= remainingEnrollments
|
||||
br
|
||||
.row
|
||||
.col-md-4
|
||||
.col-md-3
|
||||
strong.uppercase students not enrolled
|
||||
.row
|
||||
.col-md-4
|
||||
.col-md-3
|
||||
each classroom in view.classrooms.models
|
||||
if classroom.get('members').length > 0
|
||||
.not-enrolled= classroom.get('name')
|
||||
.not-enrolled Total Across All Classes
|
||||
.col-md-1
|
||||
- var totalNotEnrolled = 0
|
||||
each classroom in view.classrooms.models
|
||||
if classroom.get('members').length > 0 && view.classroomNotEnrolledMap
|
||||
.not-enrolled
|
||||
strong= view.classroomNotEnrolledMap[classroom.id]
|
||||
.not-enrolled
|
||||
strong= view.totalNotEnrolled
|
||||
|
||||
br
|
||||
br
|
||||
|
||||
p.text-center
|
||||
strong How many additional paid enrollments do you need?
|
||||
br
|
||||
|
||||
p.text-center
|
||||
input#students-input.text-center.enrollment-count(
|
||||
value=view.numberOfStudents
|
||||
value= view.numberOfStudents
|
||||
type='number'
|
||||
)
|
||||
br
|
||||
|
|
|
@ -174,6 +174,8 @@ module.exports = class ClassroomView extends RootView
|
|||
else
|
||||
onCourseInstanceCreated()
|
||||
|
||||
# TODO: update newly visible level progress bar (currently all white)
|
||||
|
||||
onClickRemoveStudentLink: (e) ->
|
||||
user = @users.get($(e.target).closest('a').data('user-id'))
|
||||
modal = new RemoveStudentModal({
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
app = require 'core/application'
|
||||
AuthModal = require 'views/core/AuthModal'
|
||||
Classroom = require 'models/Classroom'
|
||||
CocoCollection = require 'collections/CocoCollection'
|
||||
Course = require 'models/Course'
|
||||
Prepaids = require 'collections/Prepaids'
|
||||
RootView = require 'views/core/RootView'
|
||||
stripeHandler = require 'core/services/stripe'
|
||||
template = require 'templates/courses/purchase-courses-view'
|
||||
User = require 'models/User'
|
||||
utils = require 'core/utils'
|
||||
|
||||
module.exports = class PurchaseCoursesView extends RootView
|
||||
|
@ -12,12 +15,22 @@ module.exports = class PurchaseCoursesView extends RootView
|
|||
template: template
|
||||
numberOfStudents: 30
|
||||
pricePerStudent: 4
|
||||
|
||||
|
||||
initialize: (options) ->
|
||||
@listenTo stripeHandler, 'received-token', @onStripeReceivedToken
|
||||
@fromClassroom = utils.getQueryVariable('from-classroom')
|
||||
@members = new CocoCollection([], { model: User })
|
||||
@listenTo @members, 'sync', @membersSync
|
||||
@classrooms = new CocoCollection([], { url: "/db/classroom", model: Classroom })
|
||||
@classrooms.comparator = '_id'
|
||||
@listenToOnce @classrooms, 'sync', @onceClassroomsSync
|
||||
@supermodel.loadCollection(@classrooms, 'classrooms', {data: {ownerID: me.id}})
|
||||
@prepaids = new Prepaids()
|
||||
@prepaids.comparator = '_id'
|
||||
@prepaids.fetchByCreator(me.id)
|
||||
@supermodel.loadCollection(@prepaids, 'prepaids')
|
||||
super(options)
|
||||
|
||||
|
||||
events:
|
||||
'input #students-input': 'onInputStudentsInput'
|
||||
'click #purchase-btn': 'onClickPurchaseButton'
|
||||
|
@ -25,6 +38,27 @@ module.exports = class PurchaseCoursesView extends RootView
|
|||
getPriceString: -> '$' + (@getPrice()).toFixed(2)
|
||||
getPrice: -> @pricePerStudent * @numberOfStudents
|
||||
|
||||
onceClassroomsSync: ->
|
||||
for classroom in @classrooms.models
|
||||
@members.fetch({
|
||||
remove: false
|
||||
url: "/db/classroom/#{classroom.id}/members"
|
||||
})
|
||||
|
||||
membersSync: ->
|
||||
@memberEnrolledMap = {}
|
||||
for user in @members.models
|
||||
@memberEnrolledMap[user.id] = user.get('coursePrepaidID')?
|
||||
@classroomNotEnrolledMap = {}
|
||||
@totalNotEnrolled = 0
|
||||
for classroom in @classrooms.models
|
||||
@classroomNotEnrolledMap[classroom.id] = 0
|
||||
for memberID in classroom.get('members')
|
||||
@classroomNotEnrolledMap[classroom.id]++ unless @memberEnrolledMap[memberID]
|
||||
@totalNotEnrolled += @classroomNotEnrolledMap[classroom.id]
|
||||
@numberOfStudents = @totalNotEnrolled
|
||||
@render?()
|
||||
|
||||
onInputStudentsInput: ->
|
||||
@numberOfStudents = Math.max(parseInt(@$('#students-input').val()) or 0, 0)
|
||||
@updatePrice()
|
||||
|
@ -54,14 +88,14 @@ module.exports = class PurchaseCoursesView extends RootView
|
|||
onStripeReceivedToken: (e) ->
|
||||
@state = 'purchasing'
|
||||
@render?()
|
||||
|
||||
|
||||
data =
|
||||
maxRedeemers: @numberOfStudents
|
||||
type: 'course'
|
||||
stripe:
|
||||
token: e.token.id
|
||||
timestamp: new Date().getTime()
|
||||
|
||||
|
||||
$.ajax({
|
||||
url: '/db/prepaid/-/purchase',
|
||||
data: data,
|
||||
|
@ -71,7 +105,7 @@ module.exports = class PurchaseCoursesView extends RootView
|
|||
application.tracker?.trackEvent 'Finished course prepaid purchase', {price: @pricePerStudent, seats: @numberOfStudents}
|
||||
@state = 'purchased'
|
||||
@render?()
|
||||
|
||||
|
||||
error: (jqxhr, textStatus, errorThrown) ->
|
||||
application.tracker?.trackEvent 'Failed course prepaid purchase', status: textStatus
|
||||
if jqxhr.status is 402
|
||||
|
@ -82,4 +116,3 @@ module.exports = class PurchaseCoursesView extends RootView
|
|||
@stateMessage = "#{jqxhr.status}: #{jqxhr.responseText}"
|
||||
@render?()
|
||||
})
|
||||
|
||||
|
|
|
@ -552,6 +552,7 @@ module.exports = class CampaignView extends RootView
|
|||
@testParticles() if @particleMan
|
||||
|
||||
playAmbientSound: ->
|
||||
return unless me.get 'volume'
|
||||
return if @ambientSound
|
||||
return unless file = @campaign?.get('ambientSound')?[AudioPlayer.ext.substr 1]
|
||||
src = "/file/#{file}"
|
||||
|
@ -600,6 +601,7 @@ module.exports = class CampaignView extends RootView
|
|||
if volume isnt me.get 'volume'
|
||||
me.set 'volume', volume
|
||||
me.patch()
|
||||
@playAmbientSound() if volume
|
||||
|
||||
onToggleVolume: (e) ->
|
||||
button = $(e.target).closest('#volume-button')
|
||||
|
|
Loading…
Reference in a new issue