Skip to content

Commit 86dd805

Browse files
committed
Version v1.0.13-beta
0 parents  commit 86dd805

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+6671
-0
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
node_modules
5+
.cache
6+
7+
*.zip
8+
src/react/package-lock.json
9+
*.asset

LICENSE

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# tool_recitapis
2+
3+
This plugin is designed to retrieve data from various APIs for use by other RECIT plugins.
4+
5+
## GRICS API
6+
<a href='https://espaceapi.grics.ca/'>Espace API - GRICS</a>
7+
8+
This function aims to obtain data from GRICS according to user rights in order to enroll students in courses or work plans.
9+
10+
Before this plugin can read the GRICS API, you need to create your GRICS application in the GRICS API espace.
11+
Once you are logged into the GRICS espace, two applications must be created.
12+
13+
The first application will be used for reading data on the <b>client side</b>.
14+
15+
### Step 1
16+
You will need to fill in the following fields:
17+
<ul>
18+
<li>Application name</li>
19+
<li>Authorization type: Native and browser-based (Authorization code + PKCE)</li>
20+
<li>Scopes: apiclients (API Espace), openid (my user ID) and profile (my user profile: last name, first name, user name)</li>
21+
<li>URI addresses for redirection after login: YOUR_SERVER/admin/tool/recitapis/view.php</li>
22+
<li>Authentication options: Microsoft</li>
23+
<li>Link to terms of use (French)</li>
24+
<li>Link to privacy policy (French)</li>
25+
</ul>
26+
27+
Keep the <b>client ID</b> and <b>secret</b> of your application in a safe place.
28+
You will need to add them to the parameters of this plugin.
29+
30+
### Step 2
31+
Subscribe to the following product(s): <b>Plateforme d'identité Mozaïk (5.1.10)</b>.
32+
33+
### Step 3
34+
Once GRICS confirms that the subscriptions are complete, the final step is to give consent for your application.
35+
36+
Simply copy the consent URL and paste it into any web browser. If you have permission, you will be able to grant consent.
37+
38+
<hr/>
39+
40+
The second application will be used for reading data on the <b>server side</b>.
41+
42+
### Step 1
43+
You will need to fill in the following fields:
44+
<ul>
45+
<li>Application name</li>
46+
<li>Authorization type: Machine/Robot (client credentials) and PKCE server (Authorization code + PKCE + secret client)</li>
47+
<li>Scopes: apiclients (API Espace)</li>
48+
<li>URI addresses for redirection after login: YOUR_SERVER</li>
49+
<li>Link to terms of use (French)</li>
50+
<li>Link to privacy policy (French)</li>
51+
</ul>
52+
53+
Keep the <b>client ID</b> and <b>secret</b> of your application in a safe place.
54+
You will need to add them to the parameters of this plugin.
55+
56+
### Step 2
57+
Subscribe to the following product(s): <b>Élève (5.5.5)</b>.
58+
59+
### Step 3
60+
Grant the consent in the same way you did for the previous application.

create-zip.ps1

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
function Get-PluginVersion {
2+
$file_data = Get-Content ./src/version.php | Where-Object {$_ -like "*$plugin->release*"}
3+
4+
$CharArray = $file_data.Split("=")
5+
6+
$result = $CharArray[1].replace("'", "").replace(";","").trim()
7+
8+
return $result
9+
}
10+
11+
function Create-Zipfile($zipName, $pluginName, $pluginVersion){
12+
#remove the current zip file
13+
$zipFile="$($zipName)-$($pluginVersion).zip"
14+
15+
if(Test-Path -Path $zipFile -PathType Leaf){
16+
Remove-Item -Path $zipFile
17+
}
18+
19+
#zip the folder except the folders .cache and node_modules
20+
& "c:\Program Files\7-Zip\7z.exe" a -mx "$zipFile" "src\*"-mx0 -xr!"src\react\.cache" -xr!"src\react\node_modules" -xr!"src\react\package-lock.json"
21+
22+
#set the plugin name
23+
& "c:\Program Files\7-Zip\7z.exe" rn "$zipFile" "src\" "$pluginName\"
24+
}
25+
26+
$zipName="tool_recitapis"
27+
$pluginName="recitapis"
28+
$pluginVersion = Get-PluginVersion
29+
30+
Create-Zipfile $zipName $pluginName $pluginVersion

src/classes/Options.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
// This file is part of Moodle - http://moodle.org/
3+
//
4+
// Moodle is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// Moodle is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16+
17+
/**
18+
* @package tool_recitapis
19+
* @copyright 2024 RÉCIT
20+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
21+
*/
22+
23+
namespace recitapis;
24+
25+
class Options
26+
{
27+
static function getGricsApiClientId(){
28+
return get_config('tool_recitapis', 'gricsbackendclientid');
29+
}
30+
31+
static function getGricsApiSecret(){
32+
return \core\encryption::decrypt(get_config('tool_recitapis', 'gricsbackendsecret'));
33+
}
34+
35+
static function getGricsOrganizationNumber(){
36+
return get_config('tool_recitapis', 'gricsorganizationnumber');
37+
}
38+
39+
static function getGricsUrlApi(){
40+
return get_config('tool_recitapis', 'gricsurlapi');
41+
}
42+
43+
static function getGricsUrlToken($mode){
44+
return get_config('tool_recitapis', 'gricsurltoken');
45+
}
46+
}

0 commit comments

Comments
 (0)