diff --git a/classes/plagiarism_pchkorg_api_provider.php b/classes/plagiarism_pchkorg_api_provider.php
index 35837f3..9cc5149 100644
--- a/classes/plagiarism_pchkorg_api_provider.php
+++ b/classes/plagiarism_pchkorg_api_provider.php
@@ -181,9 +181,6 @@ class plagiarism_pchkorg_api_provider {
),
array(
'CURLOPT_RETURNTRANSFER' => true,
- 'CURLOPT_FOLLOWLOCATION' => true,
- 'CURLOPT_SSL_VERIFYHOST' => false,
- 'CURLOPT_SSL_VERIFYPEER' => false,
'CURLOPT_HTTPHEADER' => array(
'X-API-TOKEN: ' . $this->generate_api_token(),
'Content-Type: multipart/form-data; boundary=' . $boundary
@@ -303,9 +300,6 @@ class plagiarism_pchkorg_api_provider {
),
array(
'CURLOPT_RETURNTRANSFER' => true,
- 'CURLOPT_FOLLOWLOCATION' => true,
- 'CURLOPT_SSL_VERIFYHOST' => false,
- 'CURLOPT_SSL_VERIFYPEER' => false,
'CURLOPT_POST' => true,
'CURLOPT_HTTPHEADER' => array(
'X-API-TOKEN: ' . $this->generate_api_token(),
@@ -347,9 +341,6 @@ class plagiarism_pchkorg_api_provider {
'',
array(
'CURLOPT_RETURNTRANSFER' => true,
- 'CURLOPT_FOLLOWLOCATION' => true,
- 'CURLOPT_SSL_VERIFYHOST' => false,
- 'CURLOPT_SSL_VERIFYPEER' => false,
'CURLOPT_POST' => true,
'CURLOPT_HTTPHEADER' => array(
'X-API-TOKEN: ' . $token,
@@ -489,9 +480,6 @@ class plagiarism_pchkorg_api_provider {
'hash' => $this->user_email_to_hash($email)
), array(
'CURLOPT_RETURNTRANSFER' => true,
- 'CURLOPT_FOLLOWLOCATION' => true,
- 'CURLOPT_SSL_VERIFYHOST' => false,
- 'CURLOPT_SSL_VERIFYPEER' => false,
// The maximum number of seconds to allow cURL functions to execute.
'CURLOPT_TIMEOUT' => 8
));
@@ -537,9 +525,6 @@ class plagiarism_pchkorg_api_provider {
'hash' => $this->user_email_to_hash($email)
), array(
'CURLOPT_RETURNTRANSFER' => true,
- 'CURLOPT_FOLLOWLOCATION' => true,
- 'CURLOPT_SSL_VERIFYHOST' => false,
- 'CURLOPT_SSL_VERIFYPEER' => false,
// The maximum number of seconds to allow cURL functions to execute.
'CURLOPT_TIMEOUT' => 8
));
@@ -573,9 +558,6 @@ class plagiarism_pchkorg_api_provider {
'role' => $role,
), array(
'CURLOPT_RETURNTRANSFER' => true,
- 'CURLOPT_FOLLOWLOCATION' => true,
- 'CURLOPT_SSL_VERIFYHOST' => false,
- 'CURLOPT_SSL_VERIFYPEER' => false,
// The maximum number of seconds to allow cURL functions to execute.
'CURLOPT_TIMEOUT' => 8
));
@@ -601,12 +583,10 @@ class plagiarism_pchkorg_api_provider {
// It uses different auth.
return $this->group_check_text($textid);
}
+
$curl = new curl();
$response = $curl->get($this->endpoint . '/api/v1/text/' . $textid, array(), array(
'CURLOPT_RETURNTRANSFER' => true,
- 'CURLOPT_FOLLOWLOCATION' => true,
- 'CURLOPT_SSL_VERIFYHOST' => false,
- 'CURLOPT_SSL_VERIFYPEER' => false,
'CURLOPT_POST' => false,
'CURLOPT_HTTPHEADER' => array(
'X-API-TOKEN: ' . $this->generate_api_token(),
@@ -615,7 +595,12 @@ class plagiarism_pchkorg_api_provider {
));
if ($json = json_decode($response)) {
if (isset($json->data) && 5 == $json->data->state) {
- return $json->data->report;
+ $result = new stdClass;
+ $result->id = $json->data->report->id;
+ $result->percent = $json->data->report->percent;
+ $result->percent_ai = $json->data->ai_report->processed_percent;
+
+ return $result;
}
}
@@ -635,9 +620,6 @@ class plagiarism_pchkorg_api_provider {
'token' => $this->token
), array(
'CURLOPT_RETURNTRANSFER' => true,
- 'CURLOPT_FOLLOWLOCATION' => true,
- 'CURLOPT_SSL_VERIFYHOST' => false,
- 'CURLOPT_SSL_VERIFYPEER' => false,
'CURLOPT_POST' => false,
'CURLOPT_HTTPHEADER' => array(
'Content-Type: application/x-www-form-urlencoded'
@@ -645,7 +627,12 @@ class plagiarism_pchkorg_api_provider {
));
if ($json = json_decode($response)) {
if (isset($json->data) && 5 == $json->data->state) {
- return $json->data->report;
+ $result = new stdClass;
+ $result->id = $json->data->report->id;
+ $result->percent = $json->data->report->percent;
+ $result->percent_ai = $json->data->ai_report->processed_percent;
+
+ return $result;
}
}
diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php
index c2cdac9..955e2e2 100644
--- a/classes/privacy/provider.php
+++ b/classes/privacy/provider.php
@@ -59,6 +59,7 @@ class provider implements
'userid' => 'privacy:metadata:plagiarism_pchkorg_files:userid',
'state' => 'privacy:metadata:plagiarism_pchkorg_files:state',
'score' => 'privacy:metadata:plagiarism_pchkorg_files:score',
+ 'scoreai' => 'privacy:metadata:plagiarism_pchkorg_files:scoreai',
'created_at' => 'privacy:metadata:plagiarism_pchkorg_files:created_at',
'textid' => 'privacy:metadata:plagiarism_pchkorg_files:textid',
'reportid' => 'privacy:metadata:plagiarism_pchkorg_files:reportid',
diff --git a/db/install.xml b/db/install.xml
index 8bd3e25..cafa921 100644
--- a/db/install.xml
+++ b/db/install.xml
@@ -12,6 +12,7 @@
+
diff --git a/db/tasks.php b/db/tasks.php
index a0457d7..ce23581 100644
--- a/db/tasks.php
+++ b/db/tasks.php
@@ -27,7 +27,7 @@ $tasks = array(
array(
'classname' => 'plagiarism_pchkorg\task\update_reports',
'blocking' => 0,
- 'minute' => '*/2',
+ 'minute' => '*',
'hour' => '*',
'day' => '*',
'dayofweek' => '*',
@@ -36,7 +36,7 @@ $tasks = array(
array(
'classname' => 'plagiarism_pchkorg\task\send_submissions',
'blocking' => 0,
- 'minute' => '*/2',
+ 'minute' => '*',
'hour' => '*',
'day' => '*',
'dayofweek' => '*',
diff --git a/db/upgrade.php b/db/upgrade.php
index 3d1890e..6f8adf1 100644
--- a/db/upgrade.php
+++ b/db/upgrade.php
@@ -57,5 +57,16 @@ function xmldb_plagiarism_pchkorg_upgrade($oldversion) {
upgrade_plugin_savepoint(true, 2021072801, 'plagiarism', 'pchkorg');
}
+ if ($oldversion < 2023060713) {
+ $table = new xmldb_table('plagiarism_pchkorg_files');
+
+ $field1 = new xmldb_field('scoreai', XMLDB_TYPE_NUMBER, '4,2', XMLDB_UNSIGNED, null, null, null, null);
+ $field1->setComment('AI score');
+
+ if (!$dbman->field_exists($table, $field1)) {
+ $dbman->add_field($table, $field1);
+ }
+ }
+
return true;
}
diff --git a/lang/en/plagiarism_pchkorg.php b/lang/en/plagiarism_pchkorg.php
index 56bb89f..b007f84 100644
--- a/lang/en/plagiarism_pchkorg.php
+++ b/lang/en/plagiarism_pchkorg.php
@@ -69,6 +69,7 @@ $string['privacy:metadata:plagiarism_pchkorg_files:fileid'] = 'Identity of a sub
$string['privacy:metadata:plagiarism_pchkorg_files:userid'] = 'Identity of user who submit file';
$string['privacy:metadata:plagiarism_pchkorg_files:state'] = 'Status of a document. For example: queued, sent, checked.';
$string['privacy:metadata:plagiarism_pchkorg_files:score'] = 'Originality score';
+$string['privacy:metadata:plagiarism_pchkorg_files:scoreai'] = 'Chat GPT score';
$string['privacy:metadata:plagiarism_pchkorg_files:created_at'] = 'Date and time when document was saved.';
$string['privacy:metadata:plagiarism_pchkorg_files:textid'] = 'Identity of originality check';
$string['privacy:metadata:plagiarism_pchkorg_files:reportid'] = 'Identity of originality report';
@@ -88,6 +89,8 @@ $string['sendqueuedsubmissions'] = '';
$string['updatereportscores'] = '';
$string['pchkorg_label_title'] = 'PlagiarismCheck.org ID: %s; Similarity Score: %s%%';
$string['pchkorg_label_result'] = 'ID: %s Similarity: %s%%';
+$string['pchkorg_label_title_ai'] = 'PlagiarismCheck.org ID: %s; Similarity Score: %s%% AI: %s%%';
+$string['pchkorg_label_result_ai'] = 'ID: %s Similarity: %s%% AI: %s%%';
$string['pchkorg_label_sent'] = 'ID: %s Sent';
$string['pchkorg_label_queued'] = 'In queue';
$string['pchkorg:enable'] = 'Allow to enable/disable PlagiarismCheck.org inside an activity';
diff --git a/lib.php b/lib.php
index dcf3cdf..279e142 100644
--- a/lib.php
+++ b/lib.php
@@ -420,24 +420,44 @@ class plagiarism_plugin_pchkorg extends plagiarism_plugin {
$action = $apiprovider->get_report_action($filerecord->textid);
$reporttoken = $apiprovider->generate_api_token();
$score = $filerecord->score;
- $title = sprintf(get_string('pchkorg_label_title', 'plagiarism_pchkorg'),
- $filerecord->textid,
- $score);
- $label = sprintf(get_string('pchkorg_label_result', 'plagiarism_pchkorg'), $filerecord->textid, $score);
+ if (isset($filerecord->scoreai)) {
+ $title = sprintf(
+ get_string('pchkorg_label_title_ai', 'plagiarism_pchkorg'),
+ $filerecord->textid,
+ $score,
+ $filerecord->scoreai
+ );
+ $label = sprintf(
+ get_string('pchkorg_label_result_ai', 'plagiarism_pchkorg'),
+ $filerecord->textid,
+ $score,
+ $filerecord->scoreai
+ );
+ } else {
+ $title = sprintf(
+ get_string('pchkorg_label_title', 'plagiarism_pchkorg'),
+ $filerecord->textid,
+ $score
+ );
+ $label = sprintf(
+ get_string('pchkorg_label_result', 'plagiarism_pchkorg'),
+ $filerecord->textid,
+ $score
+ );
+ }
if ($score < 30) {
- $color = '#63ec80a1';
+ $color = '#63EC80';
} else if (30 < $score && $score < 60) {
- $color = '#f7b011';
+ $color = '#F7B011';
} else {
- $color = '#f04343';
+ $color = '#F04343';
}
$jsdata = array(
'id' => $filerecord->id,
'title' => $title,
'action' => $action,
'token' => $reporttoken,
- 'image' => $imgsrc,
'label' => $label,
'color' => $color,
'isreportallowed' => $isreportallowed,
@@ -490,20 +510,20 @@ require(['jquery'], function ($) {
a.setAttribute('href', '#');
a.setAttribute('title', data.title);
a.setAttribute('data-id', data.id);
- a.style.padding = '5px 3px';
+ a.style.fontFamily = 'Roboto';
+ a.style.fontStyle = 'normal';
+ a.style.fontWeight = '400';
+ a.style.fontSize = '16px';
+ a.style.textAlign = 'center';
+ a.style.padding = '4px 16px';
a.style.textDecoration = 'none';
a.style.backgroundColor = data.color;
a.style.color = 'black';
a.style.cursor = 'pointer';
- a.style.borderRadius = '3px 3px 3px 3px';
+ a.style.borderRadius = '4px 4px 4px 4px';
a.style.margin = '4px';
a.style.display = 'inline-block';
var label = document.createTextNode(data.label);
- var img = document.createElement('img');
- img.setAttribute('alt', 'PlagiarismCheck.org');
- img.setAttribute('src', data.image);
- img.setAttribute('width', '20');
- a.appendChild(img);
a.appendChild(label);
span.appendChild(a);
break;
@@ -1369,6 +1389,7 @@ display: inline-block;"
$filedbnew->state = 5;
$filedbnew->reportid = $report->id;
$filedbnew->score = $report->percent;
+ $filedbnew->scoreai = $report->percent_ai;
$DB->update_record('plagiarism_pchkorg_files', $filedbnew);
}
diff --git a/version.php b/version.php
index 6c5dff0..9716a66 100644
--- a/version.php
+++ b/version.php
@@ -26,9 +26,9 @@ defined('MOODLE_INTERNAL') || die();
if (!isset($plugin)) {
$plugin = new stdClass();
}
-$plugin->version = 2023060611;
+$plugin->version = 2023060713;
$plugin->requires = 2020061501; // Requires Moodle 3.9 .
-$plugin->release = 'v3.13.5';
+$plugin->release = 'v3.14.1';
$plugin->component = 'plagiarism_pchkorg';
$plugin->maturity = MATURITY_STABLE;
$plugin->dependencies = array(