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

All files from nextcloud instance are not shown in moodle

XMLWordPrintable

    • MOODLE_311_STABLE, MOODLE_400_STABLE, MOODLE_401_STABLE
    • MOODLE_311_STABLE, MOODLE_400_STABLE
    • MDL-74718-master
    • Hide

      Prerequisite for testing

      1. Docker
      2. 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 URL generated by ngrok say, https://23ba1b00d3fa.in.ngrok.io .

      2. Create the admin user and login to the nextcloud instance. Accessing via the ngrok url helps nextcloud set trusted domain as the same url and overwrite.cli.url automatically.

      3. Disable 'Password policy' app by navigating to the 'Apps' page as admin. This helps to create user accounts s1, s2, t1 etc.

      4. 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 and update it with line below (you may need to install something like vim in the container)

      'overwriteprotocol' => 'https',

      5. Navigate to Settings -> Security page

      6. 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

      7. Click on "Add" button, which would generate Client Identifier a Secret. Copy both values which are required in future steps.

      8. Create a student user by navigating to 'Users' page
           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 in 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

      1. Create a course and enroll a student in the course
      2. Create an assignment activity in the course
      3. Login as a student and try to attach an image from Nextcloud instance's Photo directory.
      4. On version 24 of nextcloud ( which I am testing at the moment), you should be able to see exact files and folders as in the nextcloud instance.

      Steps to test the second while loop here

      1. Apply the patch hack.patch (attached in this issue) to the root of the source tree (i.e, the moodle directory)

      patch -p1 < hack.patch

      1. Login as a student and navigate to the private files.
      2. Select the Nextcloud repo and navigate to the 'Photos' folder. By default you should see 8 image files and one Readme.md file.
      3. Navigate to the 'Documents' folder in the Nextcloud repo. By default you should see 2 markdown files, a pdf file and a docx file.
      4. This also proves that our second loop works as expected.
      Show
      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 URL generated by ngrok say, https://23ba1b00d3fa.in.ngrok.io . 2. Create the admin user and login to the nextcloud instance. Accessing via the ngrok url helps nextcloud set trusted domain as the same url and overwrite.cli.url automatically. 3. Disable 'Password policy' app by navigating to the 'Apps' page as admin. This helps to create user accounts s1, s2, t1 etc. 4. 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 and update it with line below (you may need to install something like vim in the container) 'overwriteprotocol' => 'https', 5. Navigate to Settings -> Security page 6. 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 7. Click on "Add" button, which would generate Client Identifier a Secret. Copy both values which are required in future steps. 8. Create a student user by navigating to 'Users' page      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 in 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 Create a course and enroll a student in the course Create an assignment activity in the course Login as a student and try to attach an image from Nextcloud instance's Photo directory. On version 24 of nextcloud ( which I am testing at the moment), you should be able to see exact files and folders as in the nextcloud instance. Steps to test the second while loop here Apply the patch hack.patch (attached in this issue) to the root of the source tree (i.e, the moodle directory) patch -p1 < hack.patch Login as a student and navigate to the private files. Select the Nextcloud repo and navigate to the 'Photos' folder. By default you should see 8 image files and one Readme.md file. Navigate to the 'Documents' folder in the Nextcloud repo. By default you should see 2 markdown files, a pdf file and a docx file. This also proves that our second loop works as expected.

      Prerequisite for testing

      1. Docker
      2. 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 the URL generated by ngrok say, https://23ba1b00d3fa.in.ngrok.io

      2. Create the admin user and login to the nextcloud instance. This would automatically add domain '23ba1b00d3fa.in.ngrok.io' to the trusted domain and 'overwrite.cli.url'.

      3. Make sure to disable the password policy app in nextcloud. You can login to the admin account and navigate to the apps page and disable the app. Else this app would cause problems while creating credentials like s1/test or t1/test etc.

      4. 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

      and update the config.php by adding this line:

      'overwriteprotocol' => 'https', 

      5. Save the changes in the config.php and access the nextcloud instance in the browser (ex. https://23ba1b00d3fa.in.ngrok.io)

      6. Navigate to Settings -> Security page

      7. 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

      8. Click on "Add" button, which would generate Client Identifier a Secret. Copy both values which are required in future steps.

      9. 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 in 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

      1. Create a course and enroll a student in the course
      2. Create an assignment activity in the course
      3. Login as a student and try to attach an image from Nextcloud instance's Photo directory.
      4. On version 24 of nextcloud ( which I am testing at the moment), I can see 9 images are there by default. But in the file picker, I could see only 5 images. After a frequent refresh of the page, I can see 9 images.

        1. filepicker.png
          filepicker.png
          49 kB
        2. files_nextcloud.png
          files_nextcloud.png
          111 kB
        3. hack.patch
          1 kB
        4. MDL-74718_master_test 1.webm
          1.51 MB
        5. MDL-74718_master_test 2.webm
          476 kB
        6. MDL-74718_v311_test 1.webm
          1.75 MB
        7. MDL-74718_v311_test 2.webm
          467 kB
        8. MDL-74718_v400_test 1.webm
          1.85 MB
        9. MDL-74718_v400_test 2.webm
          421 kB

            sujith Sujith Haridasan
            sujith Sujith Haridasan
            Carlos Escobedo Carlos Escobedo
            Jake Dallimore Jake Dallimore
            Angelia Dela Cruz Angelia Dela Cruz
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 day, 2 hours, 20 minutes
                1d 2h 20m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.