(classroom, options)
| 20 | } |
| 21 | |
| 22 | fetchForClassroom (classroom, options) { |
| 23 | if (options == null) { options = {} } |
| 24 | if (options.removeDeleted) { |
| 25 | delete options.removeDeleted |
| 26 | this.listenTo(this, 'sync', this.removeDeletedUsers) |
| 27 | } |
| 28 | const classroomID = classroom.id || classroom |
| 29 | const limit = 10 |
| 30 | let skip = 0 |
| 31 | const size = _.size(classroom.get('members')) |
| 32 | options.url = `/db/classroom/${classroomID}/members` |
| 33 | if (options.data == null) { options.data = {} } |
| 34 | options.data.memberLimit = limit |
| 35 | options.remove = false |
| 36 | const jqxhrs = [] |
| 37 | while (skip < size) { |
| 38 | options = _.cloneDeep(options) |
| 39 | options.data.memberSkip = skip |
| 40 | jqxhrs.push(this.fetch(options)) |
| 41 | skip += limit |
| 42 | } |
| 43 | return jqxhrs |
| 44 | } |
| 45 | |
| 46 | removeDeletedUsers () { |
| 47 | this.remove(this.filter(user => user.get('deleted')) |
no test coverage detected