mirror of
https://github.com/PlagiarismCheck/moodle-plagiarism_pchkorg.git
synced 2024-12-22 12:10:08 +00:00
Fix saving agreement for group user.
This commit is contained in:
parent
7951fd129c
commit
af7abda07a
@ -224,8 +224,15 @@ class plagiarism_pchkorg_api_provider {
|
||||
* Method send information to service thar agreement had been accepted.
|
||||
* Method will be called only for personal account type.
|
||||
*
|
||||
* @param string $email User email
|
||||
* @return void
|
||||
*/
|
||||
public function save_accepted_agreement() {
|
||||
public function save_accepted_agreement($email) {
|
||||
$token = $this->token;
|
||||
if ($this->is_group_token()) {
|
||||
$token = $this->token . '::' . hash('sha256', $this->token . $email);
|
||||
}
|
||||
|
||||
$curl = new curl();
|
||||
$curl->post(
|
||||
$this->endpoint . '/api/v1/agreement/create/moodle-plugin/2019-04-11/',
|
||||
@ -237,7 +244,7 @@ class plagiarism_pchkorg_api_provider {
|
||||
'CURLOPT_SSL_VERIFYPEER' => false,
|
||||
'CURLOPT_POST' => true,
|
||||
'CURLOPT_HTTPHEADER' => array(
|
||||
'X-API-TOKEN: ' . $this->generate_api_token(),
|
||||
'X-API-TOKEN: ' . $token,
|
||||
),
|
||||
)
|
||||
);
|
||||
|
2
lib.php
2
lib.php
@ -594,7 +594,7 @@ display: inline-block;"
|
||||
);
|
||||
$agreementaccepted = $DB->get_records('plagiarism_pchkorg_config', $agreementwhere);
|
||||
if (empty($agreementaccepted)) {
|
||||
$apiprovider->save_accepted_agreement();
|
||||
$apiprovider->save_accepted_agreement($user->email);
|
||||
$DB->insert_record('plagiarism_pchkorg_config', $agreementwhere);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user