Forum Discussion
Course completion with a code block?
Thanks John_Reddinger !
We are considering this. It would require authors to add the same code snippet we'll be providing to integrate code blocks with continue blocks. Then selecting something like "Track using Code block" in your export settings.
Thoughts on that approach?
- John_Reddinger11 months agoCommunity Member
Hi Kyle_Clements -- sorry, I somehow missed this reply a few weeks ago! Busy month :)
Yeah this would be great!
My use case is that I have an embed block at the end of my course, where I embed a satisfaction survey. The embed block always has some extra white space at the bottom, which often causes a few users to fail to scroll all the way to 100%.
At first I tried to mitigate this by setting the completion percentage a bit lower, which kinda worked but was a bit too inexact for my liking.
Now I'm trying to use a Storyline block with a completion at the start of the timeline -- it seems like on mobile you have to click the play button to get the timeline to start, though. I'm currently trying to figure out a way to make this work -- might just be a matter of making the storyline block literally say "click here to complete the course", I guess.
In any case, the control freak in me would just love to be able to pass completion with anything I want! LOL.
- ChloeArntzenAU2 months agoCommunity Member
I know this is an old thread... but with the enhancements that have been made over time to the code block it would be AMAZING to be able to have it as an option for tracking course completion.
Having to add Storyline blocks as well adds more maintenance than necessary to the course.- AndrewBlemings-2 months agoCommunity Member
If you're comfortable with code blocks, it is possible to use the function call John_Reddinger provided. The SCORM API lives "higher up" than the code block so we just have to prepend the call like so:
window.top.SCORM2004_CallSetValue('cmi.completion_status', 'completed');I just made a quick Rise course with a code block that calls the above function when a button in the code block is clicked, and SCORM cloud registered the completion no problem.
- Justin_H5 days agoCommunity Member
We encountered CORS errors when attempting to access the SCORM API like this in a code block when embedding in our LMS. The below code worked for us instead.
More generally, does anyone know if accessing the SCORM API like this from within a Code Block could be problematic at all? In other words, should we be thinking twice about publishing Rise SCORM packages that use the SCORM API to do things like set the score from within Code Blocks? Is this akin to calling an undocumented API?
I've been trying to find technical documentation that describes how developers can/should interact with the Rise package from within a Code Block. There are some great examples on these forums, but I've not seen any of the more "official" information with guidelines/best practices that I've been expecting.
const findScormAPI = (win) => { let attempts = 0; // Look up/through the window chain for an API object const scanChain = (currentWindow) => { while (currentWindow && attempts < 50) { attempts++; if (currentWindow.API_1484_11) return currentWindow.API_1484_11; if (currentWindow.API) return currentWindow.API; if (currentWindow.parent && currentWindow.parent !== currentWindow) { currentWindow = currentWindow.parent; } else { break; // Reached the top of this window chain } } return null; }; // 1. Search the current window's parent chain console.log("Scanning window parent chain for SCORM API..."); let api = scanChain(win); // 2. Search the opener's parent chain (i.e. for new-window launches) if (!api && win.opener && win.opener !== win) { console.log("API not found in parent chain. Scanning window.opener chain..."); api = scanChain(win.opener); } // Log the final discovery result if (api) { console.log(`API successfully found after ${attempts} total attempts.`); } else { console.log(`API NOT FOUND. Reached ${attempts} attempts limit or top of window chains.`); } return api; }; const api = findScormAPI(window); api.SetValue("cmi.score.raw", "100"); api.Commit();
Related Content
- 11 months ago
- 1 month ago
- 7 months ago