Play button goes to /courses if that's all the player has played

This commit is contained in:
Nick Winter 2015-11-30 16:43:33 -08:00
parent a8eaa79db3
commit 851e3a092e
6 changed files with 28 additions and 17 deletions

View file

@ -4,6 +4,7 @@
no_ie: "CodeCombat does not run in Internet Explorer 8 or older. Sorry!" # Warning that only shows up in IE8 and older
no_mobile: "CodeCombat wasn't designed for mobile devices and may not work!" # Warning that shows up on mobile devices
play: "Play" # The big play button that opens up the campaign view.
play_campaign_version: "Play Campaign Version" # Shows up under big play button if you only play /courses
old_browser: "Uh oh, your browser is too old to run CodeCombat. Sorry!" # Warning that shows up on really old Firefox/Chrome/Safari
old_browser_suffix: "You can try anyway, but it probably won't work."
ipad_browser: "Bad news: CodeCombat doesn't run on iPad in the browser. Good news: our native iPad app is awaiting Apple approval."

View file

@ -53,7 +53,7 @@
@media screen and ( max-height: 800px )
height: 510px
#play-button, #or-ipad, #apple-store-button, #slogan, .alert, #news, #hour-of-code
#play-button, #or-ipad, #apple-store-button, #slogan, .alert, #news, #hour-of-code, #alternate-play-button
text-align: center
text-transform: uppercase
font-weight: bold
@ -93,6 +93,12 @@
@media screen and ( max-height: 800px )
top: 310px
#alternate-play-button
top: 570px
@media screen and ( max-height: 800px )
top: 330px
#apple-store-button
top: 593px
height: 63px

View file

@ -8,7 +8,11 @@ block append site_nav
block outer_content
#spacer
a#play-button(href="/play", data-i18n="[html]home.play")
a#play-button(href=view.playURL, data-i18n="[html]home.play")
if view.alternatePlayURL
#alternate-play-button
a.btn.btn-illustrated.btn-primary(href=view.alternatePlayURL, data-i18n=view.alternatePlayText)
//a(href="https://itunes.apple.com/us/app/codecombat/id936523909?mt=8")
// #or-ipad(data-i18n="home.or_ipad")
@ -24,8 +28,8 @@ block outer_content
#hour-of-code
h1(data-i18n="home.hoc_title")
div
a.btn.btn-lg.btn-info.btn-class-code(href='/courses/students', data-i18n="home.hoc_class_code")
a.btn.btn-lg.btn-success.btn-enter(href='/hoc', data-i18n="home.hoc_enter")
a.btn.btn-illustrated.btn-lg.btn-primary.btn-class-code(href='/courses/students', data-i18n="home.hoc_class_code")
a.btn.btn-illustrated.btn-lg.btn-success.btn-enter(href='/hoc', data-i18n="home.hoc_enter")
//- #slogan(data-i18n="home.slogan")

View file

@ -13,9 +13,16 @@ 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()
@playURL = '/courses'
@alternatePlayURL = '/play'
@alternatePlayText = 'home.play_campaign_version'
else
@playURL = '/play'
onClickPlayButton: (e) ->
@playSound 'menu-button-click'
return if @playURL isnt '/play'
e.preventDefault()
e.stopImmediatePropagation()
window.tracker?.trackEvent 'Click Play', category: 'Homepage'
@ -33,3 +40,7 @@ module.exports = class HomeView extends RootView
else
console.warn 'no more jquery browser version...'
return false
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')

View file

@ -104,14 +104,6 @@ module.exports = class CampaignView extends RootView
@listenTo me, 'change:earned', -> @renderSelectors('#gems-count')
@listenTo me, 'change:heroConfig', -> @updateHero()
window.tracker?.trackEvent 'Loaded World Map', category: 'World Map', label: @terrain
# If it's a new player who didn't appear to come from Hour of Code, we register her here without setting the hourOfCode property.
# TODO: get rid of all this sometime in November 2015 when code.org/learn updates to the new version for Hour of Code tutorials.
elapsed = (new Date() - new Date(me.get('dateCreated')))
if not trackedHourOfCode and not me.get('hourOfCode') and elapsed < 5 * 60 * 1000
$('body').append($('<img src="https://code.org/api/hour/begin_codecombat.png" style="visibility: hidden;">'))
trackedHourOfCode = true
@requiresSubscription = not me.isPremium()
destroy: ->

View file

@ -193,10 +193,7 @@ module.exports = class HeroVictoryModal extends ModalView
c.i18n = utils.i18n
elapsed = (new Date() - new Date(me.get('dateCreated')))
isHourOfCode = me.get('hourOfCode') or elapsed < 120 * 60 * 1000
# Later we should only check me.get('hourOfCode'), but for now so much traffic comes in that we just assume it.
# TODO: get rid of said assumption sometime in November 2015 when code.org/learn updates to the new version for Hour of Code tutorials.
if isHourOfCode
if me.get 'hourOfCode'
# Show the Hour of Code "I'm Done" tracking pixel after they played for 20 minutes
lastLevel = @level.get('slug') is 'course-kithgard-gates'
enough = elapsed >= 20 * 60 * 1000 or lastLevel
@ -208,7 +205,7 @@ module.exports = class HeroVictoryModal extends ModalView
me.patch()
window.tracker?.trackEvent 'Hour of Code Finish'
# Show the "I'm done" button between 30 - 120 minutes if they definitely came from Hour of Code
c.showHourOfCodeDoneButton = me.get('hourOfCode') and showDone
c.showHourOfCodeDoneButton = showDone
c.showLeaderboard = @level.get('scoreTypes')?.length > 0 and @level.get('type', true) isnt 'course'