mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-12-17 19:12:33 -05:00
Add View Project buttons to /courses
This commit is contained in:
parent
341154ab31
commit
e91a15338e
4 changed files with 19 additions and 0 deletions
|
@ -1253,6 +1253,7 @@
|
|||
joining: "Joining class"
|
||||
course_complete: "Course Complete"
|
||||
play_arena: "Play Arena"
|
||||
view_project: "View Project"
|
||||
start: "Start"
|
||||
last_level: "Last Level"
|
||||
welcome_to_hoc: "Adventurers, welcome to our Hour of Code!"
|
||||
|
|
|
@ -98,10 +98,19 @@ module.exports = class Classroom extends CocoModel
|
|||
levels = new Levels(course.levels)
|
||||
return levels.find (l) -> l.isLadder()
|
||||
|
||||
getProjectLevel: (courseID) ->
|
||||
Levels = require 'collections/Levels'
|
||||
courses = @get('courses')
|
||||
course = _.findWhere(courses, {_id: courseID})
|
||||
return unless course
|
||||
levels = new Levels(course.levels)
|
||||
return levels.find (l) -> l.isProject()
|
||||
|
||||
statsForSessions: (sessions, courseID) ->
|
||||
return null unless sessions
|
||||
sessions = sessions.models or sessions
|
||||
arena = @getLadderLevel(courseID)
|
||||
project = @getProjectLevel(courseID)
|
||||
courseLevels = @getLevels({courseID: courseID, withoutLadderLevels: true})
|
||||
levelSessionMap = {}
|
||||
levelSessionMap[session.get('level').original] = session for session in sessions
|
||||
|
@ -151,6 +160,7 @@ module.exports = class Classroom extends CocoModel
|
|||
next: nextLevel
|
||||
first: courseLevels.first()
|
||||
arena: arena
|
||||
project: project
|
||||
playtime: playtime
|
||||
stats
|
||||
|
||||
|
|
|
@ -263,6 +263,9 @@ module.exports = class Level extends CocoModel
|
|||
isLadder: ->
|
||||
return @get('type')?.indexOf('ladder') > -1
|
||||
|
||||
isProject: ->
|
||||
return @get('shareable') is 'project'
|
||||
|
||||
isType: (types...) ->
|
||||
return @get('type', true) in types
|
||||
|
||||
|
|
|
@ -110,10 +110,15 @@ mixin course-instance-body(courseInstance, classroom)
|
|||
.pull-right
|
||||
if stats.levels.done
|
||||
- var arenaLevel = stats.levels.arena;
|
||||
- var projectLevel = stats.levels.project;
|
||||
if arenaLevel
|
||||
- var arenaURL = "/play/ladder/"+arenaLevel.get('slug')+"/course/"+courseInstance.id;
|
||||
a.play-btn.btn.btn-burgandy.btn-lg.m-b-1(data-href=arenaURL, data-level-slug=arenaLevel.get('slug'), data-event-action="Students Play Arena")
|
||||
span(data-i18n="courses.play_arena")
|
||||
else if projectLevel
|
||||
- var projectURL = "/play/level/"+projectLevel.get('slug')+"?course="+course.id+"&course-instance="+courseInstance.id;
|
||||
a.play-btn.btn.btn-burgandy.btn-lg.m-b-1(data-href=projectURL, data-level-slug=projectLevel.get('slug'), data-event-action="Students Play Project")
|
||||
span(data-i18n="courses.view_project")
|
||||
else
|
||||
a.btn.btn-default.btn-lg.m-b-1(disabled=true, data-i18n="courses.course_complete")
|
||||
else if stats.levels.next != stats.levels.first
|
||||
|
|
Loading…
Reference in a new issue