completion javascript in moodle from iPad
Jan 10, 2017
Hoping someone from the community has run across something like this. We have been using javascript to send completion to Moodle and to call for a certificate for quite some time.
Here is the javascript;
alert("You have completed this module. You will now be directed to your certificate in a new window. You can print it now, save it as a pdf, or come back later to retrieve it.!");
SetStatus("completed");
window.open('http://training.mdambulance.com/moodle2/mod/certificate/view.php?id=702&action=get');
I am not aware of any issues in previous modules but perhaps people did not use ipads or other challenged computers for that one. This time I have had 3 people contact me that the completion is not showing up and they cant get their certificate from Moodle (conditional to completion). I log in as them from my Macbook from home and complete with no issue. I can see that all of the required work is done but their completion is not going through. If I redo that last section then the completion takes for me. One person told me they were using an iPad so i tried that and I was unable to complete either with an iPad. The javascript is running as the new page tries to open but the certificate says not available because the completion status is not getting through. this is happening for maybe 5 people of 140 doing this section. One on an iPad, one on a macbook with no flash enabled and one on a pc that I dont know anything about. If it never worked it would be easy to troubleshoot but these intermittent things are a challenge. it is not the scorm package as it is working 95% of the time.
Any troubleshooting advice?
Thanks
Tim
6 Replies
The intermittent nature of things suggest a timing ("race condition") issue between the SetStatus call actually reaching Moodle and your call to window.open. Try wrapping the window.open with a setTimeout() call for a second (1000ms) or two, giving SL & Moodle time to connect
I would agree with it being a timing issue, , set the status and then call the alert and the website with a Timeout
Brian/Dennis;
thanks for this advice and I will try it.
I don have one concern that popped into my head as I was telling someone about this. if there is a timing issue will it block the completion from ever setting properly? When I go in a day later the completion status is still "incomplete". The description you are giving me seems to be that the call for the page comes before the completion occurs so the completion will get there after the page call. What I am seeing is the completion status is never changing to "complete" in these few cases.
sorry if I am not explaining this well.
Tim
I would expect the javascript connection between the module breaks on the page jump so at that point there is no LMS connection, adding in the timeout that Brian recommends may solve this, the other option is to set the status way before the trigger to jump elsewhere
Thanks Phil;
What I am thinking is to see if I can put in a 5 second delay and put that in the alert box "your cert will open in a new window in 5 seconds. If you dont see then click this link..."kind of thing
Or as you said I could send the completion when the final page loads rather than when they click the proper button as they cant get off that page without getting the right answer anyway.
I am willing to try anything right now.
Are iPads more susceptible? Or more problems with calling another page to open? I dont remember this issue previously with iPads but maybe I was just not being told about it.
personally I would set status as a different trigger ideally when the page loads and then the jump when they click the trigger.
Moodle used to have these intermittent issues, wasn't really iPad specific though, it could just be the way mobile safari is handling the javascript
This discussion is closed. You can start a new discussion or contact Articulate Support.