mirror of
https://github.com/PlagiarismCheck/moodle-plagiarism_pchkorg.git
synced 2024-12-22 12:10:08 +00:00
Compare commits
No commits in common. "dd15b4983d01d816ea1860e21d18a2a515d94f10" and "a46f7043e5c73946535d186bf04723751ffa4091" have entirely different histories.
dd15b4983d
...
a46f7043e5
@ -181,6 +181,9 @@ 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
|
||||
@ -300,6 +303,9 @@ 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(),
|
||||
@ -341,6 +347,9 @@ 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,
|
||||
@ -480,6 +489,9 @@ 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
|
||||
));
|
||||
@ -525,6 +537,9 @@ 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
|
||||
));
|
||||
@ -558,6 +573,9 @@ 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
|
||||
));
|
||||
@ -583,10 +601,12 @@ 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(),
|
||||
@ -595,12 +615,7 @@ class plagiarism_pchkorg_api_provider {
|
||||
));
|
||||
if ($json = json_decode($response)) {
|
||||
if (isset($json->data) && 5 == $json->data->state) {
|
||||
$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;
|
||||
return $json->data->report;
|
||||
}
|
||||
}
|
||||
|
||||
@ -620,6 +635,9 @@ 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'
|
||||
@ -627,12 +645,7 @@ class plagiarism_pchkorg_api_provider {
|
||||
));
|
||||
if ($json = json_decode($response)) {
|
||||
if (isset($json->data) && 5 == $json->data->state) {
|
||||
$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;
|
||||
return $json->data->report;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,6 @@ 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',
|
||||
|
@ -12,7 +12,6 @@
|
||||
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="false" DEFAULT="0" SEQUENCE="false"/>
|
||||
<FIELD NAME="state" TYPE="int" LENGTH="3" NOTNULL="false" SEQUENCE="false"/>
|
||||
<FIELD NAME="score" TYPE="float" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
|
||||
<FIELD NAME="scoreai" TYPE="float" NOTNULL="false" DEFAULT="NULL" SEQUENCE="false"/>
|
||||
<FIELD NAME="created_at" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
|
||||
<FIELD NAME="textid" TYPE="int" LENGTH="11" NOTNULL="false" SEQUENCE="false"/>
|
||||
<FIELD NAME="reportid" TYPE="int" LENGTH="11" NOTNULL="false" SEQUENCE="false"/>
|
||||
|
@ -27,7 +27,7 @@ $tasks = array(
|
||||
array(
|
||||
'classname' => 'plagiarism_pchkorg\task\update_reports',
|
||||
'blocking' => 0,
|
||||
'minute' => '*',
|
||||
'minute' => '*/2',
|
||||
'hour' => '*',
|
||||
'day' => '*',
|
||||
'dayofweek' => '*',
|
||||
@ -36,7 +36,7 @@ $tasks = array(
|
||||
array(
|
||||
'classname' => 'plagiarism_pchkorg\task\send_submissions',
|
||||
'blocking' => 0,
|
||||
'minute' => '*',
|
||||
'minute' => '*/2',
|
||||
'hour' => '*',
|
||||
'day' => '*',
|
||||
'dayofweek' => '*',
|
||||
|
@ -57,16 +57,5 @@ 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;
|
||||
}
|
||||
|
@ -58,7 +58,6 @@ $string['pchkorg_debug_status_error'] = 'Some error for this file';
|
||||
$string['pchkorg_debug_student_not_allowed_see_widget'] = 'Students can not see a similarity score';
|
||||
$string['pchkorg_student_can_see_widget'] = 'Students can see a similarity score';
|
||||
$string['pchkorg_student_can_see_report'] = 'Students can access a similarity report';
|
||||
$string['pchkorg_check_ai'] = 'Enable AI Detector';
|
||||
$string['pchkorg_disclosure'] = 'Submission will be sent to <a target="_blank" href="https://plagiarismcheck.org/">PlagiarismCheck.org</a> for check.
|
||||
<br />
|
||||
By submitting assignment I agree with <a target="_blank" href="https://plagiarismcheck.org/terms-of-service/">Terms & Conditions</a>
|
||||
@ -70,7 +69,6 @@ $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';
|
||||
@ -90,8 +88,6 @@ $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';
|
||||
|
65
lib.php
65
lib.php
@ -173,6 +173,7 @@ function plagiarism_pchkorg_coursemodule_standard_elements($formwrapper, $mform)
|
||||
array(get_string('no'), get_string('yes'))
|
||||
);
|
||||
|
||||
|
||||
$mform->addElement(
|
||||
'select',
|
||||
'pchkorg_student_can_see_widget',
|
||||
@ -186,14 +187,6 @@ function plagiarism_pchkorg_coursemodule_standard_elements($formwrapper, $mform)
|
||||
get_string('pchkorg_student_can_see_report', 'plagiarism_pchkorg'),
|
||||
array(get_string('no'), get_string('yes'))
|
||||
);
|
||||
|
||||
$mform->addElement(
|
||||
'select',
|
||||
'pchkorg_check_ai',
|
||||
get_string('pchkorg_check_ai', 'plagiarism_pchkorg'),
|
||||
array(get_string('no'), get_string('yes'))
|
||||
);
|
||||
$mform->setDefault('pchkorg_check_ai', 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -215,8 +208,7 @@ function plagiarism_pchkorg_coursemodule_edit_post_actions($data, $course)
|
||||
'pchkorg_include_referenced',
|
||||
'pchkorg_exclude_self_plagiarism',
|
||||
'pchkorg_student_can_see_widget',
|
||||
'pchkorg_student_can_see_report',
|
||||
'pchkorg_check_ai'
|
||||
'pchkorg_student_can_see_report'
|
||||
);
|
||||
|
||||
$records = $DB->get_records('plagiarism_pchkorg_config', array(
|
||||
@ -428,46 +420,24 @@ class plagiarism_plugin_pchkorg extends plagiarism_plugin {
|
||||
$action = $apiprovider->get_report_action($filerecord->textid);
|
||||
$reporttoken = $apiprovider->generate_api_token();
|
||||
$score = $filerecord->score;
|
||||
$isaienabled = '1' === $pchkorgconfigmodel->get_filter_for_module($cmid, 'pchkorg_check_ai');
|
||||
|
||||
if (isset($filerecord->scoreai) && $isaienabled) {
|
||||
$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
|
||||
);
|
||||
}
|
||||
$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 = '#63EC80';
|
||||
$color = '#63ec80a1';
|
||||
} 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,
|
||||
@ -520,20 +490,20 @@ require(['jquery'], function ($) {
|
||||
a.setAttribute('href', '#');
|
||||
a.setAttribute('title', data.title);
|
||||
a.setAttribute('data-id', data.id);
|
||||
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.padding = '5px 3px';
|
||||
a.style.textDecoration = 'none';
|
||||
a.style.backgroundColor = data.color;
|
||||
a.style.color = 'black';
|
||||
a.style.cursor = 'pointer';
|
||||
a.style.borderRadius = '4px 4px 4px 4px';
|
||||
a.style.borderRadius = '3px 3px 3px 3px';
|
||||
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;
|
||||
@ -1399,7 +1369,6 @@ 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);
|
||||
}
|
||||
|
@ -55,10 +55,7 @@ if (($data = $mform->get_data()) && confirm_sesskey()) {
|
||||
|
||||
foreach ($data as $field => $value) {
|
||||
if (strpos($field, 'pchkorg') === 0) {
|
||||
if ('pchkorg_use' === $field) {
|
||||
set_config('enabled', $value, 'plagiarism_pchkorg');
|
||||
}
|
||||
set_config($field, $value, 'plagiarism_pchkorg');
|
||||
set_config($field, $value, 'plagiarism');
|
||||
$pchkorgconfigmodel->set_system_config($field, $value);
|
||||
}
|
||||
}
|
||||
|
@ -26,9 +26,9 @@ defined('MOODLE_INTERNAL') || die();
|
||||
if (!isset($plugin)) {
|
||||
$plugin = new stdClass();
|
||||
}
|
||||
$plugin->version = 2023060812;
|
||||
$plugin->version = 2023060611;
|
||||
$plugin->requires = 2020061501; // Requires Moodle 3.9 .
|
||||
$plugin->release = 'v3.14.2';
|
||||
$plugin->release = 'v3.13.5';
|
||||
$plugin->component = 'plagiarism_pchkorg';
|
||||
$plugin->maturity = MATURITY_STABLE;
|
||||
$plugin->dependencies = array(
|
||||
|
Loading…
Reference in New Issue
Block a user