Have level list in CourseDetailsView include play buttons up through the last level completed and any levels started

This commit is contained in:
Scott Erickson 2015-12-11 12:59:53 -08:00
parent 6d5d3d1091
commit 71bca28148
2 changed files with 18 additions and 4 deletions

View file

@ -139,23 +139,30 @@ block content
th(data-i18n="courses.concepts") th(data-i18n="courses.concepts")
tbody tbody
if campaign if campaign
- var lastLevelCompleted = true; - var previousLevelCompleted = true;
- var lastLevelCompleted = view.getLastLevelCompleted();
- var passedLastCompletedLevel = false;
- var levelCount = 0; - var levelCount = 0;
each level, levelID in campaign.get('levels') each level, levelID in campaign.get('levels')
- var levelStatus = null;
if userLevelStateMap[me.id]
- levelStatus = userLevelStateMap[me.id][levelID]
tr tr
td td
if lastLevelCompleted || view.teacherMode if previousLevelCompleted || view.teacherMode || !passedLastCompletedLevel || levelStatus
- var i18n = level.type === 'course-ladder' ? 'play.compete' : 'home.play'; - var i18n = level.type === 'course-ladder' ? 'play.compete' : 'home.play';
button.btn.btn-success.btn-play-level(data-level-slug=level.slug, data-i18n=i18n, data-level-id=levelID) button.btn.btn-success.btn-play-level(data-level-slug=level.slug, data-i18n=i18n, data-level-id=levelID)
td td
if userLevelStateMap[me.id] if userLevelStateMap[me.id]
div= userLevelStateMap[me.id][levelID] div= userLevelStateMap[me.id][levelID]
- lastLevelCompleted = userLevelStateMap[me.id][levelID] === 'complete' - previousLevelCompleted = userLevelStateMap[me.id][levelID] === 'complete'
else else
- lastLevelCompleted = false - previousLevelCompleted = false
td= ++levelCount + '. ' + level.name.replace('Course: ', '') td= ++levelCount + '. ' + level.name.replace('Course: ', '')
td td
if levelConceptMap[levelID] if levelConceptMap[levelID]
each concept in course.get('concepts') each concept in course.get('concepts')
if levelConceptMap[levelID][concept] if levelConceptMap[levelID][concept]
span.spr.concept(data-i18n="concepts." + concept) span.spr.concept(data-i18n="concepts." + concept)
if levelID === lastLevelCompleted
- passedLastCompletedLevel = true

View file

@ -238,3 +238,10 @@ module.exports = class CourseDetailsView extends RootView
else else
storage.save 'no-school', true storage.save 'no-school', true
@$el.find('#school-form').slideUp('slow') @$el.find('#school-form').slideUp('slow')
getLastLevelCompleted: ->
lastLevelCompleted = null
for levelID in _.keys(@campaign.get('levels'))
if @userLevelStateMap?[me.id]?[levelID] is 'complete'
lastLevelCompleted = levelID
return lastLevelCompleted