mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-12-02 20:07:25 -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
|
@schema: schema
|
||||||
urlRoot: '/db/course_instance'
|
urlRoot: '/db/course_instance'
|
||||||
|
|
||||||
createForHOC: ->
|
upsertForHOC: (opts) ->
|
||||||
# encapsulates creating a special course instance for HoC
|
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
|
#courses-view
|
||||||
.row
|
h1
|
||||||
margin-top: 40px
|
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
|
extends /templates/base
|
||||||
|
|
||||||
block content
|
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
|
#main-content
|
||||||
.col-sm-6.text-center
|
if me.isAnonymous()
|
||||||
a(href="/courses/students").btn.btn-default Students Click Here
|
.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")
|
||||||
|
|
||||||
.col-sm-6.text-center
|
h3#play-now-to-learn-header.text-center PLAY NOW TO LEARN
|
||||||
a(href="/courses/teachers").btn.btn-default Teachers Click Here
|
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
|
#errors-alert.alert.alert-danger.hide
|
||||||
|
|
||||||
.text-center
|
.text-center
|
||||||
if view.willPlayMode
|
if view.willPlay
|
||||||
input#sign-up-btn.btn.btn-default(type="submit", value="Start Playing")
|
input#sign-up-btn.btn.btn-default(type="submit", value="Start Playing")
|
||||||
p
|
p
|
||||||
a#skip-link Skip this, I'll create an account later!
|
a#skip-link Skip this, I'll create an account later!
|
||||||
|
|
|
@ -2,7 +2,36 @@ app = require 'core/application'
|
||||||
AuthModal = require 'views/core/AuthModal'
|
AuthModal = require 'views/core/AuthModal'
|
||||||
RootView = require 'views/core/RootView'
|
RootView = require 'views/core/RootView'
|
||||||
template = require 'templates/courses/courses-view'
|
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
|
module.exports = class CoursesView extends RootView
|
||||||
id: 'courses-view'
|
id: 'courses-view'
|
||||||
template: template
|
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: ->
|
startHourOfCodePlay: ->
|
||||||
@$('#main-content').hide()
|
@$('#main-content').hide()
|
||||||
@$('#begin-hoc-area').removeClass('hide')
|
@$('#begin-hoc-area').removeClass('hide')
|
||||||
$.ajax({
|
hocCourseInstance = new CourseInstance()
|
||||||
method: 'POST'
|
hocCourseInstance.upsertForHOC()
|
||||||
url: '/db/course_instance/-/create-for-hoc'
|
@listenToOnce hocCourseInstance, 'sync', ->
|
||||||
context: @
|
url = hocCourseInstance.firstLevelURL()
|
||||||
success: (data) ->
|
app.router.navigate(url, { trigger: true })
|
||||||
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 })
|
|
||||||
})
|
|
||||||
|
|
||||||
onClickLogInButton: ->
|
onClickLogInButton: ->
|
||||||
modal = new StudentLogInModal()
|
modal = new StudentLogInModal()
|
||||||
|
|
|
@ -16,10 +16,11 @@ module.exports = class StudentSignUpModal extends ModalView
|
||||||
|
|
||||||
initialize: (options) ->
|
initialize: (options) ->
|
||||||
options ?= {}
|
options ?= {}
|
||||||
|
@willPlay = options.willPlay
|
||||||
|
|
||||||
onClickSkipLink: ->
|
onClickSkipLink: ->
|
||||||
@trigger 'click-skip-link' # defer to view that opened this modal
|
@trigger 'click-skip-link' # defer to view that opened this modal
|
||||||
@hide()
|
@hide?()
|
||||||
|
|
||||||
onSubmitForm: (e) ->
|
onSubmitForm: (e) ->
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|
Loading…
Reference in a new issue