Here's an app that uses Database abstraction with google apps script via the DataHandler library.
It's made up of these components
Here is a poll using my version of the webapp. Try it.
Setting up a pollThe easiest way to set up a poll is in a spreadsheet. Some concepts.
Here's an example of a sheet containing a couple of different polls. Note how answers can be shared between questions and questions can be shared amongst polls. Moving the poll to a database.You can run the whole thing directly from a sheet if you want, or any database supported by DataHandler. If you do use a sheet you'll need to create an additional sheet in your workbook called 'sheetname'Answers. Poll answers will be posted there. However, more likely you'll want to run this from a database, so the first job is to copy your sheet to the database. Here's how to replicate this sheet to a parse.com database. var parseHandler = new cDataHandler.DataHandler(siloId,cDataHandler.dhConstants.DB.PARSE,undefined,'myscriptdb',JSON.parse(UserProperties.getProperty("parseKeys"))); var sheetHandler = new cDataHandler.DataHandler(siloId,cDataHandler.dhConstants.DB.SHEET,undefined, ssid); var result = replicate (sheetHandler,parseHandler); if(result.handleError <0) throw (JSON.stringify(result)); function replicate(fromHandler, toHandler) { // get data to be copied var fromResult = fromHandler.query(); if(fromResult.handleError <0) throw (JSON.stringify(fromResult)); // delete existing data var result = toHandler.remove(); if(result.handleError <0) throw (JSON.stringify(result)); // copy it var result = toHandler.save(fromResult.data); if(result.handleError <0) throw (JSON.stringify(result)); return result; } and here's a snip of what we find in the parse.com browser. Since we've decided to use parse.com for this app, that's where you'll find the responses. Heading over again to the parse.com browser, Setting up your own polling environmentYou need the cPoll library - MhwYWpncx2kNyR0sckR24mqi_d-phDA33 and the DataHandler library - Mj61W-201_t_zC9fJg1IzYiz3TLx7pV4j And you need to make a copy of this, attach the libraries, fix your own default, and publish as a web app. Code for cPoll libraryThe client appI've bundled the styles, html and javascript into the same file for simplicity. You should make your own version of this, and modify the url to point at your google apps script webapp. For help and more information join our forum,follow the blog or follow me on twitter . |
Services > Desktop Liberation - the definitive resource for Google Apps Script and Microsoft Office automation > Apps built with data abstraction >