mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-23 15:48:11 -05:00
🐛Fix course victory dialog level progress counts
Use classroom versioned levels instead of latest course levels. Use current level session instead of stale one.
This commit is contained in:
parent
0cf04a9658
commit
16c9f10043
3 changed files with 15 additions and 19 deletions
|
@ -5,12 +5,6 @@ module.exports = class LevelSessionCollection extends CocoCollection
|
|||
url: '/db/level.session'
|
||||
model: LevelSession
|
||||
|
||||
fetchMineForCourseInstance: (courseInstanceID, options) ->
|
||||
options = _.extend({
|
||||
url: "/db/course_instance/#{courseInstanceID}/my-course-level-sessions"
|
||||
}, options)
|
||||
@fetch(options)
|
||||
|
||||
fetchForCourseInstance: (courseInstanceID, options) ->
|
||||
options = _.extend({
|
||||
url: "/db/course_instance/#{courseInstanceID}/my-course-level-sessions"
|
||||
|
|
|
@ -131,6 +131,8 @@ module.exports = class CourseVictoryModal extends ModalView
|
|||
for newItem in @newItems.models
|
||||
@views.push(new NewItemView({item: newItem}))
|
||||
|
||||
@levelSessions?.remove(@session)
|
||||
@levelSessions?.add(@session)
|
||||
progressView = new ProgressView({
|
||||
level: @level
|
||||
nextLevel: @nextLevel
|
||||
|
|
|
@ -142,13 +142,13 @@ CourseInstanceHandler = class CourseInstanceHandler extends Handler
|
|||
CourseInstance.findById courseInstanceID, (err, courseInstance) =>
|
||||
return @sendDatabaseError(res, err) if err
|
||||
return @sendNotFoundError(res) unless courseInstance
|
||||
Course.findById courseInstance.get('courseID'), (err, course) =>
|
||||
Classroom.findById courseInstance.get('classroomID'), (err, classroom) =>
|
||||
return @sendDatabaseError(res, err) if err
|
||||
return @sendNotFoundError(res) unless course
|
||||
Campaign.findById course.get('campaignID'), (err, campaign) =>
|
||||
return @sendDatabaseError(res, err) if err
|
||||
return @sendNotFoundError(res) unless campaign
|
||||
levelIDs = (levelID for levelID, level of campaign.get('levels') when not _.contains(level.type, 'ladder'))
|
||||
return @sendNotFoundError(res) unless classroom
|
||||
levelIDs = []
|
||||
for course in classroom.get('courses') when course._id.equals(courseInstance.get('courseID'))
|
||||
for level in course.levels when not _.contains(level.type, 'ladder')
|
||||
levelIDs.push(level.original + "")
|
||||
query = {$and: [{creator: req.user.id}, {'level.original': {$in: levelIDs}}]}
|
||||
cursor = LevelSession.find(query)
|
||||
cursor = cursor.select(req.query.project) if req.query.project
|
||||
|
|
Loading…
Reference in a new issue