January 22, 2016 at 9:23 am #304160
I don’t mean to bother you, but since i read a bunch of discussings now, and still was not able to solve the problem i need to ask:
I’d like to write the name of the user by using “AICC_Student_Name”… that works fine so far, unless it is formatted “lastname,firstname”.
Therefore I found the Java script that splits the names and seems to be written perfectly in JAVA Code.
It doesn’t work …
Just to figure out the Problem i first checked Java is working… “alert” works! Fine so far!
then i tried getting and setting variable values
The .set method works great but a in-lectora defined variable named “_test” containing “Mustermann,Max” is not accessable!
would not work, although
i have no clue!
Do you?January 22, 2016 at 10:42 am #304165
Action: Modify variable
Type: Set equal to
Mind that AICC_Student_Name is only accessible after publishing to Scorm and uploading to your LMS.
alert(Var_test.getValue()); (Make sure it’s “getValue” not “GetValue”)
TimThis post has received 1 vote up.January 25, 2016 at 7:32 am #304241
Hey Tim, thanks for your support!
One important hint was to use variables “somehow” inside Lectora first. But it still did not work!
Anyway, I was able to isolate the core of the problem and would like to give sound advice to all users with similar problems:
First of all:
Tim K’s Java-Code works perfectly!
If there is still trouble, just change the line
“var username = VarAICC_Student_Name.getValue().split(“, “);”
“var username = VarAICC_Student_Name.getValue().split(“,“,2);”
After adding the parameter it finally worked!
Sometimes (i think it is depending on the Java-Version) the Java split-method necessarily needs the parameter “2” to “know” in how many pieces it shall split the string!
Thanks for all your support and feel free to contact if you have any further question!January 25, 2016 at 8:53 am #304247
Darrel SomozaMember209 pts@Klaatu
I’ve just reread my code and there’s indeed a small mistake in it, which probably has been made by that old forum software that used to add blanks in random places. As AICC_Student_Name contains the users name in the form “Surname,Firstname” it must be .split(“,”) (no blank) instead of split(“, “). The “limit” parameter is optional and it doesn’t tell the number of substrings that shall be created, it tells how many of the substrings shall be added to the new variable:
The code ‘var username = VarAICC_Student_Name.getValue().split(“,“,1);’ would create two substrings “Surname” and “Firstname” but “username” would only contain “Surname”.
TimThis post has received 1 vote up.January 26, 2016 at 7:54 am #304369
…so we got that going!
What do you (as the professional) think about reposting it in a total complete thread with all the advice we brought together now?
That the parameter was optional was just an educated guess from me … ;o)
Again…. Thank you very very much for your effort!
….well, if you say so…
Just to make me clever, i would appreciate that!January 26, 2016 at 9:10 am #304384
Darrel SomozaMember209 pts@Klaatu
Here’s the two minute version.
There is a lot of information on the web about the similarities and differences of the two if you want more info.
DRSThis post has received 2 votes up.January 27, 2016 at 4:26 am #304471
I don’t think there’s need for a new thread, as it’s all in there already:
You must be logged in to reply to this topic.