From 6c9f351f010ceded7ff98044199f8ef4dcb9a122 Mon Sep 17 00:00:00 2001 From: Rob Date: Wed, 27 Jul 2016 14:17:37 -0700 Subject: [PATCH] Group concept map by campaign. --- app/templates/artisans/concept-map-view.jade | 22 +++--- app/views/artisans/LevelConceptMap.coffee | 71 +++++++++++--------- 2 files changed, 51 insertions(+), 42 deletions(-) diff --git a/app/templates/artisans/concept-map-view.jade b/app/templates/artisans/concept-map-view.jade index 67156a7d8..50368de79 100644 --- a/app/templates/artisans/concept-map-view.jade +++ b/app/templates/artisans/concept-map-view.jade @@ -8,13 +8,17 @@ block content span.glyphicon.glyphicon-chevron-left span Artisans Home br - table.table.table-striped#level-table - tr - th Level Name - th Concepts Detected - for level in (view.parsedLevels || []) + for course, k in (view.data || {}) + h3= k + table.table.table-striped tr - td(style="width:10%")= level.level.get('name') - td - for tag in (level.tags || []) - span.label.label-primary(style='margin-right: 10px; float: left; line-height: 20px; margin-bottom: 10px')= tag \ No newline at end of file + th No + th Level Name + th Concepts Detected + for level in course + tr + td= level.seqNo + td(style="width:10%")= level.get('name') + td + for tag in (level.tags || []) + span.label.label-primary(style='margin-right: 10px; float: left; line-height: 20px; margin-bottom: 10px')= tag \ No newline at end of file diff --git a/app/views/artisans/LevelConceptMap.coffee b/app/views/artisans/LevelConceptMap.coffee index 97149d251..13c1183c2 100644 --- a/app/views/artisans/LevelConceptMap.coffee +++ b/app/views/artisans/LevelConceptMap.coffee @@ -37,7 +37,7 @@ module.exports = class LevelConceptMap extends RootView unloadedCampaigns: 0 campaignLevels: {} loadedLevels: {} - parsedLevels: [] + data: {} problemCount: 0 initialize: -> @@ -55,53 +55,58 @@ module.exports = class LevelConceptMap extends RootView @unloadedCampaigns++ @campaignLevels[campaignSlug] = new Levels() - @listenTo(@campaignLevels[campaignSlug], 'sync', @onLevelsLoaded) + @listenTo(@campaignLevels[campaignSlug], 'sync', @onLevelsLoaded.bind @, campaignSlug) @supermodel.trackRequest(@campaignLevels[campaignSlug].fetchForCampaign(campaignSlug, data: project: 'thangs,name,slug,campaign' )) - onLevelsLoaded: (lvlCollection) -> - for level in lvlCollection.models - @loadedLevels[level.get('slug')] = level + onLevelsLoaded: (campaignSlug, lvlCollection) -> + for level, k in lvlCollection.models + level.campaign = campaignSlug + @loadedLevels[campaignSlug] = {} unless @loadedLevels[campaignSlug]? + ll = {} unless ll? + level.seqNo = lvlCollection.models.length - k + @loadedLevels[campaignSlug][level.get('slug')] = level if --@unloadedCampaigns is 0 @onAllLevelsLoaded() onAllLevelsLoaded: -> - for levelSlug, level of @loadedLevels - unless level? - console.error 'Level Slug doesn\'t have associated Level', levelSlug - continue + for campaignSlug, campaign of @loadedLevels + for levelSlug, level of campaign + unless level? + console.error 'Level Slug doesn\'t have associated Level', levelSlug + continue - isBad = false - for word in excludedLevelSnippets - if levelSlug.indexOf(word) isnt -1 - isBad = true - continue if isBad - thangs = level.get 'thangs' - component = null - thangs = _.filter(thangs, (elem) -> - return _.findWhere(elem.components, (elem2) -> - if elem2.config?.programmableMethods? - component = elem2 - return true + isBad = false + for word in excludedLevelSnippets + if levelSlug.indexOf(word) isnt -1 + isBad = true + continue if isBad + thangs = level.get 'thangs' + component = null + thangs = _.filter(thangs, (elem) -> + return _.findWhere(elem.components, (elem2) -> + if elem2.config?.programmableMethods? + component = elem2 + return true + ) ) - ) - if thangs.length > 1 - console.warn 'Level has more than 1 programmableMethod Thangs', levelSlug - continue + if thangs.length > 1 + console.warn 'Level has more than 1 programmableMethod Thangs', levelSlug + continue - unless component? - console.error 'Level doesn\'t have programmableMethod Thang', levelSlug - continue + unless component? + console.error 'Level doesn\'t have programmableMethod Thang', levelSlug + continue - plan = component.config.programmableMethods.plan - @parsedLevels.push - level: level - tags: @tagLevel _.find plan.solutions, (s) -> s.language is 'javascript' + plan = component.config.programmableMethods.plan + level.tags = @tagLevel _.find plan.solutions, (s) -> s.language is 'javascript' + @data[campaignSlug] = _.sortBy _.values(@loadedLevels[campaignSlug]), 'seqNo' - @renderSelectors '#level-table' + console.log @render, @loadedLevels + @render() tagLevel: (src) -> return [] if not src?.source?