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

Email quiz results variables in body of an email with JavaScript in Captivate 9

Community Beginner ,
Jan 31, 2017 Jan 31, 2017

Copy link to clipboard

Copied

This Javascript example works in Captivate 9 to send quiz data to a url: JavaScript Solution: Launch a URL with Captivate Variables as Parameters - CaptivateDev.com  (I've already successfully modified this one to include all quiz results variables)

While this JavaScript example works in Captivate 9  to open our default email (Outlook) and populate the address line, subject line, and body with text but without any quiz results data: Email via Javascript button - Articulate Storyline Discussions - E-Learning Heroes

Now, what everyone actually wants to do with Captivate 9  is to send Captivate 9 quiz results in an html 5 environment via email; however, incredibly Captivate 9 still cannot do this.

However, Articulate with this JavaScript example can apparently do so just fine here: http://matthewbibby.com/email/#filesyoumightneed

Now the following question is for anyone proficient enough in JavaScript in a Captivate 9 context to answer my question:

These are my Captivate quiz results variables:

$$cpQuizInfoTotalProjectPoints$$

$$cpQuizInfoTotalProjectPoints$$

$$cpQuizInfoTotalCorrectAnswers$$

$$cpQuizInfoTotalQuestionsPerProject$$

$$cpQuizInfoQuizPassPercent$$%

$$cpInfoPercentage$$%

$$cpQuizInfoAttempts$$

Now for my questions:

1) Even though the some of the above working JavaScript is intended for Articulate I presume it would also work in Captivate 9, yes?

2)Assuming yes, if I wanted to publish one or more of the above Captivate quiz results variables into the body of a email to be sent to a third party, how would the could we combine the aforementioned JavaScript examples, into a final JavaScript version, that would insert one or more of the above variables coded into the body of the mail along with their text descriptors, so that we get something like the below in the body of an mail?

You-Scored: $$cpQuizInfoTotalProjectPoints$$

Maximum-Score: $$cpQuizInfoTotalProjectPoints$$

Correct-Questions: $$cpQuizInfoTotalCorrectAnswers$$

Total Questions: $$cpQuizInfoTotalQuestionsPerProject$$

Percentage-to-Pass: $$cpQuizInfoQuizPassPercent$$%

Percentage-Scored: $$cpInfoPercentage$$%

Attempts: $$cpQuizInfoAttempts$$

Obviously, in the final output the score values would be visible in lieu of the $$variables$$.

Hope this works, or the alternative may be to switch to Articulate since this company does not want an LMS and is hesitant to use Quiz Analyzer.

Views

2.0K

Translate

Translate

Report

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

correct answers 1 Correct answer

New Here , Jan 11, 2018 Jan 11, 2018

Here's what I came up with:

var email="alias@emailaddress.com";

var subject="CBT Completion Notice";

var fbk=window.cpAPIInterface.getVariableValue("cpQuizInfoStudentName");

var Fbk=window.cpAPIInterface.getVariableValue("cpInfoPercentage");

var body_start="Completed CBT:";

var body_middle="%0D%0A" + "Name:" + "\xa0" + fbk;

var body_end="%0D%0A" + "Score:" + "\xa0" + Fbk;

var mailto_link='mailto:'+email+'?subject='+subject+'&body='+body_start+body_middle+body_end;

win=window.open(mailto_link,'emailWin');

...

Votes

Translate

Translate
Community Expert ,
Jan 31, 2017 Jan 31, 2017

Copy link to clipboard

Copied

Why do you put the variables between $$? That is the way they appear as placeholder in a text container but the variable name has never $$.  You can download a table with all the system variables from this blog post:

System variables in Captivate 8/9 - Captivate blog

The score obtained is cpQuizInfoPointsscored, not cpQuizInfoTotalQuizPoints nor cpQuizInfoTotalProjectPoints

Votes

Translate

Translate

Report

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
Community Beginner ,
Jan 31, 2017 Jan 31, 2017

Copy link to clipboard

Copied

Thank you for sharing the list.

Q: Why did I list the variables between double dollar signs?

A: Because nowhere in the JavaScript discussions at the Captivate or Articulate forums I reviewed did anyone explicitly mention that about CP variables in this context--using the cp prefix instead of having cp variables in between double dollar signs. But then technicians are notorious for glossing over essentials that they take for granted when talking to those less familiar with such matters.

Votes

Translate

Translate

Report

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 ,
Jan 11, 2018 Jan 11, 2018

Copy link to clipboard

Copied

Here's what I came up with:

var email="alias@emailaddress.com";

var subject="CBT Completion Notice";

var fbk=window.cpAPIInterface.getVariableValue("cpQuizInfoStudentName");

var Fbk=window.cpAPIInterface.getVariableValue("cpInfoPercentage");

var body_start="Completed CBT:";

var body_middle="%0D%0A" + "Name:" + "\xa0" + fbk;

var body_end="%0D%0A" + "Score:" + "\xa0" + Fbk;

var mailto_link='mailto:'+email+'?subject='+subject+'&body='+body_start+body_middle+body_end;

win=window.open(mailto_link,'emailWin');

Full disclosure: Today is day two of my javascripting experience (I am what the kids call a "n00b," ;)), so if my code isn't elegant, my apologies. What this does, however, is generate an email that autofills: email recipient, email subject, and email body. The email body has three line breaks to help the recipient read the content easier, including the pulled variables out of your responsive project.  You can conceivably add variables(and tweak your subject and body lines) as needed.

All the user has to do is hit "send."  I have tested this and it works.

While I recognize LMSs replace this work, I saw a challenge that I wanted to take a stab at.

I hope this helps.  Cheers!

--Harm

Votes

Translate

Translate

Report

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 ,
Mar 16, 2018 Mar 16, 2018

Copy link to clipboard

Copied

Thanks for sharing!!! I'm going to give this a stab.

Votes

Translate

Translate

Report

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 ,
May 23, 2018 May 23, 2018

Copy link to clipboard

Copied

Did this end up working for you? I am trying to similarly access the system variable cpInfoPercentage to be used in a separate HTML and /or JavaScript file ....

I am now wondering if this is the code I need = var whatever = window.cpAPIInterface.getVariableValue("cpInfoPercentage");


Are you creating this email from inside Captivate? What I am asking is if you know if this will work outside of Captivate in conjunction with the published code from a Captivate file.

Votes

Translate

Translate

Report

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 12, 2018 Jun 12, 2018

Copy link to clipboard

Copied

I found a faster solution pointing them to the google forms and I like all the results that come with it.  So no I didn't give the above solution a try.  Sorry.

Votes

Translate

Translate

Report

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 ,
Nov 03, 2021 Nov 03, 2021

Copy link to clipboard

Copied

LATEST

This works great for me!
I understand there isn't a way to automatically 'send' the message, but this should work for my use-case.
Maybe e-mailing a screenshot is possible?
Thank you for sharing the knowledge, you've made my job easier today.

Votes

Translate

Translate

Report

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