Skip to content

Commit

Permalink
jquery version ready
Browse files Browse the repository at this point in the history
  • Loading branch information
akshay111meher committed Jan 13, 2016
1 parent b50ea94 commit 1e73e5e
Show file tree
Hide file tree
Showing 110 changed files with 48,360 additions and 1 deletion.
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,30 @@
# QuizRT-jQuery-version
------------------------
Execution Steps
------------------------

1. For windows users using virtual box, install vagrant, oracle virtualbox, gitbash.
2. Create a new folder named vagrant in your C drive.
3. Clone the repository available in the github or download the zip files.
4. Do the vagrant up for this repository in the gitbash.
5. Now establish a secure connection with the ubuntu machine using vagrant ssh in gitbash.
6. Move to the QuizRT directory inside the ubuntu machine.
7. Run the following commands to install nodejs,npm,node-static etc.
1. sudo apt-get install nodejs.
2. sudo apt-get update
3. sudo apt-get install npm
4. sudo npm install node-static -g
5. sudo npm install express -g
6. npm install ejs
7. npm install supervisor
8. Run supervisor app.js to run the app.
9. Now app will start.
10. Execute localhost:<host-port>/userProfile to run the app in your host browser.

------------------
About QuizRT
------------------

It is a Quiz app developed by a team of six developers i.e. Ayush Jain, Lakshay Bansal, Raghav Goel, Saurabh Gupta, Kshitij Jain and Akshay Meher during the full stack developer training at NIIT StackRoute in Bengaluru. It is a multi player quiz app where multiple players can select their favourite topics, can create their profile and contest with different contestants from the world to play the quiz in real time. The users will be ranked according to their scores calculated from the right answers as well as time taken by them to give the answers. Users will also get different badges according to their skills.


So Have a Go and Enjoy this App.
36 changes: 36 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

vagrant_cache_server = "172.23.238.253"


# Detect the current OS. node on windows needs some symlink magic to work.
module OS
def OS.windows?
(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
end
end

Vagrant.configure(2) do |config|

config.vm.box = "stackroute/barebones-node"
config.vm.box_url = "http://#{vagrant_cache_server}/vagrant/boxes/stackroute-barebones-node.box"
config.vm.hostname = 'stackroute-node'

# Map the guest os port 8080 to host os port 8080
config.vm.network "forwarded_port", guest: 3000, host: 3040

if OS.windows?

# enable symlinks between the host/gust filesystems
config.vm.provider "virtualbox" do |vb|
vb.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]
end

# Setup the softlinks
config.vm.provision :puppet do |puppet|
puppet.manifest_file = "windows.pp"
end

end
end
35 changes: 35 additions & 0 deletions akshay.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{ userid: 222012,
name: 'Mohammad Hudson',
age: 52,
imageLink: 'https://s3.amazonaws.com/uifaces/faces/twitter/mastermindesign/128.jpg',
country: 'Seychelles',
flagLink: 'https://s3.amazonaws.com/uifaces/faces/twitter/imcoding/128.jpg',
badge: [ 'turin-master', 'turin-master', 'computer-master', 'shaana' ],
totalGames: 903652,
followers: 976731,
following: 858871,
wins: 318315,
followedtopics:
[ { topicId: 'et ut eius exercitationem quia',
topicName: 'deserunt',
topicImage: 'http://lorempixel.com/640/480',
gamesWon: 21,
level: 219 },
{ topicId: 'fugit at qui officiis quam',
topicName: 'temporibus iure reprehenderit cum est',
topicImage: 'http://lorempixel.com/640/480',
gamesWon: 495,
level: 472 },
{ topicId: 'ut',
topicName: 'cupiditate voluptas perspiciatis recusandae',
topicImage: 'http://lorempixel.com/640/480',
gamesWon: 63,
level: 235 },
{ topicId: 'omnis qui velit cupiditate',
topicName: 'qui quasi',
topicImage: 'http://lorempixel.com/640/480',
gamesWon: 251,
level: 436 } ],
friends:
[ 'impedit eos voluptatum molestiae',
'voluptatem dignissimos doloremque ex' ] }
133 changes: 133 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
var http = require('http');
var express = require('express');
var app = express();
var cookieParser = require('cookie-parser');
var session = require('express-session');
var mongoose = require('mongoose');
var server = http.createServer(app);
var io = require('socket.io')(server);
var allGames = [];
var maxPlayers = 3;
var arrayOfPlayers =[];

var quizPlayer = require('./routes/quizPlayerhandler.js');
var topicsHandler = require('./routes/topicsHandler.js');
var userProfile = require('./routes/profileHandler.js');
var quizSummaryHandler = require('./routes/quizSummaryHandler.js');


mongoose.connect('mongodb://localhost/quizRT');
var db = mongoose.connection;

// Set the view engine
app.set('view engine', 'ejs');
app.set('views', './views');

app.use(cookieParser());
app.use(session({
secret: "ksjdfjkdsjkdsajfdskjfskdjf",
cookie: { maxAge: 3000 }
}));

app.use(express.static('./public'));
app.use('/userProfile',userProfile);
app.use('/quizPlayer',quizPlayer);
app.use('/topicsHandler',topicsHandler);
app.use('/quizSummary',quizSummaryHandler);

app.get('/testingSessions', function(req, res, next) {
if(req.session.count >= 0){
req.session.count++;
res.send("testing sessions"+" "+req.session.count);
}
else{
req.session.count = 0;
res.send("testing sessions"+" "+req.session.count);
}

});

server.listen(3000, function() {
console.log('App started for EJS testing!!');
});

io.on('connection', function(client) {

client.on('join', function(data) {
console.log(data);
console.log("players connected = "+ io.sockets.sockets.length);
client.emit('messages', 'Hello from server');
});
client.on('disjoin',function(data){
console.log(data+" player disconnected");
});

// if(io.sockets.sockets.length <maxPlayers){
// io.sockets.emit('not_enough',"players not enough. waiting for "+(maxPlayers - io.sockets.sockets.length)+" more players");
// }
// else{
// io.sockets.emit("startGame","start the game");
// }

//create a group of 4 clients

arrayOfPlayers.push(client);

if(arrayOfPlayers.length < maxPlayers){
for (var i = 0; i < arrayOfPlayers.length; i++) {
arrayOfPlayers[i].emit('not_enough',"players not enough. waiting for "+(maxPlayers - arrayOfPlayers.length)+" more players");
}
}

if(arrayOfPlayers.length == maxPlayers){
var game1 = new game(makeid(),arrayOfPlayers,false);
allGames.push(game1);
arrayOfPlayers = [];
}

//for loop runs before the execution of if condition above....verify


for (var i = 0; i < allGames.length; i++) {
if(!allGames[i].isRunning)
{
console.log(allGames.length+" total games running in the server");
renderThegame(allGames[i]);
allGames[i].isRunning = true;
}
}

});

function renderThegame(game){
console.log("Multiple games render. total players = "+game.arrayOfPlayers.length);
if(game.arrayOfPlayers.length < maxPlayers){
//emit from the corresponding sockets
console.log("tsting kjhsadkjfhk kj sah "+game.arrayOfPlayers.length);
for (var i = 0; i < game.arrayOfPlayers.length; i++) {
game.arrayOfPlayers[i].emit('not_enough',"players not enough. waiting for "+(maxPlayers - game.arrayOfPlayers.length)+" more players");
}
}
else{
//emit from the aleternative from the corresponding sockets
for (var i = 0; i < game.arrayOfPlayers.length; i++) {
game.arrayOfPlayers[i].emit("startGame","start the game");
}
}
};

function makeid()
{
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";

for( var i=0; i < 5; i++ )
text += possible.charAt(Math.floor(Math.random() * possible.length));

return text;
};
function game(gameId,arrayOfPlayers,isRunning){
this.isRunning;
this.gameId = gameId;
this.arrayOfPlayers = arrayOfPlayers;
};
90 changes: 90 additions & 0 deletions bin/www
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#!/usr/bin/env node

/**
* Module dependencies.
*/

var app = require('../app');
var debug = require('debug')('express_project:server');
var http = require('http');

/**
* Get port from environment and store in Express.
*/

var port = normalizePort(process.env.PORT || '3000');
app.set('port', port);

/**
* Create HTTP server.
*/

var server = http.createServer(app);

/**
* Listen on provided port, on all network interfaces.
*/

server.listen(port);
server.on('error', onError);
server.on('listening', onListening);

/**
* Normalize a port into a number, string, or false.
*/

function normalizePort(val) {
var port = parseInt(val, 10);

if (isNaN(port)) {
// named pipe
return val;
}

if (port >= 0) {
// port number
return port;
}

return false;
}

/**
* Event listener for HTTP server "error" event.
*/

function onError(error) {
if (error.syscall !== 'listen') {
throw error;
}

var bind = typeof port === 'string'
? 'Pipe ' + port
: 'Port ' + port;

// handle specific listen errors with friendly messages
switch (error.code) {
case 'EACCES':
console.error(bind + ' requires elevated privileges');
process.exit(1);
break;
case 'EADDRINUSE':
console.error(bind + ' is already in use');
process.exit(1);
break;
default:
throw error;
}
}

/**
* Event listener for HTTP server "listening" event.
*/

function onListening() {
var addr = server.address();
var bind = typeof addr === 'string'
? 'pipe ' + addr
: 'port ' + addr.port;
debug('Listening on ' + bind);
}
17 changes: 17 additions & 0 deletions data/quizProperties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"timeLimit": 6,
"levels":[
{
"id": 1,
"minimumScore": 0
},
{
"id": 2,
"minimumScore": 200
},
{
"id": 3,
"minimumScore": 500
}
]
}
Loading

0 comments on commit 1e73e5e

Please sign in to comment.