mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 09:35:39 -05:00
Group concept map by campaign.
This commit is contained in:
parent
75e3c54d54
commit
6c9f351f01
2 changed files with 51 additions and 42 deletions
|
@ -8,13 +8,17 @@ block content
|
|||
span.glyphicon.glyphicon-chevron-left
|
||||
span Artisans Home
|
||||
br
|
||||
table.table.table-striped#level-table
|
||||
for course, k in (view.data || {})
|
||||
h3= k
|
||||
table.table.table-striped
|
||||
tr
|
||||
th No
|
||||
th Level Name
|
||||
th Concepts Detected
|
||||
for level in (view.parsedLevels || [])
|
||||
for level in course
|
||||
tr
|
||||
td(style="width:10%")= level.level.get('name')
|
||||
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
|
|
@ -37,7 +37,7 @@ module.exports = class LevelConceptMap extends RootView
|
|||
unloadedCampaigns: 0
|
||||
campaignLevels: {}
|
||||
loadedLevels: {}
|
||||
parsedLevels: []
|
||||
data: {}
|
||||
problemCount: 0
|
||||
|
||||
initialize: ->
|
||||
|
@ -55,20 +55,25 @@ 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
|
||||
for campaignSlug, campaign of @loadedLevels
|
||||
for levelSlug, level of campaign
|
||||
unless level?
|
||||
console.error 'Level Slug doesn\'t have associated Level', levelSlug
|
||||
continue
|
||||
|
@ -97,11 +102,11 @@ module.exports = class LevelConceptMap extends RootView
|
|||
continue
|
||||
|
||||
plan = component.config.programmableMethods.plan
|
||||
@parsedLevels.push
|
||||
level: level
|
||||
tags: @tagLevel _.find plan.solutions, (s) -> s.language is 'javascript'
|
||||
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?
|
||||
|
|
Loading…
Reference in a new issue