MCPcopy Create free account
hub / github.com/codecombat/codecombat / onLevelsLoaded

Method onLevelsLoaded

app/views/artisans/LevelGuidesView.js:81–139  ·  view source on GitHub ↗
(lvlCollection)

Source from the content-addressed store, hash-verified

79 // for key, level of levels
80
81 onLevelsLoaded (lvlCollection) {
82 lvlCollection.models.reverse()
83 // console.log lvlCollection
84 for (const level of Array.from(lvlCollection.models)) {
85 // console.log level
86 let jsIndex, pyIndex
87 const overview = _.find(level.get('documentation').specificArticles, { name: 'Overview' })
88 const intro = _.find(level.get('documentation').specificArticles, { name: 'Intro' })
89 // if intro and overview
90 const problems = []
91 if (!overview) {
92 problems.push('No Overview')
93 } else {
94 if (!overview.i18n) {
95 problems.push('Overview doesn\'t have i18n field')
96 }
97 if (!overview.body) {
98 problems.push('Overview doesn\'t have a body')
99 } else {
100 if (__guard__(level.get('campaign'), x => x.indexOf('web')) === -1) {
101 jsIndex = overview.body.indexOf('```javascript')
102 pyIndex = overview.body.indexOf('```python')
103 if (((jsIndex === -1) && (pyIndex !== -1)) || ((jsIndex !== -1) && (pyIndex === -1))) {
104 problems.push('Overview is missing a language example.')
105 }
106 }
107 }
108 }
109 if (!intro) {
110 problems.push('No Intro')
111 } else {
112 if (!intro.i18n) {
113 problems.push('Intro doesn\'t have i18n field')
114 }
115 if (!intro.body) {
116 problems.push('Intro doesn\'t have a body')
117 } else {
118 if (intro.body.indexOf('file/db') === -1) {
119 problems.push('Intro is missing image')
120 }
121 if (__guard__(level.get('campaign'), x1 => x1.indexOf('web')) === -1) {
122 jsIndex = intro.body.indexOf('```javascript')
123 pyIndex = intro.body.indexOf('```python')
124 if (((jsIndex === -1) && (pyIndex !== -1)) || ((jsIndex !== -1) && (pyIndex === -1))) {
125 problems.push('Intro is missing a language example.')
126 }
127 }
128 }
129 }
130 this.levels.push({
131 level,
132 overview,
133 intro,
134 problems,
135 })
136 this.levels.sort((a, b) => b.problems.length - a.problems.length)
137 }
138 return this.renderSelectors('#level-table')

Callers

nothing calls this directly

Calls 2

__guard__Function · 0.70
getMethod · 0.45

Tested by

no test coverage detected