<commit_before>export const scoreValues = {
  GOLD: 0,
  SILVER: 1,
  BRONZE: 2,
  NONE: 3,
  UNATTEMPTED: 4
};

export function getGemFromChallengeErrors(challengeErrors){
  switch (challengeErrors) {
    case 0:
      return scoreValues.GOLD;
    case 1:
      return scoreValues.SILVER;
    case 2:
      return scoreValues.BRONZE;
    default:
      return scoreValues.NONE;
  }
}

export function getChallengeGem(level, mission, challenge, gems) {
  if (gems[level] && gems[level][mission] && gems[level][mission][challenge] != null) {
    let gemArray = gems[level][mission][challenge];
    return gemArray[gemArray.length-1];     // return last gem
  } else {
    return scoreValues.UNATTEMPTED;
  }
}

export function getMissionGems(level, mission, challengeCount, gems) {
  let challengeScore = [];
  for (let i = 0; i < challengeCount; i++){
    challengeScore.push(getChallengeGem(level, mission, i, gems));
  }
  return challengeScore;
}

export function isPassingGem(score) {
  return score <= scoreValues.BRONZE;
}<commit_msg>Black gems count as passing without gating<commit_after>export const scoreValues = {
  GOLD: 0,
  SILVER: 1,
  BRONZE: 2,
  NONE: 3,
  UNATTEMPTED: 4
};

export function getGemFromChallengeErrors(challengeErrors){
  switch (challengeErrors) {
    case 0:
      return scoreValues.GOLD;
    case 1:
      return scoreValues.SILVER;
    case 2:
      return scoreValues.BRONZE;
    default:
      return scoreValues.NONE;
  }
}

export function getChallengeGem(level, mission, challenge, gems) {
  if (gems[level] && gems[level][mission] && gems[level][mission][challenge] != null) {
    let gemArray = gems[level][mission][challenge];
    return gemArray[gemArray.length-1];     // return last gem
  } else {
    return scoreValues.UNATTEMPTED;
  }
}

export function getMissionGems(level, mission, challengeCount, gems) {
  let challengeScore = [];
  for (let i = 0; i < challengeCount; i++){
    challengeScore.push(getChallengeGem(level, mission, i, gems));
  }
  return challengeScore;
}

// FIXME: Without gating, we have to count black NONE gems as passing, as otherwise
// it will keep showing dialog for missions a user has started.
export function isPassingGem(score) {
  // return score <= scoreValues.BRONZE;
  return score <= scoreValues.NONE;
}
{'fraction_non_alphanumeric': 0.1132404181184669, 'fraction_numerical': 0.008710801393728223, 'mean_word_length': 3.8357894736842106, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5272911', 'n_tokens_mistral': 794, 'n_tokens_neox': 731, 'n_words': 198}