mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-30 02:55:43 -05:00
Allow exporting clas data since specific date
This commit is contained in:
parent
6b6bd2f76d
commit
082003abac
2 changed files with 9 additions and 1 deletions
|
@ -71,6 +71,8 @@ block content
|
||||||
if view.students && view.students.models.length > 0
|
if view.students && view.students.models.length > 0
|
||||||
button.export-student-progress-btn.btn.btn-lg.btn-primary
|
button.export-student-progress-btn.btn.btn-lg.btn-primary
|
||||||
span(data-i18n='teacher.export_student_progress')
|
span(data-i18n='teacher.export_student_progress')
|
||||||
|
label Data start date
|
||||||
|
input#export-data-start-date(type="date")
|
||||||
|
|
||||||
//- .concepts.small-details
|
//- .concepts.small-details
|
||||||
//- if state.get('progressData')
|
//- if state.get('progressData')
|
||||||
|
|
|
@ -320,6 +320,7 @@ module.exports = class TeacherClassView extends RootView
|
||||||
onClickExportStudentProgress: ->
|
onClickExportStudentProgress: ->
|
||||||
# TODO: Does not yield .csv download on Safari, and instead opens a new tab with the .csv contents
|
# TODO: Does not yield .csv download on Safari, and instead opens a new tab with the .csv contents
|
||||||
window.tracker?.trackEvent 'Teachers Class Export CSV', category: 'Teachers', classroomID: @classroom.id, ['Mixpanel']
|
window.tracker?.trackEvent 'Teachers Class Export CSV', category: 'Teachers', classroomID: @classroom.id, ['Mixpanel']
|
||||||
|
startDate = new Date(@$('#export-data-start-date').val())
|
||||||
courseLabels = ""
|
courseLabels = ""
|
||||||
courseOrder = []
|
courseOrder = []
|
||||||
courses = (@courses.get(c._id) for c in @classroom.get('courses'))
|
courses = (@courses.get(c._id) for c in @classroom.get('courses'))
|
||||||
|
@ -327,7 +328,11 @@ module.exports = class TeacherClassView extends RootView
|
||||||
for course, index in courses
|
for course, index in courses
|
||||||
courseLabels += "#{courseLabelsArray[index]} Playtime,"
|
courseLabels += "#{courseLabelsArray[index]} Playtime,"
|
||||||
courseOrder.push(course.id)
|
courseOrder.push(course.id)
|
||||||
csvContent = "data:text/csv;charset=utf-8,Username,Email,Total Playtime,#{courseLabels}Concepts\n"
|
if isNaN(startDate.getTime())
|
||||||
|
startDateString = "the beginning of time"
|
||||||
|
else
|
||||||
|
startDateString = moment(startDate).toISOString().replace(/T[0:\.]+Z/, '')
|
||||||
|
csvContent = "data:text/csv;charset=utf-8,Data since #{startDateString}\nUsername,Email,Total Playtime,#{courseLabels}Concepts\n"
|
||||||
levelCourseMap = {}
|
levelCourseMap = {}
|
||||||
language = @classroom.get('aceConfig')?.language
|
language = @classroom.get('aceConfig')?.language
|
||||||
for trimCourse in @classroom.get('courses')
|
for trimCourse in @classroom.get('courses')
|
||||||
|
@ -349,6 +354,7 @@ module.exports = class TeacherClassView extends RootView
|
||||||
coursePlaytimeMap = {}
|
coursePlaytimeMap = {}
|
||||||
playtime = 0
|
playtime = 0
|
||||||
for session in @classroom.sessions.models when session.get('creator') is student.id
|
for session in @classroom.sessions.models when session.get('creator') is student.id
|
||||||
|
continue if startDate and new Date(session.get('changed')) < startDate
|
||||||
playtime += session.get('playtime') or 0
|
playtime += session.get('playtime') or 0
|
||||||
if courseID = levelCourseMap[session.get('level')?.original]?.id
|
if courseID = levelCourseMap[session.get('level')?.original]?.id
|
||||||
coursePlaytimeMap[courseID] ?= 0
|
coursePlaytimeMap[courseID] ?= 0
|
||||||
|
|
Loading…
Reference in a new issue