mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-29 23:43:51 -04:00
/courses analytics
This commit is contained in:
parent
6d6f6138b1
commit
44cd64e00e
3 changed files with 31 additions and 16 deletions
app
|
@ -13,7 +13,7 @@ module.exports = class CourseInstance extends CocoModel
|
||||||
}
|
}
|
||||||
_.extend options, opts
|
_.extend options, opts
|
||||||
@fetch(options)
|
@fetch(options)
|
||||||
|
|
||||||
addMember: (userID, opts) ->
|
addMember: (userID, opts) ->
|
||||||
options = {
|
options = {
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
|
@ -22,7 +22,10 @@ module.exports = class CourseInstance extends CocoModel
|
||||||
}
|
}
|
||||||
_.extend options, opts
|
_.extend options, opts
|
||||||
@fetch(options)
|
@fetch(options)
|
||||||
me.get('courseInstances').push(@id) if userID is me.id
|
if userID is me.id
|
||||||
|
unless me.get('courseInstances')
|
||||||
|
me.set('courseInstances', [])
|
||||||
|
me.get('courseInstances').push(@id)
|
||||||
|
|
||||||
removeMember: (userID, opts) ->
|
removeMember: (userID, opts) ->
|
||||||
options = {
|
options = {
|
||||||
|
@ -33,6 +36,6 @@ module.exports = class CourseInstance extends CocoModel
|
||||||
_.extend options, opts
|
_.extend options, opts
|
||||||
@fetch(options)
|
@fetch(options)
|
||||||
me.set('courseInstances', _.without(me.get('courseInstances'), @id)) if userID is me.id
|
me.set('courseInstances', _.without(me.get('courseInstances'), @id)) if userID is me.id
|
||||||
|
|
||||||
firstLevelURL: ->
|
firstLevelURL: ->
|
||||||
"/play/level/dungeons-of-kithgard?course=#{@get('courseID')}&course-instance=#{@id}"
|
"/play/level/dungeons-of-kithgard?course=#{@get('courseID')}&course-instance=#{@id}"
|
||||||
|
|
|
@ -22,5 +22,6 @@ module.exports = class ChangeCourseLanguageModal extends ModalView
|
||||||
@onLanguageSettingSaved()
|
@onLanguageSettingSaved()
|
||||||
|
|
||||||
onLanguageSettingSaved: ->
|
onLanguageSettingSaved: ->
|
||||||
|
application.tracker?.trackEvent 'Student changed language', category: 'Courses', label: @chosenLanguage
|
||||||
@trigger('set-language')
|
@trigger('set-language')
|
||||||
@hide()
|
@hide()
|
||||||
|
|
|
@ -26,7 +26,7 @@ module.exports = class CoursesView extends RootView
|
||||||
'click #join-class-btn': 'onClickJoinClassButton'
|
'click #join-class-btn': 'onClickJoinClassButton'
|
||||||
'submit #join-class-form': 'onSubmitJoinClassForm'
|
'submit #join-class-form': 'onSubmitJoinClassForm'
|
||||||
'click #change-language-link': 'onClickChangeLanguageLink'
|
'click #change-language-link': 'onClickChangeLanguageLink'
|
||||||
|
|
||||||
initialize: ->
|
initialize: ->
|
||||||
@courseInstances = new CocoCollection([], { url: "/db/user/#{me.id}/course_instances", model: CourseInstance})
|
@courseInstances = new CocoCollection([], { url: "/db/user/#{me.id}/course_instances", model: CourseInstance})
|
||||||
@courseInstances.comparator = (ci) -> return ci.get('classroomID') + ci.get('courseID')
|
@courseInstances.comparator = (ci) -> return ci.get('classroomID') + ci.get('courseID')
|
||||||
|
@ -48,15 +48,15 @@ module.exports = class CoursesView extends RootView
|
||||||
continue
|
continue
|
||||||
map[courseID] = courseInstance.sessions = new CocoCollection([], {
|
map[courseID] = courseInstance.sessions = new CocoCollection([], {
|
||||||
url: courseInstance.url() + '/my-course-level-sessions',
|
url: courseInstance.url() + '/my-course-level-sessions',
|
||||||
model: LevelSession
|
model: LevelSession
|
||||||
})
|
})
|
||||||
courseInstance.sessions.comparator = 'changed'
|
courseInstance.sessions.comparator = 'changed'
|
||||||
@supermodel.loadCollection(courseInstance.sessions, 'sessions', { data: { project: 'state.complete level.original playtime changed' }})
|
@supermodel.loadCollection(courseInstance.sessions, 'sessions', { data: { project: 'state.complete level.original playtime changed' }})
|
||||||
|
|
||||||
@hocCourseInstance = @courseInstances.findWhere({hourOfCode: true})
|
@hocCourseInstance = @courseInstances.findWhere({hourOfCode: true})
|
||||||
if @hocCourseInstance
|
if @hocCourseInstance
|
||||||
@courseInstances.remove(@hocCourseInstance)
|
@courseInstances.remove(@hocCourseInstance)
|
||||||
|
|
||||||
onLoaded: ->
|
onLoaded: ->
|
||||||
super()
|
super()
|
||||||
if utils.getQueryVariable('_cc', false)
|
if utils.getQueryVariable('_cc', false)
|
||||||
|
@ -68,17 +68,25 @@ module.exports = class CoursesView extends RootView
|
||||||
else
|
else
|
||||||
modal = new ChooseLanguageModal()
|
modal = new ChooseLanguageModal()
|
||||||
@openModalView(modal)
|
@openModalView(modal)
|
||||||
@listenToOnce modal, 'set-language', @startHourOfCodePlay
|
@listenToOnce modal, 'set-language', =>
|
||||||
|
@startHourOfCodePlay()
|
||||||
|
application.tracker?.trackEvent 'Automatic start hour of code play', category: 'Courses', label: 'set language'
|
||||||
|
application.tracker?.trackEvent 'Start New Game', category: 'Courses'
|
||||||
|
|
||||||
onClickLogInButton: ->
|
onClickLogInButton: ->
|
||||||
modal = new StudentLogInModal()
|
modal = new StudentLogInModal()
|
||||||
@openModalView(modal)
|
@openModalView(modal)
|
||||||
modal.on 'want-to-create-account', @openSignUpModal, @
|
modal.on 'want-to-create-account', @openSignUpModal, @
|
||||||
|
application.tracker?.trackEvent 'Started Student Login', category: 'Courses'
|
||||||
|
|
||||||
openSignUpModal: ->
|
openSignUpModal: ->
|
||||||
modal = new StudentSignUpModal({ willPlay: true })
|
modal = new StudentSignUpModal({ willPlay: true })
|
||||||
@openModalView(modal)
|
@openModalView(modal)
|
||||||
modal.once 'click-skip-link', @startHourOfCodePlay, @
|
modal.once 'click-skip-link', (=>
|
||||||
|
@startHourOfCodePlay()
|
||||||
|
application.tracker?.trackEvent 'Automatic start hour of code play', category: 'Courses', label: 'skip link'
|
||||||
|
), @
|
||||||
|
application.tracker?.trackEvent 'Started Student Signup', category: 'Courses'
|
||||||
|
|
||||||
startHourOfCodePlay: ->
|
startHourOfCodePlay: ->
|
||||||
@$('#main-content').hide()
|
@$('#main-content').hide()
|
||||||
|
@ -92,7 +100,7 @@ module.exports = class CoursesView extends RootView
|
||||||
onSubmitJoinClassForm: (e) ->
|
onSubmitJoinClassForm: (e) ->
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
@joinClass()
|
@joinClass()
|
||||||
|
|
||||||
onClickJoinClassButton: (e) ->
|
onClickJoinClassButton: (e) ->
|
||||||
@joinClass()
|
@joinClass()
|
||||||
|
|
||||||
|
@ -114,25 +122,27 @@ module.exports = class CoursesView extends RootView
|
||||||
|
|
||||||
onJoinClassroomError: (classroom, jqxhr, options) ->
|
onJoinClassroomError: (classroom, jqxhr, options) ->
|
||||||
@state = null
|
@state = null
|
||||||
application.tracker?.trackEvent 'Failed to join classroom with code', status: jqxhr.status
|
application.tracker?.trackEvent 'Failed to join classroom with code', category: 'Courses', status: jqxhr.status
|
||||||
if jqxhr.status is 422
|
if jqxhr.status is 422
|
||||||
@errorMessage = 'Please enter a code.'
|
@errorMessage = 'Please enter a code.'
|
||||||
else if jqxhr.status is 404
|
else if jqxhr.status is 404
|
||||||
@errorMessage = 'Code not found.'
|
@errorMessage = 'Code not found.'
|
||||||
else
|
else
|
||||||
@errorMessage = "#{jqxhr.responseText}"
|
@errorMessage = "#{jqxhr.responseText}"
|
||||||
@renderSelectors '#join-class-form'
|
@renderSelectors '#join-class-form'
|
||||||
|
|
||||||
onJoinClassroomSuccess: (newClassroom, jqxhr, options) ->
|
onJoinClassroomSuccess: (newClassroom, jqxhr, options) ->
|
||||||
application.tracker?.trackEvent 'Joined classroom', {
|
application.tracker?.trackEvent 'Joined classroom', {
|
||||||
classroomID: newClassroom.id,
|
category: 'Courses'
|
||||||
|
classCode: @classCode
|
||||||
|
classroomID: newClassroom.id
|
||||||
classroomName: newClassroom.get('name')
|
classroomName: newClassroom.get('name')
|
||||||
ownerID: newClassroom.get('ownerID')
|
ownerID: newClassroom.get('ownerID')
|
||||||
}
|
}
|
||||||
@classrooms.add(newClassroom)
|
@classrooms.add(newClassroom)
|
||||||
@render()
|
@render()
|
||||||
@classroomJustAdded = newClassroom.id
|
@classroomJustAdded = newClassroom.id
|
||||||
|
|
||||||
classroomCourseInstances = new CocoCollection([], { url: "/db/course_instance", model: CourseInstance })
|
classroomCourseInstances = new CocoCollection([], { url: "/db/course_instance", model: CourseInstance })
|
||||||
classroomCourseInstances.fetch({ data: {classroomID: newClassroom.id} })
|
classroomCourseInstances.fetch({ data: {classroomID: newClassroom.id} })
|
||||||
@listenToOnce classroomCourseInstances, 'sync', ->
|
@listenToOnce classroomCourseInstances, 'sync', ->
|
||||||
|
@ -151,8 +161,9 @@ module.exports = class CoursesView extends RootView
|
||||||
f = -> location.hash = '#just-added-text'
|
f = -> location.hash = '#just-added-text'
|
||||||
# quick and dirty scroll to just-added classroom
|
# quick and dirty scroll to just-added classroom
|
||||||
setTimeout(f, 10)
|
setTimeout(f, 10)
|
||||||
|
|
||||||
onClickChangeLanguageLink: ->
|
onClickChangeLanguageLink: ->
|
||||||
|
application.tracker?.trackEvent 'Student clicked change language', category: 'Courses'
|
||||||
modal = new ChangeCourseLanguageModal()
|
modal = new ChangeCourseLanguageModal()
|
||||||
@openModalView(modal)
|
@openModalView(modal)
|
||||||
modal.once 'hidden', @render, @
|
modal.once 'hidden', @render, @
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue