Add new method api for group accounts

This commit is contained in:
Jane Adelmann 2019-04-25 19:03:19 +03:00
parent 3ff871d4a5
commit 9caf4af4b8
No known key found for this signature in database
GPG Key ID: 4CCF39DF30B8AF72
3 changed files with 39 additions and 4 deletions

View File

@ -372,6 +372,11 @@ class plagiarism_pchkorg_api_provider {
* @return object|null * @return object|null
*/ */
public function check_text($textid) { 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(); $curl = new curl();
$response = $curl->get($this->endpoint . '/api/v1/text/' . $textid, array(), array( $response = $curl->get($this->endpoint . '/api/v1/text/' . $textid, array(), array(
'CURLOPT_RETURNTRANSFER' => true, 'CURLOPT_RETURNTRANSFER' => true,
@ -393,6 +398,36 @@ class plagiarism_pchkorg_api_provider {
return null; 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. * Build url for the api.
* *

View File

@ -27,7 +27,7 @@ $tasks = array(
array( array(
'classname' => 'plagiarism_pchkorg\task\update_reports', 'classname' => 'plagiarism_pchkorg\task\update_reports',
'blocking' => 0, 'blocking' => 0,
'minute' => '*/5', 'minute' => '*/2',
'hour' => '*', 'hour' => '*',
'day' => '*', 'day' => '*',
'dayofweek' => '*', 'dayofweek' => '*',
@ -36,7 +36,7 @@ $tasks = array(
array( array(
'classname' => 'plagiarism_pchkorg\task\send_submissions', 'classname' => 'plagiarism_pchkorg\task\send_submissions',
'blocking' => 0, 'blocking' => 0,
'minute' => '*/5', 'minute' => '*/2',
'hour' => '*', 'hour' => '*',
'day' => '*', 'day' => '*',
'dayofweek' => '*', 'dayofweek' => '*',

View File

@ -26,9 +26,9 @@ defined('MOODLE_INTERNAL') || die();
if (!isset($plugin)) { if (!isset($plugin)) {
$plugin = new stdClass(); $plugin = new stdClass();
} }
$plugin->version = 2019041701; $plugin->version = 2019042501;
$plugin->requires = 2017051501; // Requires Moodle 3.3 . $plugin->requires = 2017051501; // Requires Moodle 3.3 .
$plugin->release = 'v3.3'; $plugin->release = 'v3.4';
$plugin->maturity = MATURITY_STABLE; $plugin->maturity = MATURITY_STABLE;
$plugin->component = 'plagiarism_pchkorg'; $plugin->component = 'plagiarism_pchkorg';
$plugin->dependencies = array( $plugin->dependencies = array(