codecombat/app/views/courses/TeacherCoursesView.coffee

77 lines
3.3 KiB
CoffeeScript
Raw Normal View History

2015-11-03 19:41:06 -05:00
app = require 'core/application'
CocoCollection = require 'collections/CocoCollection'
CocoModel = require 'models/CocoModel'
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'
Classrooms = require 'collections/Classrooms'
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'
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
events:
'click .guide-btn': 'onClickGuideButton'
2016-04-08 15:59:10 -04:00
'click .play-level-button': 'onClickPlayLevel'
2016-03-30 16:57:19 -04:00
guideLinks:
{
Stuff Partially fix ActivateLicensesModal.spec [IN PROGRESS] Don't display deleted users Move userID to classroom.deletedMembers on user delete (not retroactive) Fix PDF links for course guides, remove old PDFs from repo Remove deprecated SalesView Remove underline for not-yet-linked student names Only show class select when there's more than one Ignore case when sorting student names Use student.broadName instead of name for display and sorting Fix initial load not showing progress after joining a course (hacky) Fix text entry for enrollment number input Fix enrollment statistics Fix enrollment stats completely (and add back in per-class unenrolled count) Add deletedMembers to classroom schema More fixes to enrollment stats (don't count nonmember prepaids) Don't use 0 as implicit false for openSpots Update suggested number of credit to buy automatically Fix classroom edit form ignoring cleared values Add alert text when more users selected than enrollments available Alert user when trying to assign course to unenrolled students Alert user when assigning course to nobody Add some tests for TeacherClassView bulk assign alerts Fix TeacherClassView tests failing without demos Use model/collection.fakeRequests :D Remove unused comment Fix handling of improperly sorted deleted users on clientside Add test for moving deleted users to deletedMembers Add script for moving all deleted classroom members to classroom.deletedMembers Completely rewrite tallying up enrollment statistics Fix some tests to not be dependent on logged-in user Address PR comments Fix default number of enrollments to buy Fix i18n for not enough enrollments Use custom error message for classroom name length
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
getTitle: -> return $.i18n.t('teacher.courses')
2015-11-03 19:41:06 -05:00
constructor: (options) ->
super(options)
@ownedClassrooms = new Classrooms()
@ownedClassrooms.fetchMine({data: {project: '_id'}})
@supermodel.trackCollection(@ownedClassrooms)
@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()
@supermodel.trackRequest @campaigns.fetchByType('course', { data: { project: 'levels,levelsUpdated' } })
2015-11-03 19:41:06 -05:00
@
initialize: (options) ->
window.tracker?.trackEvent 'Classes Guides Loaded', category: 'Teachers', ['Mixpanel']
super(options)
2015-12-01 16:41:02 -05: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']
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()
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}"
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 })