Skip to content

Commit

Permalink
Merge 91ac063 into 0918b52
Browse files Browse the repository at this point in the history
  • Loading branch information
chethana-sastry committed Jul 31, 2018
2 parents 0918b52 + 91ac063 commit d697eda
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions app/views/play/CampaignView.coffee
Expand Up @@ -110,7 +110,8 @@ module.exports = class CampaignView extends RootView
@levelPlayCountMap = {}
@levelDifficultyMap = {}
@levelScoreMap = {}

@jqxhr = null

if utils.getQueryVariable('hour_of_code')
if me.isStudent() or me.isTeacher()
if @terrain is 'dungeon'
Expand Down Expand Up @@ -181,9 +182,9 @@ module.exports = class CampaignView extends RootView
@courseLevelsFake = {}
@courseInstanceID = utils.getQueryVariable('course-instance')
@courseInstance = new CourseInstance(_id: @courseInstanceID)
jqxhr = @courseInstance.fetch()
@supermodel.trackRequest(jqxhr)
new Promise(jqxhr.then).then(=>
@jqxhr = @courseInstance.fetch()
@supermodel.trackRequest(@jqxhr)
new Promise(@jqxhr.then).then(=>
courseID = @courseInstance.get('courseID')

@course = new Course(_id: courseID)
Expand Down Expand Up @@ -622,7 +623,14 @@ module.exports = class CampaignView extends RootView
level.locked = true if level.requiresSubscription and @requiresSubscription and me.get('hourOfCode')
level.locked = false if @levelStatusMap[level.slug] in ['started', 'complete']
level.locked = false if @editorMode
level.locked = false if not @course? and @campaign?.get('name') in ['Auditions', 'Intro']
if @jqxhr
new Promise(@jqxhr.then).then(=>
# In certain race condition, orderedLevels are initialized but course is not yet initialized (which is done asynchronously).
# In that scenario, the below condition is wrongly met and all levels are unlocked.
# Added this inside a promise so that this executes only after the asynchronous call that initiailizes course is completed
if not @course? and @campaign?.get('name') in ['Auditions', 'Intro']
level.locked = false
)
level.locked = false if me.isInGodMode()
level.disabled = true if level.adminOnly and @levelStatusMap[level.slug] not in ['started', 'complete']
level.disabled = false if me.isInGodMode()
Expand Down

0 comments on commit d697eda

Please sign in to comment.