turnitin / moodle-plagiarism_turnitin

Turnitin Plagiarism plugin for Moodle
http://www.turnitin.com
45 stars 69 forks source link

Error on "View the Rubric used for marking" as a student #537

Closed sleitao closed 3 years ago

sleitao commented 4 years ago

When submitting an assignment as a student, if I click "View the Rubric used for marking" I get the following error:

Exception - Argument 2 passed to has_capability() must be an instance of context, null given, called in [dirroot]/plagiarism/turnitin/ajax.php on line 162

$plugin->version = 2020072201;

jonof commented 3 years ago

This is a fix we're presently evaluating:


index 863d466..fef68fd 100644
--- a/amd/src/rubric.js
+++ b/amd/src/rubric.js
@@ -37,11 +37,13 @@ define(['jquery',
             },
             rubricCreateModal: function(modalType) {
                 var courseid = ($('input[name="course"]')) ? $('input[name="course"]').val() : 0;
+                var cmid = $('input[name="coursemodule"], input[name="id"]').val() || 0;

                 ModalFactory.create({
                     type: modalType,
                     templateContext: {
                         courseid: courseid,
+                        cmid: cmid,
                         wwwroot: M.cfg.wwwroot
                     },
                     large: true
@@ -53,4 +55,4 @@ define(['jquery',
                     });
             }
         };
-    });
\ No newline at end of file
+    });
jmcgettrick commented 3 years ago

https://github.com/turnitin/moodle-plagiarism_turnitin/pull/550

jonof commented 3 years ago

It seems my fix is not enough to solve the error you still get if you click the rubric icon once a submission is no longer editable and there's no form from which the plugin can steal the cmid or courseid. I'll contemplate a more robust solution.

jonof commented 3 years ago

This alternative works reliably from our testing: jonof@385f22ec7ec0eade8a2bc13fe6f85cf79d630577

jmcgettrick commented 3 years ago

Hey @jonof - can you make a PR for that please?