diff --git a/classes/plagiarism_pchkorg_api_provider.php b/classes/plagiarism_pchkorg_api_provider.php index b7033ff..d1782c1 100644 --- a/classes/plagiarism_pchkorg_api_provider.php +++ b/classes/plagiarism_pchkorg_api_provider.php @@ -226,14 +226,13 @@ class plagiarism_pchkorg_api_provider { 'Content-Type: application/x-www-form-urlencoded' ), )); - $id = null; if ($json = json_decode($response)) { 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) { diff --git a/lang/en/plagiarism_pchkorg.php b/lang/en/plagiarism_pchkorg.php index 3416d64..533c7c7 100644 --- a/lang/en/plagiarism_pchkorg.php +++ b/lang/en/plagiarism_pchkorg.php @@ -33,6 +33,7 @@ $string['pchkorg_token'] = 'API Token'; $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_submit'] = 'Submit'; +$string['pchkorg_check_for_plagiarism_report'] = 'View report'; $string['savedconfigsuccess'] = 'Settings had been changed'; $string['pchkorg_check_for_plagiarism'] = 'Check for plagiarism'; diff --git a/page/check.php b/page/check.php index c2499e9..975d083 100644 --- a/page/check.php +++ b/page/check.php @@ -69,20 +69,10 @@ if (!$filerecord) { )); } -$reportid = $apiprovider->check_text($filerecord->textid); -if ($checked = (null !== $reportid)) { - $report = $apiprovider->get_report($filerecord->textid); - $json = json_decode($report); - $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; +$report = $apiprovider->check_text($filerecord->textid); +if ($checked = (null !== $report)) { + $filerecord->reportid = $report->id; + $filerecord->score = $report->percent; $DB->update_record('plagiarism_pchkorg_files', $filerecord); } diff --git a/version.php b/version.php index 542c906..74d8e39 100644 --- a/version.php +++ b/version.php @@ -26,9 +26,9 @@ defined('MOODLE_INTERNAL') || die(); if (!isset($plugin)) { $plugin = new stdClass(); } -$plugin->version = 2019013003; +$plugin->version = 2019020501; $plugin->requires = 2017051501; // Requires Moodle 3.3 . -$plugin->release = 'v2.1'; +$plugin->release = 'v2.2'; $plugin->maturity = MATURITY_STABLE; $plugin->component = 'plagiarism_pchkorg'; diff --git a/view/report.php b/view/report.php index 3febc9a..4e51da7 100644 --- a/view/report.php +++ b/view/report.php @@ -17,13 +17,13 @@ defined('MOODLE_INTERNAL') || die(); 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(); ?>
- +