numbas / numbas-lti-provider

An LTI tool provider to run Numbas exams
https://docs.numbas.org.uk/lti/en/latest/
Other
11 stars 12 forks source link

lti_entry links which specify the exam within an editorlink #219

Closed jhoobergs closed 3 months ago

jhoobergs commented 2 years ago

Context

Currently, the only way to create an LTI link is to use the /lti_entry path and then open it once as an instructor to set up the exam. This is enough if you see each course in the VLE as unrelated. We have, however, some courses that use Numbas LTI links and that are duplicated at the start of each academic year. When we copy the courses, the LTI links are copied as well, but they are entirely new LTI resources for the provider so we need to set up all exams again and this can be a lot of manual work.

The Numbas LTI provider does already support the use of editorlinks to link an Numbas editor to the Numbas LTI provider to easily select exams instead of needing to download the zip file manually and upload it manually.

Proposed solution

This draft PR adds support for creating an lti link with the following path:

When this lti resource is opened and there is no exam associated with it, it will automatically download the zip file for the exam with reference exam_ref from the editor specified by editorlink_name.

When using this kind of lti link in courses, duplication of the courses works without any trouble.

Questions and topics to discuss

This is a MVP version of what I think is useful. I create this draft PR to ask the following questions / discuss the following topics.

Usefull feature?

Do you think that this feature is useful to merge into the main repo of the Numbas LTI provider?

Refs

Instead of using the id of the editorlink and the id of the exam, I would like to use a (human readable) reference.

Editor link ref

For the editorlink I currently use the name, but I think it would be better to add an extra char field named ref to an editorlink which can only contain alphanumerical characters.

Exam reference

The exam ids are never actually stored in the database as an integer because they are only stored in the urls in the cached_available_exams json of the editorlink. The current implementation does not depend on the exam ids being integer. This implies that the current implementation would also work for api's returning an url like https://numbas.mathcentre.ac.uk/api/exams/a-folder/an-exam-ref (compared to https://numbas.mathcentre.ac.uk/api/exams/3017/).

For rumbas I would like to host exams by pretending to be a Numbas editor (by implementing the api calls) and I would use paths to files as their reference instead of an numeric id.

Loading exams from projects that are not selected

Currently, the editorlink only keeps track of the exams of the projects that are selected by the admin (= the ones from which you can chose exams when using the normal /lti_entry path). The current implementation implies that you will only be able to load exams from projects that are selected by the admin.

I think that this is a valid solution.

Code style

I would like to get some general feedback on the code style that I used and on the structure of the code. I was, for example, not sure where to put the download_scorm_file function that I extracted.

christianp commented 2 years ago

I see you've found #128. I think that supporting the history parameters for copied content is the right way to handle this. I looked at it a while ago, but couldn't get a good test framework set up to check that I'd done it properly.

I don't think it's that common that instructors can set their own LTI launch URLs. At Newcastle we have to pick from a fixed list set up by our Canvas admins, and I think that's true for many other institutions too.

I can't see a point for this feature, if the history parameters are supported. Anyway, I'm not keen on the editor links feature as it exists - without any user authentication, it can only show public material, which isn't much use. If I was passing in an exam during the LTI launch, I would prefer to use the share URL generated by the editor, so the LTI server can just has to have the ability to fetch any URL.

christianp commented 2 years ago

The style of your code looks fine. I think that I would use CreateExamForm as part of your alternate lti_entry method, rather than spinning out the function download_scorm_file and replicating the other logic.