Google Forms as Multiple Choice Quiz - How to Provide Results -
i've built google form multiple selection quiz, linked spreadsheet results, works well. have specific problem, i'd nowadays user's results them (i.e. how many answers got right/wrong). approach i've taken far is:
create sheet on spreadsheet formula calculate number of right answers each response. gives me 2 columns "full name" , "scores" embed form google site create google apps script read results sheet , display output embed above same site below form apps script gadgetcurrently able display of results recorded far. see here:
https://sites.google.com/site/mcqtest123/home
the script looks like:
// script-as-app template. function doget() { var app = uiapp.createapplication(); var title = app.createlabel("survey results").setstyleattribute("fontsize","16px"); app.add(title); //readrows(app); calculatescores(app); homecoming app; }; function calculatescores(app) { var sheet = spreadsheetapp.openbyid("0alnr-ou0qtandffzx1jcu1vrdtl0nvbrntfjoufhd1e"); var responsesheet = sheet.getsheetbyname("form responses"); var alldata = responsesheet.getdatarange().getvalues(); var right = alldata[1]; var responses = alldata.slice(2); //logger.log("timestamp, name, score"); logger.log("name, score"); (var = 0; < responses.length; i++) { var timestamp = responses[i][0]; var name = responses[i][1]; var score = 0; (var j = 2; j < correct.length; j++) { if(responses[i][j] == correct[j]) { score += 1; } } //var output = timestamp + ", " + name + ", " + score + "/" + correct.length var output = name + ", " + score + "/" + correct.length print(app, output); } }; function print(app, line) { logger.log(line); app.add(app.createlabel(line)); };
so leaves 2 problems:
when page loads, loads scores all respondents. i'd able nowadays score person filled out form.
the scores don't updated when form completed - when page refreshed.
for problem 1), wondered if there way access info in form iframe (e.g. using document.getelementbyid('targetframe')
, except google scripts don't seem have access document model) display results of person total name matches name in form (of course of study view else's results if know they'd set total name, without using timestamp don't see away round this).
for problem 2), wondered if there way trigger script when responses sheet updated. when go spreadsheet , tools->script manager message "no scripts found", don't know how add together trigger.
if create own form using htmlservice or uiapp , posting script populate spreadsheet, can generate uid in hidden field , utilize determine results needs see.
this results instant feedback answers quiz. see these @ later date, add together bookmarkable link included uid parameter. doget() e.parameters.uid
example.
from google forms stand not sure. potentially, new form styles, offer pre-filled field such uid, route form submission webapp 1 time again unclear.
google-app-engine google-apps-script google-spreadsheet-api google-sites
No comments:
Post a Comment