2015-11-03 19:41:06 -05:00
|
|
|
app = require 'core/application'
|
|
|
|
CocoCollection = require 'collections/CocoCollection'
|
2015-11-05 20:26:31 -05:00
|
|
|
CocoModel = require 'models/CocoModel'
|
2016-07-22 19:37:53 -04:00
|
|
|
Courses = require 'collections/Courses'
|
2016-04-08 15:59:10 -04:00
|
|
|
Campaigns = require 'collections/Campaigns'
|
2015-11-03 19:41:06 -05:00
|
|
|
Classroom = require 'models/Classroom'
|
2016-03-30 19:20:37 -04:00
|
|
|
Classrooms = require 'collections/Classrooms'
|
2015-11-05 20:26:31 -05:00
|
|
|
User = require 'models/User'
|
2015-11-03 19:41:06 -05:00
|
|
|
CourseInstance = require 'models/CourseInstance'
|
|
|
|
RootView = require 'views/core/RootView'
|
|
|
|
template = require 'templates/courses/teacher-courses-view'
|
2016-08-15 15:43:28 -04:00
|
|
|
HeroSelectModal = require 'views/courses/HeroSelectModal'
|
2015-11-03 19:41:06 -05:00
|
|
|
|
|
|
|
module.exports = class TeacherCoursesView extends RootView
|
|
|
|
id: 'teacher-courses-view'
|
|
|
|
template: template
|
2015-11-19 18:32:52 -05:00
|
|
|
|
2015-11-04 19:54:13 -05:00
|
|
|
events:
|
2016-06-08 09:24:59 -04:00
|
|
|
'click .guide-btn': 'onClickGuideButton'
|
2016-04-08 15:59:10 -04:00
|
|
|
'click .play-level-button': 'onClickPlayLevel'
|
2016-06-08 09:24:59 -04:00
|
|
|
|
2016-03-30 16:57:19 -04:00
|
|
|
guideLinks:
|
|
|
|
{
|
2016-04-07 17:55:42 -04:00
|
|
|
"560f1a9f22961295f9427742":
|
|
|
|
python: 'http://files.codecombat.com/teacherguides/CodeCombat_TeacherGuide_intro_python.pdf'
|
|
|
|
javascript: 'http://files.codecombat.com/teacherguides/CodeCombat_TeacherGuide_intro_javascript.pdf'
|
|
|
|
"5632661322961295f9428638":
|
|
|
|
python: 'http://files.codecombat.com/teacherguides/CodeCombat_TeacherGuide_course-2_python.pdf'
|
|
|
|
javascript: 'http://files.codecombat.com/teacherguides/CodeCombat_TeacherGuide_course-2_javascript.pdf'
|
|
|
|
"56462f935afde0c6fd30fc8c":
|
|
|
|
python: 'http://files.codecombat.com/teacherguides/CodeCombat_TeacherGuide_course-3_python.pdf'
|
|
|
|
javascript: 'http://files.codecombat.com/teacherguides/CodeCombat_TeacherGuide_course-3_javascript.pdf'
|
2016-03-30 16:57:19 -04:00
|
|
|
"56462f935afde0c6fd30fc8d": null
|
|
|
|
"569ed916efa72b0ced971447": null
|
|
|
|
}
|
2015-11-03 19:41:06 -05:00
|
|
|
|
2016-05-27 12:40:46 -04:00
|
|
|
getTitle: -> return $.i18n.t('teacher.courses')
|
|
|
|
|
2015-11-03 19:41:06 -05:00
|
|
|
constructor: (options) ->
|
|
|
|
super(options)
|
2016-03-30 19:20:37 -04:00
|
|
|
@ownedClassrooms = new Classrooms()
|
|
|
|
@ownedClassrooms.fetchMine({data: {project: '_id'}})
|
|
|
|
@supermodel.trackCollection(@ownedClassrooms)
|
2016-07-22 19:37:53 -04:00
|
|
|
@courses = new Courses()
|
2016-08-04 21:37:01 -04:00
|
|
|
if me.isAdmin()
|
|
|
|
@supermodel.trackRequest @courses.fetch()
|
|
|
|
else
|
|
|
|
@supermodel.trackRequest @courses.fetchReleased()
|
2016-04-08 15:59:10 -04:00
|
|
|
@campaigns = new Campaigns()
|
2016-05-09 18:16:54 -04:00
|
|
|
@supermodel.trackRequest @campaigns.fetchByType('course', { data: { project: 'levels,levelsUpdated' } })
|
2015-11-03 19:41:06 -05:00
|
|
|
@
|
2015-11-04 19:54:13 -05:00
|
|
|
|
2016-06-08 09:24:59 -04:00
|
|
|
initialize: (options) ->
|
|
|
|
window.tracker?.trackEvent 'Classes Guides Loaded', category: 'Teachers', ['Mixpanel']
|
|
|
|
super(options)
|
2015-12-01 16:41:02 -05:00
|
|
|
|
2016-06-08 09:24:59 -04:00
|
|
|
onClickGuideButton: (e) ->
|
|
|
|
courseID = $(e.currentTarget).data('course-id')
|
|
|
|
courseName = $(e.currentTarget).data('course-name')
|
|
|
|
eventAction = $(e.currentTarget).data('event-action')
|
|
|
|
window.tracker?.trackEvent eventAction, category: 'Teachers', courseID: courseID, courseName: courseName, ['Mixpanel']
|
2015-11-17 19:09:29 -05:00
|
|
|
|
2016-04-08 15:59:10 -04:00
|
|
|
onClickPlayLevel: (e) ->
|
|
|
|
form = $(e.currentTarget).closest('.play-level-form')
|
|
|
|
levelSlug = form.find('.level-select').val()
|
|
|
|
courseID = form.data('course-id')
|
|
|
|
language = form.find('.language-select').val()
|
2016-06-08 09:24:59 -04:00
|
|
|
window.tracker?.trackEvent 'Classes Guides Play Level', category: 'Teachers', courseID: courseID, language: language, levelSlug: levelSlug, ['Mixpanel']
|
2016-04-08 15:59:10 -04:00
|
|
|
url = "/play/level/#{levelSlug}?course=#{courseID}&codeLanguage=#{language}"
|
2016-08-15 15:43:28 -04:00
|
|
|
firstLevelSlug = @campaigns.get(@courses.at(0).get('campaignID')).getLevels().at(0).get('slug')
|
|
|
|
if levelSlug is firstLevelSlug
|
|
|
|
@listenToOnce @openModalView(new HeroSelectModal()),
|
|
|
|
'hidden': ->
|
|
|
|
application.router.navigate(url, { trigger: true })
|
|
|
|
else
|
|
|
|
application.router.navigate(url, { trigger: true })
|