From 0a1be8e80e57662a661936895aecad90b572e6f5 Mon Sep 17 00:00:00 2001 From: Nick Winter Date: Sun, 6 Dec 2015 12:33:28 -0800 Subject: [PATCH 1/3] Don't load ambient sound in CampaignView if muted --- app/views/play/CampaignView.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/views/play/CampaignView.coffee b/app/views/play/CampaignView.coffee index 4492a23a7..e48c16033 100644 --- a/app/views/play/CampaignView.coffee +++ b/app/views/play/CampaignView.coffee @@ -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') From cb4d8fee8cf7fe74518b52792203366eb0c2c2c2 Mon Sep 17 00:00:00 2001 From: Matt Lott Date: Sun, 6 Dec 2015 14:26:32 -0800 Subject: [PATCH 2/3] Update /courses/purchase visuals --- app/styles/courses/purchase-courses-view.sass | 6 +++ .../courses/purchase-courses-view.jade | 35 ++++++++++++++- app/views/courses/PurchaseCoursesView.coffee | 45 ++++++++++++++++--- 3 files changed, 79 insertions(+), 7 deletions(-) diff --git a/app/styles/courses/purchase-courses-view.sass b/app/styles/courses/purchase-courses-view.sass index 5cbb7308a..1eda341af 100644 --- a/app/styles/courses/purchase-courses-view.sass +++ b/app/styles/courses/purchase-courses-view.sass @@ -3,3 +3,9 @@ .enrollment-count font-size: 30px width: 120px + + .not-enrolled + line-height: 16px + + .uppercase + text-transform: uppercase diff --git a/app/templates/courses/purchase-courses-view.jade b/app/templates/courses/purchase-courses-view.jade index 096fd9487..1bb41f789 100644 --- a/app/templates/courses/purchase-courses-view.jade +++ b/app/templates/courses/purchase-courses-view.jade @@ -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 diff --git a/app/views/courses/PurchaseCoursesView.coffee b/app/views/courses/PurchaseCoursesView.coffee index cf22d56e1..3101a553d 100644 --- a/app/views/courses/PurchaseCoursesView.coffee +++ b/app/views/courses/PurchaseCoursesView.coffee @@ -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?() }) - From 66f434adba24bc4d94c3fdb6bf9016ad8dc034eb Mon Sep 17 00:00:00 2001 From: Matt Lott Date: Sun, 6 Dec 2015 15:00:00 -0800 Subject: [PATCH 3/3] Update class progress colors --- app/styles/courses/classroom-view.sass | 9 ++++++++- app/templates/courses/classroom-view.jade | 4 ++-- app/views/courses/ClassroomView.coffee | 2 ++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/styles/courses/classroom-view.sass b/app/styles/courses/classroom-view.sass index e01743d0c..30175651d 100644 --- a/app/styles/courses/classroom-view.sass +++ b/app/styles/courses/classroom-view.sass @@ -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 diff --git a/app/templates/courses/classroom-view.jade b/app/templates/courses/classroom-view.jade index de5caf573..f971585fc 100644 --- a/app/templates/courses/classroom-view.jade +++ b/app/templates/courses/classroom-view.jade @@ -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 diff --git a/app/views/courses/ClassroomView.coffee b/app/views/courses/ClassroomView.coffee index 2e17c6147..9398494ee 100644 --- a/app/views/courses/ClassroomView.coffee +++ b/app/views/courses/ClassroomView.coffee @@ -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({