Puzzling JS behaviour

Hello

I am trying to read the value of the AICC_Student_Name reserved variable into a JS script.

I am using moodle 3.0.3+

Lectora receives AICC_Student_Name from Moodle correctly as I can display it in a textbox.

However, the JS program seems to choke on the following line

var FullNameJS= VarAICC_Student_Name.getValue();

I have used similar function calls before.

I am just baffled. Any help gladly accepted.

Thanks

Andrew

undefined

Discussion (3)

G'day Andrew,

All you need is:AICC_Student_Name.getValue()

However, the variable will not be available on the page or pages unless Lectora knows that it is needed, therefore, you need to use it. To do that just create a dummy variable, I use "junk", then I load junk with all the variables I will need, so I do:

Modify Variable

junk

Set Equale to

VAR(PageInTitle) + VAR(CurrentPageName) + VAR(AICC_Student_Name)

Then I can get the current page name by doing: CurrentPageName.getValue()

HTH

Regards, Peter

www.LectoraDeveloper.com

Hello Peter

Thanks a lot. I knew about the need to "activate" the variable but it seems I was using the wrong syntax in calling the lectora variable into JS. Changing that fixed my problem.

Thank you again

Andrew

Yep, Lectora's own variables don't need the Var.... prefix, so it's just AICC_something_something etc.

Discussions have been disabled for this post