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

Small fixes and new release 2.2

This commit is contained in:
Jane Adelmann 2019-02-05 16:22:49 +02:00
parent 6e1758e001
commit 44ea7a3080
No known key found for this signature in database
GPG Key ID: 4CCF39DF30B8AF72
5 changed files with 11 additions and 21 deletions

View File

@ -226,14 +226,13 @@ class plagiarism_pchkorg_api_provider {
'Content-Type: application/x-www-form-urlencoded' 'Content-Type: application/x-www-form-urlencoded'
), ),
)); ));
$id = null;
if ($json = json_decode($response)) { if ($json = json_decode($response)) {
if (isset($json->data) && 5 == $json->data->state) { if (isset($json->data) && 5 == $json->data->state) {
$id = $json->data->report->id; return $json->data->report;
} }
} }
return $id; return null;
} }
public function get_report_action($id) { public function get_report_action($id) {

View File

@ -33,6 +33,7 @@ $string['pchkorg_token'] = 'API Token';
$string['pchkorg_token_help'] = 'You can receive your token by contact us'; $string['pchkorg_token_help'] = 'You can receive your token by contact us';
$string['pchkorg_description'] = 'You can receive your token by contact us'; $string['pchkorg_description'] = 'You can receive your token by contact us';
$string['pchkorg_submit'] = 'Submit'; $string['pchkorg_submit'] = 'Submit';
$string['pchkorg_check_for_plagiarism_report'] = 'View report';
$string['savedconfigsuccess'] = 'Settings had been changed'; $string['savedconfigsuccess'] = 'Settings had been changed';
$string['pchkorg_check_for_plagiarism'] = 'Check for plagiarism'; $string['pchkorg_check_for_plagiarism'] = 'Check for plagiarism';

View File

@ -69,20 +69,10 @@ if (!$filerecord) {
)); ));
} }
$reportid = $apiprovider->check_text($filerecord->textid); $report = $apiprovider->check_text($filerecord->textid);
if ($checked = (null !== $reportid)) { if ($checked = (null !== $report)) {
$report = $apiprovider->get_report($filerecord->textid); $filerecord->reportid = $report->id;
$json = json_decode($report); $filerecord->score = $report->percent;
$score = 0;
if (isset($json->data)
&& isset($json->data->report)
&& isset($json->data->report->percent)
) {
$score = $json->data->report->percent;
}
$filerecord->reportid = $reportid;
$filerecord->score = $score;
$DB->update_record('plagiarism_pchkorg_files', $filerecord); $DB->update_record('plagiarism_pchkorg_files', $filerecord);
} }

View File

@ -26,9 +26,9 @@ defined('MOODLE_INTERNAL') || die();
if (!isset($plugin)) { if (!isset($plugin)) {
$plugin = new stdClass(); $plugin = new stdClass();
} }
$plugin->version = 2019013003; $plugin->version = 2019020501;
$plugin->requires = 2017051501; // Requires Moodle 3.3 . $plugin->requires = 2017051501; // Requires Moodle 3.3 .
$plugin->release = 'v2.1'; $plugin->release = 'v2.2';
$plugin->maturity = MATURITY_STABLE; $plugin->maturity = MATURITY_STABLE;
$plugin->component = 'plagiarism_pchkorg'; $plugin->component = 'plagiarism_pchkorg';

View File

@ -17,13 +17,13 @@
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
if (empty($error)) { if (empty($error)) {
$PAGE->requires->js_init_code('window.document.getElementById("plagiarism_pchkorg_report_id").submit();', true); $PAGE->requires->js_init_code('window.document.getElementById("plagiarism_pchkorg_report_id").submit();', false);
echo $OUTPUT->header(); echo $OUTPUT->header();
?> ?>
<form id="plagiarism_pchkorg_report_id" action="<?php echo htmlspecialchars($action) ?>" method="post"> <form id="plagiarism_pchkorg_report_id" action="<?php echo htmlspecialchars($action) ?>" method="post">
<input type="hidden" name="token" value="<?php echo htmlspecialchars($token) ?>"/> <input type="hidden" name="token" value="<?php echo htmlspecialchars($token) ?>"/>
<input type="hidden" name="lms-type" value="moodle"/> <input type="hidden" name="lms-type" value="moodle"/>
<input type="submit" value="Check Report"> <input type="submit" value="<?php echo get_string('pchkorg_check_for_plagiarism_report', 'plagiarism_pchkorg');?>">
</form> </form>
<?php <?php
} else { } else {