Web window communicate with Lectora course?
July 8, 2019 12:00 AM
Hi,
Something I have never done, but it has come up for a new project I'm working on. I'm developing a training game using a game development tool (Godot). Godot can export to an HTML target, which I could then import into a web window. Is there any straightforward way for the web window to communicate with the course? At a minimum, to send a Boolean indicating that the student passed or failed, so the course can tell the LMS?
Thanks.
Discussion (7)
Yes, you can use JavaScript to communicate back and forth.
@Klaatu, like I say, I have not done this. Do you mean that JS in my game could set a variable which would be visible to the Lectora course's JS, which in turn could set a Lectora variable that I could then test to determine pass/fail? Or would JS in the web window be able to directly set the JS equivalent of a Lectora variable?
Thanks.
Yes, you can use JavaScript to assign the Lectora reserved variable AICC_Score in a dummy hidden Lectora test.. VarAICC_Score.set(godotScore) if your variable in the Godot content that holds the final score is called godotScore.
This is an over simplification, you still need to set up a dummy test in Lectora and if memory serves me correct, you might have other default Lectora test settings that need to be adjusted (perhaps include test score in overall score needs to be unchecked because there is no (Lectora) test score?)
If you have a sample, including the Godot content authoring files, time permitting I will try to work on it. No promises though as I am busier than a long tailed cat in a room full of rocking chairs.
Thanks, Darrel. I'm not ready to actually implement the Lectora--the game isn't even fully designed yet!
I also still have to figure out how to set JS variables from within the game. The Godot environment natively supports its own scripting language and C# only.
I do appreciate the help, and offer of further help, though.
1. Yes it is possible to communicate from a web window to the parent Lectora page.
2. Yes it is possible to use JS in your web window to alter a Lectora variable.
3. Depending on whether the contents of your web window is hosted with the course or remotely, communication approach will vary. Locally hosted content can directly access parent window variables. Remote content will not be able to do so. You will have to set up communication using postMessages. In short, the web content will send postmessages to parent Lectora page, and a local script in the parent page will catch those messages and act on them, e.g. change Lectora variables. Generally speaking, the latter is the "correct" way of doing this even if your web window content is not hosted remotely.
I would suggest that prior to building out your game that you first construct a very very simple test (Godot web window button changing lectora content and vice versa maybe?) just to get your Godot content to communicate with Lectora.
Wow, a Sergey sighting. Long time no see. Hope all is well.
Discussions have been disabled for this post