Javascript trigger not working when uploaded as SCORM to moodle
Mar 11, 2014
Hi
I have a print notes fuctionality in my course set up to work before the course quiz. The button triggers javascript causing a new window to open, referencing a print.hml file and a logo.html file; the file extracts the notes variables from the player.
It works perfectly when uploaded to google drive as a test environment, however when packaged as a SCORM object and uploaded to moodle, the trigger doesn't do anything visible.
I've added the files manually to the resource list in the imsmanifest.xml
I initially put the two extra files in the course root in the zip file, but then tried putting them in the story_content folder on the assumption that perhaps the relative path for the swf was different to that from the html file - updating the manifest accordingly and re-testing, but it still doesn't work.
I'm stumped!
Really grateful for any help anyone can give, as I'd hate to have to remove this functionality from the course!
Her's the javascript I'm using (originally sourced from a page on e-learning brothers):
var player = window.top.GetPlayer();
var header = "Safeguarding E-Learning Notes~~";
var args = ("What might you see and hear:~~" + player.GetVar("WhatSeeHear") + "~~What Makes people more vulnerable:~~" + player.GetVar("MoreVulnerable") + "~~Notes from Recording Video:~~" + player.GetVar("NotOnOwnNotes") + "~~Thoughts on Recording:~~" + player.GetVar("RecordVidThoughts") + "~~Questions for group training day:~~" + player.GetVar("GroupQuestions"));
var url = ("print.html?=" + header + args);
window.top.open(url, "_blank", "width=800,height=600,menubar=no,scrollbars=yes");
Thanks!
Nicola
7 Replies
I think the problem is that the javascript isn't being triggered at all at the moment...would anyone have a clue why the javascript isn't executing (i.e. no popup window launching, nevermind displaying a file) - as I said, it works fine outside the moodle environment.
Hi Nicola,
I don't know much about Javascript, but you may want to review this article on Javascript best practices.
I've narrowed this down a bit...
If I strip back the javascript to just open a new window containing my html file, that works...however, when I start trying to get the variables from the player to do something with them, it stops working - and completely so - it doesn't open the new window or load the html file any more. The javascript itself seems good, given it works in other contexts.
Is there an issue with accessing the player variables when running it on moodle?
Hi Nicola,
If you're looking to do more with the player elements you may want to look into customizing a player with the Storyline SDK as currently player elements such as the menu, next button, volume, etc. are not accessible through triggers.
I've fixed this problem; posting this solution in case it helps any other poor bugger some time in the future, saving them from hours of drudgery.
The problem is with the javascript I got from the e-learning brothers site in their tutorial on how to create a printed notes page.
The original code (customised for my project) is:
var player = window.top.GetPlayer();
var header = "Safeguarding E-Learning Notes~~";
var args = ("What might you see and hear:~~" + player.GetVar("WhatSeeHear") + "~~What Makes people more vulnerable:~~" + player.GetVar("MoreVulnerable") + "~~Notes from Recording Video:~~" + player.GetVar("NotOnOwnNotes") + "~~Thoughts on Recording:~~" + player.GetVar("RecordVidThoughts") + "~~Questions for group training day:~~" + player.GetVar("GroupQuestions"));
var url = ("print.html?=" + header + args);
window.top.open(url, "_blank", "width=800,height=600,menubar=no,scrollbars=yes");
To make it work you have to edit the first and last lines, removing 'window.top' from the first one, so it just reads:
var player = GetPlayer();
and taking out the 'top' from the last line so it reads:
window.open(url..... etc);
I removed that and it worked great.
Thanks Nicola!
Thanks Nicola... your solution helps me a lot!
This discussion is closed. You can start a new discussion or contact Articulate Support.