Using variables in HTML Extension Object

ewalsh-3688
ewalsh-3688 Community Member Posts: 23 ☆ Roadie ☆
Hi,

Can anyone help me with the correct way to use a Lectora variable in the Ace Code editor for a HTML Extension Object? I've used the dropdown at the top of the screen, and depending on the variable, it will either insert the variable name, or prefix 'var'. However, it doesn't appear to be detected correctly when run though.

I'm trying to insert an img tag with a URL that contains the learner's username, something like this:
<img src="https://example.com/image?q=AICC_Student_ID"></img>
In this example, the AICC_Student_ID isn't being changed to the learner's LMS username when run from an LMS as a SCORM 1.2 package.

I was anticipating it changing to:
<img src="https://example.com/image?q=johnsmith1"></img>
The HTML Extension Object is currently an 'Other' type.

Any advice would be most appreciated,

Thanks,

Best Answer

  • wheels
    wheels Florida USACommunity Member, Administrator, Moderator, Rockstar Manager Posts: 631 eLearning ROCKSTAR Admin Team
    Answer ✓
    Here is one way to do it:
    <image class="studentpic" style="width:50px;height:50px" src=""></image>
    <script>
        triv$(".studentpic").attr("src","https://example.com/image?q="+AICC_Student_ID.getValue());
    </script>
    

Answers