mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-03-23 19:32:03 -04:00
Improve StudentCoursesView
* Add alert explaining when a user joins a course, and links directly to the course * Add header to My Courses list * Have My Courses list sorted by classroom creation then course creation
This commit is contained in:
parent
4561ff42ce
commit
a0212da789
2 changed files with 18 additions and 0 deletions
|
@ -20,12 +20,28 @@ block content
|
||||||
|
|
||||||
if view.state === 'unknown_error'
|
if view.state === 'unknown_error'
|
||||||
.alert.alert-danger= view.stateMessage
|
.alert.alert-danger= view.stateMessage
|
||||||
|
|
||||||
|
- var justJoinedCourseInstance = view.courseInstances.find(function(ci) { return ci.justJoined; });
|
||||||
|
if justJoinedCourseInstance
|
||||||
|
- var course = view.courses.get(justJoinedCourseInstance.get('courseID'));
|
||||||
|
- var classroom = view.classrooms.get(justJoinedCourseInstance.get('classroomID'));
|
||||||
|
if course && classroom
|
||||||
|
.alert.alert-info
|
||||||
|
span.spr Successfully joined "#{classroom.get('name')}"!
|
||||||
|
a(href="/courses/#{course.id}/#{justJoinedCourseInstance.id}")
|
||||||
|
strong Click here to start taking "#{course.get('name')}".
|
||||||
|
|
||||||
.panel.panel-default
|
.panel.panel-default
|
||||||
.panel-heading
|
.panel-heading
|
||||||
.panel-title My Courses
|
.panel-title My Courses
|
||||||
|
|
||||||
.list-group
|
.list-group
|
||||||
|
.list-group-item
|
||||||
|
.row
|
||||||
|
.col-sm-3
|
||||||
|
strong Classroom
|
||||||
|
.col-sm-3
|
||||||
|
strong Course
|
||||||
for courseInstance in view.courseInstances.models
|
for courseInstance in view.courseInstances.models
|
||||||
- var classroom = view.classrooms.get(courseInstance.get('classroomID'))
|
- var classroom = view.classrooms.get(courseInstance.get('classroomID'))
|
||||||
- var course = view.courses.get(courseInstance.get('courseID'))
|
- var course = view.courses.get(courseInstance.get('courseID'))
|
||||||
|
|
|
@ -22,6 +22,7 @@ module.exports = class StudentCoursesView extends RootView
|
||||||
constructor: (options) ->
|
constructor: (options) ->
|
||||||
super(options)
|
super(options)
|
||||||
@courseInstances = new CocoCollection([], { url: "/db/user/#{me.id}/course_instances", model: CourseInstance})
|
@courseInstances = new CocoCollection([], { url: "/db/user/#{me.id}/course_instances", model: CourseInstance})
|
||||||
|
@courseInstances.comparator = (ci) -> return ci.get('classroomID') + ci.get('courseID')
|
||||||
@supermodel.loadCollection(@courseInstances, 'course_instances')
|
@supermodel.loadCollection(@courseInstances, 'course_instances')
|
||||||
@classrooms = new CocoCollection([], { url: "/db/classroom", model: Classroom })
|
@classrooms = new CocoCollection([], { url: "/db/classroom", model: Classroom })
|
||||||
@supermodel.loadCollection(@classrooms, 'classrooms', { data: {memberID: me.id} })
|
@supermodel.loadCollection(@classrooms, 'classrooms', { data: {memberID: me.id} })
|
||||||
|
@ -85,6 +86,7 @@ module.exports = class StudentCoursesView extends RootView
|
||||||
context: @
|
context: @
|
||||||
success: (data) ->
|
success: (data) ->
|
||||||
@courseInstances.add(data)
|
@courseInstances.add(data)
|
||||||
|
@courseInstances.get(data._id).justJoined = true
|
||||||
})
|
})
|
||||||
$.when(jqxhrs...).done =>
|
$.when(jqxhrs...).done =>
|
||||||
@state = ''
|
@state = ''
|
||||||
|
|
Loading…
Add table
Reference in a new issue