mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-23 15:48:11 -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
|
||||
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
|
||||
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
|
|
@ -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?
|
||||
|
|
Loading…
Reference in a new issue