<commit_before>var Alexa = require('alexa-sdk');
var APP_ID = undefined;
var QUESTION_TOTAL = 5;
var questionNumber;
var states = {
  TRIVIA: "_TRIVIAMODE", // Asking trivia questions.
  START: "_STARTMODE", // Entry point, start the game.
  HELP: "_HELPMODE" // The user is asking for help.
};
var questions = require('./questions');

var currentQuestion;
var score;
function getQuestion() {
  var keys = Object.keys(questions);
  var rnd = Math.floor(Math.random() * keys.length);
  var key = keys[rnd];
  return key;
}

exports.handler = function(event, context, callback){
  var alexa_one = Alexa.handler(event, context);
  alexa_one.registerHandlers(newSessionHandlers, triviaModeHandlers);
  alexa_one.appId = APP_ID;
  alexa_one.execute();
};


var newSessionHandlers = {

  "LaunchRequest": function () {
    this.emit(':ask', 'Welcome to Quiz bot! Say start when you\'re ready.');
  },
  "AMAZON.StartOverIntent": function() {
    questionNumber = 1;
    score = 0;
    this.handler.state = states.TRIVIA;
    this.emitWithState('QuestionIntent', "Alright then. Let\'s begin. I will give an algebraic equation and your task is to find the value of x.");
  },
  "AMAZON.HelpIntent": function() {
    this.emit(':ask', 'To begin the quiz, say start.');
  },
  "MenuIntent": function(message) {
    this.emit(':ask', message + ' say start to begin a new game.')
  },
  "Unhandled": function() {
    this.emit(':ask', 'Sorry, I didn\'t catch that, say start to begin.');
  }
};

<commit_msg>added medals method<commit_after>var Alexa = require('alexa-sdk');
var APP_ID = undefined;
var QUESTION_TOTAL = 5;
var GOLD_MEDAL = QUESTION_TOTAL;
var SILVER_MEDAL = 4;
var BRONZE_MEDAL = 3;
var questionNumber;
var states = {
  TRIVIA: "_TRIVIAMODE", // Asking trivia questions.
  START: "_STARTMODE", // Entry point, start the game.
  HELP: "_HELPMODE" // The user is asking for help.
};
var questions = require('./questions')
var currentQuestion;
var score;

function getQuestion() {
  var keys = Object.keys(questions);
  var rnd = Math.floor(Math.random() * keys.length);
  var key = keys[rnd];
  return key;
}

function getMedal(score) {
  if (score === GOLD_MEDAL) {
    return 'Gold'
  } else if (score >= SILVER_MEDAL) {
    return 'Silver'
  } else if (score >= BRONZE_MEDAL) {
    return 'Bronze'
  }
}

exports.handler = function(event, context, callback){
  var alexa_one = Alexa.handler(event, context);
  this.handler.state = states.MENU
  alexa_one.registerHandlers(newSessionHandlers, triviaModeHandlers);
  alexa_one.appId = APP_ID;
  alexa_one.execute();
};


var newSessionHandlers = {

  "LaunchRequest": function () {
    this.emit(':ask', 'Welcome to Quiz bot! Say start when you\'re ready.');
  },
  "AMAZON.StartOverIntent": function() {
    questionNumber = 1;
    score = 0;
    this.handler.state = states.TRIVIA;
    this.emitWithState('QuestionIntent', "Alright then. Let\'s begin. I will give an algebraic equation and your task is to find the value of x.");
  },
  "AMAZON.HelpIntent": function() {
    this.emit(':ask', 'To begin the quiz, say start.');
  },
  "MenuIntent": function(message) {
    this.emit(':ask', message + ' say start to begin a new game.')
  },
  "Unhandled": function() {
    this.emit(':ask', 'Sorry, I didn\'t catch that, say start to begin.');
  }
};


{'fraction_non_alphanumeric': 0.1451466586029634, 'fraction_numerical': 0.002419110976716057, 'mean_word_length': 3.8790560471976403, 'pattern_counts': {'":': 10, '<': 3, '<?xml version=': 0, '>': 5, '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': '4957771', 'n_tokens_mistral': 1168, 'n_tokens_neox': 1111, 'n_words': 316}