Forum Discussion
Exporting Variables into a Google Spreadsheet
Having read this post on how to export variables to be read in a google spreadsheet, I set about trying to get this working in my project, I soon ran into problems, I just could not get it to work as google have changed some of the ways they work their drive documents.
So, after a LOT of google searching and testing various methods, plus reading this article, I came up with the following method which is a combination of the two articles – and it works, hurrah!
1. Create a new google spreadsheet and change the sheet name (lower left hand corner) to DATA. Make sure your column names are the same as the variables you want to export (exactly matching case)
2. Find out your spreadsheet ‘key’ by looking in the address bar, the key is the long series of letters and numbers after /d/ and before /edit:
Eg: https://docs.google.com/spreadsheets/d/1gF0QCNA1TZCNY3qr2zNpWKQ8r43D39o-nqz56c7cQUs/edit#gid=1283040575
Key = 1gF0QCNA1TZCNY3qr2zNpWKQ8r43D39o-nqz56c7cQUs
3. Open the script editor (Tools ==> Script Editor) in your spreadsheet and paste the script from the attached file (I have copied and pasted this script and just kept in all the instructions)
4. There are two places in the script where it says “KEY” – copy and paste your key into these two places, between the “”.
5. Run the setUp script twice (Run menu). The first time it will ask for permission to run (grant it), then the second time you select to run it you won't get any popup indication it has run.
6. Go to Publish > Deploy as web app, enter Project Version name and click 'Save New Version', set security level and enable service (most likely execute as 'me' and access 'anyone, even anonymously).
7. Copy the 'Current web app URL' and paste in a notepad file to keep safe.
8. In Articulate, add a trigger to run javascript and use the following code, replacing “Current web app URL” with your URL you copied in the previous step (in””):
var player = GetPlayer();
$.ajax({
url:
"Current web app URL",
type: "POST",
data: {"Name": player.GetVar("Name")
, "Rating1": player.GetVar("Rating1")
, "Rating2": player.GetVar("Rating2")
, "Rating3": player.GetVar("Rating3")
, "Rating4": player.GetVar("Rating4")
, "postRating1": player.GetVar("postRating1")
, "postRating2": player.GetVar("postRating2")
, "postRating3": player.GetVar("postRating3")
, "Postrating4": player.GetVar("Postrating4")},
success: function(data)
{
console.log(data);
},
error: function(err) {
console.log('Error:', err);
}
});
return false;
9. Publish your articulate project – you need to host it somewhere like SCORM cloud or a LMS. When it has finished publishing click to open the files and edit the story.html and story_html5.html files – add the following line in under the line <!-- version: X.X.XXX.XXX --> or somewhere after <head>:
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
10. Go back to articulate and click ‘zip’ – then publish your zip file and hopefully it will work!
This isn’t for the faint hearted but it is so worth it if you can get it working! Good luck!
- Mohammad-HassamCommunity Member
HI Kate,
I followed all the steps you mentioned but still not working. I have uploaded the published file on the server but still no response. I think there is something wrong I am doing that's why the data is not appearing in Google sheet. Kindly find the files attached.
Google drive link: https://docs.google.com/spreadsheets/d/1L1YtRjp0Kd94XQx-1AjH8cEh-sctGmRPL7VXCRCzdNk/edit?usp=sharing
Published version uploaded: http://blendtolearn.com/articulate/exportgooglesheet/story.html
I look forward to hearing from you.
- KateRobertsonCommunity Member
Hi Mohammad, I have sent you a reply via email but for anyone else, here are the changes I made:
1. You need to call the spreadsheet ‘DATA’ – the name at the bottom, not at the top
2. You need to put column headers in that match the variable names
3. I edited the variable names in your articulate project
4. I edited the javascript to match the variables and took out the ones you didn’t need.
5. I added in a second javascript that stops you needing to do any post-publish surgery- RobertKankelborCommunity Member
Thanks for this, too, Kate. I haven't been successful at this yet and hope implementing these changes will work for me.
- VladKolchanovCommunity Member
Hi everybody! Here is another good solution:
http://elearningbrothers.com/how-to-create-a-leaderboard-elearning-google/
- KateRobertsonCommunity Member
Great, thanks Vlad!
- CarrieBoothCommunity Member
I have been wanting to connect courses to spreadsheets for year! Thank you so much!
- ErezGorenCommunity Member
Hello,
Amazing methods. This is going to serve many purposes for us - thank you.
Is there anyway to grab different variables at different times and log them to the same row in the spreadsheet?
Simple example - I would like to grab the timestamp when a student begins the test, and one when they finish it.
complex example - I would like to grab the score for each section of the quiz the student completes - not at the final results slide, but at the end of each section.
Thanks in advance,
Erez
- KateRobertsonCommunity Member
Hi Erez, there might be a way to do that but I'm not sure. My method just adds data to the next line of the spreadsheet. I guess if you included a name stamp each time you could collate the lines together that relate to the same person, if that makes sense?!
- GerardSteele-4cCommunity Member
Hey everyone,
First, I'd like to say thanks to everyone participating in this thread. I was able to get a spreadsheet running a few months ago and it's been immensely helpful to my organization. My supervisor has now asked for a way to update information to save us some runaround. The only way I can see this maybe working is to work in a javascript command to delete a row based on an id and have user re-enter their new information. Does this sound feasible? Are there any other solutions I'm not seeing? Keep in mind the most experience with javascript I have is setting up spreadsheets using this thread. Thanks!
- VladKolchanovCommunity Member
Hi everyone,
is there any method to use other sheets? I have a few quizzes, united in a single project. The user has to solve several quizzes. I would like to have the results of a quiz on one page, and the results of other quizzes — on other sheets.
Thanks!
- JasonNagelsCommunity Member
I've been banging my head against a wall with this for a few hours, and haven't made much success. I'm hoping the group can point me in the right direction as to what I'm doing wrong.
I have a eLearning with 3 variables I'm trying to pass to the spreadhseet (FirstName, LastName, Score).
I believe I have followed the instructions exactly, but it's not working. I must be overlooking something.
Google Spreadsheet: https://docs.google.com/spreadsheets/d/1RNQz2Dnt0lNYQUwVsa_s2welexxr4YfjVrOXd35tak8/edit?usp=sharing
Posted eLearning: http://www.nagelsconsulting.com/Lockout/story.html
I have made sure to edit the story.html and story_html5.html files with the text:
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
Any suggestions or help would much appreciated!
I have attached the source story file.
Thanks,
J
- ErichRenkenCommunity Member
After taking a quick look, I saw that this error message is generated:
XMLHttpRequest cannot load https://script.google.com/macros/s/AKfycbz7Xe_atONE7a8RSxj8UVZU5qqkEvLRdNZnGL8FXeFk_PJYPoo/exec. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://www.nagelsconsulting.com' is therefore not allowed access.
Recheck your permissions (Step #6).
Also, when I just this:
https://script.google.com/macros/s/AKfycbz7Xe_atONE7a8RSxj8UVZU5qqkEvLRdNZnGL8FXeFk_PJYPoo/exec
I get a "Script function not found: doGet" message. Don't have the time at the moment to find how those are related, but hopefully it will serve as a valuable clue.
For what it's worth, I had to take a few attempts at this before I got all the steps correct. Lots of moving parts.
- ChristiePollickCommunity Member
Hi, Jason -- So sorry to hear of your frustrations, and I see Erich has offered an idea, so hopefully that will help! As we don't support exporting variables to an excel document or Google spreadsheet, I'll need to defer to the community should you need further assistance here.
- JasonNagelsCommunity Member
Thanks Erich for the suggestion. I double-checked step 6 and it turns out I didn't have the privleges set properly. I have corrected this, and now 'anyone, even anonymous' has access to the web app; however I'm still getting the "Script Function not found: doGet: error when clicking https://script.google.com/macros/s/AKfycbz7Xe_atONE7a8RSxj8UVZU5qqkEvLRdNZnGL8FXeFk_PJYPoo/exec
When I look at the code in the script editor - I see there are the following lines:
// If you don't want to expose either GET or POST methods you can comment out the appropriate function
function doGet(e){
return handleResponse(e);
}
function doPost(e){
return handleResponse(e);
}Does it look like there is something wrong with these lines?
I tried commenting out the doGet but I still get the same error.
Thansk,
J