mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-23 23:58:02 -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
|
||||
|
||||
|
||||
svg[id|="visualisation"]
|
||||
svg.visualisation
|
||||
// background-color: $navy
|
||||
display: none
|
||||
|
||||
|
|
|
@ -161,8 +161,6 @@ mixin inlineUserList(users)
|
|||
ul.inline-student-list.small
|
||||
each student in users
|
||||
li
|
||||
//- a(href='TODO')
|
||||
//- = student.broadName()
|
||||
span.inline-student-name
|
||||
= student.broadName()
|
||||
|
||||
|
|
|
@ -14,27 +14,27 @@ block content
|
|||
- var isOwner = view.classroom ? view.classroom.get('ownerID') === me.id : false;
|
||||
|
||||
if isOwner
|
||||
h3(class="m-t-2")
|
||||
h3.m-t-2
|
||||
span(data-i18n="teacher.student_profile")
|
||||
span.spr :
|
||||
span= view.user.get('name')
|
||||
.classroom-info-row.container-fluid.row
|
||||
.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'))
|
||||
div(class="small-details")
|
||||
.small-details
|
||||
span(data-i18n="teacher.student_email")
|
||||
span.spr :
|
||||
span= view.user.get('email')
|
||||
else
|
||||
div(class="small-details")
|
||||
.small-details
|
||||
i(data-i18n="teacher.no_email")
|
||||
div(class="small-details")
|
||||
.small-details
|
||||
span(data-i18n="user.last_played")
|
||||
span.spr :
|
||||
span= view.lastPlayedString
|
||||
|
||||
div(class="small-details")
|
||||
.small-details
|
||||
- var status = view.user.prepaidStatus()
|
||||
span(data-i18n='view.user.status')
|
||||
span.spr
|
||||
|
@ -63,19 +63,19 @@ block content
|
|||
- continue;
|
||||
- var instance = view.courseInstances.findWhere({ courseID: course.id, classroomID: view.classroom.id })
|
||||
- if ((instance && instance.hasMember(view.user)))
|
||||
option(value=course.id)=course.get('name')
|
||||
option(value= course.id)= course.get('name')
|
||||
|
||||
div.legend
|
||||
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")
|
||||
|
||||
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")
|
||||
|
||||
svg(width=15, height=15 style="margin: 0 5px 0 15px")
|
||||
rect(width=15, height=15,fill="rgb(92, 180, 208)")
|
||||
svg(width=15, height=15, style="margin: 0 5px 0 15px")
|
||||
rect(width=15, height=15, fill="rgb(92, 180, 208)")
|
||||
span(data-i18n="teacher.class_average")
|
||||
|
||||
.graphs
|
||||
|
@ -83,55 +83,21 @@ block content
|
|||
- var course = _.find(view.courses.models, function(c) {return c.id === versionedCourse._id;});
|
||||
if !course
|
||||
- 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 })
|
||||
- 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)
|
||||
|
||||
//- h4 Actions:
|
||||
//- TODO Hookup student management actions:
|
||||
// Assign courses from dropdown
|
||||
// Export CSV
|
||||
// Apply License
|
||||
// Edit password
|
||||
// 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")
|
||||
div.student-levels-progress
|
||||
.student-levels-progress
|
||||
each versionedCourse in view.classroom.get('courses') || []
|
||||
- var course = _.find(view.courses.models, function(c) {return c.id === versionedCourse._id;});
|
||||
if !course
|
||||
|
@ -139,15 +105,12 @@ block content
|
|||
- 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
|
||||
div.course-info= course.get('name')
|
||||
.course-row.alternating-background
|
||||
.course-info= course.get('name')
|
||||
- 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')]
|
||||
//- p= levelNumber + ". " + level.name + " Progress: " + view.levelProgressMap[level.original]
|
||||
//- - console.log(level)
|
||||
+studentLevelProgressDot(levelProgress, level, levelNumber, course)
|
||||
|
||||
|
||||
|
@ -165,9 +128,8 @@ block content
|
|||
- continue;
|
||||
- var instance = view.courseInstances.findWhere({ courseID: course.id, classroomID: view.classroom.id })
|
||||
- if (!(instance && instance.hasMember(view.user)))
|
||||
div(class="small-details")
|
||||
div.small-details
|
||||
span=course.get('name')
|
||||
// add a button to assign this course
|
||||
|
||||
//- else
|
||||
//- 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'};
|
||||
if view.levelSessionMap && view.levelSessionMap[level.get('original')]
|
||||
- context.session = view.levelSessionMap[level.get('original')];
|
||||
//- - console.log(view.levelSessionMap[level.get('original')])
|
||||
- link = null;
|
||||
- labelText = levelNumber;
|
||||
if level.isLadder()
|
||||
|
|
|
@ -66,14 +66,11 @@ module.exports = class TeacherStudentView extends RootView
|
|||
}).delegate '.tooltip', 'mousemove', ->
|
||||
dot.tooltip('hide')
|
||||
|
||||
# @drawLineGraph()
|
||||
@drawBarGraph()
|
||||
@onChangeCourseChart()
|
||||
|
||||
|
||||
onChangeCourseChart: (e)->
|
||||
# show() the one that's selected
|
||||
# console.log ((e.currentTarget).value)
|
||||
if (e)
|
||||
selected = ('#visualisation-'+((e.currentTarget).value))
|
||||
$("[id|='visualisation']").hide()
|
||||
|
@ -93,11 +90,11 @@ module.exports = class TeacherStudentView extends RootView
|
|||
memberBit = 0
|
||||
for versionedLevel in versionedCourse.levels
|
||||
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
|
||||
# in @levelData there's a levelProgress. If for this levelID, levelProgress = complete or started, go ahead.
|
||||
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
|
||||
memberBit += 1
|
||||
if session.get('creator') is @studentID
|
||||
|
@ -147,12 +144,12 @@ module.exports = class TeacherStudentView extends RootView
|
|||
|
||||
@courseComparisonMap.push {
|
||||
courseID: course.get('_id')
|
||||
student: studentRate
|
||||
studentRate: studentRate
|
||||
standardDev: StandardDev
|
||||
mean: MEAN
|
||||
performance: perf
|
||||
}
|
||||
console.log (@courseComparisonMap)
|
||||
# console.log (@courseComparisonMap)
|
||||
|
||||
# calculateStandardDev: ->
|
||||
# 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') ? []
|
||||
# this does all of the courses, logic for whether student was assigned is in corresponding jade file
|
||||
vis = d3.select('#visualisation-'+versionedCourse._id)
|
||||
# TODO: continue if selector isn't found.
|
||||
courseLevelData = []
|
||||
for level in @levelData when level.courseID is versionedCourse._id
|
||||
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
|
||||
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))
|
||||
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)
|
||||
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
|
||||
|
||||
chart = vis.selectAll('rect')
|
||||
.data(courseLevelData)
|
||||
.enter()
|
||||
.data(courseLevelData)
|
||||
.enter()
|
||||
# draw classroom average bars
|
||||
chart.append('rect')
|
||||
.attr('id', 'classroom')
|
||||
.attr('class', 'classroom-bar')
|
||||
.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('height', (d) -> HEIGHT - (MARGINS.bottom) - yRange(d.class))
|
||||
.attr('height', (d) -> HEIGHT - (MARGINS.bottom) - yRange(d.classAvg))
|
||||
.attr('fill', '#5CB4D0')
|
||||
|
||||
# add classroom average values
|
||||
chart.append('text')
|
||||
.attr('x', ((d) -> xRange(d.levelIndex) + (xRange.rangeBand())/2))
|
||||
.attr('y', ((d) -> yRange(d.class) - 3 ))
|
||||
.text((d)-> if d.class isnt 0 then d.class)
|
||||
.attr('y', ((d) -> yRange(d.classAvg) - 3 ))
|
||||
.text((d)-> if d.classAvg isnt 0 then d.classAvg)
|
||||
.attr('class', 'label')
|
||||
|
||||
# draw student playtime bars
|
||||
chart.append('rect')
|
||||
.attr('id', 'student')
|
||||
.attr('class', 'student-bar')
|
||||
.attr('x', ((d) -> xRange(d.levelIndex)))
|
||||
.attr('y', (d) -> yRange(d.student))
|
||||
.attr('y', (d) -> yRange(d.studentTime))
|
||||
.attr('width', (xRange.rangeBand())/2)
|
||||
.attr('height', (d) -> HEIGHT - (MARGINS.bottom) - yRange(d.student))
|
||||
.attr('fill', (d) -> if d.levelProgress == 'complete' then '#20572B' else '#F2BE19')
|
||||
|
||||
.attr('height', (d) -> HEIGHT - (MARGINS.bottom) - yRange(d.studentTime))
|
||||
.attr('fill', (d) -> if d.levelProgress is 'complete' then '#20572B' else '#F2BE19')
|
||||
# add student playtime value
|
||||
chart.append('text')
|
||||
.attr('x', ((d) -> xRange(d.levelIndex)) )
|
||||
.attr('y', ((d) -> yRange(d.student) - 3 ))
|
||||
.text((d)-> if d.student isnt 0 then d.student)
|
||||
.attr('y', ((d) -> yRange(d.studentTime) - 3 ))
|
||||
.text((d)-> if d.studentTime isnt 0 then d.studentTime)
|
||||
.attr('class', 'label')
|
||||
|
||||
labels = vis.append("g").attr("class", "labels")
|
||||
|
||||
# add Playtime axis label
|
||||
labels.append("text")
|
||||
.attr("transform", "rotate(-90)")
|
||||
.attr("y", 20)
|
||||
|
@ -271,22 +264,13 @@ module.exports = class TeacherStudentView extends RootView
|
|||
.attr("dy", ".71em")
|
||||
.style("text-anchor", "middle")
|
||||
.text($.i18n.t("teacher.playtime_axis"))
|
||||
|
||||
# add levels axis label
|
||||
labels.append("text")
|
||||
.attr("x", WIDTH/2)
|
||||
.attr("y", HEIGHT - 10)
|
||||
.text("Levels in " + (course.get('name')))
|
||||
.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: ->
|
||||
# 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()
|
||||
jqxhrs = @students.fetchForClassroom(@classroom, removeDeleted: true)
|
||||
# @listenTo @students, ->
|
||||
# console.log @students
|
||||
@supermodel.trackRequests jqxhrs
|
||||
|
||||
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
|
||||
@levelSessionMap = {}
|
||||
# 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
|
||||
|
||||
|
@ -397,32 +379,32 @@ module.exports = class TeacherStudentView extends RootView
|
|||
for versionedCourse in @classroom.get('courses') ? []
|
||||
course = _.find @courses.models, (c) => c.id is versionedCourse._id
|
||||
for versionedLevel in versionedCourse.levels
|
||||
@playTime = 0 # this and @timesPlayed should probably only count when the levels are completed
|
||||
@timesPlayed = 0
|
||||
@studentTime = 0
|
||||
@levelProgress = 'not started'
|
||||
playTime = 0 # TODO: this and timesPlayed should probably only count when the levels are completed
|
||||
timesPlayed = 0
|
||||
studentTime = 0
|
||||
levelProgress = 'not started'
|
||||
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
|
||||
@playTime += session.get('playtime') or 0
|
||||
@timesPlayed += 1
|
||||
playTime += session.get('playtime') or 0
|
||||
timesPlayed += 1
|
||||
if session.get('creator') is @studentID
|
||||
@studentTime = session.get('playtime') # this can be null, apparently.
|
||||
if @levelProgressMap[versionedLevel.original] == 'complete'
|
||||
@levelProgress = 'complete'
|
||||
else if @levelProgressMap[versionedLevel.original] == '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
|
||||
# console.log (@timesPlayed)
|
||||
studentTime = session.get('playtime') or 0
|
||||
if @levelProgressMap[versionedLevel.original] is 'complete'
|
||||
levelProgress = 'complete'
|
||||
else if @levelProgressMap[versionedLevel.original] is 'started'
|
||||
levelProgress = 'started'
|
||||
classAvg = if timesPlayed > 0 then Math.round(playTime / timesPlayed) else 0 # only when someone other than the user has played
|
||||
# console.log (timesPlayed)
|
||||
@levelData.push {
|
||||
levelID: versionedLevel.original
|
||||
levelIndex: @classroom.getLevelNumber(versionedLevel.original)
|
||||
levelName: versionedLevel.name
|
||||
courseName: course.get('name')
|
||||
courseID: course.get('_id')
|
||||
class: classAvg
|
||||
student: if @studentTime then @studentTime else 0
|
||||
levelProgress: @levelProgress
|
||||
classAvg: classAvg
|
||||
studentTime: if studentTime then studentTime else 0
|
||||
levelProgress: levelProgress
|
||||
# required:
|
||||
}
|
||||
# console.log (@levelData)
|
||||
|
@ -448,22 +430,24 @@ module.exports = class TeacherStudentView extends RootView
|
|||
when 'expired' then $.i18n.t('teacher.status_expired')
|
||||
return string.replace('{{date}}', moment(expires).utc().format('l'))
|
||||
|
||||
onClickEnrollStudentButton: (e) ->
|
||||
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']
|
||||
# TODO: Hookup enroll/assign functionality
|
||||
|
||||
enrollStudents: (selectedUsers) ->
|
||||
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
|
||||
# onClickEnrollStudentButton: (e) ->
|
||||
# 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) ->
|
||||
# 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