Copyleaks / moodle-plagiarism_copyleaks

Copyleaks Plagiarism plugin for Moodle
GNU General Public License v3.0
3 stars 3 forks source link

Argument 2 passed to plagiarism_copyleaks_comms::submit_for_plagiarism_scan() must be of the type string, null given, called in #15

Closed qqtuyen closed 2 years ago

qqtuyen commented 2 years ago

Getting this error with the latest code

$plugin->version = 2022072100; $plugin->release = "3.5+"; $plugin->requires = 2018051700; $plugin->component = 'plagiarism_copyleaks'; $plugin->maturity = MATURITY_STABLE; Moodle version 3.11.8 php 7.4

Scheduled task failed: Copyleaks plagiarism plugin - handle queued files (plagiarism_copyleaks\task\plagiarism_copyleaks_sendsubmissions),Argument 2 passed to plagiarism_copyleaks_comms::submit_for_plagiarism_scan() must be of the type string, null given, called in /var/www/name/plagiarism/copyleaks/classes/task/plagiarism_copyleaks_sendsubmissions.php on line 239 Backtrace:

CL-BayanAbuawad commented 2 years ago

Hey, @qqtuyen it seems that the submission type is missing for this request, can you please tell me what kind of submission you have? ('File Upload', 'Text Content', 'Forum Post', 'Quiz Answer')

qqtuyen commented 2 years ago

The plugin is only setup to work on assignments and forums. Does that help narrow it down?

Thank You, Q

CL-BayanAbuawad commented 2 years ago

@qqtuyen yes thank you, I will be checking this ASAP

CL-BayanAbuawad commented 2 years ago

@qqtuyen I installed the same version of Moodle & the same version of the plugin, and I wasn't able to recreate the issue, can you please provide a screenshot of your plugin settings & a screenshot of the submission that is stuck because of this?

nrosenquist commented 2 years ago

Hi I'm on the same team as @qqtuyen, having just done some further investigation of the issue on our end I can provide some more info:

select count() from mdl_forum_posts where id = 2891849; +----------+ | count() | +----------+ | 0 | +----------+ 1 row in set (0.001 sec)

The user does have other posts: select count() from mdl_forum_posts where userid = 46181; +----------+ | count() | +----------+ | 603 | +----------+ 1 row in set (0.003 sec)

* Obscuring the problem further is the fact that while the code does catch the error and $errormessage gets assigned the string value 'Content not found for the submission.', your if() check of the $errormessage later on doesn't catch, because in PHP strings cast to numbers will return 0 if they do not obviously represent some numerical value. eg:

$example = "I am a non-numerical string"; if ($example == 0){ echo "This code runs, because non-numerical strings are equivalent to integer value 0"; }


So instead of the task catching it's own error and stepping gracefully over it, it crashes further down on submit_for_plagiarism_scan() after giving it a blank value for argument 2.

Hope that helps! Let me know if there's any further info that I can provide for you here.

CL-BayanAbuawad commented 2 years ago

Thanks, @nrosenquist, with your provided information I was able to fix the issue. It seems that condition is not necessary and it should have been removed.

new version with a fix was deployed v2022082100