Explore the community Forums Lectora Lectora Questions & Answers Puzzling JS behaviour

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #311444 Score: 0
    Profile photo of Andrew Lian
    Andrew Lian
    Member
    beginner
    intermediate
    friend finder
    advanced
    contributor
    wise owl
    curious george
    profile
    12 pts
    @mlapl1

    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

     

    #311445 Score: 2
    Profile photo of Peter Jackson
    Peter Jackson
    Member
    beginner
    intermediate
    advanced
    friend finder
    contributor
    junior moderator
    wise owl
    group mod
    entry
    winner
    17 pts
    @pjackson2462

    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

    http://www.LectoraDeveloper.com

    This post has received 2 votes up.
    #311460 Score: 0
    Profile photo of Andrew Lian
    Andrew Lian
    Member
    beginner
    intermediate
    friend finder
    advanced
    contributor
    wise owl
    curious george
    profile
    12 pts
    @mlapl1

    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

    #311500 Score: 0
    Profile photo of Sergey Snegirev
    Sergey Snegirev
    Member
    contributor
    intermediate
    advanced
    friend finder
    lab member
    junior moderator
    advocate
    LUC16
    LUC16 Attendee
    wise owl
    339 pts
    @ssneg

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

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.