mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 17:45:40 -05:00
Set up courses view for anonymous users
This commit is contained in:
parent
f1d4a9d53b
commit
5aff591a8b
7 changed files with 85 additions and 22 deletions
|
@ -6,5 +6,13 @@ module.exports = class CourseInstance extends CocoModel
|
|||
@schema: schema
|
||||
urlRoot: '/db/course_instance'
|
||||
|
||||
createForHOC: ->
|
||||
# encapsulates creating a special course instance for HoC
|
||||
upsertForHOC: (opts) ->
|
||||
options = {
|
||||
url: _.result(@, 'url') + '/~/create-for-hoc'
|
||||
type: 'POST'
|
||||
}
|
||||
_.extend options, opts
|
||||
@fetch(options)
|
||||
|
||||
firstLevelURL: ->
|
||||
"/play/level/course-dungeons-of-kithgard?course=#{@get('courseID')}&course-instance=#{@id}"
|
|
@ -1,3 +1,14 @@
|
|||
#courses-view
|
||||
.row
|
||||
margin-top: 40px
|
||||
h1
|
||||
margin-bottom: 30px
|
||||
|
||||
#play-now-to-learn-header
|
||||
margin-top: 60px
|
||||
|
||||
ul
|
||||
margin: 0 auto 40px
|
||||
width: 320px
|
||||
|
||||
#begin-hoc-area
|
||||
width: 50%
|
||||
margin: 0 auto
|
|
@ -1,12 +1,30 @@
|
|||
extends /templates/base
|
||||
|
||||
block content
|
||||
.pull-right
|
||||
a(href="/teachers") Teachers, click here!
|
||||
|
||||
h1.text-center Welcome to CodeCombat Courses
|
||||
h1.text-center Adventurers, welcome to Courses!
|
||||
|
||||
.row
|
||||
.col-sm-6.text-center
|
||||
a(href="/courses/students").btn.btn-default Students Click Here
|
||||
|
||||
.col-sm-6.text-center
|
||||
a(href="/courses/teachers").btn.btn-default Teachers Click Here
|
||||
#main-content
|
||||
if me.isAnonymous()
|
||||
.text-center
|
||||
p
|
||||
h3 Ready to play?
|
||||
p
|
||||
button#start-new-game-btn.btn.btn-default Start New Game
|
||||
p - OR -
|
||||
p
|
||||
button#log-in-btn.btn.btn-default(data-i18n="login.log_in")
|
||||
|
||||
h3#play-now-to-learn-header.text-center PLAY NOW TO LEARN
|
||||
ul
|
||||
li basic syntax to control your character
|
||||
li while loops to solve pesky puzzles
|
||||
li strings & variables to customize actions
|
||||
li how to defeat an ogre (important life skills!)
|
||||
|
||||
#begin-hoc-area.hide
|
||||
h2.text-center(data-i18n="common.loading")
|
||||
.progress.progress-striped.active
|
||||
.progress-bar(style="width: 100%")
|
|
@ -33,7 +33,7 @@ block modal-body-content
|
|||
#errors-alert.alert.alert-danger.hide
|
||||
|
||||
.text-center
|
||||
if view.willPlayMode
|
||||
if view.willPlay
|
||||
input#sign-up-btn.btn.btn-default(type="submit", value="Start Playing")
|
||||
p
|
||||
a#skip-link Skip this, I'll create an account later!
|
||||
|
|
|
@ -2,7 +2,36 @@ app = require 'core/application'
|
|||
AuthModal = require 'views/core/AuthModal'
|
||||
RootView = require 'views/core/RootView'
|
||||
template = require 'templates/courses/courses-view'
|
||||
StudentLogInModal = require 'views/courses/StudentLogInModal'
|
||||
StudentSignUpModal = require 'views/courses/StudentSignUpModal'
|
||||
CourseInstance = require 'models/CourseInstance'
|
||||
|
||||
module.exports = class CoursesView extends RootView
|
||||
id: 'courses-view'
|
||||
template: template
|
||||
|
||||
events:
|
||||
'click #log-in-btn': 'onClickLogInButton'
|
||||
'click #start-new-game-btn': 'onClickStartNewGameButton'
|
||||
|
||||
onClickStartNewGameButton: ->
|
||||
@openSignUpModal()
|
||||
|
||||
onClickLogInButton: ->
|
||||
modal = new StudentLogInModal()
|
||||
@openModalView(modal)
|
||||
modal.on 'want-to-create-account', @openSignUpModal, @
|
||||
|
||||
openSignUpModal: ->
|
||||
modal = new StudentSignUpModal({ willPlay: true })
|
||||
@openModalView(modal)
|
||||
modal.once 'click-skip-link', @startHourOfCodePlay, @
|
||||
|
||||
startHourOfCodePlay: ->
|
||||
@$('#main-content').hide()
|
||||
@$('#begin-hoc-area').removeClass('hide')
|
||||
hocCourseInstance = new CourseInstance()
|
||||
hocCourseInstance.upsertForHOC()
|
||||
@listenToOnce hocCourseInstance, 'sync', ->
|
||||
url = hocCourseInstance.firstLevelURL()
|
||||
app.router.navigate(url, { trigger: true })
|
||||
|
|
|
@ -77,15 +77,11 @@ module.exports = class HourOfCodeView extends RootView
|
|||
startHourOfCodePlay: ->
|
||||
@$('#main-content').hide()
|
||||
@$('#begin-hoc-area').removeClass('hide')
|
||||
$.ajax({
|
||||
method: 'POST'
|
||||
url: '/db/course_instance/-/create-for-hoc'
|
||||
context: @
|
||||
success: (data) ->
|
||||
application.tracker?.trackEvent 'Finished HoC student course creation', {courseID: data.courseID}
|
||||
url = "/play/level/course-dungeons-of-kithgard?course=#{data.courseID}&course-instance=#{data._id}"
|
||||
app.router.navigate(url, { trigger: true })
|
||||
})
|
||||
hocCourseInstance = new CourseInstance()
|
||||
hocCourseInstance.upsertForHOC()
|
||||
@listenToOnce hocCourseInstance, 'sync', ->
|
||||
url = hocCourseInstance.firstLevelURL()
|
||||
app.router.navigate(url, { trigger: true })
|
||||
|
||||
onClickLogInButton: ->
|
||||
modal = new StudentLogInModal()
|
||||
|
|
|
@ -16,10 +16,11 @@ module.exports = class StudentSignUpModal extends ModalView
|
|||
|
||||
initialize: (options) ->
|
||||
options ?= {}
|
||||
@willPlay = options.willPlay
|
||||
|
||||
onClickSkipLink: ->
|
||||
@trigger 'click-skip-link' # defer to view that opened this modal
|
||||
@hide()
|
||||
@hide?()
|
||||
|
||||
onSubmitForm: (e) ->
|
||||
e.preventDefault()
|
||||
|
|
Loading…
Reference in a new issue