Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Help: Submitting a Google Form with Corona
Started by michael714 Dec 26 2013 01:10 PM

- - - - -
7 replies to this topic
google forms spreadsheet

Best Answer michael714 , 27 December 2013 - 02:17 PM

Ok, got it to work.  And it's lovely.  And I will share:

 

1) Create your Google Form and choose to save responses in a new spreadsheet

 

2) While you are on the design page for the form, click the Responses menu and then choose Get pre-filled URL

 

3) Answer the questions in the form however you like and submit.  Copy the resulting URL.  It should look something like this:

https://docs.google.com/forms/d/1lwf1b5poDKR_-YseRlLU-WAC_F59Jb_F9viEMTLvfB8/viewform?entry.720168203=first&entry.1374940375=last&entry.1797375424=ID

 

In my form, I was asking for firstName, lastName and studentID, so I filled in the blanks in such a way that I could identify which question was associated with entry.XXXXXXXXX. 

 

4) To make it so that you can submit the form, change /viewform? to /formResponse?   and add &submit=Submit to the end of the whole URL.   You can then "post" the form using "GET".   Here is my sample code below:

 

local myText = display.newText("(Waiting for response)", display.contentCenterX, 120, native.systemFont, 16)
 
local function networkListener( event )
    if ( event.isError ) then
        myText.text = "Network error!"
    else
        myText.text = "See Corona Terminal for response"
        print ( "RESPONSE: " .. event.response )
    end
end
 
local URL = "https://docs.google.com/forms/d/1lwf1b5poDKR_-YseRlLU-WAC_F59Jb_F9viEMTLvfB8/formResponse?"
 
local firstName = "entry.720168203="
local lastName = "&entry.1374940375="
local studentID = "&entry.1797375424="
 
local first = "Steve"
local last = "Smith"
local ID = math.random(100000)
 
local postString = URL..firstName..first..lastName..last..studentID..ID.."&submit=Submit"
 
-- Access Google over SSL:
network.request( postString, "GET", networkListener )

[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

michael714

[GLOBAL: userInfoPane.html]
michael714
  • Pro
  • PipPipPipPipPipPip
  • 153 posts
  • Jedi

Hello,

I would like to create an app which would allow my students to submit their results to me.   I was thinking that I could do this via MySQL, but if other teachers wanted to use my app, I don't want them to all have to be dependent on my MySQL server.   So, I was thinking it would be nice if I could just submit the results through a Google Form that I create and that form would then store the results in a Google Spreadsheet.  Nice idea, no?

 

This way, any student could submit their results and the results would automatically be stored in my database.   Only problem is, I don't see a way to make this happen. There is a Google Forms API (https://developers.google.com/apps-script/reference/forms/) but I can't see how to access it from Corona (it would be nice if it was RESTful).   I guess it would be possible to use showWebPopup() and then actually just pull up the Google Form web page?  But that seems to lack finesse!

 

I know there is also a Google Spreadsheet API, but I have the same problem as with the Google Forms API- no way to run the scripts from Corona.  

 

If anyone has thoughts on this, I would greatly appreciate it.  Thanks!



[TOPIC: post.html]
#2

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Corona Staff
  • 10,051 posts
  • Jedi

API's like that are probably available via Andorid native SDK's which would require Corona Enterprise to use.  Wufoo forums has a REST api that you probably could use.

 

http://www.wufoo.com/docs/api/v3/

 

Rob



[TOPIC: post.html]
#3

michael714

[GLOBAL: userInfoPane.html]
michael714
  • Pro
  • PipPipPipPipPipPip
  • 153 posts
  • Jedi

Rob, thank you for your quick response.  Wufoo looks interesting, but it still has two major problems for me:

 

1) It requires authorization (which usually takes me days to implement and probably takes several years off of my life!).

2) It looks like it would cost at least $15 per month for access.

 

Neither problem is insurmountable, but submitting a Google Form is so easy (when it's done by me with my fingers and keyboard and mouse).  No authorization, no cost, simple.   It would be the perfect solution if only it was easy to do from Corona.  Maybe others have some ideas?



[TOPIC: post.html]
#4

michael714

[GLOBAL: userInfoPane.html]
michael714
  • Pro
  • PipPipPipPipPipPip
  • 153 posts
  • Jedi

This page seems to indicate that there is a way to do what I want:

http://stackoverflow.com/questions/15824276/posting-data-to-new-google-forms

 

So, I'm going to give that a shot.  However, I would like to be able to submit multiple "entries", so I still may need to play with this a bit.  Still open to suggestions...



[TOPIC: post.html]
#5

michael714

[GLOBAL: userInfoPane.html]
michael714
  • Pro
  • PipPipPipPipPipPip
  • 153 posts
  • Jedi


[TOPIC: post.html]
#6

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Corona Staff
  • 10,051 posts
  • Jedi

It is a web form, so it should be submittable by an HTTP POST request.

 

Rob



[TOPIC: post.html]
#7

michael714

[GLOBAL: userInfoPane.html]
michael714
  • Pro
  • PipPipPipPipPipPip
  • 153 posts
  • Jedi

Yep, gonna try it out today.  This will be awesome if it works!



[TOPIC: post.html]
#8

michael714

[GLOBAL: userInfoPane.html]
michael714
  • Pro
  • PipPipPipPipPipPip
  • 153 posts
  • Jedi

  Best Answer

Ok, got it to work.  And it's lovely.  And I will share:

 

1) Create your Google Form and choose to save responses in a new spreadsheet

 

2) While you are on the design page for the form, click the Responses menu and then choose Get pre-filled URL

 

3) Answer the questions in the form however you like and submit.  Copy the resulting URL.  It should look something like this:

https://docs.google.com/forms/d/1lwf1b5poDKR_-YseRlLU-WAC_F59Jb_F9viEMTLvfB8/viewform?entry.720168203=first&entry.1374940375=last&entry.1797375424=ID

 

In my form, I was asking for firstName, lastName and studentID, so I filled in the blanks in such a way that I could identify which question was associated with entry.XXXXXXXXX. 

 

4) To make it so that you can submit the form, change /viewform? to /formResponse?   and add &submit=Submit to the end of the whole URL.   You can then "post" the form using "GET".   Here is my sample code below:

 

local myText = display.newText("(Waiting for response)", display.contentCenterX, 120, native.systemFont, 16)
 
local function networkListener( event )
    if ( event.isError ) then
        myText.text = "Network error!"
    else
        myText.text = "See Corona Terminal for response"
        print ( "RESPONSE: " .. event.response )
    end
end
 
local URL = "https://docs.google.com/forms/d/1lwf1b5poDKR_-YseRlLU-WAC_F59Jb_F9viEMTLvfB8/formResponse?"
 
local firstName = "entry.720168203="
local lastName = "&entry.1374940375="
local studentID = "&entry.1797375424="
 
local first = "Steve"
local last = "Smith"
local ID = math.random(100000)
 
local postString = URL..firstName..first..lastName..last..studentID..ID.."&submit=Submit"
 
-- Access Google over SSL:
network.request( postString, "GET", networkListener )



[topic_controls]
[/topic_controls]



Also tagged with one or more of these keywords: google forms, spreadsheet