1
0
mirror of https://github.com/PlagiarismCheck/moodle-plagiarism_pchkorg.git synced 2024-12-22 04:10:07 +00:00

Add filters for personal token

This commit is contained in:
Jane Adelmann 2022-05-03 13:59:11 +03:00
parent 4f1c16bf57
commit dfb8593114
No known key found for this signature in database
GPG Key ID: 4CCF39DF30B8AF72
3 changed files with 48 additions and 6 deletions

View File

@ -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);
}

10
lib.php
View File

@ -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(),

View File

@ -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(