mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-24 08:08:15 -05:00
Update course level routing
This commit is contained in:
parent
b4d59ced3e
commit
d7d6694ee9
4 changed files with 49 additions and 22 deletions
|
@ -23,9 +23,9 @@ module.exports = class CourseDetailsView extends RootView
|
||||||
'mouseenter .progress-level-cell': 'onMouseEnterPoint'
|
'mouseenter .progress-level-cell': 'onMouseEnterPoint'
|
||||||
'mouseleave .progress-level-cell': 'onMouseLeavePoint'
|
'mouseleave .progress-level-cell': 'onMouseLeavePoint'
|
||||||
|
|
||||||
constructor: (options, @courseID) ->
|
constructor: (options, @courseID, @courseInstanceID) ->
|
||||||
super options
|
super options
|
||||||
@courseInstanceID = utils.getQueryVariable('ciid', false) or options.courseInstanceID
|
@courseInstanceID ?= utils.getQueryVariable('ciid', false) or options.courseInstanceID
|
||||||
@adminMode = me.isAdmin()
|
@adminMode = me.isAdmin()
|
||||||
@memberSort = 'nameAsc'
|
@memberSort = 'nameAsc'
|
||||||
@course = @supermodel.getModel(Course, @courseID) or new Course _id: @courseID
|
@course = @supermodel.getModel(Course, @courseID) or new Course _id: @courseID
|
||||||
|
@ -90,7 +90,8 @@ module.exports = class CourseDetailsView extends RootView
|
||||||
loadCourseInstance: (courseInstanceID) ->
|
loadCourseInstance: (courseInstanceID) ->
|
||||||
# console.log 'loadCourseInstance'
|
# console.log 'loadCourseInstance'
|
||||||
return if @courseInstance?
|
return if @courseInstance?
|
||||||
@courseInstance = @supermodel.getModel(CourseInstance, courseInstanceID) or new CourseInstance _id: courseInstanceID
|
@courseInstanceID = courseInstanceID
|
||||||
|
@courseInstance = @supermodel.getModel(CourseInstance, @courseInstanceID) or new CourseInstance _id: @courseInstanceID
|
||||||
@listenTo @courseInstance, 'sync', @onCourseInstanceSync
|
@listenTo @courseInstance, 'sync', @onCourseInstanceSync
|
||||||
if @courseInstance.loaded
|
if @courseInstance.loaded
|
||||||
@onCourseInstanceSync()
|
@onCourseInstanceSync()
|
||||||
|
@ -191,7 +192,7 @@ module.exports = class CourseDetailsView extends RootView
|
||||||
Backbone.Mediator.publish 'router:navigate', {
|
Backbone.Mediator.publish 'router:navigate', {
|
||||||
route: "/play/level/#{levelSlug}"
|
route: "/play/level/#{levelSlug}"
|
||||||
viewClass: 'views/play/level/PlayLevelView'
|
viewClass: 'views/play/level/PlayLevelView'
|
||||||
viewArgs: [{}, levelSlug]
|
viewArgs: [{courseID: @courseID, courseInstanceID: @courseInstanceID}, levelSlug]
|
||||||
}
|
}
|
||||||
|
|
||||||
onClickSaveSettings: (e) ->
|
onClickSaveSettings: (e) ->
|
||||||
|
|
|
@ -28,6 +28,9 @@ module.exports = class ControlBarView extends CocoView
|
||||||
'click #control-bar-sign-up-button': 'onClickSignupButton'
|
'click #control-bar-sign-up-button': 'onClickSignupButton'
|
||||||
|
|
||||||
constructor: (options) ->
|
constructor: (options) ->
|
||||||
|
@courseID = options.courseID
|
||||||
|
@courseInstanceID = options.courseInstanceID
|
||||||
|
|
||||||
@worldName = options.worldName
|
@worldName = options.worldName
|
||||||
@session = options.session
|
@session = options.session
|
||||||
@level = options.level
|
@level = options.level
|
||||||
|
@ -88,13 +91,15 @@ module.exports = class ControlBarView extends CocoView
|
||||||
@homeLink += '/' + campaign
|
@homeLink += '/' + campaign
|
||||||
@homeViewArgs.push campaign
|
@homeViewArgs.push campaign
|
||||||
else if @level.get('type', true) in ['course']
|
else if @level.get('type', true) in ['course']
|
||||||
@homeLink = '/courses/mock1'
|
@homeLink = '/courses'
|
||||||
@homeViewClass = 'views/courses/mock1/CourseDetailsView'
|
@homeViewClass = 'views/courses/CoursesView'
|
||||||
#campaign = @level.get 'campaign'
|
if @courseID
|
||||||
#@homeLink += '/' + campaign
|
@homeLink += "/#{@courseID}"
|
||||||
#@homeViewArgs.push campaign
|
@homeViewArgs.push @courseID
|
||||||
@homeLink += '/' + '0'
|
@homeViewClass = 'views/courses/CourseDetailsView'
|
||||||
@homeViewArgs.push '0'
|
if @courseInstanceID
|
||||||
|
@homeLink += "?ciid=#{@courseInstanceID}"
|
||||||
|
@homeViewArgs.push @courseInstanceID
|
||||||
else
|
else
|
||||||
@homeLink = '/'
|
@homeLink = '/'
|
||||||
@homeViewClass = 'views/HomeView'
|
@homeViewClass = 'views/HomeView'
|
||||||
|
|
|
@ -94,6 +94,9 @@ module.exports = class PlayLevelView extends RootView
|
||||||
console.profile?() if PROFILE_ME
|
console.profile?() if PROFILE_ME
|
||||||
super options
|
super options
|
||||||
|
|
||||||
|
@courseID = options.courseID
|
||||||
|
@courseInstanceID = options.courseInstanceID
|
||||||
|
|
||||||
@isEditorPreview = @getQueryVariable 'dev'
|
@isEditorPreview = @getQueryVariable 'dev'
|
||||||
@sessionID = @getQueryVariable 'session'
|
@sessionID = @getQueryVariable 'session'
|
||||||
@observing = @getQueryVariable 'observing'
|
@observing = @getQueryVariable 'observing'
|
||||||
|
@ -248,7 +251,7 @@ module.exports = class PlayLevelView extends RootView
|
||||||
@insertSubView new ChatView levelID: @levelID, sessionID: @session.id, session: @session
|
@insertSubView new ChatView levelID: @levelID, sessionID: @session.id, session: @session
|
||||||
@insertSubView new ProblemAlertView session: @session, level: @level, supermodel: @supermodel
|
@insertSubView new ProblemAlertView session: @session, level: @level, supermodel: @supermodel
|
||||||
@insertSubView new DuelStatsView level: @level, session: @session, otherSession: @otherSession, supermodel: @supermodel, thangs: @world.thangs if @level.get('type') in ['hero-ladder', 'course-ladder']
|
@insertSubView new DuelStatsView level: @level, session: @session, otherSession: @otherSession, supermodel: @supermodel, thangs: @world.thangs if @level.get('type') in ['hero-ladder', 'course-ladder']
|
||||||
@insertSubView @controlBar = new ControlBarView {worldName: utils.i18n(@level.attributes, 'name'), session: @session, level: @level, supermodel: @supermodel}
|
@insertSubView @controlBar = new ControlBarView {worldName: utils.i18n(@level.attributes, 'name'), session: @session, level: @level, supermodel: @supermodel, courseID: @courseID, courseInstanceID: @courseInstanceID}
|
||||||
#_.delay (=> Backbone.Mediator.publish('level:set-debug', debug: true)), 5000 if @isIPadApp() # if me.displayName() is 'Nick'
|
#_.delay (=> Backbone.Mediator.publish('level:set-debug', debug: true)), 5000 if @isIPadApp() # if me.displayName() is 'Nick'
|
||||||
|
|
||||||
initVolume: ->
|
initVolume: ->
|
||||||
|
@ -444,7 +447,7 @@ module.exports = class PlayLevelView extends RootView
|
||||||
showVictory: ->
|
showVictory: ->
|
||||||
return if @level.hasLocalChanges() # Don't award achievements when beating level changed in level editor
|
return if @level.hasLocalChanges() # Don't award achievements when beating level changed in level editor
|
||||||
@endHighlight()
|
@endHighlight()
|
||||||
options = {level: @level, supermodel: @supermodel, session: @session, hasReceivedMemoryWarning: @hasReceivedMemoryWarning}
|
options = {level: @level, supermodel: @supermodel, session: @session, hasReceivedMemoryWarning: @hasReceivedMemoryWarning, courseID: @courseID, courseInstanceID: @courseInstanceID}
|
||||||
ModalClass = if @level.get('type', true) in ['hero', 'hero-ladder', 'hero-coop', 'course', 'course-ladder'] then HeroVictoryModal else VictoryModal
|
ModalClass = if @level.get('type', true) in ['hero', 'hero-ladder', 'hero-coop', 'course', 'course-ladder'] then HeroVictoryModal else VictoryModal
|
||||||
victoryModal = new ModalClass(options)
|
victoryModal = new ModalClass(options)
|
||||||
@openModalView(victoryModal)
|
@openModalView(victoryModal)
|
||||||
|
|
|
@ -42,6 +42,9 @@ module.exports = class HeroVictoryModal extends ModalView
|
||||||
|
|
||||||
constructor: (options) ->
|
constructor: (options) ->
|
||||||
super(options)
|
super(options)
|
||||||
|
@courseID = options.courseID
|
||||||
|
@courseInstanceID = options.courseInstanceID
|
||||||
|
|
||||||
@session = options.session
|
@session = options.session
|
||||||
@level = options.level
|
@level = options.level
|
||||||
@thangTypes = {}
|
@thangTypes = {}
|
||||||
|
@ -399,13 +402,17 @@ module.exports = class HeroVictoryModal extends ModalView
|
||||||
if @level.get('type', true) is 'course' and nextLevel = @level.get('nextLevel') and not returnToCourse
|
if @level.get('type', true) is 'course' and nextLevel = @level.get('nextLevel') and not returnToCourse
|
||||||
# need to do something more complicated to load its slug
|
# need to do something more complicated to load its slug
|
||||||
console.log 'have @nextLevel', @nextLevel, 'from nextLevel', nextLevel
|
console.log 'have @nextLevel', @nextLevel, 'from nextLevel', nextLevel
|
||||||
return "/play/level/#{@nextLevel.get('slug')}"
|
link = "/play/level/#{@nextLevel.get('slug')}"
|
||||||
else if @level.get('type', true) is 'course'
|
else if @level.get('type', true) is 'course'
|
||||||
# TODO: figure out which course it is
|
link = "/courses"
|
||||||
return '/courses/mock1/0'
|
if @courseID
|
||||||
link = '/play'
|
link += "/#{@courseID}"
|
||||||
nextCampaign = @getNextLevelCampaign()
|
if @courseInstanceID
|
||||||
link += '/' + nextCampaign
|
link += "?ciid=#{@courseInstanceID}"
|
||||||
|
else
|
||||||
|
link = '/play'
|
||||||
|
nextCampaign = @getNextLevelCampaign()
|
||||||
|
link += '/' + nextCampaign
|
||||||
link
|
link
|
||||||
|
|
||||||
onClickContinue: (e, extraOptions=null) ->
|
onClickContinue: (e, extraOptions=null) ->
|
||||||
|
@ -418,11 +425,22 @@ module.exports = class HeroVictoryModal extends ModalView
|
||||||
_.merge options, extraOptions if extraOptions
|
_.merge options, extraOptions if extraOptions
|
||||||
if @level.get('type', true) is 'course' and @nextLevel and not options.returnToCourse
|
if @level.get('type', true) is 'course' and @nextLevel and not options.returnToCourse
|
||||||
viewClass = require 'views/play/level/PlayLevelView'
|
viewClass = require 'views/play/level/PlayLevelView'
|
||||||
|
if @courseID
|
||||||
|
options.courseID = @courseID
|
||||||
|
if @courseInstanceID
|
||||||
|
options.courseInstanceID = @courseInstanceID
|
||||||
viewArgs = [options, @nextLevel.get('slug')]
|
viewArgs = [options, @nextLevel.get('slug')]
|
||||||
else if @level.get('type', true) is 'course'
|
else if @level.get('type', true) is 'course'
|
||||||
options.studentMode = true
|
# TODO: shouldn't set viewClass and route in different places
|
||||||
viewClass = require 'views/courses/mock1/CourseDetailsView'
|
viewClass = require 'views/courses/CoursesView'
|
||||||
viewArgs = [options, '0']
|
viewArgs = [options]
|
||||||
|
if @courseID
|
||||||
|
viewClass = require 'views/courses/CourseDetailsView'
|
||||||
|
options.courseID = @courseID
|
||||||
|
viewArgs.push @courseID
|
||||||
|
if @courseInstanceID
|
||||||
|
options.courseInstanceID = @courseInstanceID
|
||||||
|
viewArgs.push @courseInstanceID
|
||||||
else
|
else
|
||||||
viewClass = require 'views/play/CampaignView'
|
viewClass = require 'views/play/CampaignView'
|
||||||
viewArgs = [options, @getNextLevelCampaign()]
|
viewArgs = [options, @getNextLevelCampaign()]
|
||||||
|
|
Loading…
Reference in a new issue