(language)
| 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 '' } |
no test coverage detected