mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-30 02:55:43 -05:00
Calculate the last time any of a teacher's students played
This commit is contained in:
parent
01affc2054
commit
6b6bd2f76d
1 changed files with 17 additions and 0 deletions
|
@ -5,6 +5,8 @@ Prepaid = require 'models/Prepaid'
|
||||||
StripeCoupons = require 'collections/StripeCoupons'
|
StripeCoupons = require 'collections/StripeCoupons'
|
||||||
forms = require 'core/forms'
|
forms = require 'core/forms'
|
||||||
Prepaids = require 'collections/Prepaids'
|
Prepaids = require 'collections/Prepaids'
|
||||||
|
LevelSessions = require 'collections/LevelSessions'
|
||||||
|
Classrooms = require 'collections/Classrooms'
|
||||||
|
|
||||||
module.exports = class AdministerUserModal extends ModalView
|
module.exports = class AdministerUserModal extends ModalView
|
||||||
id: 'administer-user-modal'
|
id: 'administer-user-modal'
|
||||||
|
@ -23,8 +25,23 @@ module.exports = class AdministerUserModal extends ModalView
|
||||||
@supermodel.trackRequest @coupons.fetch({cache: false})
|
@supermodel.trackRequest @coupons.fetch({cache: false})
|
||||||
@prepaids = new Prepaids()
|
@prepaids = new Prepaids()
|
||||||
@supermodel.trackRequest @prepaids.fetchByCreator(@userHandle)
|
@supermodel.trackRequest @prepaids.fetchByCreator(@userHandle)
|
||||||
|
@classrooms = new Classrooms()
|
||||||
|
@supermodel.trackRequest(@classrooms.fetch({data:{ownerID: @user.id}})).then =>
|
||||||
|
@classrooms.each (classroom) =>
|
||||||
|
classroom.levelSessions = new LevelSessions()
|
||||||
|
@supermodel.trackRequests classroom.levelSessions.fetchForAllClassroomMembers(classroom)
|
||||||
|
|
||||||
onLoaded: ->
|
onLoaded: ->
|
||||||
|
@allLevelSessions = new LevelSessions(_.reduce((@classrooms.map (c) -> c.levelSessions.models), (a,b) -> (a.concat(b))))
|
||||||
|
console.log @allLevelSessions
|
||||||
|
mostRecentSession = @allLevelSessions.max (session) ->
|
||||||
|
new Date(session.get('changed'))
|
||||||
|
console.log new Date(mostRecentSession.get('changed'))
|
||||||
|
console.log @allLevelSessions.filter (session) ->
|
||||||
|
changed = new Date(session.get('changed'))
|
||||||
|
if changed > new Date(mostRecentSession.get('changed'))
|
||||||
|
console.log changed
|
||||||
|
changed > new Date(mostRecentSession.get('changed'))
|
||||||
# TODO: Figure out a better way to expose this info, perhaps User methods?
|
# TODO: Figure out a better way to expose this info, perhaps User methods?
|
||||||
stripe = @user.get('stripe') or {}
|
stripe = @user.get('stripe') or {}
|
||||||
@free = stripe.free is true
|
@free = stripe.free is true
|
||||||
|
|
Loading…
Reference in a new issue