codecombat/app/collections/LevelSessions.coffee

41 lines
1.2 KiB
CoffeeScript
Raw Normal View History

2016-01-19 18:42:20 -05:00
CocoCollection = require 'collections/CocoCollection'
LevelSession = require 'models/LevelSession'
module.exports = class LevelSessionCollection extends CocoCollection
url: '/db/level.session'
model: LevelSession
2016-04-13 12:54:24 -04:00
fetchMineForCourseInstance: (courseInstanceID, options) ->
options = _.extend({
url: "/db/course_instance/#{courseInstanceID}/my-course-level-sessions"
}, options)
@fetch(options)
2016-01-19 18:42:20 -05:00
fetchForCourseInstance: (courseInstanceID, options) ->
options = _.extend({
url: "/db/course_instance/#{courseInstanceID}/my-course-level-sessions"
}, options)
@fetch(options)
2016-03-30 16:57:19 -04:00
fetchForClassroomMembers: (classroomID, options) ->
# Params: memberSkip, memberLimit
options = _.extend({
url: "/db/classroom/#{classroomID}/member-sessions"
}, options)
@fetch(options)
fetchForAllClassroomMembers: (classroom, options={}) ->
limit = 10
skip = 0
size = _.size(classroom.get('members'))
options.data ?= {}
options.data.memberLimit = limit
options.remove = false
jqxhrs = []
while skip < size
options = _.cloneDeep(options)
options.data.memberSkip = skip
jqxhrs.push(@fetchForClassroomMembers(classroom.id, options))
skip += limit
return jqxhrs