From dfb85931146bc5f514637d5df08c061a52547fed Mon Sep 17 00:00:00 2001 From: Jane Adelmann Date: Tue, 3 May 2022 13:59:11 +0300 Subject: [PATCH] Add filters for personal token --- classes/plagiarism_pchkorg_api_provider.php | 40 +++++++++++++++++++-- lib.php | 10 +++++- version.php | 4 +-- 3 files changed, 48 insertions(+), 6 deletions(-) diff --git a/classes/plagiarism_pchkorg_api_provider.php b/classes/plagiarism_pchkorg_api_provider.php index 007616f..9c713fa 100644 --- a/classes/plagiarism_pchkorg_api_provider.php +++ b/classes/plagiarism_pchkorg_api_provider.php @@ -185,6 +185,7 @@ class plagiarism_pchkorg_api_provider { $body .= $this->get_part('language', 'en', $boundary); $body .= $this->get_part('skip_english_words_validation', '1', $boundary); $body .= $this->get_part('skip_percentage_words_validation', '1', $boundary); + $body .= $this->get_part('lms', 'moodle', $boundary); foreach ($filters as $filtername => $filtervalue) { $body .= $this->get_part($filtername, $filtervalue, $boundary); } @@ -202,14 +203,32 @@ class plagiarism_pchkorg_api_provider { * @param $filename * @return |null */ - public function send_text($content, $mime, $filename, $filters = array()) { + public function send_text( + $cousereid, + $assignmentid, + $submissionid, + $attachmentid, + $content, + $mime, + $filename, + $filters = array()) { $boundary = sprintf('PLAGCHECKBOUNDARY-%s', uniqid(time())); $curl = new curl(); $response = $curl->post( $this->endpoint . '/api/v1/text', - $this->get_body($boundary, $content, $mime, $filename, $filters), + $this->get_body( + $boundary, + $cousereid, + $assignmentid, + $submissionid, + $attachmentid, + $content, + $mime, + $filename, + $filters, + ), array( 'CURLOPT_RETURNTRANSFER' => true, 'CURLOPT_FOLLOWLOCATION' => true, @@ -316,13 +335,28 @@ class plagiarism_pchkorg_api_provider { * @param $filename * @return string */ - private function get_body($boundary, $content, $mime, $filename, $filters = array()) { + private function get_body( + $boundary, + $cousereid, + $assignmentid, + $submissionid, + $attachmentid, + $content, + $mime, + $filename, + $filters = array() + ) { $eol = "\r\n"; $body = ''; $body .= $this->get_part('language', 'en', $boundary); $body .= $this->get_part('skip_english_words_validation', '1', $boundary); $body .= $this->get_part('skip_percentage_words_validation', '1', $boundary); + $body .= $this->get_part('course_id', $cousereid, $boundary); + $body .= $this->get_part('assignment_id', $assignmentid, $boundary); + $body .= $this->get_part('submission_id', $submissionid, $boundary); + $body .= $this->get_part('attachment_id', $attachmentid, $boundary); + $body .= $this->get_part('lms', 'moodle', $boundary); foreach ($filters as $filtername => $filtervalue) { $body .= $this->get_part($filtername, $filtervalue, $boundary); } diff --git a/lib.php b/lib.php index 9c9f069..c2222b4 100644 --- a/lib.php +++ b/lib.php @@ -646,10 +646,14 @@ display: inline-block;" ); } else { $textid = $apiprovider->send_text( + $cm->course, + $cm->id, + $moodletextsubmission->id, + $moodletextsubmission->id, html_to_text($content, 75, false), 'plain/text', sprintf('%s-submussion.txt', $moodletextsubmission->id), - $filters + $filters, ); } } @@ -697,6 +701,10 @@ display: inline-block;" } $textid = $apiprovider->send_text( + $cm->course, + $cm->id, + $moodlesubmission->id, + $file->get_id(), $file->get_content(), $file->get_mimetype(), $file->get_filename(), diff --git a/version.php b/version.php index 1250ea5..58cac0c 100644 --- a/version.php +++ b/version.php @@ -26,9 +26,9 @@ defined('MOODLE_INTERNAL') || die(); if (!isset($plugin)) { $plugin = new stdClass(); } -$plugin->version = 2022042714; +$plugin->version = 2022050313; $plugin->requires = 2017051500; // Requires Moodle 3.3 . -$plugin->release = 'v3.8.1'; +$plugin->release = 'v3.8.2'; $plugin->maturity = MATURITY_STABLE; $plugin->component = 'plagiarism_pchkorg'; $plugin->dependencies = array(