mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 17:45:40 -05:00
Cleanup per Code Review
This commit is contained in:
parent
f78464e7d9
commit
b76e956fb2
4 changed files with 78 additions and 135 deletions
|
@ -19,7 +19,7 @@
|
||||||
// font-weight: 600
|
// font-weight: 600
|
||||||
|
|
||||||
|
|
||||||
svg[id|="visualisation"]
|
svg.visualisation
|
||||||
// background-color: $navy
|
// background-color: $navy
|
||||||
display: none
|
display: none
|
||||||
|
|
||||||
|
|
|
@ -161,8 +161,6 @@ mixin inlineUserList(users)
|
||||||
ul.inline-student-list.small
|
ul.inline-student-list.small
|
||||||
each student in users
|
each student in users
|
||||||
li
|
li
|
||||||
//- a(href='TODO')
|
|
||||||
//- = student.broadName()
|
|
||||||
span.inline-student-name
|
span.inline-student-name
|
||||||
= student.broadName()
|
= student.broadName()
|
||||||
|
|
||||||
|
|
|
@ -14,27 +14,27 @@ block content
|
||||||
- var isOwner = view.classroom ? view.classroom.get('ownerID') === me.id : false;
|
- var isOwner = view.classroom ? view.classroom.get('ownerID') === me.id : false;
|
||||||
|
|
||||||
if isOwner
|
if isOwner
|
||||||
h3(class="m-t-2")
|
h3.m-t-2
|
||||||
span(data-i18n="teacher.student_profile")
|
span(data-i18n="teacher.student_profile")
|
||||||
span.spr :
|
span.spr :
|
||||||
span= view.user.get('name')
|
span= view.user.get('name')
|
||||||
.classroom-info-row.container-fluid.row
|
.classroom-info-row.container-fluid.row
|
||||||
.overview.col-md-4
|
.overview.col-md-4
|
||||||
h4(class="student-details" data-i18n="teacher.student_overview")
|
h4.student-details(data-i18n="teacher.student_overview")
|
||||||
if (view.user.get('email'))
|
if (view.user.get('email'))
|
||||||
div(class="small-details")
|
.small-details
|
||||||
span(data-i18n="teacher.student_email")
|
span(data-i18n="teacher.student_email")
|
||||||
span.spr :
|
span.spr :
|
||||||
span= view.user.get('email')
|
span= view.user.get('email')
|
||||||
else
|
else
|
||||||
div(class="small-details")
|
.small-details
|
||||||
i(data-i18n="teacher.no_email")
|
i(data-i18n="teacher.no_email")
|
||||||
div(class="small-details")
|
.small-details
|
||||||
span(data-i18n="user.last_played")
|
span(data-i18n="user.last_played")
|
||||||
span.spr :
|
span.spr :
|
||||||
span= view.lastPlayedString
|
span= view.lastPlayedString
|
||||||
|
|
||||||
div(class="small-details")
|
.small-details
|
||||||
- var status = view.user.prepaidStatus()
|
- var status = view.user.prepaidStatus()
|
||||||
span(data-i18n='view.user.status')
|
span(data-i18n='view.user.status')
|
||||||
span.spr
|
span.spr
|
||||||
|
@ -63,19 +63,19 @@ block content
|
||||||
- continue;
|
- continue;
|
||||||
- var instance = view.courseInstances.findWhere({ courseID: course.id, classroomID: view.classroom.id })
|
- var instance = view.courseInstances.findWhere({ courseID: course.id, classroomID: view.classroom.id })
|
||||||
- if ((instance && instance.hasMember(view.user)))
|
- if ((instance && instance.hasMember(view.user)))
|
||||||
option(value=course.id)=course.get('name')
|
option(value= course.id)= course.get('name')
|
||||||
|
|
||||||
div.legend
|
div.legend
|
||||||
svg(width=15, height=15, style="margin: 0 5px 0 0")
|
svg(width=15, height=15, style="margin: 0 5px 0 0")
|
||||||
rect(width=15, height=15,fill="rgb(32, 87, 43)")
|
rect(width=15, height=15, fill="rgb(32, 87, 43)")
|
||||||
span(data-i18n="teacher.student_completed")
|
span(data-i18n="teacher.student_completed")
|
||||||
|
|
||||||
svg(width=15, height=15, style="margin: 0 5px 0 15px")
|
svg(width=15, height=15, style="margin: 0 5px 0 15px")
|
||||||
rect(width=15, height=15,fill="rgb(242, 190, 25)")
|
rect(width=15, height=15, fill="rgb(242, 190, 25)")
|
||||||
span(data-i18n="teacher.student_in_progress")
|
span(data-i18n="teacher.student_in_progress")
|
||||||
|
|
||||||
svg(width=15, height=15 style="margin: 0 5px 0 15px")
|
svg(width=15, height=15, style="margin: 0 5px 0 15px")
|
||||||
rect(width=15, height=15,fill="rgb(92, 180, 208)")
|
rect(width=15, height=15, fill="rgb(92, 180, 208)")
|
||||||
span(data-i18n="teacher.class_average")
|
span(data-i18n="teacher.class_average")
|
||||||
|
|
||||||
.graphs
|
.graphs
|
||||||
|
@ -83,55 +83,21 @@ block content
|
||||||
- var course = _.find(view.courses.models, function(c) {return c.id === versionedCourse._id;});
|
- var course = _.find(view.courses.models, function(c) {return c.id === versionedCourse._id;});
|
||||||
if !course
|
if !course
|
||||||
- continue;
|
- continue;
|
||||||
//- - var rate = _.find(view.courseComparisonMap, function(c) {return c.id === versionedCourse._id;});
|
|
||||||
//- - console.log (rate);
|
|
||||||
//- - console.log (rate.rate);
|
|
||||||
//- span= _.find(view.courseComparisonMap)
|
|
||||||
- var instance = view.courseInstances.findWhere({ courseID: course.id, classroomID: view.classroom.id })
|
- var instance = view.courseInstances.findWhere({ courseID: course.id, classroomID: view.classroom.id })
|
||||||
- if ((instance && instance.hasMember(view.user)))
|
- if ((instance && instance.hasMember(view.user)))
|
||||||
svg(id='visualisation-'+versionedCourse._id, width="1142", height="600")
|
svg(id='visualisation-'+versionedCourse._id, width="1142", height="600", class='visualisation')
|
||||||
|
|
||||||
|
|
||||||
//- - console.log (view.levelData[1].levelIndex)
|
//- TODO Hookup student management actions:
|
||||||
|
|
||||||
//- h4 Actions:
|
|
||||||
// Assign courses from dropdown
|
// Assign courses from dropdown
|
||||||
// Export CSV
|
// Export CSV
|
||||||
// Apply License
|
// Apply License
|
||||||
// Edit password
|
// Edit password
|
||||||
// Remove Student
|
// Remove Student
|
||||||
|
|
||||||
|
|
||||||
//- .student-chart
|
|
||||||
//- div.student-levels-progress
|
|
||||||
//- //- if view.allLevelSessionMap
|
|
||||||
//- //- - console.log (view.allLevelSessionMap)
|
|
||||||
//- each versionedCourse in view.classroom.get('courses') || []
|
|
||||||
//- - var course = _.find(view.courses.models, function(c) {return c.id === versionedCourse._id;});
|
|
||||||
//- if !course
|
|
||||||
//- - continue;
|
|
||||||
//- - var instance = view.courseInstances.findWhere({ courseID: course.id, classroomID: view.classroom.id })
|
|
||||||
//- - if (instance && instance.hasMember(view.user))
|
|
||||||
//- if course
|
|
||||||
//- div.course-row.alternating-background
|
|
||||||
//- strong
|
|
||||||
//- div.course-info= course.get('name')
|
|
||||||
//- - var coursePlaytime = 0
|
|
||||||
//- - var levels = view.classroom.getLevels({courseID: course.id}).models
|
|
||||||
//- each level, index in levels
|
|
||||||
//- - var levelNumber = view.classroom.getLevelNumber(level.get('original'), index + 1)
|
|
||||||
//- //- - console.log (level)
|
|
||||||
//- - var levelProgress = view.levelProgressMap[level.get('original')]
|
|
||||||
//- if view.levelSessionMap && view.levelSessionMap[level.get('original')]
|
|
||||||
//- - var session = view.levelSessionMap[level.get('original')];
|
|
||||||
//- - coursePlaytime += session.get('playtime')
|
|
||||||
//- //- - var levelAverage = view.allLevelSessionMap[level.get('original')]
|
|
||||||
//- p= levelNumber + ". " + level.get('name') + ": " + session.get('playtime') + " (average: " + ")"
|
|
||||||
//- p= coursePlaytime
|
|
||||||
|
|
||||||
div.student-levels
|
.student-levels
|
||||||
h4(data-i18n="teacher.course_progress")
|
h4(data-i18n="teacher.course_progress")
|
||||||
div.student-levels-progress
|
.student-levels-progress
|
||||||
each versionedCourse in view.classroom.get('courses') || []
|
each versionedCourse in view.classroom.get('courses') || []
|
||||||
- var course = _.find(view.courses.models, function(c) {return c.id === versionedCourse._id;});
|
- var course = _.find(view.courses.models, function(c) {return c.id === versionedCourse._id;});
|
||||||
if !course
|
if !course
|
||||||
|
@ -139,15 +105,12 @@ block content
|
||||||
- var instance = view.courseInstances.findWhere({ courseID: course.id, classroomID: view.classroom.id })
|
- var instance = view.courseInstances.findWhere({ courseID: course.id, classroomID: view.classroom.id })
|
||||||
- if (instance && instance.hasMember(view.user))
|
- if (instance && instance.hasMember(view.user))
|
||||||
if course
|
if course
|
||||||
div.course-row.alternating-background
|
.course-row.alternating-background
|
||||||
div.course-info= course.get('name')
|
.course-info= course.get('name')
|
||||||
- var levels = view.classroom.getLevels({courseID: course.id}).models
|
- var levels = view.classroom.getLevels({courseID: course.id}).models
|
||||||
each level, index in levels
|
each level, index in levels
|
||||||
- var levelNumber = view.classroom.getLevelNumber(level.get('original'), index + 1)
|
- var levelNumber = view.classroom.getLevelNumber(level.get('original'), index + 1)
|
||||||
//- - console.log (level)
|
|
||||||
- var levelProgress = view.levelProgressMap[level.get('original')]
|
- var levelProgress = view.levelProgressMap[level.get('original')]
|
||||||
//- p= levelNumber + ". " + level.name + " Progress: " + view.levelProgressMap[level.original]
|
|
||||||
//- - console.log(level)
|
|
||||||
+studentLevelProgressDot(levelProgress, level, levelNumber, course)
|
+studentLevelProgressDot(levelProgress, level, levelNumber, course)
|
||||||
|
|
||||||
|
|
||||||
|
@ -165,9 +128,8 @@ block content
|
||||||
- continue;
|
- continue;
|
||||||
- var instance = view.courseInstances.findWhere({ courseID: course.id, classroomID: view.classroom.id })
|
- var instance = view.courseInstances.findWhere({ courseID: course.id, classroomID: view.classroom.id })
|
||||||
- if (!(instance && instance.hasMember(view.user)))
|
- if (!(instance && instance.hasMember(view.user)))
|
||||||
div(class="small-details")
|
div.small-details
|
||||||
span=course.get('name')
|
span=course.get('name')
|
||||||
// add a button to assign this course
|
|
||||||
|
|
||||||
//- else
|
//- else
|
||||||
//- p Apply a license to this student to assign additional courses!
|
//- p Apply a license to this student to assign additional courses!
|
||||||
|
@ -182,7 +144,6 @@ mixin studentLevelProgressDot(levelProgress, level, levelNumber, course)
|
||||||
- var context = { levelName: levelName, levelNumber: levelNumber, moment: moment , started: levelProgress == 'started', completed: levelProgress == 'complete'};
|
- var context = { levelName: levelName, levelNumber: levelNumber, moment: moment , started: levelProgress == 'started', completed: levelProgress == 'complete'};
|
||||||
if view.levelSessionMap && view.levelSessionMap[level.get('original')]
|
if view.levelSessionMap && view.levelSessionMap[level.get('original')]
|
||||||
- context.session = view.levelSessionMap[level.get('original')];
|
- context.session = view.levelSessionMap[level.get('original')];
|
||||||
//- - console.log(view.levelSessionMap[level.get('original')])
|
|
||||||
- link = null;
|
- link = null;
|
||||||
- labelText = levelNumber;
|
- labelText = levelNumber;
|
||||||
if level.isLadder()
|
if level.isLadder()
|
||||||
|
|
|
@ -66,14 +66,11 @@ module.exports = class TeacherStudentView extends RootView
|
||||||
}).delegate '.tooltip', 'mousemove', ->
|
}).delegate '.tooltip', 'mousemove', ->
|
||||||
dot.tooltip('hide')
|
dot.tooltip('hide')
|
||||||
|
|
||||||
# @drawLineGraph()
|
|
||||||
@drawBarGraph()
|
@drawBarGraph()
|
||||||
@onChangeCourseChart()
|
@onChangeCourseChart()
|
||||||
|
|
||||||
|
|
||||||
onChangeCourseChart: (e)->
|
onChangeCourseChart: (e)->
|
||||||
# show() the one that's selected
|
|
||||||
# console.log ((e.currentTarget).value)
|
|
||||||
if (e)
|
if (e)
|
||||||
selected = ('#visualisation-'+((e.currentTarget).value))
|
selected = ('#visualisation-'+((e.currentTarget).value))
|
||||||
$("[id|='visualisation']").hide()
|
$("[id|='visualisation']").hide()
|
||||||
|
@ -93,11 +90,11 @@ module.exports = class TeacherStudentView extends RootView
|
||||||
memberBit = 0
|
memberBit = 0
|
||||||
for versionedLevel in versionedCourse.levels
|
for versionedLevel in versionedCourse.levels
|
||||||
for session in @sessions.models
|
for session in @sessions.models
|
||||||
if session.get('level').original == versionedLevel.original and session.get('creator') == member
|
if session.get('level').original is versionedLevel.original and session.get('creator') is member
|
||||||
# TODO IMPORTANT: only add number if @studentID in levelProgressMap has complete or started for the corresponding level
|
# TODO IMPORTANT: only add number if @studentID in levelProgressMap has complete or started for the corresponding level
|
||||||
# in @levelData there's a levelProgress. If for this levelID, levelProgress = complete or started, go ahead.
|
# in @levelData there's a levelProgress. If for this levelID, levelProgress = complete or started, go ahead.
|
||||||
temp = _.findWhere(@levelData, {levelID: session.get('level').original})
|
temp = _.findWhere(@levelData, {levelID: session.get('level').original})
|
||||||
if temp.levelProgress == 'complete' or temp.levelProgress == 'started'
|
if temp.levelProgress is 'complete' or temp.levelProgress is 'started'
|
||||||
NUMBER += session.get('playtime') or 0
|
NUMBER += session.get('playtime') or 0
|
||||||
memberBit += 1
|
memberBit += 1
|
||||||
if session.get('creator') is @studentID
|
if session.get('creator') is @studentID
|
||||||
|
@ -147,12 +144,12 @@ module.exports = class TeacherStudentView extends RootView
|
||||||
|
|
||||||
@courseComparisonMap.push {
|
@courseComparisonMap.push {
|
||||||
courseID: course.get('_id')
|
courseID: course.get('_id')
|
||||||
student: studentRate
|
studentRate: studentRate
|
||||||
standardDev: StandardDev
|
standardDev: StandardDev
|
||||||
mean: MEAN
|
mean: MEAN
|
||||||
performance: perf
|
performance: perf
|
||||||
}
|
}
|
||||||
console.log (@courseComparisonMap)
|
# console.log (@courseComparisonMap)
|
||||||
|
|
||||||
# calculateStandardDev: ->
|
# calculateStandardDev: ->
|
||||||
# return unless @courses.loaded and @levels.loaded and @sessions?.loaded
|
# return unless @courses.loaded and @levels.loaded and @sessions?.loaded
|
||||||
|
@ -209,22 +206,17 @@ module.exports = class TeacherStudentView extends RootView
|
||||||
for versionedCourse in @classroom.get('courses') ? []
|
for versionedCourse in @classroom.get('courses') ? []
|
||||||
# this does all of the courses, logic for whether student was assigned is in corresponding jade file
|
# this does all of the courses, logic for whether student was assigned is in corresponding jade file
|
||||||
vis = d3.select('#visualisation-'+versionedCourse._id)
|
vis = d3.select('#visualisation-'+versionedCourse._id)
|
||||||
|
# TODO: continue if selector isn't found.
|
||||||
courseLevelData = []
|
courseLevelData = []
|
||||||
for level in @levelData when level.courseID is versionedCourse._id
|
for level in @levelData when level.courseID is versionedCourse._id
|
||||||
courseLevelData.push level
|
courseLevelData.push level
|
||||||
|
|
||||||
# rate = null
|
|
||||||
# for course in @courseComparisonMap when course.courseID is versionedCourse._id
|
|
||||||
# if course.rate isnt null
|
|
||||||
# rate = (course.rate).toFixed(2)
|
|
||||||
# console.log (rate)
|
|
||||||
|
|
||||||
course = _.find @courses.models, (c) => c.id is versionedCourse._id
|
course = _.find @courses.models, (c) => c.id is versionedCourse._id
|
||||||
levels = @classroom.getLevels({courseID: course.id}).models
|
levels = @classroom.getLevels({courseID: course.id}).models
|
||||||
|
|
||||||
|
|
||||||
xRange = d3.scale.ordinal().rangeRoundBands([MARGINS.left, WIDTH - MARGINS.right], 0.1).domain(courseLevelData.map( (d) -> d.levelIndex))
|
xRange = d3.scale.ordinal().rangeRoundBands([MARGINS.left, WIDTH - MARGINS.right], 0.1).domain(courseLevelData.map( (d) -> d.levelIndex))
|
||||||
yRange = d3.scale.linear().range([HEIGHT - (MARGINS.top), MARGINS.bottom]).domain([0, d3.max(courseLevelData, (d) -> if d.class > d.student then d.class else d.student)])
|
yRange = d3.scale.linear().range([HEIGHT - (MARGINS.top), MARGINS.bottom]).domain([0, d3.max(courseLevelData, (d) -> if d.classAvg > d.studentTime then d.classAvg else d.studentTime)])
|
||||||
xAxis = d3.svg.axis().scale(xRange).tickSize(1).tickSubdivide(true)
|
xAxis = d3.svg.axis().scale(xRange).tickSize(1).tickSubdivide(true)
|
||||||
yAxis = d3.svg.axis().scale(yRange).tickSize(1).orient('left').tickSubdivide(true)
|
yAxis = d3.svg.axis().scale(yRange).tickSize(1).orient('left').tickSubdivide(true)
|
||||||
|
|
||||||
|
@ -232,38 +224,39 @@ module.exports = class TeacherStudentView extends RootView
|
||||||
vis.append('svg:g').attr('class', 'y axis').attr('transform', 'translate(' + MARGINS.left + ',0)').call yAxis
|
vis.append('svg:g').attr('class', 'y axis').attr('transform', 'translate(' + MARGINS.left + ',0)').call yAxis
|
||||||
|
|
||||||
chart = vis.selectAll('rect')
|
chart = vis.selectAll('rect')
|
||||||
.data(courseLevelData)
|
.data(courseLevelData)
|
||||||
.enter()
|
.enter()
|
||||||
|
# draw classroom average bars
|
||||||
chart.append('rect')
|
chart.append('rect')
|
||||||
.attr('id', 'classroom')
|
.attr('class', 'classroom-bar')
|
||||||
.attr('x', ((d) -> xRange(d.levelIndex) + (xRange.rangeBand())/2))
|
.attr('x', ((d) -> xRange(d.levelIndex) + (xRange.rangeBand())/2))
|
||||||
.attr('y', (d) -> yRange(d.class))
|
.attr('y', (d) -> yRange(d.classAvg))
|
||||||
.attr('width', (xRange.rangeBand())/2)
|
.attr('width', (xRange.rangeBand())/2)
|
||||||
.attr('height', (d) -> HEIGHT - (MARGINS.bottom) - yRange(d.class))
|
.attr('height', (d) -> HEIGHT - (MARGINS.bottom) - yRange(d.classAvg))
|
||||||
.attr('fill', '#5CB4D0')
|
.attr('fill', '#5CB4D0')
|
||||||
|
# add classroom average values
|
||||||
chart.append('text')
|
chart.append('text')
|
||||||
.attr('x', ((d) -> xRange(d.levelIndex) + (xRange.rangeBand())/2))
|
.attr('x', ((d) -> xRange(d.levelIndex) + (xRange.rangeBand())/2))
|
||||||
.attr('y', ((d) -> yRange(d.class) - 3 ))
|
.attr('y', ((d) -> yRange(d.classAvg) - 3 ))
|
||||||
.text((d)-> if d.class isnt 0 then d.class)
|
.text((d)-> if d.classAvg isnt 0 then d.classAvg)
|
||||||
.attr('class', 'label')
|
.attr('class', 'label')
|
||||||
|
# draw student playtime bars
|
||||||
chart.append('rect')
|
chart.append('rect')
|
||||||
.attr('id', 'student')
|
.attr('class', 'student-bar')
|
||||||
.attr('x', ((d) -> xRange(d.levelIndex)))
|
.attr('x', ((d) -> xRange(d.levelIndex)))
|
||||||
.attr('y', (d) -> yRange(d.student))
|
.attr('y', (d) -> yRange(d.studentTime))
|
||||||
.attr('width', (xRange.rangeBand())/2)
|
.attr('width', (xRange.rangeBand())/2)
|
||||||
.attr('height', (d) -> HEIGHT - (MARGINS.bottom) - yRange(d.student))
|
.attr('height', (d) -> HEIGHT - (MARGINS.bottom) - yRange(d.studentTime))
|
||||||
.attr('fill', (d) -> if d.levelProgress == 'complete' then '#20572B' else '#F2BE19')
|
.attr('fill', (d) -> if d.levelProgress is 'complete' then '#20572B' else '#F2BE19')
|
||||||
|
# add student playtime value
|
||||||
chart.append('text')
|
chart.append('text')
|
||||||
.attr('x', ((d) -> xRange(d.levelIndex)) )
|
.attr('x', ((d) -> xRange(d.levelIndex)) )
|
||||||
.attr('y', ((d) -> yRange(d.student) - 3 ))
|
.attr('y', ((d) -> yRange(d.studentTime) - 3 ))
|
||||||
.text((d)-> if d.student isnt 0 then d.student)
|
.text((d)-> if d.studentTime isnt 0 then d.studentTime)
|
||||||
.attr('class', 'label')
|
.attr('class', 'label')
|
||||||
|
|
||||||
labels = vis.append("g").attr("class", "labels")
|
labels = vis.append("g").attr("class", "labels")
|
||||||
|
# add Playtime axis label
|
||||||
labels.append("text")
|
labels.append("text")
|
||||||
.attr("transform", "rotate(-90)")
|
.attr("transform", "rotate(-90)")
|
||||||
.attr("y", 20)
|
.attr("y", 20)
|
||||||
|
@ -271,22 +264,13 @@ module.exports = class TeacherStudentView extends RootView
|
||||||
.attr("dy", ".71em")
|
.attr("dy", ".71em")
|
||||||
.style("text-anchor", "middle")
|
.style("text-anchor", "middle")
|
||||||
.text($.i18n.t("teacher.playtime_axis"))
|
.text($.i18n.t("teacher.playtime_axis"))
|
||||||
|
# add levels axis label
|
||||||
labels.append("text")
|
labels.append("text")
|
||||||
.attr("x", WIDTH/2)
|
.attr("x", WIDTH/2)
|
||||||
.attr("y", HEIGHT - 10)
|
.attr("y", HEIGHT - 10)
|
||||||
.text("Levels in " + (course.get('name')))
|
.text("Levels in " + (course.get('name')))
|
||||||
.style("text-anchor", "middle")
|
.style("text-anchor", "middle")
|
||||||
|
|
||||||
# if rate isnt 0 and rate isnt null
|
|
||||||
# if rate > 0 then rate = "+" + rate
|
|
||||||
# labels.append("text")
|
|
||||||
# .attr("x", WIDTH - 50)
|
|
||||||
# .attr("y", HEIGHT - 10)
|
|
||||||
# .text("Student Course Speed: " + rate + "%")
|
|
||||||
# .style("text-anchor", "end")
|
|
||||||
# .style("fill", (d) -> if rate > 0 then "green" else "red")
|
|
||||||
|
|
||||||
|
|
||||||
onClassroomSync: ->
|
onClassroomSync: ->
|
||||||
# Now that we have the classroom from db, can request all level sessions for this classroom
|
# Now that we have the classroom from db, can request all level sessions for this classroom
|
||||||
|
@ -298,7 +282,6 @@ module.exports = class TeacherStudentView extends RootView
|
||||||
@students = new Users()
|
@students = new Users()
|
||||||
jqxhrs = @students.fetchForClassroom(@classroom, removeDeleted: true)
|
jqxhrs = @students.fetchForClassroom(@classroom, removeDeleted: true)
|
||||||
# @listenTo @students, ->
|
# @listenTo @students, ->
|
||||||
# console.log @students
|
|
||||||
@supermodel.trackRequests jqxhrs
|
@supermodel.trackRequests jqxhrs
|
||||||
|
|
||||||
onSessionsSync: ->
|
onSessionsSync: ->
|
||||||
|
@ -372,7 +355,6 @@ module.exports = class TeacherStudentView extends RootView
|
||||||
|
|
||||||
# Map levels to sessions once, so we don't have to search entire session list multiple times below
|
# Map levels to sessions once, so we don't have to search entire session list multiple times below
|
||||||
@levelSessionMap = {}
|
@levelSessionMap = {}
|
||||||
# for session in @sessions.models when session.get('creator') is @studentID
|
|
||||||
for session in @sessions.models when session.get('creator') is @studentID
|
for session in @sessions.models when session.get('creator') is @studentID
|
||||||
@levelSessionMap[session.get('level').original] = session
|
@levelSessionMap[session.get('level').original] = session
|
||||||
|
|
||||||
|
@ -397,32 +379,32 @@ module.exports = class TeacherStudentView extends RootView
|
||||||
for versionedCourse in @classroom.get('courses') ? []
|
for versionedCourse in @classroom.get('courses') ? []
|
||||||
course = _.find @courses.models, (c) => c.id is versionedCourse._id
|
course = _.find @courses.models, (c) => c.id is versionedCourse._id
|
||||||
for versionedLevel in versionedCourse.levels
|
for versionedLevel in versionedCourse.levels
|
||||||
@playTime = 0 # this and @timesPlayed should probably only count when the levels are completed
|
playTime = 0 # TODO: this and timesPlayed should probably only count when the levels are completed
|
||||||
@timesPlayed = 0
|
timesPlayed = 0
|
||||||
@studentTime = 0
|
studentTime = 0
|
||||||
@levelProgress = 'not started'
|
levelProgress = 'not started'
|
||||||
for session in @sessions.models
|
for session in @sessions.models
|
||||||
if session.get('level').original == versionedLevel.original
|
if session.get('level').original is versionedLevel.original
|
||||||
# if @levelProgressMap[versionedLevel.original] == 'complete' # ideally, don't log sessions that aren't completed in the class
|
# if @levelProgressMap[versionedLevel.original] == 'complete' # ideally, don't log sessions that aren't completed in the class
|
||||||
@playTime += session.get('playtime') or 0
|
playTime += session.get('playtime') or 0
|
||||||
@timesPlayed += 1
|
timesPlayed += 1
|
||||||
if session.get('creator') is @studentID
|
if session.get('creator') is @studentID
|
||||||
@studentTime = session.get('playtime') # this can be null, apparently.
|
studentTime = session.get('playtime') or 0
|
||||||
if @levelProgressMap[versionedLevel.original] == 'complete'
|
if @levelProgressMap[versionedLevel.original] is 'complete'
|
||||||
@levelProgress = 'complete'
|
levelProgress = 'complete'
|
||||||
else if @levelProgressMap[versionedLevel.original] == 'started'
|
else if @levelProgressMap[versionedLevel.original] is 'started'
|
||||||
@levelProgress = 'started'
|
levelProgress = 'started'
|
||||||
classAvg = if @timesPlayed and @timesPlayed > 0 then Math.round(@playTime / @timesPlayed) else 0 # only when someone other than the user has played
|
classAvg = if timesPlayed > 0 then Math.round(playTime / timesPlayed) else 0 # only when someone other than the user has played
|
||||||
# console.log (@timesPlayed)
|
# console.log (timesPlayed)
|
||||||
@levelData.push {
|
@levelData.push {
|
||||||
levelID: versionedLevel.original
|
levelID: versionedLevel.original
|
||||||
levelIndex: @classroom.getLevelNumber(versionedLevel.original)
|
levelIndex: @classroom.getLevelNumber(versionedLevel.original)
|
||||||
levelName: versionedLevel.name
|
levelName: versionedLevel.name
|
||||||
courseName: course.get('name')
|
courseName: course.get('name')
|
||||||
courseID: course.get('_id')
|
courseID: course.get('_id')
|
||||||
class: classAvg
|
classAvg: classAvg
|
||||||
student: if @studentTime then @studentTime else 0
|
studentTime: if studentTime then studentTime else 0
|
||||||
levelProgress: @levelProgress
|
levelProgress: levelProgress
|
||||||
# required:
|
# required:
|
||||||
}
|
}
|
||||||
# console.log (@levelData)
|
# console.log (@levelData)
|
||||||
|
@ -448,22 +430,24 @@ module.exports = class TeacherStudentView extends RootView
|
||||||
when 'expired' then $.i18n.t('teacher.status_expired')
|
when 'expired' then $.i18n.t('teacher.status_expired')
|
||||||
return string.replace('{{date}}', moment(expires).utc().format('l'))
|
return string.replace('{{date}}', moment(expires).utc().format('l'))
|
||||||
|
|
||||||
onClickEnrollStudentButton: (e) ->
|
# TODO: Hookup enroll/assign functionality
|
||||||
userID = $(e.currentTarget).data('user-id')
|
|
||||||
user = @user.get(userID)
|
|
||||||
selectedUsers = new Users([user])
|
|
||||||
@enrollStudents(selectedUsers)
|
|
||||||
window.tracker?.trackEvent $(e.currentTarget).data('event-action'), category: 'Teachers', classroomID: @classroom.id, userID: userID, ['Mixpanel']
|
|
||||||
|
|
||||||
enrollStudents: (selectedUsers) ->
|
# onClickEnrollStudentButton: (e) ->
|
||||||
modal = new ActivateLicensesModal { @classroom, selectedUsers, users: @user }
|
# userID = $(e.currentTarget).data('user-id')
|
||||||
@openModalView(modal)
|
# user = @user.get(userID)
|
||||||
modal.once 'redeem-users', (enrolledUsers) =>
|
# selectedUsers = new Users([user])
|
||||||
enrolledUsers.each (newUser) =>
|
# @enrollStudents(selectedUsers)
|
||||||
user = @user.get(newUser.id)
|
# window.tracker?.trackEvent $(e.currentTarget).data('event-action'), category: 'Teachers', classroomID: @classroom.id, userID: userID, ['Mixpanel']
|
||||||
if user
|
#
|
||||||
user.set(newUser.attributes)
|
# enrollStudents: (selectedUsers) ->
|
||||||
null
|
# modal = new ActivateLicensesModal { @classroom, selectedUsers, users: @user }
|
||||||
|
# @openModalView(modal)
|
||||||
|
# modal.once 'redeem-users', (enrolledUsers) =>
|
||||||
|
# enrolledUsers.each (newUser) =>
|
||||||
|
# user = @user.get(newUser.id)
|
||||||
|
# if user
|
||||||
|
# user.set(newUser.attributes)
|
||||||
|
# null
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue