Student Name reversed on the certificate (Lectora Version 11)

After trying following several different instructions that were posted on here in lectora forum to do the student name reversed (first name and last name in that order) on the certificate but none of those work in lectora 11.


Please help to supply with correct and workable of step by step guide for me for lectora version 11? I would be grateful to know how to do the student name reversed on the certificate pulled from LMS.


Thanks

David

Discussion (10)

@diggler 57113 wrote:

After trying following several different instructions that were posted on here in lectora forum to do the student name reversed (first name and last name in that order) on the certificate but none of those work in lectora 11.


Please help to supply with correct and workable of step by step guide for me for lectora version 11? I would be grateful to know how to do the student name reversed on the certificate pulled from LMS.


Thanks

David



Hi David,


What results are you seeing on the cert? Does it have the student's name on it at all? Is it blank? Did you add the JS code to flip the name, put it into a variable, do a change contents of the 'placeholder' with the variable with the reversed name?


-kelly

1. How to Reverse the Student Name from an LMS

The name you get from an LMS is in the form of “last, first middle”

To reverse them code this action with the below JavaScript function.

Action: Modify Variable

Target: _studentName

Value: Javascript: reverseName()

Condition: AICC_Student_Name Is Not Empty

And in an HTML object enter this JavaScript:



There are likely slightly simpler ways to do this in 11 but this should work.

Hi,


I am trying to do something similar here with a javascript I found on the forum but it is not working.


Here is the script and instructions. Can anyone see if there is anything that needs to be changed:


Separating first and last names.


It can be done in three steps:


1.

Create a textfield that's initially invisible

Add an action

On: Page show

Action: Change content

Target: This object

Value: VAR(AICC_Student_Name)


2.

Create two variables

-> lastname

-> firstname


3.

Add an action on page level


On: Show

Action: Run JavaScript

Javascript:

var username = VarAICC_Student_Name.getValue().split(", ");

Varlastname.set(username[0]);

Varfirstname.set(username[1]);


"lastname" now contains the users' lastname (i.e. everything before the ", ") "firstname" contains the users' firstname. Both variables can now be used throughout the course.


When I try this on my LMS it doesn't work. It also seems to be interfering with some other actions I am running on the page, which no longer work with this on the page.


I am not sure how the javascript picks up the student name from the text field created in step 1. Is there something I am missing here.

@ssneg 57128 wrote:

There's a problem. You have to use the variables lastname and firstname in Lectora on this page (in an action, or in a condition to an action), otherwise Lectora will not create these variables in the html page code, and the script will fail when trying to change them.


I do have actions with that include the lastname and firstname variables on this page. It is the first page of the course and I am trying to personalize the course with the learner's name. Could it be something else that I am not doing correctly here?


Thank you!

Well, there goes my theory. Hard to help further without seeing the course or at least the output. Can you make a sample title with one page and share it?

Try putting the code in an HTML object as a function with javaScript tags around it and call the function.

@plc 57126 wrote:

Hi,


I am trying to do something similar here with a javascript I found on the forum but it is not working.


Here is the script and instructions. Can anyone see if there is anything that needs to be changed:


Separating first and last names.


It can be done in three steps:


1.

Create a textfield that's initially invisible

Add an action

On: Page show

Action: Change content

Target: This object

Value: VAR(AICC_Student_Name)


2.

Create two variables

-> lastname

-> firstname


3.

Add an action on page level


On: Show

Action: Run JavaScript

Javascript:

var username = VarAICC_Student_Name.getValue().split(", ");

Varlastname.set(username[0]);

Varfirstname.set(username[1]);


"lastname" now contains the users' lastname (i.e. everything before the ", ") "firstname" contains the users' firstname. Both variables can now be used throughout the course.


When I try this on my LMS it doesn't work. It also seems to be interfering with some other actions I am running on the page, which no longer work with this on the page.


I am not sure how the javascript picks up the student name from the text field created in step 1. Is there something I am missing here.



There's a problem. You have to use the variables lastname and firstname in Lectora on this page (in an action, or in a condition to an action), otherwise Lectora will not create these variables in the html page code, and the script will fail when trying to change them.

Hi there,


First of all, I'm sorry if some field in the steps below is different of Lectora's menu in english, mine is in portuguese (moderators feel free to edit).


In Lectora v11.3.1 I used the same logic, but to work in Moodle and Scorm Cloud without javascript errors I did the following:


1. Create two variables

-> firstname

-> lastname



2. In the top of the project (before AU), add 3 actions

On: Show

Action: Modify variable

Target: firstname

Type: Set equal to

Value: 0

Condition: firstname => is empty


On: Show

Action: Modify variable

Target: lastname

Type: Set equal to

Value: 0

Condition: lastname=> is empty


On: Show

Action: Execute javascript

Javascript:

var name = AICC_Student_Name.getValue().split(", ");

Varfirstname.set(name[0].toString());

Varlastname.set(name[1].toString());



3. Create a textfield (initially hidden) in the top of the project (before AU and after previous actions), and inside it an action

On: Show page

Action: Change content

Target: This object

Value: AICC_Student_Name



4. TO USE: Create two textfields in the page, within an action in each

On: Show page

Action: Change content

Target: This object

Value: firstname



On: Show page

Action: Change content

Target: This object

Value: lastname



After many attempts, this was the one that worked perfectly for me.

Hope that helps others.

Hi Ben.

Could you please provide the javascript? looked like it was cut off from your post.

undefined

Many thanks,

I've got this working.

What I felt was missing in some of the step-by-steps was the importance of making sure your variables are referenced in the course before they're used - my JS errored because variables weren't defined.

Below is how I got this to work nicely - I've got it in a demo Lectora file as well so let me know if you want me to package it up.

I find this set of instructions can be used on any level of your course - so you can run it on the first page, or just have it running every time a page loads. The important thing is if you're using a version of Lectora that doesn't update a variable value live on the page (so only presents the value it was at on page load), you'll need to use a change content action to present your newly split name as the JS command will have run after your page load.

Step 1

Create variables for how I'd like the name to look (in my case I want to split the variable into First Name and Last Name so I've got options for Informal and Formal presentation of the name.

These are the options I went with in my example:

firstname

lastname

Step 2 - this is so the variables are referenced as the course opens and values set

Create a text box and put all three variable names into the text box.

(Create Text Box > Double Click Text Box > Select Properties > Select Variables > Select your variable from the drop down)

Put all of the variables in there:

- firstname

- lastname

- AICC_Student_Name

You can put this text box off canvas and hidden but make sure you have one so it defines the variable values in the courses first instance of opening.

Step 3

Create an Action > Run Javascript

Input this code into the JS box:

var name = AICC_Student_Name.getValue().split(",");

Varlastname.set(name[0]);

Varfirstname.set(name[1]);

Set delay for action: 0.1 (so your file will populate the text box before trying to run this code)

Note

If you want to use different variable names from firstname and lastname simply replace this text Var[myvariablename]

Step 4

If you are referencing VAR(firstname) or VAR(lastname) on the same page as this action you're running, you will need to run a change content action to update the variable value if using a version of Lectora that doesn't automatically update this later than the page being loaded.