Commit b258f2a9 authored by Francois Gannaz's avatar Francois Gannaz
Browse files

dev doc: upgrading and user binding

parent f4418aef
......@@ -33,7 +33,6 @@ sequenceDiagram
alt user unknown
L-->>M: HTTP 403
M-->>H: redirect user-binding.php ➀
Note right of H: see next sequence diagram
else user found by M ID
L-->>M: HTTP 200 user token
M-->>H: HTML form
......@@ -68,7 +67,56 @@ but prepared by the PHP server using the (U) token.
Binding Moodle and LabNbook accounts
------------------------------------
**TODO**
In `mod/labnbook/`, the page `user-binding.php` tries to bind
a Moodle account with a LabNbook account.
If the binds succeeds, the user will be redirected to the Moodle page
that requested the bind.
```mermaid
sequenceDiagram
participant H as Human (web browser)
participant M as Moodle
participant L as LabNbook
H->>M: user-binding.php
activate M
M->>L: /v1/auth/login (I)
alt user found by M ID
L-->>M: HTTP 200 user token
Note over M: stores (U) token
M-->>H: redirect to Moodle
else user unknown
L-->>M: HTTP 403
M-->>H: HTML form
end
deactivate M
note over H: form with buttons
alt existing account
note over H: button Existing
H->>L: /v1/redirect (I)
L-->>H: redirect /user/bind
H->>L: /user/bind
L-->>H: HTML page
Note over H: fills the form
H->>L: submit
L->>H: redirect to Moodle
else new account
note over H: button Create
H->>M: user-binding.php?create
M->>L: /v1/user/create (I)
L-->>M: user token
Note over M: stores (U) token
M->>H: redirect to Moodle
end
```
If the M user binds to an existing L account, Moodle won't receive the user token directly.
This token will be receined from L after the final redirection, when Moodle checks for authentication.
With the other cases, Moodle receives the user token before the final redirection,
so the user token is stored in the session, and the check for authentication
will not send a request to the L API.
Moodle documentation
......@@ -85,3 +133,18 @@ see [Automatic class loading](Automatic class loading).
Texts should be inserted with `get_string(<stringid>, "labnbook")` so that translations are possible.
The string IDs are mapped to strings through the file `lang/en/labnbook.php`.
See [Strings API](https://docs.moodle.org/dev/String_API) (sic) for l10n.
### Upgrading
The process is the standard Moodle plugin process,
see <https://docs.moodle.org/dev/Activity_modules#upgrade.php> for a tutorial.
If the DB structure is modified, you must modify the XML structure *and*
write the PHP migration.
If necessary, update the DB structure *for new installs* in `db/install.xml`.
Editing the XML is possible, but the recommended way is to use the
[web interface in Moodle](https://docs.moodle.org/dev/XMLDB_editor).
Then modify `db/upgrade.php` to apply the changes to plugins already installed.
......@@ -15,10 +15,12 @@ You must have an *admin access to LabNbook*,
in order to create an institution that will be linked to this Moodle instance.
Install this module like any Moodle activity.
If deploying from Git, use [composer](https://getcomposer.org/download/) to install the PHP dependencies.
```
cd /path/to/moodle
git clone https://gricad-gitlab.univ-grenoble-alpes.fr/labnbook/moodle-labnbook mod/labnbook
(cd mod/labnbook && composer install --no-dev)
php admin/cli/upgrade.php
```
......@@ -27,6 +29,16 @@ You will be prompted for the new plugin configuration.
Input the URL of the LabNbook web API and other settings displayed in the LnB admin view.
## Upgrade
Like any Moodle plugin:
1. update the source code in `mod/labnbook/`
2. apply the migration,
through CLI with `php admin/cli/upgrade.php`,
or through web by connecting as as an admin on the "Administration" page.
## License
Copyright 2019 Université Grenoble Alpes
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment