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

WebService core_notes_get_course_notes should return if the user has permission to manage notes

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.6.2
    • Fix Version/s: 3.7
    • Component/s: Other
    • Labels:
    • Testing Instructions:
      Hide
      1. As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings
      2. Create two courses: C1 and C2
      3. Create two users: U1 and U2
      4. Enrol U1 into C1 as student
      5. Enrol U2 into C1 as teacher
      6. Enrol U2 into C2 as teacher
      7. Create a Token in the mobile app service for all the users you created. Creato also a token for the site admin account.
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      8. Now, as U2 login into the site, go to course C1
      9. Via the Participants page, open U1 profile and go to the option "Notes"
      10. From there, you have to create a Site, Course and Personal note (three in total). Add a custom note so you can distinguish the type of note, for example: "This is a site note"
      11. Open the console an execute this new curl request, replacing wstoken with the token of U2, courseid with C1 and the site url with yours.

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_notes_get_course_notes&courseid=2&wstoken=3af67232a7596ceb658df4db329e5ad6' | python -m "json.tool"

      1. Check that:
        • You receive all the notes you created and canmanagecoursenotes is set to true while canmanagesystemnotes is set to false
      2. Execute the last CURL request but replacing courseid with C2
      3. Check that:
        • You receive only the "Site notes" and canmanagecoursenotes is set to true while canmanagesystemnotes is set to false
      4. Execute the last CURL request but replacing courseid with C1 and the wstoken with U1 one
      5. Check that:
        • You receive a "nopermissions" error code.
      6. Execute the last CURL request but replacing the wstoken with admin one
      7. Check that:
        • You receive the site and course notes only (not personal notes) and both canmanagecoursenotes and canmanagesystemnotes are set to true
      Show
      As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings Create two courses: C1 and C2 Create two users: U1 and U2 Enrol U1 into C1 as student Enrol U2 into C1 as teacher Enrol U2 into C2 as teacher Create a Token in the mobile app service for all the users you created. Creato also a token for the site admin account. Click on Site administration ► Plugins ► Web services ► Manage tokens Now, as U2 login into the site, go to course C1 Via the Participants page, open U1 profile and go to the option "Notes" From there, you have to create a Site, Course and Personal note (three in total). Add a custom note so you can distinguish the type of note, for example: "This is a site note" Open the console an execute this new curl request, replacing wstoken with the token of U2, courseid with C1 and the site url with yours. curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_notes_get_course_notes&courseid= 2 &wstoken= 3af67232a7596ceb658df4db329e5ad6 ' | python -m "json.tool" Check that: You receive all the notes you created and canmanagecoursenotes is set to true while canmanagesystemnotes is set to false Execute the last CURL request but replacing courseid with C2 Check that: You receive only the "Site notes" and canmanagecoursenotes is set to true while canmanagesystemnotes is set to false Execute the last CURL request but replacing courseid with C1 and the wstoken with U1 one Check that: You receive a "nopermissions" error code. Execute the last CURL request but replacing the wstoken with admin one Check that: You receive the site and course notes only (not personal notes) and both canmanagecoursenotes and canmanagesystemnotes are set to true
    • Affected Branches:
      MOODLE_36_STABLE
    • Fixed Branches:
      MOODLE_37_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-64705-master

      Description

      Apart from retrieving the notes, the WebService should return if the user has permissions to manage notes at system level (canmanagesystemnotes) and the given course (canmanagecoursenotes) level.

      This is necessary in order to display the "Delete | Edit" options just close to the notes.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  20/May/19

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 hour, 33 minutes
                  1h 33m