WeBWorK Main Forum

LTI in Moodle 4.3 (and up)

LTI in Moodle 4.3 (and up)

by Bernd Sing -
Number of replies: 2

It seems that in Moodle 4.3 (and up), the LTI behavior has been changed which affects the interaction with WeBWorK (in my case 2.18) -- unless I have been overlooking something fundamental...

In Moodle, LTI integration (both 1.1 and 1.3) is done via the External Tool plugin. This plugin allows to create a "preconfigured tool" for WeBWorK by the admin, and prior to Moodle 4.3 the instructor could then use this tool to connect to WeBWorK with the exact URL of a specific homework set or quiz on the respective WeBWorK server.

However, with Moodle 4.3 the textbox for the (exact) "Tool URL" has been removed from the settings page (technically, it is "hidden", see below). So, when I tried to setup the "External Tool" (respectively, the preconfigured WeBWorK tool) I couldn't find a way to specify the particular WeBWorK homework set anymore. Indeed, checking the Moodle forum, I found the following at https://moodle.org/mod/forum/discuss.php?d=454439:

Tools must now be set up prior to their use in a course. We no longer support manual configuration of a tool at the activity level, so this kind of on-the-fly tool instance creation isn't supported. So, regardless of whether the tool uses custom params or URL params to identify resources, it must be configured prior to its use.

So, in your case, the only 'solution' (it's not really feasible at scale) would be to configure these 'tools' (they are not really distinct tools in your case, but must be set up as such) and then use those tools via the activity chooser to create each link. Of course this gets messy quickly as the activity chooser fills up fast.

This certainly is a quite different behavior of the LTI tool in Moodle, and seems to substantially impact the way how one can connect to WeBWorK...

I did notice, however, that all connections between Moodle and WeBWorK (via LTI 1.1) setup before updating to Moodle 4.3 are still working, of course (or thankfully), and checking Moodle's database showed that the tool url could still be modified (using SQL, it is in the table mdl_lti) and thus be set to the homework set specific url there. In fact, the tool url textbox in Moodle 4.3 has only be "hidden", and so my current work-around (based on a similar suggestion in https://moodle.org/mod/forum/discuss.php?d=450974#p1825748 linked to in the above cited Moodle forum post) is to bring it back in Moodle by modifying the file moodle/mod/lti/mod_form.php.
At around line 440, I commented out the lines
//        $mform->addElement('hidden', 'toolurl', '', ['id' => 'id_toolurl']);
//        $mform->setType('toolurl', PARAM_URL);
//        $mform->addElement('hidden', 'securetoolurl', '', ['id' => 'id_securetoolurl']);
//        $mform->setType('securetoolurl', PARAM_URL);   
and replaced them by 
        $mform->addElement('text', 'toolurl', get_string('launch_url', 'lti'), array('size' => '64'));
        $mform->setType('toolurl', PARAM_URL);
        $mform->addHelpButton('toolurl', 'launch_url', 'lti');
        $mform->hideIf('toolurl', 'typeid', 'in', $noncontentitemtypes);

        $mform->addElement('text', 'securetoolurl', get_string('secure_launch_url', 'lti'), array('size' => '64'));
        $mform->setType('securetoolurl', PARAM_URL);
        $mform->setAdvanced('securetoolurl');
        $mform->addHelpButton('securetoolurl', 'secure_launch_url', 'lti');
        $mform->hideIf('securetoolurl', 'typeid', 'in', $noncontentitemtypes);

This seems to work in my case (this code is taken from the github files of MOODLE_402_STABLE). However, I likely have to re-do it with every future Moodle update.

I hope this will help someone using LTI  to connect Moodle and WeBWorK. Or maybe there is a better solution...


In reply to Bernd Sing

Re: LTI in Moodle 4.3 (and up)

by Alex Jordan -
What you are describing sounds similar to the way it has always been when Desire2Learn is your LMS. In D2L, my D2L site administrators have enabled faculty to create their own external learning tools, and have flagged our WW server as an approved domain. So the usual workflow is that an instructor creates an External Learning Tool using their course management tools, and this is where they state the URL to the WeBWorK course. Then in the content area (or navbar, or wherever) they can place links that use the ELT they created. There is no opportunity to change the launch URL at this stage; it has to be the one that was written into the External Learning Tool. And at least with my instance of D2L, it has always been this way.

This is frustrating for anyone who wants to use "homework" grade passback mode, where the launch URL is supposed to be specific to an assignment in WeBWorK. For us, that means creating separate External Learning Tools for each assignment, and then placing links that use each of those ELTs you created.

I don't know the ins and outs of why D2L (or Moodle) is designed to disallow adjusting the launch URL when the link gets placed. But if there is a good reason for that, it may be that the Moodle developers decided this is how it should be for security or something.

You modified your Moodle source code and that is working for you. If you had not done that, does what we do here with D2L sound like it would be a workaround (albeit a tedious one)? That is, can individual instructors create their own "External Learning Tools" (or whatever the right term is when using Moodle)? And could they create multiple such tools that use the same domain?
In reply to Alex Jordan

Re: LTI in Moodle 4.3 (and up)

by Bernd Sing -
Yes, inside each course in Moodle, the instructor can add an "LTI External Tool" with all the necessary parameters for each assignment individually -- just as you described for D2L. So, the answer to all your questions int he last paragraph is 'yes'.

Previously, the Moodle admin would have created such an External Tool (where, e.g., the specific 'consumer key' of the WeBWorK server would go), and a lecturer would then select that tool and add the specific URL to the homework set or quiz to it (and would not have to care about the 'consumer key' etc. that ensure the communication between WeBWorK and Moodle via LTI). Now, the Moodle admin could still create such an External Tool but it would not be of much use since the instructor cannot specify the particular homework set. The code snippet in my previous post brings back this option of specify the particular homework set using its full URL -- at least for the current Moodle release.