Tuesday, November 4, 2014

Module Chooser Using Javascript AND Apps Script

6:49 AM

I had hoped that there might be a new Google Forms Add-on to do this, but no. I guess I'll have to have a go at doing it myself later.

Imagine you want your students to make a choice of four modules from a list of modules you're offering. To make the form easier to "not get wrong" it'd be good if when you chose module one, it disappeared from the following form items...

... like this.

The above is a hosted HTML on Google Drive ( because the Caja sanitation, or Chrome killed my Javascript ).

When a student chooses their preferred modules, the form is submitted to a regular doPost() method in a Google Spreadsheet's Apps Script like this...


function doPost(e) {
Logger.log("Hi there")
try{
//Get values from form
var email = Session.getActiveUser().getEmail()

var module_one = e.parameter.module_one
var module_two= e.parameter.module_two
var module_three = e.parameter.module_three
var module_four = e.parameter.module_four
add_students_selection(email,module_one,module_two,module_three,module_four )

var template = HtmlService.createTemplateFromFile('thank_you.html')
template.this_url = ScriptApp.getService().getUrl( )

return template.evaluate().setTitle("Thank You").setSandboxMode(HtmlService.SandboxMode.EMULATED)



}catch(e){
Logger.log(e)
var template = HtmlService.createTemplateFromFile('error.html');
template.this_url = ScriptApp.getService().getUrl( );
template.error_title = e
template.error_detail = e.stack
return template.evaluate().setTitle("Error").setSandboxMode(HtmlService.SandboxMode.EMULATED)
}

}

Written by

We are one of the initiators of the development of information technology in understanding the need for a solution that is familiar and close to us.

0 comments:

Post a Comment

 

© 2013 Klick Dev. All rights resevered.

Back To Top