-
Bug
-
Resolution: Cannot Reproduce
-
Minor
-
None
-
4.1
-
None
-
MOODLE_401_STABLE
Prerequisite for testing
- Docker
- ngrok
For instance, use this ngrok for nextcloud:
ngrok http --region=in 8081 |
Setup nextcloud instance
1. Using docker (make sure docker is installed in your machine), run the command below:
docker run -d -p 8081:80 nextcloud |
You should get the latest version of nextcloud installed on your machine. Access it using say, http://localhost:8081 (note the port used its 8081, you may use whatever port available in your machine, but make sure to change it first in the docker command)
2. Create the admin user and login to the nextcloud instance.
3. Now access the config/config.php file of your Nextcloud instance from the terminal using:
docker exec -it <CONTAINER ID> bash |
Where ID is the container ID of your Nextcloud instance( you may get it from 'docker ps' command)
After this open config/config.php
4. Update the 'trusted_domains' array and add the url to the nextcloud instance generated by ngrok (ex. '23ba1b00d3fa.in.ngrok.io'):
array ( |
0 => 23ba1b00d3fa.in.ngrok.io |
) |
5. Update the 'overwrite.cli.url' with:
'overwrite.cli.url' => 'http://23ba1b00d3fa.in.ngrok.io' |
6. Save the changes in the config.php and access the nextcloud instance in the browser (ex. https://23ba1b00d3fa.in.ngrok.io)
7. Navigate to Settings -> Security page
8. Under OAuth 2.0 clients fill up the details like:
a) Name: Moodle
b) Redirection URI: http://localhost/m/pg_stable_master/admin/oauth2callback.php
The redirection URL is your moodle URL + admin/oauth2callback.php
9. Click on "Add" button, which would generate Client Identifier a Secret. Copy both values which are required in future steps.
10. Create a student user
username: s1
password: test
Configure moodle instance
1. Log in to moodle as admin.
2. Navigate to Site Administration -> Server -> OAuth 2 services
3. In the "Create new service" section select Nextcloud.
4. Now fill the Client ID (copy it from step 4 of Nextcloud setup instance)
5. Fill the Client secret (copy it from step 4 of Nextcloud setup instance)
6. Fill in the "Service base URL". This has to be https address. Kindly refer to the ngrok https address which you executed in the prerequisite section. Use the https URL in "Service base URL".
7. Click on the button "Save changes"
8. Click on "System account connected" section of Nextcloud. And login as an admin account of Nextcloud.
9. Navigate to: Site administration -> Plugins -> Repositories -> Manage repositories
10. Select Nextcloud as "Enabled and visible".
11. Click on the "Settings" link right next to "Enable and visible" option.
12. Click the button "Create a repository instance".
13. Give a name to your repo: Nextcloud repo
Select issuer as Nextcloud
Select Default return types as 'External (only links stored in Moodle)'
And Save it.
Steps to test
- Login as an admin in moodle and create a course and enroll a student in the course
- Add assignment activity to the course.
- Now login as student and attach a file from s1 student of nextcloud instance to the assignment.
- An exception is thrown as shown below:
A request to Nextcloud repo has failed. The requested action could not be executed. If this happens repeatedly, please contact the site administrator with the following additional information:<br />"<i>Folder path /System (pg_stable_master_siteadmin) could not be created in the system account.</i>".
|