From 77e45072a53d2cdd2d81ee66b087dc8304ca0df7 Mon Sep 17 00:00:00 2001 From: Scott Erickson Date: Thu, 1 Sep 2016 10:33:43 -0700 Subject: [PATCH] Remove justPlayCourses heuristic, replace with isStudent, remove old HomeView --- app/core/Router.coffee | 2 - app/models/User.coffee | 5 -- app/templates/home-view.jade | 52 ------------------- app/templates/new-home-view.jade | 2 +- app/templates/user/email-verified-view.jade | 2 +- app/views/HomeView.coffee | 55 --------------------- app/views/NewHomeView.coffee | 4 +- 7 files changed, 4 insertions(+), 118 deletions(-) delete mode 100644 app/templates/home-view.jade delete mode 100644 app/views/HomeView.coffee diff --git a/app/core/Router.coffee b/app/core/Router.coffee index ddbda09fd..1a499bf6e 100644 --- a/app/core/Router.coffee +++ b/app/core/Router.coffee @@ -54,8 +54,6 @@ module.exports = class CocoRouter extends Backbone.Router 'artisans/level-concepts': go('artisans/LevelConceptMap') 'artisans/level-guides': go('artisans/LevelGuidesView') - 'beta': go('HomeView') - 'careers': => window.location.href = 'https://jobs.lever.co/codecombat' 'Careers': => window.location.href = 'https://jobs.lever.co/codecombat' diff --git a/app/models/User.coffee b/app/models/User.coffee index 35f62b3ae..1e63b65b5 100644 --- a/app/models/User.coffee +++ b/app/models/User.coffee @@ -81,11 +81,6 @@ module.exports = class User extends CocoModel isTeacher: -> return @get('role') in ['teacher', 'technology coordinator', 'advisor', 'principal', 'superintendent', 'parent'] - 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 true if me.get('role') is 'student' - return me.get('stats')?.gamesCompleted and not me.get('heroConfig') - isSessionless: -> # TODO: Fix old users who got mis-tagged as teachers # TODO: Should this just be isTeacher, eventually? diff --git a/app/templates/home-view.jade b/app/templates/home-view.jade deleted file mode 100644 index 75da07cb7..000000000 --- a/app/templates/home-view.jade +++ /dev/null @@ -1,52 +0,0 @@ -extends /templates/base - -block append site_nav - #kids-coding-container - img#boy-coding.kid-coding(src="/images/pages/home/boy_coding.png", alt="", draggable="false") - img#girl-coding.kid-coding(src="/images/pages/home/girl_coding.png", alt="", draggable="false") - -block outer_content - #spacer - - 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") - // - //a(href="https://itunes.apple.com/us/app/codecombat/id936523909?mt=8") - // img(src="/images/pages/home/app_store_badge.svg")#apple-store-button - - //- Example of how to throw down a temporary news link - //- #news - //- a(href="/play/ladder/ace-of-coders", data-i18n="temp.ace_of_coders_tournament") New: play in the Ace of Coders tournament now! - - #slogan(data-i18n="home.slogan") - - //- TODO: This does not work on IE8 - .alert.alert-danger.lt-ie9 - strong(data-i18n="home.no_ie") CodeCombat does not run in Internet Explorer 8 or older. Sorry! - - if view.isIPadBrowser() || view.isMobile() - .alert.alert-danger.mobile - strong(data-i18n="home.no_mobile") CodeCombat wasn't designed for mobile devices and may not work! - else if view.isOldBrowser() - .alert.alert-danger.old-browser - strong(data-i18n="home.old_browser") Uh oh, your browser is too old to run CodeCombat. Sorry! - br - span(data-i18n="home.old_browser_suffix") You can try anyway, but it probably won't work. - - if view.withTeacherNote - .style-flat - .bg-navy - a#close-teacher-note-link.glyphicon.glyphicon-remove.pull-right - h3 Teachers! - h4 Want the most engaging way to teach programming at your school? - .text-center - a.btn.btn-primary-alt.btn-lg(href="/teachers/quote") Request a Quote - h6 - a.small(href="/schools") Learn More - \ No newline at end of file diff --git a/app/templates/new-home-view.jade b/app/templates/new-home-view.jade index d81ae6bc2..be7851e7c 100644 --- a/app/templates/new-home-view.jade +++ b/app/templates/new-home-view.jade @@ -22,7 +22,7 @@ mixin box h6(data-i18n="new_home.want_coco") button.btn.btn-primary.btn-lg.request-demo(data-event-action="Homepage Request Demo CTA", data-i18n="new_home.request_demo") - else if me.justPlaysCourses() + else if me.isStudent() div a.btn.btn-forest.btn-lg.btn-block.play-btn(href=view.playURL, data-event-action="Homepage Classroom Continue Playing CTA", data-i18n="courses.continue_playing") div diff --git a/app/templates/user/email-verified-view.jade b/app/templates/user/email-verified-view.jade index cdd0bb6bf..b17207b12 100644 --- a/app/templates/user/email-verified-view.jade +++ b/app/templates/user/email-verified-view.jade @@ -15,7 +15,7 @@ block content else if view.user.isTeacher() a.btn.btn-lg.btn-forest(href="/teachers/classes") span(data-i18n="new_home.goto_classes") - else if me.justPlaysCourses() + else if me.isStudent() div.m-b-1 a.btn.btn-forest.btn-lg(href="/courses", data-i18n="courses.continue_playing") div diff --git a/app/views/HomeView.coffee b/app/views/HomeView.coffee deleted file mode 100644 index ab70e9eae..000000000 --- a/app/views/HomeView.coffee +++ /dev/null @@ -1,55 +0,0 @@ -RootView = require 'views/core/RootView' -template = require 'templates/home-view' -CreateAccountModal = require 'views/core/CreateAccountModal' - -module.exports = class HomeView extends RootView - id: 'home-view' - template: template - - events: - 'click #play-button': 'onClickPlayButton' - 'click #close-teacher-note-link': 'onClickCloseTeacherNoteLink' - - constructor: (options={}) -> - super() - @withTeacherNote = options.withTeacherNote - window.tracker?.trackEvent 'Homepage Loaded', category: 'Homepage' - if @getQueryVariable 'hour_of_code' - application.router.navigate "/hoc", trigger: true - - isHourOfCodeWeek = false # 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' - 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' - window.open '/play', '_blank' - - afterInsert: -> - super(arguments...) - modal = new CreateAccountModal() - @openModalView(modal) - - 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') - - onClickCloseTeacherNoteLink: -> - @$('.style-flat').addClass('hide') diff --git a/app/views/NewHomeView.coffee b/app/views/NewHomeView.coffee index cddba6ce4..b9ff0d865 100644 --- a/app/views/NewHomeView.coffee +++ b/app/views/NewHomeView.coffee @@ -45,12 +45,12 @@ module.exports = class NewHomeView extends RootView @supermodel.loadCollection(@trialRequests) isHourOfCodeWeek = false # Temporary: default to /hoc flow during the main event week - if isHourOfCodeWeek and (@isNewPlayer() or (me.justPlaysCourses() and me.isAnonymous())) + if isHourOfCodeWeek and (@isNewPlayer() or (me.isStudent() 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 me.justPlaysCourses() + else if me.isStudent() # Save players who might be in a classroom from getting into the campaign @playURL = '/courses' else