From 30c879ddc0d40570d2358baf57b17607d2cbe169 Mon Sep 17 00:00:00 2001 From: Josh Callebaut Date: Fri, 29 Apr 2016 15:58:30 -0700 Subject: [PATCH] Fix bug with Solution Problem View's problem count; add start of Course Gear View --- app/core/Router.coffee | 1 + app/styles/artisans/courseGearView.sass | 0 app/templates/artisans/artisansView.jade | 8 +- app/templates/artisans/courseGearView.jade | 3 + app/views/artisans/CourseGearView.coffee | 16 ++++ .../artisans/SolutionProblemsView.coffee | 86 +++++++++++++------ 6 files changed, 87 insertions(+), 27 deletions(-) create mode 100644 app/styles/artisans/courseGearView.sass create mode 100644 app/templates/artisans/courseGearView.jade create mode 100644 app/views/artisans/CourseGearView.coffee diff --git a/app/core/Router.coffee b/app/core/Router.coffee index 830aa5f9e..64ba4535e 100644 --- a/app/core/Router.coffee +++ b/app/core/Router.coffee @@ -46,6 +46,7 @@ module.exports = class CocoRouter extends Backbone.Router 'artisans': go('artisans/ArtisansView') 'artisans/solution-problems': go('artisans/SolutionProblemsView') + 'artisans/course-gear': go('artisans/CourseGearView') 'artisans/level-tasks': go('artisans/LevelTasksView') 'artisans/thang-tasks': go('artisans/ThangTasksView') diff --git a/app/styles/artisans/courseGearView.sass b/app/styles/artisans/courseGearView.sass new file mode 100644 index 000000000..e69de29bb diff --git a/app/templates/artisans/artisansView.jade b/app/templates/artisans/artisansView.jade index 0cf81943f..7d5becb36 100644 --- a/app/templates/artisans/artisansView.jade +++ b/app/templates/artisans/artisansView.jade @@ -7,4 +7,10 @@ block content |Thang Tasks div a(href="artisans/level-tasks") - |Level Tasks \ No newline at end of file + |Level Tasks + div + a(href="artisans/solution-problems") + |Solution Problems + div + a(href="artisans/course-gear") + |Course Gear Progression \ No newline at end of file diff --git a/app/templates/artisans/courseGearView.jade b/app/templates/artisans/courseGearView.jade new file mode 100644 index 000000000..5b40f96a0 --- /dev/null +++ b/app/templates/artisans/courseGearView.jade @@ -0,0 +1,3 @@ +extends /templates/base + +block content \ No newline at end of file diff --git a/app/views/artisans/CourseGearView.coffee b/app/views/artisans/CourseGearView.coffee new file mode 100644 index 000000000..838b33d9b --- /dev/null +++ b/app/views/artisans/CourseGearView.coffee @@ -0,0 +1,16 @@ +RootView = require 'views/core/RootView' +template = require 'templates/artisans/courseGearView' +Level = require 'models/Level' +Campaign = require 'models/Campaign' +Level = require 'models/Level' +CocoCollection = require 'collections/CocoCollection' + +module.exports = class CourseGearView extends RootView + template: template + id: 'course-gear-view' + initialize: -> + @campaigns = new CocoCollection([], + url: '/db/campaign?project=slug' + model: Campaign + ) + @supermodel.trackRequest(@campaigns.fetch()) \ No newline at end of file diff --git a/app/views/artisans/SolutionProblemsView.coffee b/app/views/artisans/SolutionProblemsView.coffee index 4ec2030db..cdd76bb30 100644 --- a/app/views/artisans/SolutionProblemsView.coffee +++ b/app/views/artisans/SolutionProblemsView.coffee @@ -12,29 +12,46 @@ module.exports = class SolutionProblemsView extends RootView "picoctf" "auditions" - # "dungeon" - # "forest" - # "desert" - # "mountain" - # "glacier" + #"dungeon" + #"forest" + #"desert" + #"mountain" + #"glacier" "dungeon-branching-test" "forest-branching-test" "desert-branching-test" - "intro" - "course-2" - "course-3" - "course-4" - "course-5" - "course-6" + #"intro" + #"course-2" + #"course-3" + #"course-4" + #"course-5" + #"course-6" ] excludedSimulationLevels = [ + # Course Arenas "wakka-maul" "cross-bones" ] + excludedSolutionLevels = [ + # Multiplayer Levels + "cavern-survival" + + "dueling-grounds" + "multiplayer-treasure-grove" + + "harrowland" + + "zero-sum" + + "ace-of-coders" + "capture-their-flag" + ] levelOffset: 0 isReady: 0 + requiresSubs: 0 + rob: [] constructor: (options) -> super options @campaigns = new CocoCollection([], @@ -63,13 +80,15 @@ module.exports = class SolutionProblemsView extends RootView continue unless excludedCampaigns.indexOf(campaign.get 'slug') is -1 count++ @test[campaign.get('slug')] = new CocoCollection([], - url: '/db/campaign/' + campaign.get('slug') + '/levels?project=thangs,slug' + url: '/db/campaign/' + campaign.get('slug') + '/levels?project=thangs,slug,requiresSubscription' model: Level ) @test[campaign.get('slug')].fetch() @listenTo(@test[campaign.get('slug')], 'sync', (e) -> #@loadedLevels = _uniq(_.union(@loadedLevels, e.models)) for level in e.models + if not @loadedLevels[level.get('slug')]? and level.get('requiresSubscription') + @requiresSubs++ @loadedLevels[level.get('slug')] = level count-- if count is 0 @@ -79,6 +98,7 @@ module.exports = class SolutionProblemsView extends RootView readyUp: -> console.log("Count of levels: " + _.size(@loadedLevels)) + console.log("Count requires sub: " + @requiresSubs) @parsedLevels = [] @problemCount = 0 @@ -94,6 +114,14 @@ module.exports = class SolutionProblemsView extends RootView return true ) ) + thangs = _.filter(thangs, (elem) -> + return _.findWhere(elem.components, (elem2) -> + if elem2.config?.programmableMethods? + return true + ) + ) + if thangs.length > 1 + console.log levelSlug + ":" + thangs.length + " " + thangs.map((elem) -> return elem.id) unless thang? and component console.log("Cannot find programmableMethods component in: " + levelSlug) continue @@ -105,37 +133,43 @@ module.exports = class SolutionProblemsView extends RootView problems = [] + if excludedSolutionLevels.indexOf(levelSlug) is -1 + for lang in ["python", "javascript", "lua", "java"] + if _.findWhere(solutions, (elem) -> return elem.language is lang) + @rob.push language: lang, level: levelSlug + else if lang not in ["lua", "java"] + problems.push { + "type":"Missing Solution Language", + "value":lang + } + @problemCount++ + else + # monitor lua/java when we care about it here - for lang in ["python", "javascript"] - unless _.findWhere(solutions, (elem) -> return elem.language is lang) - problems.push { - "type":"Missing Solution Language", - "value":lang - } - for solutionIndex of solutions solution = solutions[solutionIndex] if excludedSimulationLevels.indexOf(levelSlug) is -1 - for req in ["seed", "succeeds", "heroConfig", 'lastHash', 'frameCount', 'goals'] + for req in ["seed", "succeeds", "heroConfig", 'frameCount', 'goals'] # Implement a fix for lastHash unless solution[req]? + console.log levelSlug, req problems.push { "type":"Solution is not simulatable", "value":solution.language } @problemCount++ break - if solution.source.indexOf("<%=") is -1 - problems.push { - "type":"Solution is not i18n'd", - "value":solution.language - } - @problemCount++ if solution.source.indexOf("pass") isnt -1 problems.push { "type":"Solution contains pass", "value":solution.language } @problemCount++ + if solution.source.indexOf("<%=") is -1 + problems.push { + "type":"Solution is not i18n'd", + "value":solution.language + } + @problemCount++ if solution.language is 'javascript' if solution.source is plan.source problems.push {