MCPcopy Index your code
hub / github.com/codecombat/codecombat / getSolutionForLanguage

Method getSolutionForLanguage

app/models/Level.js:537–554  ·  view source on GitHub ↗
(language)

Source from the content-addressed store, hash-verified

535 }
536
537 getSolutionForLanguage (language) {
538 if (!language) { return '' }
539 const solutions = this.getSolutions()
540 if (this.isType('web-dev')) {
541 const solution = _.find(solutions, { language: 'html', succeeds: true })
542 if (/<playercode>/.test(solution?.source)) {
543 solution.source = utils.extractPlayerCodeTag(solution.source)
544 }
545 if (solution) return solution
546 }
547 let solution = _.find(solutions, { language, succeeds: true })
548 if (solution || language === 'javascript') return solution
549 const jsSolution = _.find(solutions, { language: 'javascript', succeeds: true })
550 if (!jsSolution) return null
551 solution = _.cloneDeep(jsSolution)
552 solution.source = translateUtils.translateJS(jsSolution.source, language)
553 return solution
554 }
555
556 getSampleCodeForLanguage (language) {
557 if (!language) { return '' }

Callers 2

getSolutionCodeFunction · 0.95
practiceLevelDataFunction · 0.95

Calls 2

getSolutionsMethod · 0.95
isTypeMethod · 0.95

Tested by

no test coverage detected