mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-04 17:19:47 -04:00
Fix last level text and continue button
This commit is contained in:
parent
b25312265b
commit
e65a9248f3
2 changed files with 10 additions and 8 deletions
app
|
@ -60,20 +60,22 @@ module.exports = class Classroom extends CocoModel
|
|||
return null unless sessions
|
||||
stats = {}
|
||||
sessions = sessions.models or sessions
|
||||
sessions = _.sortBy sessions, (s) -> s.get('changed')
|
||||
arena = @getLadderLevel(courseID)
|
||||
levels = @getLevels({courseID: courseID, withoutLadderLevels: true})
|
||||
levelOriginals = levels.pluck('original')
|
||||
sessionOriginals = (session.get('level').original for session in sessions when session.get('state').complete)
|
||||
levelsLeft = _.size(_.difference(levelOriginals, sessionOriginals))
|
||||
lastSession = _.last(sessions)
|
||||
completeSessionOriginals = (session.get('level').original for session in sessions when session.get('state').complete)
|
||||
incompleteSessionOriginals = (session.get('level').original for session in sessions when not session.get('state').complete)
|
||||
levelsLeft = _.size(_.difference(levelOriginals, completeSessionOriginals))
|
||||
next = _.find levels.models, (level) -> level.get('original') not in completeSessionOriginals
|
||||
lastPlayed = _.find levels.models, (level) -> level.get('original') in incompleteSessionOriginals
|
||||
stats.levels = {
|
||||
size: levels.size()
|
||||
left: levelsLeft
|
||||
done: levelsLeft is 0
|
||||
numDone: levels.size() - levelsLeft
|
||||
pctDone: (100 * (levels.size() - levelsLeft) / levels.size()).toFixed(1) + '%'
|
||||
lastPlayed: if lastSession then levels.findWhere({ original: lastSession.get('level').original }) else null
|
||||
lastPlayed: lastPlayed
|
||||
next: next
|
||||
first: levels.first()
|
||||
arena: arena
|
||||
}
|
||||
|
|
|
@ -104,9 +104,9 @@ mixin course-instance-body(courseInstance, classroom)
|
|||
span(data-i18n="courses.play_arena")
|
||||
else
|
||||
a.btn.btn-default.btn-lg.m-b-1(disabled=true, data-i18n="courses.course_complete")
|
||||
else if courseInstance.sessions.size()
|
||||
- var lastLevel = stats.levels.lastPlayed;
|
||||
- var levelURL = "/play/level/"+lastLevel.get('slug')+"?course="+courseInstance.get('courseID')+"&course-instance="+courseInstance.id;
|
||||
else if stats.levels.next != stats.levels.first
|
||||
- var next = stats.levels.next;
|
||||
- var levelURL = "/play/level/"+next.get('slug')+"?course="+courseInstance.get('courseID')+"&course-instance="+courseInstance.id;
|
||||
a.btn.btn-forest.btn-lg.m-b-1(href=levelURL)
|
||||
span(data-i18n="common.continue")
|
||||
else
|
||||
|
|
Loading…
Add table
Reference in a new issue