Explore the community Forums Lectora Lectora Questions & Answers Trigger Lectora event from JavaScript Reply To: Trigger Lectora event from JavaScript

#398457 Score: 0
Profile photo of Zachary Liquorman
Zachary Liquorman
friend finder
curious george
wise owl
picture perfect
8 pts

How did you get a course to publish by setting the completion in JavaScript? When I try that, Lectora says, “Assignable Unit … is missing a scored Test or a Modify Variable action for either AICC_Lesson_Status or AICC_Score.” I suppose I could add a test that nobody sees and set the score on that, but that’s pretty hacky.

Sorry, I think it sounded like I was saying this was done externally without any Lectora variables. I meant that you could trigger Lectora actions via Javascript directly or otherwise just use Lectora actions to trigger what you need.

So, like Tim K said, you could create an action group which modifies the completion variables. For example, when the onload event fires for the second time, you have Javascript run (e.g. runGroup_ActionGroupName() )

That action group would contain (at the very least) an action to modify the variable AICC_Lesson_Status (which is just Lectora’s name for the underlying variable it is referring to, the SCORM 1.2 variable cmi.core.lesson_status), and set it equal to one of the statuses in that run-time reference I posted before (e.g. completed).

As long as the AICC_Lesson_Status is being modified in the Lectora content, it doesn’t care about the score (in SCORM 1.2 the score of an assessment is directly tied to the lesson status, but not all LMS’s are set up to recognize this which is why I would play it safe and modify the AICC_Lesson_Status variable instead of modifying the AICC_Score variable).

To summarize: 

In Lectora, you can group together at least two actions, and call it something like completion_group. Create whatever other actions you feel are necessary in the group, but make sure to at the very least have the action Modify Variable set to target AICC_Lesson_Status with type Set Equal To with value completed.

Then, in your Javascript, when your second onload event fires, you call the function runGroup_completion_group(). This will set the completion status of the course to completed and your LMS should update accordingly.