Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

communicating scorm data to google docs?

New Here ,
Jan 15, 2016 Jan 15, 2016

Hello

I am currently using Captivate 9 and I am wanting to get the SCORM Data in my published project to communicate to a google form so I can easily collect data.  A friend of mine, who uses Articulate, has sent me the Java Script over that he uses and I have tried to recreate it in captivate.

Here is the script I am using:

var player = GetPlayer();   

    $.ajax({

url: "https://docs.google.com/forms/d/1MoKIpyIMjfJdb9zKs3BdY2HRvjjzdcKcJky_KtfaZl8/formResponse",

           type: "POST",

           data: {"entry.1690054005" :player.GetVar("cpQuizInfoStudentName"), "entry.611090497":player.GetVar("cpQuizInfoStudentID"), "entry.1316822733" :player.GetVar("cpInfoCurrentDateStringDDMMYYYY"), "entry.1402162927" :player.GetVar("cpInfoElapsedTimeMS"), "entry.618856082" :player.GetVar("cpInfoLastVisitedSlide"), "entry.193520631" :player.GetVar("cpInfoPercentage"),"entry.991115191" :player.GetVar("cpQuizInfoAttempts"), "entry.250243260" :player.GetVar("cpQuizInfoPassFail"), "entry.1161631701" :player.GetVar("cpQuizInfoTotalCorrectAnswers"), "entry.1109168399" :player.GetVar("cpQuizInfoTotalQuestionsPerProject"), "entry.1991159250" :player.GetVar("cpQuizInfoTotalUnansweredQuestions")},

           success: function(data)
{

               //alert(data);

           }

         });

    return false;

and I have this executed on entry of my quiz results slide, so in theory the google form should update each time somebody completes the quiz, see below:

script 1.PNG

Finally, when I publish the package (unzipped) I add in a final piece of script into the index.html file:

<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>

I have tried numerous times to upload the package to the LMS system (we use ItsLearning) and have it set to SCORM API communication.

However, each time the data will not pull through and the form remains empty:

Capture.PNG

I have spoken to guy who gave me the original code and he thinks I may have to duplicate the default variables incase the form doesn't recognize it. (apparently this is an issues in storyline) however I have no idea how to go about this?

Can anybody help me or guide me in the right direction.

thanks

Gary

1.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 02, 2016 Jun 02, 2016

Hey Gary,

I also have this question. I have done this via storyline, but I'm not sure how to do the same on captivate. If you figured this out, I'd love to know.

Callie

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jun 03, 2016 Jun 03, 2016

The first line var player = GetPlayer();  is for Articulate only, you could change it to:

var player = window.cpAPIInterface

Then everywhere it says  player.GetVar, change it to:

player.getVariableValue

Also, is the key the key you got from google docs?

Did you set up the google docs script for all of the variables you are sending?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 03, 2016 Jun 03, 2016

Thank you for the help! Here's what I have...

var player = window.cpAPIInterface   
    $.ajax({
url: "https://docs.google.com/forms/d/1Au2ThWq3ejgfvnNZnjjdVIhktsZX6c-PU3Om9PzKM20/formResponse",
           type: "POST",
dataType: "jsonp",
           data: {"entry.393583531" :player.getVariableValue("Resistor_Content_Viewed")},
           success: function(data)
           {
               alert(data);
           }
         });

    return false;

When I publish my course, it does not work. I haven't posted it to a web server yet, though. Could that be a problem?

Callie

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jun 03, 2016 Jun 03, 2016

Yes, that could be a problem.

Do you have the script that is in google docs?

This is an example that I use. This is the script in Captivate, I deleted the key:

function writeStorage()

{

var sheetURL = 'Enter your key here';

var d = new Date();

var n = d.toDateString() + " " + d.toLocaleTimeString();

var quizPoints = window.cpQuizInfoTotalQuizPoints - window.cpQuizInfoPreTestMaxScore; 

 

var a = window.cpInfoProjectName;

var b = window.cpQuizInfoStudentID;

var c = window.cpQuizInfoStudentName;

var d = window.cpQuizInfoPretestPointsscored + "/" + window.cpQuizInfoPreTestMaxScore + " " + passFail;

var e = window.cpQuizInfoPointsscored + "/" + quizPoints + " " + passFail;

var f = n;

if ( !preTestAttempted )

{

  d = 'NA'

}

if ( !postTestAttempted )

{

  e = 'NA'

}

var xhttp;

if ( window.XMLHttpRequest )

{

  xhttp = new XMLHttpRequest();

}

else

{

  xhttp = new ActiveXObject( 'Microsoft.XMLHTTP' );

}

xhttp.open('GET', sheetURL + '?id=' + a + '&hid=' + b + '&name=' + c + '&pretest=' + d + '&posttest=' + e + '&tDate=' + n, true);

xhttp.send();

xhttp.onreadystatechange = function ()

{

  if ( xhttp.readyState == 4 && xhttp.status == 200 )

  {

   //var msg = JSON.parse(xhttp.responseText);  

   console.log( xhttp.responseText )

  }

}

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 03, 2016 Jun 03, 2016

So, I tried out a new code to see if the problem was the javascript or the webserver, and it worked. I used an alert to show the variable information that I retrieved using getVariableValue.

Here's the new script:

alert(window.cpAPIInterface.getVariableValue("Resistor_Content_Viewed"));

So, I know that the getVariableValue part is working. I just need to figure out how to send it to my google form. I'm very new to Javascript so your response overwhelmed me a bit.

I want the variable "Resistor_Content_Viewed" to answer the question in this form https://docs.google.com/a/umich.edu/forms/d/1Au2ThWq3ejgfvnNZnjjdVIhktsZX6c-PU3Om9PzKM20/viewform

When I did this on storyline, I found the script above and replaced my form's information. However, this isn't working for me on Captivate, even with changes you recommended.

Is the script you just posted a better way to do it? Would you mind walking me through how to change it for my needs?

Thank you so much! I can use all the help in the world!

Callie

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jun 03, 2016 Jun 03, 2016
LATEST

It's really a bit too complicated to build something for you on a forum, especially since I don't have any of the files or access to the google sheet itself. YOu can contact us and we'd be happy to help you out for a fee.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Help resources