WebFund 2016W: Tutorial 6: Difference between revisions

From Soma-notes
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
In this tutorial you'll be playing with [http://homeostasis.scs.carleton.ca/~soma/webfund-2016w/code/graph-demo.zip graph-demo].  This code is similar to form-demo; however, now there are survey questions that are being asked with the results graphed.
In this tutorial you'll be playing with [http://homeostasis.scs.carleton.ca/~soma/webfund-2016w/code/graph-demo.zip graph-demo].  This code is similar to form-demo; however, now there are survey questions that are being asked with the results graphed.
To run the code, run "bin/www".


To complete this tutorial successfully, do the following:
To complete this tutorial successfully, do the following:
* Fix the /add callback so it saves the answer to all the questions and  calcResultsStats() so it reports the results of questions answered rather than the dummy data hard coded into the app.
* Fix the /add callback so it saves the answer to all the questions and  calcResultsStats() so it reports the results of questions answered rather than the dummy data hard coded into the app.
* Store the answers in MongoDB.  Store them in a database called "graph-demo" in a collection called "answers".  Each document should just be an answer object.  (MongoDB of course will add an ID field.)
* Store the answers in MongoDB.  Store them in a database called "graph-demo" in a collection called "answers".  Each document should just be an answer object.  (MongoDB of course will add an ID field.)
Optional: Make the graphs fancier!
===Hints===
* Object.keys() gives you the "enumerable" keys (properties) of any object.  Note that it does not get the keys from any prototypes.  So <tt>Object.keys(obj).forEach(function(key) {console.log(key);}); </tt> should print out all of the properties of obj.

Latest revision as of 20:59, 2 March 2016

In this tutorial you'll be playing with graph-demo. This code is similar to form-demo; however, now there are survey questions that are being asked with the results graphed.

To run the code, run "bin/www".

To complete this tutorial successfully, do the following:

  • Fix the /add callback so it saves the answer to all the questions and calcResultsStats() so it reports the results of questions answered rather than the dummy data hard coded into the app.
  • Store the answers in MongoDB. Store them in a database called "graph-demo" in a collection called "answers". Each document should just be an answer object. (MongoDB of course will add an ID field.)

Optional: Make the graphs fancier!

Hints

  • Object.keys() gives you the "enumerable" keys (properties) of any object. Note that it does not get the keys from any prototypes. So Object.keys(obj).forEach(function(key) {console.log(key);}); should print out all of the properties of obj.