diff --git a/classes/plagiarism_pchkorg_api_provider.php b/classes/plagiarism_pchkorg_api_provider.php index 75e7337..c4522b5 100644 --- a/classes/plagiarism_pchkorg_api_provider.php +++ b/classes/plagiarism_pchkorg_api_provider.php @@ -372,6 +372,11 @@ class plagiarism_pchkorg_api_provider { * @return object|null */ public function check_text($textid) { + if ($this->is_group_token()) { + // The same method but for group users. + // 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, @@ -393,6 +398,36 @@ class plagiarism_pchkorg_api_provider { return null; } + /** + * Check status of document for Group User + * If document has been checked, state is 5. + * + * @param $textid + * @return object|null + */ + public function group_check_text($textid) { + $curl = new curl(); + $response = $curl->get("{$this->endpoint}/lms/check-report/{$textid}/", array( + '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' + ), + )); + if ($json = json_decode($response)) { + if (isset($json->data) && 5 == $json->data->state) { + return $json->data->report; + } + } + + return null; + } + /** * Build url for the api. * diff --git a/db/tasks.php b/db/tasks.php index 66c1c33..a0457d7 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' => '*/5', + 'minute' => '*/2', 'hour' => '*', 'day' => '*', 'dayofweek' => '*', @@ -36,7 +36,7 @@ $tasks = array( array( 'classname' => 'plagiarism_pchkorg\task\send_submissions', 'blocking' => 0, - 'minute' => '*/5', + 'minute' => '*/2', 'hour' => '*', 'day' => '*', 'dayofweek' => '*', diff --git a/version.php b/version.php index 71b603b..5834ca4 100644 --- a/version.php +++ b/version.php @@ -26,9 +26,9 @@ defined('MOODLE_INTERNAL') || die(); if (!isset($plugin)) { $plugin = new stdClass(); } -$plugin->version = 2019041701; +$plugin->version = 2019042501; $plugin->requires = 2017051501; // Requires Moodle 3.3 . -$plugin->release = 'v3.3'; +$plugin->release = 'v3.4'; $plugin->maturity = MATURITY_STABLE; $plugin->component = 'plagiarism_pchkorg'; $plugin->dependencies = array(