<commit_before><?php

global $db;
require_once '../shared/connect.php';

function exitWithJson($json) {
  header("Content-Type: application/json");
  header("Connection: close");
  echo json_encode($json);
  exit;
}

function exitWithJsonFailure($message) {
  $result = array("success" => false, "error" => $message);
  exitWithJson($result);
}

function getRequiredParam($key) {
  if (!array_key_exists($key, $_REQUEST)) {
    exitWithJsonFailure($key.' param is required');
  }
  return $_REQUEST[$key];
}

/* Return the user details for the matching (badgeName, code) pair, or null if
   no match is found. */
function verifyCode($badgeName, $code) {
  global $db;
  $stmt = $db->prepare('SELECT algorea_registration.lastName as sLastName, algorea_registration.firstName as sFirstName, algorea_registration.genre as genre, algorea_registration.email as sEmail, algorea_registration.zipcode as sZipcode, algorea_registration.franceioiID, algorea_registration.category FROM algorea_registration, contest WHERE code = :code and contest.badgeName = :badgeName;');
  $stmt->execute(['code' => $code, 'badgeName' => $badgeName]);

  $contestant = $stmt->fetch(PDO::FETCH_ASSOC);

  if (!$contestant) {
    return null;
  }

  $contestant['sSex'] = ($contestant['genre'] == 2 ? 'Male' : 'Female');
  unset($contestant['genre']);<commit_msg>add grade to data returned by badge<commit_after><?php

global $db;
require_once '../shared/connect.php';

function exitWithJson($json) {
  header("Content-Type: application/json");
  header("Connection: close");
  echo json_encode($json);
  exit;
}

function exitWithJsonFailure($message) {
  $result = array("success" => false, "error" => $message);
  exitWithJson($result);
}

function getRequiredParam($key) {
  if (!array_key_exists($key, $_REQUEST)) {
    exitWithJsonFailure($key.' param is required');
  }
  return $_REQUEST[$key];
}

/* Return the user details for the matching (badgeName, code) pair, or null if
   no match is found. */
function verifyCode($badgeName, $code) {
  global $db;
  $stmt = $db->prepare('SELECT algorea_registration.lastName as sLastName, algorea_registration.firstName as sFirstName, algorea_registration.grade, algorea_registration.genre as genre, algorea_registration.email as sEmail, algorea_registration.zipcode as sZipcode, algorea_registration.franceioiID, algorea_registration.category FROM algorea_registration, contest WHERE code = :code and contest.badgeName = :badgeName;');
  $stmt->execute(['code' => $code, 'badgeName' => $badgeName]);

  $contestant = $stmt->fetch(PDO::FETCH_ASSOC);

  if (!$contestant) {
    return null;
  }

  $contestant['sSex'] = ($contestant['genre'] == 2 ? 'Male' : 'Female');
  unset($contestant['genre']);
{'fraction_non_alphanumeric': 0.14988978692138133, 'fraction_numerical': 0.0007347538574577516, 'mean_word_length': 5.69041769041769, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '214637', 'n_tokens_mistral': 915, 'n_tokens_neox': 865, 'n_words': 204}