We're converting from ANGEL to D2L.  We've created JavaScript-based widgets that use the $SECTION_ID$ token to tell the script what course it is running from.  In Desire2Learn the equivalent would be the replacement string {OrgUnitCode}.  We'd like to just use that replacement string, but they don't work properly in course page (where most of my widget useage is).  Is there some other way to find out what course a JavaScript widget is running in?

Here is an example the code for one of our widgets that a user would paste into a page in their course: 

<script type="text/javascript" data-id="NotablePAD540" section="{OrgUnitCode}">
     var DAT = DAT || {}; if (!DAT.n) { (function (d) {
     var f = d.getElementsByTagName('SCRIPT')[0], s = d.createElement('SCRIPT'); s.async = true;
     s.type = 'text/javascript'; s.charset = 'utf-8'; s.src = '//dev.notable.vudat.msu.edu/n.js'; 
     f.parentNode.insertBefore(s, f); }(document)); }; DAT.n = 1; </script>

Each notepad has a unique ID, this code snippet example is for a notepad with the id 540.  The dynamic bit, {OrgUnitCode}, is what would separate out data, allowing me to use the same snippet in multiple course offerings and have the data stored separately.

有帮助吗?

解决方案

If the case is purely to have a widget on course home page that contains dynamic information the most effective solution is probably to use a "Remote Plugin Widget".

These can be set up by administrators uing the "Manage Remote Plugins" tool.

They Remote Plugins effectively just combine LTI launches into iframes and make them available as widgets when you are configuring home pages(or in other areas of the system). There are examples posted of how to use this for richer server side applications.

The LTI launch itself passes information on where it is being launched from (i.e. context related information).

In your case it looks like just hosting a static page containing javascript would work. Then you could use the javascript to inspect the query string. (A bit tricky to test the LTI signatures from javascript safely, if you care about trust at that point...)

Also, Valence APIs (the GET calls) can be used from the javascript if you need to supplement with other information that is available.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top