From 53e68a79a67deed2fa0d7f1a37ef0f333f62165d Mon Sep 17 00:00:00 2001 From: Josh Callebaut Date: Thu, 25 Aug 2016 15:31:24 -0700 Subject: [PATCH] Add a page for tracking intro/guide issues --- app/core/Router.coffee | 1 + app/styles/artisans/level-guides-view.sass | 5 + app/templates/artisans/artisans-view.jade | 11 ++- app/templates/artisans/level-guides-view.jade | 36 +++++++ app/views/artisans/LevelGuidesView.coffee | 98 +++++++++++++++++++ 5 files changed, 147 insertions(+), 4 deletions(-) create mode 100644 app/styles/artisans/level-guides-view.sass create mode 100644 app/templates/artisans/level-guides-view.jade create mode 100644 app/views/artisans/LevelGuidesView.coffee diff --git a/app/core/Router.coffee b/app/core/Router.coffee index c083e408d..ddbda09fd 100644 --- a/app/core/Router.coffee +++ b/app/core/Router.coffee @@ -52,6 +52,7 @@ module.exports = class CocoRouter extends Backbone.Router 'artisans/solution-problems': go('artisans/SolutionProblemsView') 'artisans/thang-tasks': go('artisans/ThangTasksView') 'artisans/level-concepts': go('artisans/LevelConceptMap') + 'artisans/level-guides': go('artisans/LevelGuidesView') 'beta': go('HomeView') diff --git a/app/styles/artisans/level-guides-view.sass b/app/styles/artisans/level-guides-view.sass new file mode 100644 index 000000000..d1a2c1975 --- /dev/null +++ b/app/styles/artisans/level-guides-view.sass @@ -0,0 +1,5 @@ +#level-guides-view + .problem + color: red + .level-details + width: 15% \ No newline at end of file diff --git a/app/templates/artisans/artisans-view.jade b/app/templates/artisans/artisans-view.jade index 2f6321319..039e9bd5c 100644 --- a/app/templates/artisans/artisans-view.jade +++ b/app/templates/artisans/artisans-view.jade @@ -6,11 +6,14 @@ block content a(href='/artisans/thang-tasks') |Thang Tasks div - a(href="/artisans/level-tasks") + a(href='/artisans/level-tasks') |Level Tasks div - a(href="/artisans/solution-problems") + a(href='/artisans/solution-problems') |Solution Problems div - a(href="/artisans/level-concepts") - |Level Concept Map \ No newline at end of file + a(href='/artisans/level-concepts') + |Level Concept Map + div + a(href='/artisans/level-guides') + |Level Guides Overview \ No newline at end of file diff --git a/app/templates/artisans/level-guides-view.jade b/app/templates/artisans/level-guides-view.jade new file mode 100644 index 000000000..4de83eafe --- /dev/null +++ b/app/templates/artisans/level-guides-view.jade @@ -0,0 +1,36 @@ +// DNT +extends /templates/base + +block content + div + a(href='/artisans') + span.glyphicon.glyphicon-chevron-left + span Artisans Home + button#overview-button Show Overviews + br + button#intro-button Show Intros + table.table#level-table + for levelObj in (view.levels || []) + - var level = levelObj.level + tr + td.level-details + a(href='http://direct.codecombat.com/editor/level/'+level.get('slug') target="_blank")=level.get('name') + div + ul + for problem in levelObj.problems + li.problem=problem + td(style='width:90%') + .panel.panel-default + .panel-heading + h2.panel-title + a(data-toggle='collapse' href='#'+level.get('slug')+'-overview-collapse') Overview + .panel-collapse.collapse.overview(id=level.get('slug')+'-overview-collapse') + pre=levelObj.overview ? levelObj.overview.body : 'NOPE' + .panel.panel-default + .panel-heading + h2.panel-title + a(data-toggle='collapse' href='#'+level.get('slug')+'-intro-collapse') Intro + .panel-collapse.collapse.intro(id=level.get('slug')+'-intro-collapse') + pre=levelObj.intro ? levelObj.intro.body : 'NOPE' + + \ No newline at end of file diff --git a/app/views/artisans/LevelGuidesView.coffee b/app/views/artisans/LevelGuidesView.coffee new file mode 100644 index 000000000..e0d5b58f7 --- /dev/null +++ b/app/views/artisans/LevelGuidesView.coffee @@ -0,0 +1,98 @@ +RootView = require 'views/core/RootView' +template = require 'templates/artisans/level-guides-view' + +Campaigns = require 'collections/Campaigns' +Campaign = require 'models/Campaign' + +Levels = require 'collections/Levels' +Level = require 'models/Level' + +module.exports = class LevelGuidesView extends RootView + template: template + id: 'level-guides-view' + events: + 'click #overview-button': 'onOverviewButtonClicked' + 'click #intro-button': 'onIntroButtonClicked' + + excludedCampaigns = [ + 'pico-ctf', 'auditions' + ] + includedCampaigns = [ + 'intro', 'course-2', 'course-3', 'course-4', 'course-5', 'course-6', + 'web-dev-1', 'web-dev-2', + 'game-dev-1', 'game-dev-2' + ] + levels: [] + + onOverviewButtonClicked: (e) -> + @$(".overview").toggleClass("in") + onIntroButtonClicked: (e) -> + @$(".intro").toggleClass("in") + + initialize: () -> + + @campaigns = new Campaigns() + + @listenTo(@campaigns, 'sync', @onCampaignsLoaded) + @supermodel.trackRequest(@campaigns.fetch( + data: + project: 'name,slug,levels' + )) + onCampaignsLoaded: (campCollection) -> + for camp in campCollection.models + campaignSlug = camp.get 'slug' + continue if campaignSlug in excludedCampaigns + continue unless campaignSlug in includedCampaigns + levels = camp.get 'levels' + + levels = new Levels() + @listenTo(levels, "sync", @onLevelsLoaded) + levels.fetchForCampaign(campaignSlug) + #for key, level of levels + + onLevelsLoaded: (lvlCollection) -> + lvlCollection.models.reverse() + #console.log lvlCollection + for level in lvlCollection.models + #console.log level + levelSlug = level.get 'slug' + overview = _.find(level.get('documentation').specificArticles, name:"Overview") + intro = _.find(level.get('documentation').specificArticles, name:"Intro") + #if intro and overview + problems = [] + if not overview + problems.push "No Overview" + else + if not overview.i18n + problems.push "Overview doesn't have i18n field" + if not overview.body + problems.push "Overview doesn't have a body" + else + if level.get('campaign')?.indexOf('web') is -1 + jsIndex = overview.body.indexOf('```javascript') + pyIndex = overview.body.indexOf('```python') + if jsIndex is -1 and pyIndex isnt -1 or jsIndex isnt -1 and pyIndex is -1 + problems.push "Overview is missing a language example." + if not intro + problems.push "No Intro" + else + if not intro.i18n + problems.push "Intro doesn't have i18n field" + if not intro.body + problems.push "Intro doesn't have a body" + else + if intro.body.indexOf('file/db') is -1 + problems.push "Intro is missing image" + if level.get('campaign')?.indexOf('web') is -1 + jsIndex = intro.body.indexOf('```javascript') + pyIndex = intro.body.indexOf('```python') + if jsIndex is -1 and pyIndex isnt -1 or jsIndex isnt -1 and pyIndex is -1 + problems.push "Intro is missing a language example." + @levels.push + level: level + overview: overview + intro: intro + problems: problems + @levels.sort (a, b) -> + return b.problems.length - a.problems.length + @renderSelectors '#level-table' \ No newline at end of file