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

Nextcloud error when moving/copying access controlled link file over existing file having the same name

XMLWordPrintable

    • MOODLE_311_STABLE, MOODLE_37_STABLE, MOODLE_39_STABLE, MOODLE_400_STABLE
    • MOODLE_311_STABLE, MOODLE_400_STABLE
    • MDL69756_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 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. Login as an admin in moodle and create a course and enroll a student in the course
      2. Add assignment activity to the course.
      3. Now login as a student and attach a file from s1 student of nextcloud instance to the assignment.
      4. Save the change.
      5. Re-edit the assignment submitted by removing the file and re-attach the file. You should not see exception.
      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 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 a student and attach a file from s1 student of nextcloud instance to the assignment. Save the change. Re-edit the assignment submitted by removing the file and re-attach the file. You should not see exception.

      There is an ownCloud repository plugin for Moodle but it's deprecated and it recommends using the core Nextcloud repository instead. That works generally. But I've run into an issue with this when using access controlled links. There is one case where they don't work:

      1. Create an assignment.
      2. Student A hands in a file from an ownCloud server via the Nextcloud repository as "External (only links stored in Moodle)".
      3. Student A deletes the file again in Moodle from the assignment submissions.
      4. Student A hands in a file with the same name the same way as in step 2.

      You get this error:

      A request to owncloud-test test 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>A webdav request to copy a file failed.</i>".

      After encountering this error you will also have the respective file lying in the root folder of your ownCloud system user instead of being in the correct Moodle > category > course > activity etc. subfolder in ownCloud.

      Cause

      ownCloud returns http status code 204 which the Nextcloud repository treats as an error. See https://github.com/moodle/moodle/blob/f852aa8ad5546b8c40a5176078195c3de113b026/repository/nextcloud/classes/access_controlled_link_manager.php#L210

        1. MDL-69756_v400.webm
          1.03 MB
        2. MDL-69756_v311.webm
          1.21 MB
        3. MDL-69756_master.webm
          1.20 MB

            A_Deb Amrita Deb Dutta
            tschroeder Tim Schroeder
            Sujith Haridasan Sujith Haridasan
            Jake Dallimore Jake Dallimore
            Angelia Dela Cruz Angelia Dela Cruz
            Votes:
            2 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 4 hours
                4h

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