Permalink
Browse files

[Branching]

  • Loading branch information...
Saturn-V committed Apr 20, 2017
1 parent 08f640f commit 634e5706dc72e354684b1634366664151db3649b
View
@@ -0,0 +1,15 @@
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
//Will contain a name and a game code along with a question array.
var AnswerSchema = new Schema({
createdAt : { type: Date, default: Date() },
updatedAt : { type: Date, default: Date() },
body : { type: String, required: true },
question: {
type: Schema.Types.ObjectId,
ref: 'Question'
},
socketId : { type: String }
});
module.exports = mongoose.model('Answer', AnswerSchema);

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.
View
@@ -5,14 +5,10 @@ var gameCode = ""
//ONCE WE HIT THE GAMES SHOW PAGE, GRAB GAME CODE AND EMIT TO SERVER
$(function() {
$('.question').first().show().addClass('current-question');
gameCode = window.location.href.split('/')[3];
socket.emit('join_room', gameCode, function(game) { });
//Fill page in with questions and answers
// function questionAnswerFill(){
// $('question').append('<h1>' + Which of these letters is a B ? + '</h1>');
// }
//ONCE USER CLICKS ON AN ANSWER, GRAB TEXT AND EMIT DATA TO SERVER
$('body').on('click', '.answer', function(e) {
e.preventDefault();
@@ -23,7 +19,7 @@ $(function() {
questionId: questionId,
answerChosen: answerChosen
}
// console.log(data);
//Once answer is chosen, emit it and compare with answer on server
socket.emit('answer_chosen', data, function(result) {
console.log(result);
@@ -41,32 +37,21 @@ $(function() {
$('.current-question').next().show().addClass('current-question')
$('.current-question').first().removeClass('current-question');
}, 5000);
// var data = {
// code: gameCode,
// index: questionIndex
// }
// setTimeout(function() {
//
// socket.emit('get_next', data, function(question) {
// console.log('question :' + question)
// $('#question').text = question.text;
// $('#_id').text(question._id);
// });
// }, 5000);
// display correct or incorrect stuff
// dipslay timer for next question
// when that is over, display next question
});
});
});
$('#submit-lie').click(function(event) {
var fakeAnswer = $('#fake-answer').val();
var socketId = socket.id;
var data = {
socketId: socketId,
answer: fakeAnswer
}
socket.emit('answer_created', data, function() {
});
});
// socket.on('broadcast:join_room', function(data) {
// console.log("Event 'broadcast:join_room' emitted.");
// console.log("---> Data: " + data);
// console.log($('#connected-users'));
// $('#connected-users').append($('<p>').text(data));
// });
});
View
@@ -1,9 +1,10 @@
module.exports = function(io) {
var GameCodes = [];
var loadedAnswer = [];
var Game = require('../models/game/game.js');
var Question = require('../models/question/question.js');
var Answer = require('../models/answer/answer.js');
var helper = require('./helpers/nextQuestion.js');
io.on('connection', function(socket) {
@@ -63,10 +64,8 @@ module.exports = function(io) {
})
});
socket.on('get_next', function(data, cb) {
helper(data.code, data.index, function(question) {
cb(question);
})
socket.on('answer_created', function(data, cb) {
Answer.create()
});
});
@@ -106,12 +106,11 @@ to compare with answer. -->
</div>
<br>
<script>
$('.question').first().show().addClass('current-question');
</script>
<input type="text" id="fake-answer" name="fake-answer" placeholder="Enter your lie">
<input type="submit" value="Lie!" id="submit-lie">
<div class="answers">
<input class="answer" type="submit" value="B" style="display: block;">
<div class="answers" style="display:none;">
<!-- <input class="answer" type="submit" value="B" style="display: block;"> -->
<!-- <input class="answer" type="submit" value="B" style="display: block;">
<input class="answer" type="submit" value="C" style="display: block;">
<input class="answer" type="submit" value="D" style="display: block;">

0 comments on commit 634e570

Please sign in to comment.