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

Geo-pattern images are not available via pluginfile.php for courses that are visible but the user is not enrolled

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • 4.2, 4.3
    • Course
    • MOODLE_402_STABLE, MOODLE_403_STABLE
    • MDL-78439-master
    • Hide
      1. As admin, enable WebServices and "Mobile services":
        General > Advanced features
        Server ► Web services ► Overview
      2. Create a course without a course image in it
      3. Create a second course without a course image in it
        • Activate guest access with password in the course: Course►Participants ► Enrolment Methods ►Enable Guest Access
        • Add a password to the Guest enrolment method
        • Disable the other enrolment methods
      4. Create third course with a summary image in it
        • Create a user and enroll the user as a student in the course
      5. Create a Token for the student user:
        • Click on Site administration ► Server ► Web services ► Manage tokens
          • User: the student enrolled in step 4
          • Service: Moodle mobile web service
      6. Next, you should do some CURL REST calling simulating a WS client with the student user.
        • You need to replace the wstoken, coursename is the shortname of the course without summary image created in step 2, and the URL of your moodle instance

          curl 'MOODLE_URL/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_course_search_courses&wstoken=$wstoken&criterianame=search&criteriavalue=$coursename' --compressed

      7. Confirm that:
        • You receive the course object in the response
        • You have a param for courseimage that point to a URL similar to this: 

          $MOODLE_URL/pluginfile.php/$contextid/course/generated/course.svg

      8. Access and download the courseimage URL in your browser
        • Check if you can access and see the image
        • Access your server logs and check if there are no warnings related to accessing this image
      9. Make the same request but now change the course to the course with the guest password method created in step 3 and confirm that:
        • You receive the course object in the response
        • You have a param for courseimage that point to a URL similar to this: 

          $MOODLE_URL/pluginfile.php/$contextid/course/generated/course.svg

      10. Access and download the courseimage URL in your browser
        • Check if you can access and see the image
        • Access your server logs and check if there are no warnings related to accessing this image
      11. Make the same request but now change the course to the third course with a summary image created in step 4. Confirm that:
        • You receive the course object in the response
        • You have a param for courseimage that point to a URL similar to this: 

          $MOODLE_URL/pluginfile.php/$contextid/course/overviewfiles/$imagename

      12. Access and download the courseimage URL in your browser
        • Check if you can access and see the image
        • Access your server logs and check if there are no warnings related to accessing this image
      13. Enrol the student in the first course without the image
      14. Another CURL REST calling simulating a WS client with the student user.
        • You need to replace the wstoken, studentid, and the URL of your moodle instance

          curl 'MOODLE_URL/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_enrol_get_users_courses&wstoken=$wstoken&userid=$studentid' --compressed

      15. Confirm if the courses have courseimage following the same pattern inside the response
      16. Access and download the courseimage URL in your browser
        • Check if you can access and see the image
        • Access your server logs and check if there are no warnings related to accessing image
      17. Go to Site administration ► Users ► Permissions ► Define roles
      18. Choose Authenticated user and search for moodle/category:viewcourselist and set it as NOT ALLOWED.
      19. Next, do the CURL REST calling simulating a WS client with the student user.
        • You need to replace the wstoken, coursename is the shortname of the course without summary image created in step 2, and the URL of your moodle instance

          curl 'MOODLE_URL/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_course_search_courses&wstoken=$wstoken&criterianame=search&criteriavalue=$coursename' --compressed

      20. Confirm that:
        • You receive the course object in the response
      21. Access and try to download the courseimage URL in your browser
        • Check if you see the message: Sorry, the requested file could not be found
      Show
      As admin, enable WebServices and "Mobile services": General > Advanced features Server ► Web services ► Overview Create a course without a course image in it Create a second course without a course image in it Activate guest access with password in the course: Course►Participants ► Enrolment Methods ►Enable Guest Access Add a password to the Guest enrolment method Disable the other enrolment methods Create third course with a summary image in it Create a user and enroll the user as a student in the course Create a Token for the student user: Click on Site administration ► Server ► Web services ► Manage tokens User: the student enrolled in step 4 Service: Moodle mobile web service Next, you should do some CURL REST calling simulating a WS client with the student user. You need to replace the wstoken, coursename is the shortname of the course without summary image created in step 2, and the URL of your moodle instance curl 'MOODLE_URL/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_course_search_courses&wstoken=$wstoken&criterianame=search&criteriavalue=$coursename' --compressed Confirm that: You receive the course object in the response You have a param for courseimage that point to a URL similar to this:  $MOODLE_URL/pluginfile.php/$contextid/course/generated/course.svg Access and download the courseimage URL in your browser Check if you can access and see the image Access your server logs and check if there are no warnings related to accessing this image Make the same request but now change the course to the course with the guest password method created in step 3 and confirm that: You receive the course object in the response You have a param for courseimage that point to a URL similar to this:  $MOODLE_URL/pluginfile.php/$contextid/course/generated/course.svg Access and download the courseimage URL in your browser Check if you can access and see the image Access your server logs and check if there are no warnings related to accessing this image Make the same request but now change the course to the third course with a summary image created in step 4. Confirm that: You receive the course object in the response You have a param for courseimage that point to a URL similar to this:  $MOODLE_URL/pluginfile.php/$contextid/course/overviewfiles/$imagename Access and download the courseimage URL in your browser Check if you can access and see the image Access your server logs and check if there are no warnings related to accessing this image Enrol the student in the first course without the image Another CURL REST calling simulating a WS client with the student user. You need to replace the wstoken, studentid, and the URL of your moodle instance curl 'MOODLE_URL/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_enrol_get_users_courses&wstoken=$wstoken&userid=$studentid' --compressed Confirm if the courses have courseimage following the same pattern inside the response Access and download the courseimage URL in your browser Check if you can access and see the image Access your server logs and check if there are no warnings related to accessing image Go to Site administration ► Users ► Permissions ► Define roles Choose Authenticated user and search for moodle/category:viewcourselist and set it as NOT ALLOWED. Next, do the CURL REST calling simulating a WS client with the student user. You need to replace the wstoken, coursename is the shortname of the course without summary image created in step 2, and the URL of your moodle instance curl 'MOODLE_URL/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_course_search_courses&wstoken=$wstoken&criterianame=search&criteriavalue=$coursename' --compressed Confirm that: You receive the course object in the response Access and try to download the courseimage URL in your browser Check if you see the message: Sorry, the requested file could not be found

      To display the geo-pattern course image we are now using require_login, instead, we should've used core_course_category::can_view_course_info($course).

      The access problem happens when we try to entry the URL and try to download the image. Depending on the enrolment method we get an exception before this patch, but this exception just happens when we try to download that image in the URL provided by the WS.

      Before this patch, the CURL requests on the testing instructions are working normally, but we can't access the geo-pattern image or the course summary image.

      The image attached and on MOBILE-3973 represents well this problem.

            jleyva Juan Leyva
            jleyva Juan Leyva
            Juan Leyva Juan Leyva
            Amaia Anabitarte Amaia Anabitarte
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 days, 2 hours, 27 minutes
                2d 2h 27m

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