Admin teacher demo requests page

Incoming rates table
Student counts table
This commit is contained in:
Matt Lott 2016-05-11 11:52:30 -07:00
parent ea6d5e4867
commit 8bc9cd5ee6
5 changed files with 122 additions and 10 deletions

View file

@ -37,6 +37,7 @@ module.exports = class CocoRouter extends Backbone.Router
'admin/level-sessions': go('admin/LevelSessionsView')
'admin/users': go('admin/UsersView')
'admin/base': go('admin/BaseView')
'admin/demo-requests': go('admin/DemoRequestsView')
'admin/trial-requests': go('admin/TrialRequestsView')
'admin/user-code-problems': go('admin/UserCodeProblemsView')
'admin/pending-patches': go('admin/PendingPatchesView')

View file

@ -0,0 +1,23 @@
#admin-demo-requests-view
#site-content-area
width: 100%
td
max-width: 120px
overflow: hidden
.btn-deny
float: right
.status-cell
width: 120px
td.created
min-width: 90px
td.reviewed
min-width: 90px
th.number
max-width: 50px

View file

@ -39,8 +39,17 @@ block content
li
a(href="/admin/users") Users
h4 Other
if me.isAdmin()
h4 Analytics
ul
li
a(href="/admin/analytics") Dashboard
li
a(href="/admin/analytics/subscriptions") Subscriptions
li
a(href="/admin/demo-requests") Teacher Demo Requests
h4 Other
ul
li
a(href="/admin/base") Base (for debugging base.jade)
@ -48,15 +57,7 @@ block content
a(href="/admin/clas") CLAs
li
a(href="/admin/pending-patches") Patches
if me.isAdmin()
li
a(href="/admin/analytics") Analytics
ul
li
a(href="/admin/analytics/subscriptions") Subscriptions
li
a(href="/admin/design-elements") Design Elements
if me.isAdmin()
hr
h3 Prepaids

View file

@ -0,0 +1,52 @@
extends /templates/base
block content
if !me.isAdmin()
div You must be logged in as an admin to view this page.
else
h2 Teacher Demo Requests
if view.trialRequests.models.length < 1
h4 Fetching trial requests...
else
h3 Incoming Rate
table.table.table-condensed
thead
tr
th Day
th Count
th 7-day Average
tbody
each dayCount in view.dayCounts
tr
td= dayCount.day
td= dayCount.count
td= dayCount.sevenAverage
h3 Student Counts
table.table.table-condensed
thead
tr
th Created
th NCES District
th School Name
th.number NCES District Schools
th.number NCES District Students
th.number NCES School Students
th.number School Students
th.number Teacher Students
tbody
each trialRequest in view.trialRequests.models
if trialRequest.get('type') !== 'course'
- continue;
tr
td.created= trialRequest.get('created').substring(0, 10)
td= trialRequest.get('properties').nces_district || ''
td= trialRequest.get('properties').organization || ''
td= trialRequest.get('properties').nces_district_schools || ''
td= trialRequest.get('properties').nces_district_students || ''
td= trialRequest.get('properties').nces_students || ''
td= trialRequest.get('properties').numStudentsTotal || ''
td= trialRequest.get('properties').numStudents || ''

View file

@ -0,0 +1,35 @@
RootView = require 'views/core/RootView'
template = require 'templates/admin/demo-requests'
CocoCollection = require 'collections/CocoCollection'
TrialRequest = require 'models/TrialRequest'
module.exports = class DemoRequestsView extends RootView
id: 'admin-demo-requests-view'
template: template
constructor: (options) ->
super options
return unless me.isAdmin()
@trialRequests = new CocoCollection([], { url: '/db/trial.request?conditions[sort]="-created"&conditions[limit]=5000', model: TrialRequest })
@supermodel.loadCollection(@trialRequests, 'trial-requests', {cache: false})
@dayCounts = []
onLoaded: ->
return super() unless me.isAdmin()
dayCountMap = {}
for trialRequest in @trialRequests.models
day = trialRequest.get('created').substring(0, 10)
dayCountMap[day] ?= 0
dayCountMap[day]++
@dayCounts = []
for day, count of dayCountMap
@dayCounts.push(day: day, count: count)
@dayCounts.sort((a, b) -> b.day.localeCompare(a.day))
sevenCounts = []
for dayCount in @dayCounts
sevenCounts.push(dayCount.count)
while sevenCounts.length > 7
sevenCounts.shift()
if sevenCounts.length is 7
dayCount.sevenAverage = Math.round(sevenCounts.reduce(((a, b) -> a + b), 0) / 7)
super()