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'
|
||||
'mouseleave .progress-level-cell': 'onMouseLeavePoint'
|
||||
|
||||
constructor: (options, @courseID) ->
|
||||
constructor: (options, @courseID, @courseInstanceID) ->
|
||||
super options
|
||||
@courseInstanceID = utils.getQueryVariable('ciid', false) or options.courseInstanceID
|
||||
@courseInstanceID ?= utils.getQueryVariable('ciid', false) or options.courseInstanceID
|
||||
@adminMode = me.isAdmin()
|
||||
@memberSort = 'nameAsc'
|
||||
@course = @supermodel.getModel(Course, @courseID) or new Course _id: @courseID
|
||||
|
@ -90,7 +90,8 @@ module.exports = class CourseDetailsView extends RootView
|
|||
loadCourseInstance: (courseInstanceID) ->
|
||||
# console.log 'loadCourseInstance'
|
||||
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
|
||||
if @courseInstance.loaded
|
||||
@onCourseInstanceSync()
|
||||
|
@ -191,7 +192,7 @@ module.exports = class CourseDetailsView extends RootView
|
|||
Backbone.Mediator.publish 'router:navigate', {
|
||||
route: "/play/level/#{levelSlug}"
|
||||
viewClass: 'views/play/level/PlayLevelView'
|
||||
viewArgs: [{}, levelSlug]
|
||||
viewArgs: [{courseID: @courseID, courseInstanceID: @courseInstanceID}, levelSlug]
|
||||
}
|
||||
|
||||
onClickSaveSettings: (e) ->
|
||||
|
|
|
@ -28,6 +28,9 @@ module.exports = class ControlBarView extends CocoView
|
|||
'click #control-bar-sign-up-button': 'onClickSignupButton'
|
||||
|
||||
constructor: (options) ->
|
||||
@courseID = options.courseID
|
||||
@courseInstanceID = options.courseInstanceID
|
||||
|
||||
@worldName = options.worldName
|
||||
@session = options.session
|
||||
@level = options.level
|
||||
|
@ -88,13 +91,15 @@ module.exports = class ControlBarView extends CocoView
|
|||
@homeLink += '/' + campaign
|
||||
@homeViewArgs.push campaign
|
||||
else if @level.get('type', true) in ['course']
|
||||
@homeLink = '/courses/mock1'
|
||||
@homeViewClass = 'views/courses/mock1/CourseDetailsView'
|
||||
#campaign = @level.get 'campaign'
|
||||
#@homeLink += '/' + campaign
|
||||
#@homeViewArgs.push campaign
|
||||
@homeLink += '/' + '0'
|
||||
@homeViewArgs.push '0'
|
||||
@homeLink = '/courses'
|
||||
@homeViewClass = 'views/courses/CoursesView'
|
||||
if @courseID
|
||||
@homeLink += "/#{@courseID}"
|
||||
@homeViewArgs.push @courseID
|
||||
@homeViewClass = 'views/courses/CourseDetailsView'
|
||||
if @courseInstanceID
|
||||
@homeLink += "?ciid=#{@courseInstanceID}"
|
||||
@homeViewArgs.push @courseInstanceID
|
||||
else
|
||||
@homeLink = '/'
|
||||
@homeViewClass = 'views/HomeView'
|
||||
|
|
|
@ -94,6 +94,9 @@ module.exports = class PlayLevelView extends RootView
|
|||
console.profile?() if PROFILE_ME
|
||||
super options
|
||||
|
||||
@courseID = options.courseID
|
||||
@courseInstanceID = options.courseInstanceID
|
||||
|
||||
@isEditorPreview = @getQueryVariable 'dev'
|
||||
@sessionID = @getQueryVariable 'session'
|
||||
@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 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 @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'
|
||||
|
||||
initVolume: ->
|
||||
|
@ -444,7 +447,7 @@ module.exports = class PlayLevelView extends RootView
|
|||
showVictory: ->
|
||||
return if @level.hasLocalChanges() # Don't award achievements when beating level changed in level editor
|
||||
@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
|
||||
victoryModal = new ModalClass(options)
|
||||
@openModalView(victoryModal)
|
||||
|
|
|
@ -42,6 +42,9 @@ module.exports = class HeroVictoryModal extends ModalView
|
|||
|
||||
constructor: (options) ->
|
||||
super(options)
|
||||
@courseID = options.courseID
|
||||
@courseInstanceID = options.courseInstanceID
|
||||
|
||||
@session = options.session
|
||||
@level = options.level
|
||||
@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
|
||||
# need to do something more complicated to load its slug
|
||||
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'
|
||||
# TODO: figure out which course it is
|
||||
return '/courses/mock1/0'
|
||||
link = '/play'
|
||||
nextCampaign = @getNextLevelCampaign()
|
||||
link += '/' + nextCampaign
|
||||
link = "/courses"
|
||||
if @courseID
|
||||
link += "/#{@courseID}"
|
||||
if @courseInstanceID
|
||||
link += "?ciid=#{@courseInstanceID}"
|
||||
else
|
||||
link = '/play'
|
||||
nextCampaign = @getNextLevelCampaign()
|
||||
link += '/' + nextCampaign
|
||||
link
|
||||
|
||||
onClickContinue: (e, extraOptions=null) ->
|
||||
|
@ -418,11 +425,22 @@ module.exports = class HeroVictoryModal extends ModalView
|
|||
_.merge options, extraOptions if extraOptions
|
||||
if @level.get('type', true) is 'course' and @nextLevel and not options.returnToCourse
|
||||
viewClass = require 'views/play/level/PlayLevelView'
|
||||
if @courseID
|
||||
options.courseID = @courseID
|
||||
if @courseInstanceID
|
||||
options.courseInstanceID = @courseInstanceID
|
||||
viewArgs = [options, @nextLevel.get('slug')]
|
||||
else if @level.get('type', true) is 'course'
|
||||
options.studentMode = true
|
||||
viewClass = require 'views/courses/mock1/CourseDetailsView'
|
||||
viewArgs = [options, '0']
|
||||
# TODO: shouldn't set viewClass and route in different places
|
||||
viewClass = require 'views/courses/CoursesView'
|
||||
viewArgs = [options]
|
||||
if @courseID
|
||||
viewClass = require 'views/courses/CourseDetailsView'
|
||||
options.courseID = @courseID
|
||||
viewArgs.push @courseID
|
||||
if @courseInstanceID
|
||||
options.courseInstanceID = @courseInstanceID
|
||||
viewArgs.push @courseInstanceID
|
||||
else
|
||||
viewClass = require 'views/play/CampaignView'
|
||||
viewArgs = [options, @getNextLevelCampaign()]
|
||||
|
|
Loading…
Reference in a new issue