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:
parent
4f1c16bf57
commit
dfb8593114
@ -185,6 +185,7 @@ class plagiarism_pchkorg_api_provider {
|
|||||||
$body .= $this->get_part('language', 'en', $boundary);
|
$body .= $this->get_part('language', 'en', $boundary);
|
||||||
$body .= $this->get_part('skip_english_words_validation', '1', $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('skip_percentage_words_validation', '1', $boundary);
|
||||||
|
$body .= $this->get_part('lms', 'moodle', $boundary);
|
||||||
foreach ($filters as $filtername => $filtervalue) {
|
foreach ($filters as $filtername => $filtervalue) {
|
||||||
$body .= $this->get_part($filtername, $filtervalue, $boundary);
|
$body .= $this->get_part($filtername, $filtervalue, $boundary);
|
||||||
}
|
}
|
||||||
@ -202,14 +203,32 @@ class plagiarism_pchkorg_api_provider {
|
|||||||
* @param $filename
|
* @param $filename
|
||||||
* @return |null
|
* @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()));
|
$boundary = sprintf('PLAGCHECKBOUNDARY-%s', uniqid(time()));
|
||||||
|
|
||||||
$curl = new curl();
|
$curl = new curl();
|
||||||
$response = $curl->post(
|
$response = $curl->post(
|
||||||
$this->endpoint . '/api/v1/text',
|
$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(
|
array(
|
||||||
'CURLOPT_RETURNTRANSFER' => true,
|
'CURLOPT_RETURNTRANSFER' => true,
|
||||||
'CURLOPT_FOLLOWLOCATION' => true,
|
'CURLOPT_FOLLOWLOCATION' => true,
|
||||||
@ -316,13 +335,28 @@ class plagiarism_pchkorg_api_provider {
|
|||||||
* @param $filename
|
* @param $filename
|
||||||
* @return string
|
* @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";
|
$eol = "\r\n";
|
||||||
|
|
||||||
$body = '';
|
$body = '';
|
||||||
$body .= $this->get_part('language', 'en', $boundary);
|
$body .= $this->get_part('language', 'en', $boundary);
|
||||||
$body .= $this->get_part('skip_english_words_validation', '1', $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('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) {
|
foreach ($filters as $filtername => $filtervalue) {
|
||||||
$body .= $this->get_part($filtername, $filtervalue, $boundary);
|
$body .= $this->get_part($filtername, $filtervalue, $boundary);
|
||||||
}
|
}
|
||||||
|
10
lib.php
10
lib.php
@ -646,10 +646,14 @@ display: inline-block;"
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$textid = $apiprovider->send_text(
|
$textid = $apiprovider->send_text(
|
||||||
|
$cm->course,
|
||||||
|
$cm->id,
|
||||||
|
$moodletextsubmission->id,
|
||||||
|
$moodletextsubmission->id,
|
||||||
html_to_text($content, 75, false),
|
html_to_text($content, 75, false),
|
||||||
'plain/text',
|
'plain/text',
|
||||||
sprintf('%s-submussion.txt', $moodletextsubmission->id),
|
sprintf('%s-submussion.txt', $moodletextsubmission->id),
|
||||||
$filters
|
$filters,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -697,6 +701,10 @@ display: inline-block;"
|
|||||||
}
|
}
|
||||||
|
|
||||||
$textid = $apiprovider->send_text(
|
$textid = $apiprovider->send_text(
|
||||||
|
$cm->course,
|
||||||
|
$cm->id,
|
||||||
|
$moodlesubmission->id,
|
||||||
|
$file->get_id(),
|
||||||
$file->get_content(),
|
$file->get_content(),
|
||||||
$file->get_mimetype(),
|
$file->get_mimetype(),
|
||||||
$file->get_filename(),
|
$file->get_filename(),
|
||||||
|
@ -26,9 +26,9 @@ defined('MOODLE_INTERNAL') || die();
|
|||||||
if (!isset($plugin)) {
|
if (!isset($plugin)) {
|
||||||
$plugin = new stdClass();
|
$plugin = new stdClass();
|
||||||
}
|
}
|
||||||
$plugin->version = 2022042714;
|
$plugin->version = 2022050313;
|
||||||
$plugin->requires = 2017051500; // Requires Moodle 3.3 .
|
$plugin->requires = 2017051500; // Requires Moodle 3.3 .
|
||||||
$plugin->release = 'v3.8.1';
|
$plugin->release = 'v3.8.2';
|
||||||
$plugin->maturity = MATURITY_STABLE;
|
$plugin->maturity = MATURITY_STABLE;
|
||||||
$plugin->component = 'plagiarism_pchkorg';
|
$plugin->component = 'plagiarism_pchkorg';
|
||||||
$plugin->dependencies = array(
|
$plugin->dependencies = array(
|
||||||
|
Loading…
Reference in New Issue
Block a user