From 03ab8a45d956f7780001828b418d8c7560d0d2cd Mon Sep 17 00:00:00 2001 From: Scott Persinger Date: Wed, 8 Oct 2014 16:30:57 -0700 Subject: [PATCH] Some register and README refinements --- README.md | 27 ++++++++++++++++++++++----- client/README.md | 17 ----------------- client/index.html | 4 ---- client/js/app.js | 4 ++-- client/templates/register.html | 8 ++------ server/models.js | 4 ++-- 6 files changed, 28 insertions(+), 36 deletions(-) delete mode 100644 client/README.md diff --git a/README.md b/README.md index ac21aa6..9132ad8 100644 --- a/README.md +++ b/README.md @@ -43,13 +43,13 @@ user registration, data storage, and event broadcast. | [Postgres DB] -## Deployment +# Deployment The app can be deployed to Heroku, and distributed to the mobile device either through the mobile web browser, or by compiling the AngularJS application into a native app using an Apach Cordova container. -## Installation and setup +# Installation and setup Clone this repo to your local machine and install the requirements: @@ -68,10 +68,27 @@ and open the client app: http://localhost:5000 -## Deploy to Heroku +From the home screen click "Register". Enter your name and email and click `Register`. The first user +is automatically marked as the adminstrator. Click the _Open Admin Page_ link on the quiz page. + +On the admin page, use the following controls + +`Next Question` - queue up the next quiz question +`Restart Quiz` - erase all current scores and start over + +As you click `Next Question` a new question will appear automatically for anyone running +the app. Additional users can register for the app and play at the same time. Users accumulate +points by answering questions correctly, with a bonus awarded to the person who answers +correctly first. + + +# Deploy to Heroku When you are ready to share the app, just create a new Heroku app, provision a Postgres -database addon for your app, and then deploy the code. +database addon for your app, and then deploy the code. After you deploy you should +bootstrap the database: + + $ heroku run ./bootstrap.sh # Understanding the code @@ -115,7 +132,7 @@ so the server starts: $ node-debug server.js - + # Building a native app To bundle your client app as a native mobile app, you can use the Cordova tool. Note that to build diff --git a/client/README.md b/client/README.md deleted file mode 100644 index 1ff2501..0000000 --- a/client/README.md +++ /dev/null @@ -1,17 +0,0 @@ -# Heroku sample mobile app, client portion - -This directory contains the code for the Ionic framework+Angular app which constitutes the -client side of our mobile app. - -The client app is a single-page web app served by the root 'index.html'. The Javascript -in the `js/` directory contains the Angular application which creates the app using -the html templates in `templates/'. Those templates use the Ionic framework to create the -basic mobile-ready UI components. - - -Template structure: - -index.html - -> templates/tabs-container.html - -> templates/tabs-todos.html - -> templates/tabs- \ No newline at end of file diff --git a/client/index.html b/client/index.html index 8277109..d5e5d3a 100644 --- a/client/index.html +++ b/client/index.html @@ -35,10 +35,6 @@ - - - - diff --git a/client/js/app.js b/client/js/app.js index 95fc378..cc9a59a 100644 --- a/client/js/app.js +++ b/client/js/app.js @@ -12,9 +12,9 @@ angular.module('starter', ['ionic', 'starter.controllers', 'starter.services', ' }; if ($rootScope.user.is_admin) { - AuthenticationService.is_admin = true; + AuthenticationService.isAdmin = true; } - + $rootScope.$on("$stateChangeStart", function(event, toState) { //redirect only if both isAuthenticated is false and no token is set diff --git a/client/templates/register.html b/client/templates/register.html index 4316ce2..ac78730 100644 --- a/client/templates/register.html +++ b/client/templates/register.html @@ -1,4 +1,4 @@ - + @@ -25,15 +25,11 @@
or
- - Already registered?  Log In  diff --git a/server/models.js b/server/models.js index 96a0161..b1aefbf 100644 --- a/server/models.js +++ b/server/models.js @@ -45,13 +45,13 @@ module.exports = function(bookshelf) { } function next_question(req, res, next) { - var idWhere = '(select min(id) from questions where show = false and id > (select max(id) from questions where show = true))'; + var idWhere = '(select min(id) from questions where (show = false or show is null) and id > (select max(id) from questions where show = true))'; return bookshelf.knex('questions').update({ 'show': bookshelf.knex.raw('(id = ' + idWhere + ')') }) .then(function() { res.send('OK'); - }); + }).catch(next); } function leaders(req, res, next) {