Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-71191

Implement FILE_EXTERNAL for nextcloud repository

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Won't Do
    • Affects Version/s: 3.9.6, 3.10.3, 3.11, 4.0
    • Fix Version/s: None
    • Component/s: Repositories
    • Testing Instructions:
      Hide

      Prerequisite for testing

      1. Docker

      2. ngrok

      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. Now access the config/config.php file of your Nextcloud instance using:

      docker exec -it <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

      3. Update the 'trusted_domains' array with:

      array (
         0 => 23ba1b00d3fa.in.ngrok.io
      )

      4.  Update the 'overwrite.cli.url' with:

      'overwrite.cli.url' => 'http://23ba1b00d3fa.in.ngrok.io'
      

      5. Save the changes in the config.php and access https://23ba1b00d3fa.in.ngrok.io

       

      6. Create the admin user and login to the nextcloud instance.

      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 teacher user
          username: t1
          password: test
          Create a student user
           username: s1
           password: test

      Configure Moodle instance

      1. Login 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. To use this, you can create with the help of ngrok. For instance:

      ngrok http --region=in 8081
      

        This will create http and https address for your nextcloud( assuming you are using 8081, mentioned in this instruction). 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

             Supported files and Default return types as default.

       

      Start testing

      1. Create a course and enroll the teacher and student. Make sure you have logged out of the Nextcloud instance from your browser.

      2. Login as a teacher and navigate to "Private files".

      3. You should see Nextcloud repo. Login as a teacher instance in Nextcloud. Remember to have same username for the teacher in Nextcloud and Moodle.

      4. Now click on a file from Nextcloud repo

      5. User should see a pop-up with 3 different options. One of the options should be: "Link to the file"

      6. If you select "Link to the file", from Nextcloud repo, you should see a warning message pop up: "Warning: This file would become public if you choose this option."

      7. Click "Ok" on the warning pop-up.

      8. Click on "Select this file" button.

       

      Further testing

      1. From the file selected from Nextcloud and added to teachers private files, you may also test if the files are downloaded successfully.

      2. You may also check if the content of the files are correct.

      3. A minor hack in the sync_reference function(replace DAYSECS with say 4 or 5), should help you test with the updated files from Nextcloud. Say you update the same file in Nextcloud and in the Moodle, check you get the same version of it. Once done testing replace the integer with DAYSECS in sync_reference function.

      Show
      Prerequisite for testing 1. Docker 2. ngrok 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. Now access the config/config.php file of your Nextcloud instance using: docker exec -it <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 3. Update the 'trusted_domains' array with: array ( 0 => 23ba1b00d3fa.in.ngrok.io ) 4.  Update the 'overwrite.cli.url' with: 'overwrite.cli.url' => 'http://23ba1b00d3fa.in.ngrok.io' 5. Save the changes in the config.php and access https://23ba1b00d3fa.in.ngrok.io   6. Create the admin user and login to the nextcloud instance. 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 teacher user     username: t1     password: test     Create a student user      username: s1      password: test Configure Moodle instance 1. Login 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. To use this, you can create with the help of ngrok. For instance: ngrok http --region=in 8081   This will create http and https address for your nextcloud( assuming you are using 8081, mentioned in this instruction). 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        Supported files and Default return types as default.   Start testing 1. Create a course and enroll the teacher and student. Make sure you have logged out of the Nextcloud instance from your browser. 2. Login as a teacher and navigate to "Private files". 3. You should see Nextcloud repo. Login as a teacher instance in Nextcloud. Remember to have same username for the teacher in Nextcloud and Moodle. 4. Now click on a file from Nextcloud repo 5. User should see a pop-up with 3 different options. One of the options should be : "Link to the file" 6. If you select "Link to the file", from Nextcloud repo, you should see a warning message pop up: " Warning: This file would become public if you choose this option." 7. Click "Ok" on the warning pop-up. 8. Click on "Select this file" button.   Further testing 1. From the file selected from Nextcloud and added to teachers private files, you may also test if the files are downloaded successfully. 2. You may also check if the content of the files are correct. 3. A minor hack in the sync_reference function(replace DAYSECS with say 4 or 5), should help you test with the updated files from Nextcloud. Say you update the same file in Nextcloud and in the Moodle, check you get the same version of it. Once done testing replace the integer with DAYSECS in sync_reference function.
    • Affected Branches:
      MOODLE_310_STABLE, MOODLE_311_STABLE, MOODLE_39_STABLE, MOODLE_400_STABLE
    • Pull from Repository:
    • Pull 3.9 Branch:
    • Pull 3.10 Branch:
      MDL-71191-310
    • Pull 3.11 Branch:
      MDL-71191-311
    • Pull Master Branch:
      MDL-71191-master
    • Story Points:
      0
    • Sprint:
      QA blitz, QA blitz 3

      Description

      Implement the FILE_EXTERNAL and user notification part for the nextcloud repository in core.

        Attachments

        1. folder_public_lin.png
          folder_public_lin.png
          153 kB
        2. img1.png
          img1.png
          39 kB
        3. img2.png
          img2.png
          56 kB
        4. img3.png
          img3.png
          40 kB
        5. img4.png
          img4.png
          37 kB
        6. nextcloud1.gif
          nextcloud1.gif
          4.32 MB
        7. permission_for_public_link.png
          permission_for_public_link.png
          385 kB

          Issue Links

            Activity

              People

              Assignee:
              sujith Sujith Haridasan
              Reporter:
              sujith Sujith Haridasan
              Peer reviewer:
              Mihail Geshoski
              Participants:
              Component watchers:
              Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Sujith Haridasan
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 week, 1 day, 2 hours, 30 minutes
                  1w 1d 2h 30m