Passing number variables to html/print report

Nov 25, 2014

Hi,

(sorry for my english, I'm french speaker)

In my Storyline activity, I used text and number variables. They all work perfectly. At the end of activity, the students will print a report.


The text variables passed very well to the html rapport. But I'm unable to pass number variables to the report. (in the html/printed report, the number variables appears "undefinied".


I think the problem is somewhere in this script (in the html page):

var player=window.opener.GetPlayer();

//text variables:

 var vPrenom=player.GetVar("Prenom").replace(/(\r\n|\r|\n)/g);      
 var vChoixFinal1=player.GetVar("ChoixFinal1").replace(/(\r\n|\r|\n)/g);
 var vChoixFinal2=player.GetVar("ChoixFinal2").replace(/(\r\n|\r|\n)/g);

 // number variables:

var vResultat=player.GetVar("Resultat").replace(/(\r\n|\r|\n)/g);          
var vMultiR=player.GetVar("MultiR").replace(/(\r\n|\r|\n)/g);
var vMultiI=player.GetVar("MultiI").replace(/(\r\n|\r|\n)/g);
    // -->


Or in this extract of body code:

    <td width="30%" class="lettre"><script>document.write(vPrenom);</script></td>
    <td width="30%" class="lettre"><script>document.write(vResultat);</script></td>


Or ... ?

Thanks for your help,
Alain

12 Replies
Basit Hussain

Hi Alain,

I didn't get time to simulate your issue but could you please try using toString() to convert your number variables and then use replace() on them. So your code will be:

var vResultat=player.GetVar("Resultat").toString().replace(/(\r\n|\r|\n)/g); 
var vMultiR=player.GetVar("MultiR").toString().replace(/(\r\n|\r|\n)/g);
var vMultiI=player.GetVar("MultiI").toString().replace(/(\r\n|\r|\n)/g);

I assume GetVar() might be returning number and replace might not work on it.

Let me know if that works.

Regards,
Basit

Alain Dumais

Bonjour Allison,

La solution proposée par Basit a très bien fonctionnée.

Si vous souhaiteriez la tester, je vous invite au : http://moodle.ticfga.ca/login/index.php

Accédez ensuite à l’activité « Champlain dans le temps ». (Il s'agit de ma première création Storyline, soyez indulgente please  :-) 

Toutefois, pour avoir accès aux activités de ce Moodle, il faut être inscrit ou devoir s’inscrire. Cependant, pour une simple visite dans cette activité, vous pouvez utiliser les informations suivantes :

Nom d’utilisateur : yasmina
Mot de passe : contact7

Comme il s’agit d’un identifiant pour faire des tests, plusieurs personnes utilisent ce même identifiant. Si le système vous demande « Souhaitez-vous reprendre… » cliquez sur Non afin de faire recommencer l’activité dès le début.

Dans la 2e ou 3e diapositive, il y a un lien sous la forme d'une icône casse-tête intitulée « Ici juste pour passer le RIASEC? » cliquez dessus, le rapport à imprimer se trouve à la fin de cette partie.

Merci encore pour l'excellent service!

Alain

 

onEnterFrame (James Kingsley)

Just building on what Basit said... 

The issue is happening because .replace is a string function and SL is returning a number. Basit's solution is working because it turns that number into a string before running replace on it. 

But I am wondering why you are using a regex to remove line breaks from a number? Since it is just a number it should not have any line breaks in it.  It should safe to run it as 

var vMultiR=player.GetVar("MultiR")

That will save a few CPU cycles and they all add up :-)

Kaan Saygı

Bonjour,

J’ai crée un module de quiz sur SL1.

J’aimerais le même résultat que Alain a reçu quant aux variables dans le format html.

J’ai crée deux variables de text intitulées “namesurname” et “date”. Les étudiants y vont insérer.

En plus de ces deux variables au-dessus, deux variables prédéfinies ( Results.PassPoints et Results.ScorePoints doivent se présenter en html.

Je vous prie de me fournir les codes nécessaires ici.

Merci en avance,

Kaan

 

Alyssa Gomez

Bonjour Kaan!

JavaScript is not something I can help support, but I do know that we have many savvy users in the community that may be able to pop in and assist you in providing the necessary codes for: 

  • 'namesurname'
  • 'date'
  • 'Results.PassPoints'
  • 'Results.ScorePoints'

I also wanted to point out this article on Storyline 1: JavaScript Best Practices and Examples.

Ga An

Hi how to do it that script in below worked in html5 because it's only working on flash, why:

var a=player.GetVar("a");
var b=player.GetVar("b");
var c=player.GetVar("c");
var d=player.GetVar("d");
var e=player.GetVar("e");
var link='http://192.168.1.44/woaz_msql/records.php?a='+a+'&b='+b+'&c='+c+'&d='+d+'&e='+e;
window.open(link, "_self");

I use Articulate 360 to generate my project.

This discussion is closed. You can start a new discussion or contact Articulate Support.