mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-12-18 03:23:42 -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"
|
joining: "Joining class"
|
||||||
course_complete: "Course Complete"
|
course_complete: "Course Complete"
|
||||||
play_arena: "Play Arena"
|
play_arena: "Play Arena"
|
||||||
|
view_project: "View Project"
|
||||||
start: "Start"
|
start: "Start"
|
||||||
last_level: "Last Level"
|
last_level: "Last Level"
|
||||||
welcome_to_hoc: "Adventurers, welcome to our Hour of Code!"
|
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)
|
levels = new Levels(course.levels)
|
||||||
return levels.find (l) -> l.isLadder()
|
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) ->
|
statsForSessions: (sessions, courseID) ->
|
||||||
return null unless sessions
|
return null unless sessions
|
||||||
sessions = sessions.models or sessions
|
sessions = sessions.models or sessions
|
||||||
arena = @getLadderLevel(courseID)
|
arena = @getLadderLevel(courseID)
|
||||||
|
project = @getProjectLevel(courseID)
|
||||||
courseLevels = @getLevels({courseID: courseID, withoutLadderLevels: true})
|
courseLevels = @getLevels({courseID: courseID, withoutLadderLevels: true})
|
||||||
levelSessionMap = {}
|
levelSessionMap = {}
|
||||||
levelSessionMap[session.get('level').original] = session for session in sessions
|
levelSessionMap[session.get('level').original] = session for session in sessions
|
||||||
|
@ -151,6 +160,7 @@ module.exports = class Classroom extends CocoModel
|
||||||
next: nextLevel
|
next: nextLevel
|
||||||
first: courseLevels.first()
|
first: courseLevels.first()
|
||||||
arena: arena
|
arena: arena
|
||||||
|
project: project
|
||||||
playtime: playtime
|
playtime: playtime
|
||||||
stats
|
stats
|
||||||
|
|
||||||
|
|
|
@ -263,6 +263,9 @@ module.exports = class Level extends CocoModel
|
||||||
isLadder: ->
|
isLadder: ->
|
||||||
return @get('type')?.indexOf('ladder') > -1
|
return @get('type')?.indexOf('ladder') > -1
|
||||||
|
|
||||||
|
isProject: ->
|
||||||
|
return @get('shareable') is 'project'
|
||||||
|
|
||||||
isType: (types...) ->
|
isType: (types...) ->
|
||||||
return @get('type', true) in types
|
return @get('type', true) in types
|
||||||
|
|
||||||
|
|
|
@ -110,10 +110,15 @@ mixin course-instance-body(courseInstance, classroom)
|
||||||
.pull-right
|
.pull-right
|
||||||
if stats.levels.done
|
if stats.levels.done
|
||||||
- var arenaLevel = stats.levels.arena;
|
- var arenaLevel = stats.levels.arena;
|
||||||
|
- var projectLevel = stats.levels.project;
|
||||||
if arenaLevel
|
if arenaLevel
|
||||||
- var arenaURL = "/play/ladder/"+arenaLevel.get('slug')+"/course/"+courseInstance.id;
|
- 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")
|
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")
|
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
|
else
|
||||||
a.btn.btn-default.btn-lg.m-b-1(disabled=true, data-i18n="courses.course_complete")
|
a.btn.btn-default.btn-lg.m-b-1(disabled=true, data-i18n="courses.course_complete")
|
||||||
else if stats.levels.next != stats.levels.first
|
else if stats.levels.next != stats.levels.first
|
||||||
|
|
Loading…
Reference in a new issue