Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
qqtuyen opened this issue Aug 10, 2022 · 6 comments

Comments

@qqtuyen
Copy link

qqtuyen commented Aug 10, 2022

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:

  • line 239 of /plagiarism/copyleaks/classes/task/plagiarism_copyleaks_sendsubmissions.php: call to plagiarism_copyleaks_comms->submit_for_plagiarism_scan()
  • line 51 of /plagiarism/copyleaks/classes/task/plagiarism_copyleaks_sendsubmissions.php: call to plagiarism_copyleaks\task\plagiarism_copyleaks_sendsubmissions->send_queued_submissions()
  • line 253 of /lib/cronlib.php: call to plagiarism_copyleaks\task\plagiarism_copyleaks_sendsubmissions->execute()
  • line 120 of /lib/cronlib.php: call to cron_run_inner_scheduled_task()
  • line 73 of /lib/cronlib.php: call to cron_run_scheduled_tasks()
  • line 178 of /admin/cli/cron.php: call to cron_run()
@CL-BayanAbuawad
Copy link
Collaborator

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
Copy link
Author

qqtuyen commented Aug 11, 2022

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

Thank You,
Q

@CL-BayanAbuawad
Copy link
Collaborator

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

@CL-BayanAbuawad
Copy link
Collaborator

@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
Copy link

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:

  • The problematic record in mdl_plagiarism_copyleaks_files is of type forum_post
  • Here is an mtrace(print_r($submission, true)) of the submission record:
stdClass Object
(
    [id] => 573
    [cm] => 886145
    [userid] => 46181
    [submitter] => 46181
    [identifier] => c7bb85d05fb78821b07bec1cf4c9dcd7780e46b5
    [externalid] => 
    [itemid] => 2891849
    [statuscode] => queued
    [similarityscore] => 
    [lastmodified] => 1658260826
    [submissiontype] => forum_post
    [errormsg] => 
    [scheduledscandate] => 1658260766
    [ischeatingdetected] => 0
)
  • The issue appears to be that the particular forum post no longer exists (Or perhaps the mdl_plagiarism_copyleaks_files record was recorded incorrectly from the start?):
> select count(*) from mdl_forum_posts where userid = 46181 and id = 2891849;
+----------+
| count(*) |
+----------+
|        0 |
+----------+
1 row in set (0.001 sec)

> 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
Copy link
Collaborator

CL-BayanAbuawad commented Aug 21, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants