google apps script - Dynamically changing the Image file in a form -
I hope someone can help me what I'm doing is the right way. My Google Site should be the only form of a form (only a question) to organize online questions. The form contains the user, email, question id, an image (the image is basically a question), the multichause answer. Since the questions are too much I would like to keep only one form to get the answer. I spread the scheme (see only) to share the url for each exam for each user. My problem is that how to change the image file on a fly by clicking on the URL shared by a user.
What did I do? I change the image based on script execution, and ask the user to click Change the image to take the test on the URL is done by creating a pilot form which Will read the question id and lift the image related to g.drive. But I have to face an issue that the user has to refresh the page to get the correct URL (only changes to the question id in the URL, so if not refreshing, then it raises the old question ID).
Is there any way a user can be done with a single click? Is there any way to avoid refreshing? The script is given below. Any help will be highly appreciated // This script is executed for creating the URL for the pilot form based on the question id
Function BuildPilotUrls () {var form = FormApp.openById ("1fe3cuSwx2YgW6ruKTXFNbHcXSz3e0MztlSJqVb2pNkw") .; // pilot form var items = form.getItems (); Var ss = SpreadsheetApp.openById ("1XNRrLPcWMNV8fORJn7jvfpc5WsM1i_rArCtZKD6b9pc"); Sheet = ss.getSheetByName ("question"); // var letter = ss.getActiveSheet (); Var data = sheet.getDataRange (). GetValues (); // Data for pre-filling // var form url = s .getFormUrl (); // Use the form attached to the form form form company = form.createResponse (); // headers, then create a URL for each line in sheet 1 ({ii; ii; i; l;; data.length; i ++)} for {// Create a form response object, and prefill it / Prefil name var form item = item [0] .asTextItem (); Var response = formItem.createResponse (data [i] [5]); FormResponse.withItemResponse (feedback); // prefile form URL var url = formResponse.toPrefilledUrl (); Logger.log (url); Sheet.getRange (i + 1,10) .setValue (URL); Url = 'HYPERLINK ("' + url + '", "Click here")'; Sheet.getRange (i + 1,9) .setFormula (URL); }}; // It is triggered on submitting the pilot form with the question id Function Set Image () {// Open the pilot form first. Get feedback for Qid and create a file name // Check the name of the file in the folder and insert that image as a real question in the test form. Var form = FormEp.OpenBiID ("1fe3cuSwx2YgW6ruKTXFNbHcXSz3e0MztlSJqVb2pNkw"); //// CBSE-X-math-pilot form form formsports = form.gate response (); Var formSports = FormSpons [formResponses.length-1]; Var itemspace = formResponse.getItemResponses (); Var itemspace = item response [0]; // logger.log ('response #% s' for query "% s", "% s",' (i + 1), .toString (), // itemResponse.getItem (). GetTitle (), var Qid = itemResponse.getResponse (); Logger.log ('response QID "% s"', Qid); var array1 = [{}]; array1 = Qid.split ("-"); // Based on base - var Str = "CXM-"; var ChNo = "000" + array1 [2]; var QNo = "000" + array1 [3]; Chino = Chino Solisa (-3); QNO = Qoosely (-3); FileName = Str + chno + "-" + QNo + "JPG." Var MyFolder = DriveApp.getFolderById ('0B5AzqjFpdDjkTEYxQXFmSk43dEk'); // files in the CBSE-X-Maths folder = myFolder.getFilesByName (file name), while ( Files .hasNext ()) {var file = files.next (); Form = Fo at logger.log (file);} RmApp.openById ("1FUFb23eH8hrxbwJBrb1ezV0-W6k-IbQri2zXmGYZ0LQ"); CBSE-X-Maths Test matches form = item.gate items (); form item = item [3] .asImageItem (); formItem.setImage () File.getBlob ()); // url var ss = SpreadsheetApp.openById ("1XNRrLPcWMNV8fORJn7jvfpc5WsM1i_rArCtZKD6b9pc"); Sheet = SS getSheetByNa me ("UserUrl"); Var data = sheet.getDataRange (). GetValues (); Var Forces = Form. Secret Response (); For (var i = 1; i & lt; data. Lamps; i ++) {var formItem = item [0] .asTextItem (); Var response = formItem.createResponse (data [i] [2]); FormResponse.withItemResponse (feedback); FormItem = Item [1] .asTextItem (); Feedback = formItem.createResponse (data [i] [3]); FormResponse.withItemResponse (feedback); FormItem = Objects [2] .asTextItem (); Feedback = formItem.createResponse (Qid); FormResponse.withItemResponse (feedback); Var url = formResponse.toPrefilledUrl (); Url = 'HYPERLINK ("' + url + '", "Click here")'; Sheet.getRange (i + 1,5) .setFormula (url); }};
Comments
Post a Comment