<commit_before>'use strict';
module.change_code = 1;
var _ = require('lodash');
var Alexa = require('alexa-app');
var app = new Alexa.app('quiz');
var Questions = require('./questions');
let quiz = [];

app.launch(function(req, res) {
    var prompt = 'Lets play a quiz yeahh';
    var numberOfQuestion = 0;
    res.session('numberOfQuestion', numberOfQuestion);
    res.say(prompt).reprompt(prompt).shouldEndSession(false);
});

app.intent('quiz', {
        'slots': {
            'CATEGORY': 'CATEGORIES'
        },
        'utterances': ['i will play with {-|CATEGORY}']
    },
    function(req, res) {
        var category = req.slot('CATEGORY');
        if (_.isEmpty(category)) {
            var prompt = 'I didn\'t hear a category name. Tell me the category please Bro';
            res.say(prompt).reprompt(reprompt).shouldEndSession(false);
            return true;
        } else {
            var questions = new Questions();
            questions.getByCategory(category).then(function(response) {
                var quiz = response.body.results;
                var question = questions.parseQuestion(quiz[0].question);
                res.say(question).send();
            });
            return false;
        }
    }
);

//hack to support custom utterances in utterance expansion string
var utterancesMethod = app.utterances;
app.utterances = function() {
    return utterancesMethod().replace(/\{\-\|/g, '{');
};

module.exports = app;<commit_msg>Quiz: game intent<commit_after>'use strict';
module.change_code = 1;
var _ = require('lodash');
var Alexa = require('alexa-app');
var app = new Alexa.app('quiz');
var Questions = require('./questions');
let quiz = [];

app.launch(function(req, res) {
    var prompt = 'Lets play a quiz yeahh';
    var numberOfQuestion = 0;
    res.session('numberOfQuestion', numberOfQuestion);
    res.say(prompt).reprompt(prompt).shouldEndSession(false);
});

app.intent('quiz', {
        'slots': {
            'CATEGORY': 'CATEGORIES'
        },
        'utterances': ['i will play with {-|CATEGORY}']
    },
    function(req, res) {
        var category = req.slot('CATEGORY');
        if (_.isEmpty(category)) {
            var prompt = 'I didn\'t hear a category name. Tell me the category please Bro';
            res.say(prompt).reprompt(reprompt).shouldEndSession(false);
            return true;
        } else {
            var questions = new Questions();
            questions.getByCategory(category).then(function(response) {
                var quiz = response.body.results;
                var question = questions.parseQuestion(quiz[0].question);
                res.say(question).send();
            });
            return false;
        }
    }
);

app.intent('game', {
        'slots': {},
        'utterances': ['start game']
    },
    function(req, res) {
        
    }
);

//hack to support custom utterances in utterance expansion string
var utterancesMethod = app.utterances;
app.utterances = function() {
    return utterancesMethod().replace(/\{\-\|/g, '{');
};

module.exports = app;
{'fraction_non_alphanumeric': 0.1479425212279556, 'fraction_numerical': 0.001959503592423253, 'mean_word_length': 2.5005714285714284, 'pattern_counts': {'":': 0, '<': 3, '<?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': '895349', 'n_tokens_mistral': 932, 'n_tokens_neox': 894, 'n_words': 208}