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

Method thresholdForScore

app/models/Level.js:590–606  ·  view source on GitHub ↗
({ level, type, score })

Source from the content-addressed store, hash-verified

588 }
589
590 static thresholdForScore ({ level, type, score }) {
591 let levelScoreType, levelScoreTypes
592 if (!(levelScoreTypes = level.scoreTypes)) { return null }
593 if (!(levelScoreType = _.find(levelScoreTypes, { type }))) { return null }
594 for (const threshold of ['gold', 'silver', 'bronze']) {
595 let achieved
596 const thresholdValue = levelScoreType.thresholds[threshold]
597 if (Array.from(LevelConstants.lowerIsBetterScoreTypes).includes(type)) {
598 achieved = score <= thresholdValue
599 } else {
600 achieved = score >= thresholdValue
601 }
602 if (achieved) {
603 return threshold
604 }
605 }
606 }
607
608 isSummative () {
609 return ['open-ended', 'cumulative'].includes(this.get('assessment'))

Callers 1

getTopScoresMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected