mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 17:45:40 -05:00
Default Play to /hoc route during Hour of Code week
This commit is contained in:
parent
417d4802ee
commit
16b1928fdb
2 changed files with 19 additions and 5 deletions
|
@ -13,7 +13,15 @@ module.exports = class HomeView extends RootView
|
|||
window.tracker?.trackEvent 'Homepage Loaded', category: 'Homepage'
|
||||
if @getQueryVariable 'hour_of_code'
|
||||
application.router.navigate "/hoc", trigger: true
|
||||
if @justPlaysCourses()
|
||||
|
||||
isHourOfCodeWeek = true # Temporary: default to /hoc flow during the main event week
|
||||
if isHourOfCodeWeek and (@isNewPlayer() or (@justPlaysCourses() and me.isAnonymous()))
|
||||
# Go/return straight to playing single-player HoC course on Play click
|
||||
@playURL = '/hoc?go=true'
|
||||
@alternatePlayURL = '/play'
|
||||
@alternatePlayText = 'home.play_campaign_version'
|
||||
else if @justPlaysCourses()
|
||||
# Save players who might be in a classroom from getting into the campaign
|
||||
@playURL = '/courses'
|
||||
@alternatePlayURL = '/play'
|
||||
@alternatePlayText = 'home.play_campaign_version'
|
||||
|
@ -44,3 +52,6 @@ module.exports = class HomeView extends RootView
|
|||
justPlaysCourses: ->
|
||||
# This heuristic could be better, but currently we don't add to me.get('courseInstances') for single-player anonymous intro courses, so they have to beat a level without choosing a hero.
|
||||
return me.get('stats')?.gamesCompleted and not me.get('heroConfig')
|
||||
|
||||
isNewPlayer: ->
|
||||
not me.get('stats')?.gamesCompleted and not me.get('heroConfig')
|
||||
|
|
|
@ -52,7 +52,7 @@ module.exports = class HourOfCodeView extends RootView
|
|||
project: 'name,slug'
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
setUpHourOfCode: ->
|
||||
# If we haven't tracked this player as an hourOfCode player yet, and it's a new account, we do that now.
|
||||
elapsed = new Date() - new Date(me.get('dateCreated'))
|
||||
|
@ -62,6 +62,10 @@ module.exports = class HourOfCodeView extends RootView
|
|||
$('body').append($('<img src="https://code.org/api/hour/begin_codecombat.png" style="visibility: hidden;">'))
|
||||
application.tracker?.trackEvent 'Hour of Code Begin'
|
||||
|
||||
afterRender: ->
|
||||
super()
|
||||
@onClickStartNewGameButton() if @getQueryVariable('go') and not @lastLevel
|
||||
|
||||
onClickStartNewGameButton: ->
|
||||
# user without hour of code course instance, creates one, starts playing
|
||||
modal = new ChooseLanguageModal({
|
||||
|
@ -69,7 +73,7 @@ module.exports = class HourOfCodeView extends RootView
|
|||
})
|
||||
@openModalView(modal)
|
||||
@listenToOnce modal, 'set-language', @startHourOfCodePlay
|
||||
|
||||
|
||||
continuePlayingLink: ->
|
||||
ci = @hourOfCodeCourseInstance
|
||||
"/play/level/#{@lastLevel.get('slug')}?course=#{ci.get('courseID')}&course-instance=#{ci.id}"
|
||||
|
@ -93,5 +97,4 @@ module.exports = class HourOfCodeView extends RootView
|
|||
@openModalView(modal)
|
||||
|
||||
onClickLogOutLink: ->
|
||||
auth.logoutUser()
|
||||
|
||||
auth.logoutUser()
|
||||
|
|
Loading…
Reference in a new issue