mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-03-14 07:00:01 -04:00
parent
cdba1788e7
commit
61be34a0f4
6 changed files with 43 additions and 44 deletions
|
@ -18,6 +18,17 @@ module.exports.combineAncestralObject = (obj, propertyName) ->
|
|||
obj = Object.getPrototypeOf(obj)
|
||||
combined
|
||||
|
||||
module.exports.courseIDs = courseIDs =
|
||||
INTRODUCTION_TO_COMPUTER_SCIENCE: '560f1a9f22961295f9427742'
|
||||
COMPUTER_SCIENCE_2: '5632661322961295f9428638'
|
||||
GAME_DEVELOPMENT_1: '5789587aad86a6efb573701e'
|
||||
WEB_DEVELOPMENT_1: '5789587aad86a6efb573701f'
|
||||
COMPUTER_SCIENCE_3: '56462f935afde0c6fd30fc8c'
|
||||
GAME_DEVELOPMENT_2: '57b621e7ad86a6efb5737e64'
|
||||
WEB_DEVELOPMENT_2: '5789587aad86a6efb5737020'
|
||||
COMPUTER_SCIENCE_4: '56462f935afde0c6fd30fc8d'
|
||||
COMPUTER_SCIENCE_5: '569ed916efa72b0ced971447'
|
||||
|
||||
module.exports.normalizeFunc = (func_thing, object) ->
|
||||
# func could be a string to a function in this class
|
||||
# or a function in its own right
|
||||
|
@ -382,6 +393,24 @@ module.exports.findNextLevel = (levels, currentIndex, needsPractice) ->
|
|||
module.exports.needsPractice = (playtime=0, threshold=2) ->
|
||||
playtime / 60 > threshold
|
||||
|
||||
module.exports.sortCourses = (courses) ->
|
||||
orderedIDs = [
|
||||
courseIDs.INTRODUCTION_TO_COMPUTER_SCIENCE
|
||||
courseIDs.COMPUTER_SCIENCE_2
|
||||
courseIDs.GAME_DEVELOPMENT_1
|
||||
courseIDs.WEB_DEVELOPMENT_1
|
||||
courseIDs.COMPUTER_SCIENCE_3
|
||||
courseIDs.GAME_DEVELOPMENT_2
|
||||
courseIDs.WEB_DEVELOPMENT_2
|
||||
courseIDs.COMPUTER_SCIENCE_4
|
||||
courseIDs.COMPUTER_SCIENCE_5
|
||||
]
|
||||
_.sortBy courses, (course) ->
|
||||
# ._id can be from classroom.courses, otherwise it's probably .id
|
||||
index = orderedIDs.indexOf(course.id ? course._id)
|
||||
index = 9001 if index is -1
|
||||
index
|
||||
|
||||
module.exports.usStateCodes =
|
||||
# https://github.com/mdzhang/us-state-codes
|
||||
# generated by js2coffee 2.2.0
|
||||
|
@ -481,3 +510,4 @@ module.exports.usStateCodes =
|
|||
getStateCodeByStateName: getStateCodeByStateName
|
||||
}
|
||||
)()
|
||||
|
||||
|
|
|
@ -186,6 +186,9 @@ module.exports = class Classroom extends CocoModel
|
|||
options.type = 'POST'
|
||||
@fetch(options)
|
||||
|
||||
getSortedCourses: ->
|
||||
utils.sortCourses(@get('courses') ? [])
|
||||
|
||||
updateCourses: (options={}) ->
|
||||
options.url = @url() + '/update-courses'
|
||||
options.type = 'POST'
|
||||
|
|
|
@ -220,9 +220,9 @@ mixin studentRow(student)
|
|||
+longLevelName(student.latestCompleteLevel)
|
||||
td
|
||||
if state.get('progressData')
|
||||
- var courses = view.classroom.get('courses').map(function(c) { return view.courses.get(c._id); });
|
||||
- var courses = view.sortedCourses.map(function(c) { return view.courses.get(c._id); });
|
||||
- var courseLabelsArray = view.helper.courseLabelsArray(courses);
|
||||
each trimCourse, index in view.classroom.get('courses')
|
||||
each trimCourse, index in view.sortedCourses
|
||||
- var course = view.courses.get(trimCourse._id);
|
||||
- var instance = view.courseInstances.findWhere({ courseID: course.id, classroomID: classroom.id })
|
||||
if instance && instance.hasMember(student)
|
||||
|
@ -255,7 +255,7 @@ mixin courseProgressTab
|
|||
span(data-i18n='teacher.select_course')
|
||||
span.spr :
|
||||
select.course-select
|
||||
each trimCourse in view.classroom.get('courses')
|
||||
each trimCourse in view.sortedCourses
|
||||
- var course = view.courses.get(trimCourse._id);
|
||||
option(value=course.id selected=(course===state.get('selectedCourse')))
|
||||
= i18n(course.attributes, 'name')
|
||||
|
@ -423,7 +423,7 @@ mixin bulkAssignControls
|
|||
span(data-i18n='teacher.bulk_assign')
|
||||
span :
|
||||
select.bulk-course-select.form-control
|
||||
each trimCourse in _.rest(view.classroom.get('courses'))
|
||||
each trimCourse in _.rest(view.sortedCourses)
|
||||
- var course = view.courses.get(trimCourse._id)
|
||||
option(value=course.id selected=(course===state.get('selectedCourse')))
|
||||
= i18n(course.attributes, 'name')
|
||||
|
|
|
@ -77,7 +77,7 @@ mixin classRow(classroom)
|
|||
if classroom.get('members').length == 0
|
||||
+addStudentsButton(classroom)
|
||||
else
|
||||
- var courses = classroom.get('courses').map(function(c) { return view.courses.get(c._id); });
|
||||
- var courses = classroom.getSortedCourses().map(function(c) { return view.courses.get(c._id); });
|
||||
- var courseLabelsArray = view.helper.courseLabelsArray(courses);
|
||||
each trimCourse, index in classroom.get('courses') || []
|
||||
- var course = view.courses.get(trimCourse._id);
|
||||
|
|
|
@ -83,6 +83,7 @@ module.exports = class TeacherClassView extends RootView
|
|||
@classroom = new Classroom({ _id: classroomID })
|
||||
@supermodel.trackRequest @classroom.fetch()
|
||||
@onKeyPressStudentSearch = _.debounce(@onKeyPressStudentSearch, 200)
|
||||
@sortedCourses = []
|
||||
|
||||
@students = new Users()
|
||||
@listenTo @classroom, 'sync', ->
|
||||
|
@ -164,6 +165,7 @@ module.exports = class TeacherClassView extends RootView
|
|||
null
|
||||
|
||||
onLoaded: ->
|
||||
@sortedCourses = @classroom.getSortedCourses()
|
||||
@removeDeletedStudents() # TODO: Move this to mediator listeners? For both classroom and students?
|
||||
@calculateProgressAndLevels()
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ mongoose = require 'mongoose'
|
|||
config = require '../../server_config'
|
||||
plugins = require '../plugins/plugins'
|
||||
jsonSchema = require '../../app/schemas/models/course.schema'
|
||||
{sortCourses} = require '../../app/core/utils'
|
||||
|
||||
CourseSchema = new mongoose.Schema {}, {strict: false, minimize: false, read:config.mongo.readpref}
|
||||
|
||||
|
@ -18,45 +19,8 @@ CourseSchema.statics.editableProperties = [
|
|||
CourseSchema.statics.jsonSchema = jsonSchema
|
||||
|
||||
CourseSchema.statics.sortCourses = (courses) ->
|
||||
ordering = [
|
||||
'introduction-to-computer-science'
|
||||
'computer-science-2'
|
||||
'game-dev-1'
|
||||
'game-development-1'
|
||||
'web-dev-1'
|
||||
'web-development-1'
|
||||
'computer-science-3'
|
||||
'game-dev-2'
|
||||
'game-development-2'
|
||||
'web-dev-2'
|
||||
'web-development-2'
|
||||
'computer-science-4'
|
||||
'game-dev-3'
|
||||
'game-development-3'
|
||||
'web-dev-3'
|
||||
'web-development-3'
|
||||
'computer-science-5'
|
||||
'game-dev-4'
|
||||
'game-development-4'
|
||||
'web-dev-4'
|
||||
'web-development-4'
|
||||
'computer-science-6'
|
||||
'game-dev-5'
|
||||
'game-development-5'
|
||||
'web-dev-5'
|
||||
'web-development-5'
|
||||
'computer-science-7'
|
||||
'game-dev-6'
|
||||
'game-development-6'
|
||||
'web-dev-6'
|
||||
'web-development-6'
|
||||
'computer-science-8'
|
||||
]
|
||||
_.sortBy courses, (course) ->
|
||||
index = ordering.indexOf(course.get?('slug') or course.slug)
|
||||
index = 9001 if index is -1
|
||||
index
|
||||
|
||||
sortCourses(courses)
|
||||
|
||||
CourseSchema.post 'init', (doc) ->
|
||||
if !doc.get('i18nCoverage')
|
||||
doc.set('i18nCoverage', [])
|
||||
|
|
Loading…
Reference in a new issue