What are the possible reasons backups of LTI tools won't export the data?

What are the possible reasons backups of LTI tools won't export the data?

by Diane Soini -
Number of replies: 2

I've got many different instances of moodle. Our production system will not backup LTI tool information. Here is an example of exporting an LTI tool that is configured as a pre-configured tool.

https://moodle.org/pluginfile.php/127/mod_forum/post/1722765/Gradescope%20LTI%20export.xml

You can see that the ltitype element for the tool is mostly empty. This means if we migrate to another instance of moodle, the tool doesn't get restored in any useful way. It's like this for all the external tools.

I've tried setting up LTI tools on the other instances and then created courses with those tools and backed them up and the ltitype element contains all the data you need.

So I am wondering what are possible reasons on our production system why the data doesn't get exported in the backup. Are there settings somewhere I'm missing?

Average of ratings: -
In reply to Diane Soini

Re: What are the possible reasons backups of LTI tools won't export the data?

by Diane Soini -
Okay I think I figured it out. Moodle has decided that it won't actually export LTI tool information for pre-configured tools. It leaves everything null except the name and database id, even the toolurl is null, and assumes the information can be found in the database with the database id. In this way it is impossible to properly restore the pre-configured tools in a course to another system.

I've had to add a hack to do a database query on the name of the pre-configured tool. Name and course = 1. Take the most recent one and match that up. That was the only way I could figure out how to map them to a new system. Since both of these are our systems this should work okay because we will set up our new system to name the tools the same thing and have them ready to go before the migration we are planning to do.

I hacked the code of mod/lti/backup/moodle2/restore_lti_stepslib.php find_existing_lti_type function and added a section of code to query on name = :name and course = 1 right after the block of code that always fails because it's not really the same site even though it thinks it is. I also added code to the process_ltitype function to update the name of the tool to add " - not fully restored" if a match was not found by name with the pre-configured tools and there is no toolurl in the data.

Hope that helps any devs out there who are struggling with this.
Average of ratings: Useful (1)
In reply to Diane Soini

Re: What are the possible reasons backups of LTI tools won't export the data?

by Randy Thornton -
Picture of Documentation writers
Diane,

Thanks for posting the solution. I think "won't actually export LTI tool information for pre-configured tools" is by design since those are part of the system and not the course: it would certainly open up some security issues if the credentials for such connections were included in every course backup file.

It would be useful if there was a way to export those from the Site admin menus for porting to a new site (maybe with key/secret optional).