diff --git a/app/models/SuperModel.coffee b/app/models/SuperModel.coffee index eb9fc5b82..ea8058f79 100644 --- a/app/models/SuperModel.coffee +++ b/app/models/SuperModel.coffee @@ -295,10 +295,27 @@ class ModelResource extends Resource @model = modelOrCollection @fetchOptions = fetchOptions @jqxhr = @model.jqxhr + @loadsAttempted = 0 load: -> - @markLoading() - @fetchModel() + timeToWait = 5000 + tryLoad = => + return if this.isLoaded + if @loadsAttempted > 4 + @markFailed() + return @ + @markLoading() + if @loadsAttempted > 0 + console.log "Didn't load model in #{timeToWait}ms (attempt ##{@loadsAttempted}), trying again: ", this + @fetchModel() + @listenTo @model, 'error', (levelComponent, request) -> + if request.status isnt 504 + clearTimeout(@timeoutID) + clearTimeout(@timeoutID) if @timeoutID + @timeoutID = setTimeout(tryLoad, timeToWait) + @loadsAttempted += 1 + timeToWait *= 1.5 + tryLoad() @ fetchModel: -> diff --git a/app/views/play/level/PlayLevelView.coffee b/app/views/play/level/PlayLevelView.coffee index c844e720f..733e4c059 100644 --- a/app/views/play/level/PlayLevelView.coffee +++ b/app/views/play/level/PlayLevelView.coffee @@ -217,9 +217,10 @@ module.exports = class PlayLevelView extends RootView # TODO: Update terminology to always be opponentSession or otherSession # TODO: E.g. if it's always opponent right now, then variable names should be opponentSession until we have coop play @otherSession = @levelLoader.opponentSession - @worldLoadFakeResources = [] # first element (0) is 1%, last (99) is 100% - for percent in [1 .. 100] - @worldLoadFakeResources.push @supermodel.addSomethingResource 1 + unless @level.isType('game-dev') + @worldLoadFakeResources = [] # first element (0) is 1%, last (99) is 100% + for percent in [1 .. 100] + @worldLoadFakeResources.push @supermodel.addSomethingResource 1 @renderSelectors '#stop-real-time-playback-button' onWorldLoadProgressChanged: (e) -> @@ -570,7 +571,7 @@ module.exports = class PlayLevelView extends RootView ModalClass = CourseVictoryModal if @isCourseMode() or me.isSessionless() if @level.isType('course-ladder') ModalClass = CourseVictoryModal - options.courseInstanceID = @getQueryVariable 'league' + options.courseInstanceID = @getQueryVariable 'course-instance' or @getQueryVariable 'league' ModalClass = PicoCTFVictoryModal if window.serverConfig.picoCTF victoryModal = new ModalClass(options) @openModalView(victoryModal) diff --git a/app/views/play/level/modal/CourseVictoryModal.coffee b/app/views/play/level/modal/CourseVictoryModal.coffee index 1e320698f..2b52e999e 100644 --- a/app/views/play/level/modal/CourseVictoryModal.coffee +++ b/app/views/play/level/modal/CourseVictoryModal.coffee @@ -14,7 +14,7 @@ module.exports = class CourseVictoryModal extends ModalView initialize: (options) -> @courseID = options.courseID - @courseInstanceID = options.courseInstanceID + @courseInstanceID = options.courseInstanceID or @getQueryVariable 'course-instance' or @getQueryVariable 'league' @views = [] @session = options.session diff --git a/scripts/mongodb/updateCourses.js b/scripts/mongodb/updateCourses.js index 90e2355d2..1e92d7cf7 100644 --- a/scripts/mongodb/updateCourses.js +++ b/scripts/mongodb/updateCourses.js @@ -64,10 +64,8 @@ var courses = slug: "game-dev-1", campaignID: ObjectId("5789236960deed1f00ec2ab8"), description: "Learn to create your owns games which you can share with your friends.", - duration: NumberInt(5), + duration: NumberInt(1), free: false, - //screenshot: "/images/pages/courses/105_info.png", - adminOnly: true, // Until we finish transitioning to releasePhase releasePhase: 'beta' }, { @@ -75,10 +73,8 @@ var courses = slug: "web-dev-1", campaignID: ObjectId("578913f2c8871ac2326fa3e4"), description: "Learn the basics of web development in this introductory HTML & CSS course.", - duration: NumberInt(5), + duration: NumberInt(1), free: false, - //screenshot: "/images/pages/courses/105_info.png", - adminOnly: true, // Until we finish transitioning to releasePhase releasePhase: 'beta' }, { @@ -86,10 +82,17 @@ var courses = slug: "web-dev-2", campaignID: ObjectId("57891570c8871ac2326fa3f8"), description: "Learn more advanced web development, including scripting to make interactive webpages.", - duration: NumberInt(5), + duration: NumberInt(2), + free: false, + releasePhase: 'beta' + }, + { + name: "JS Primer", + slug: "js-primer", + campaignID: ObjectId("579a5f37843ad12000e6d4c7"), + description: "Learn JavaScript after you already know another programming language like Python.", + duration: NumberInt(1), free: false, - //screenshot: "/images/pages/courses/105_info.png", - adminOnly: true, // Until we finish transitioning to releasePhase releasePhase: 'beta' } ];