diff --git a/app/views/HomeView.coffee b/app/views/HomeView.coffee index 2fd1f1af5..377202c93 100644 --- a/app/views/HomeView.coffee +++ b/app/views/HomeView.coffee @@ -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') diff --git a/app/views/courses/HourOfCodeView.coffee b/app/views/courses/HourOfCodeView.coffee index e40daf131..cbff1a060 100644 --- a/app/views/courses/HourOfCodeView.coffee +++ b/app/views/courses/HourOfCodeView.coffee @@ -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($('')) 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()