mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-05-04 09:53:55 -04: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
app/views
|
@ -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')
|
||||
|
|
|
@ -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({
|
||||
|
@ -94,4 +98,3 @@ module.exports = class HourOfCodeView extends RootView
|
|||
|
||||
onClickLogOutLink: ->
|
||||
auth.logoutUser()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue