WebFund 2016W: Tutorial 6

From Soma-notes
Jump to navigation Jump to search

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.