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

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
*/
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.
*

View File

@ -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' => '*',

View File

@ -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(