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

core_roles_unassign_roles ws function contains contextid as parameters, which is not correct

XMLWordPrintable

    • MOODLE_24_STABLE
    • MOODLE_26_STABLE
    • MDL-39153-master
    • Hide

      Setup

      1. Testing requires database and code changes
      2. Run unit tests and make sure they all pass
      3. Setup webservices for the api core_roles_unassign_roles()
        http://docs.moodle.org/25/en/Using_web_services
      4. In the above setup make sure the user you are going to use for making ws calls is admin or as all the role:assign permissions
      5. Get your fav client from https://github.com/moodlehq/sample-ws-clients or use the one I use https://github.com/ankitagarwal/moodle-ws-client/blob/master/client.php
      6. Make sure you have few courses and users and roles (Users must be enrolled in the course, that we would use to test)
      7. Note the various roleids for different roles from database (mdl_role)
      8. Note the format of params to use for your unassign_roles api , based on your client protocol from (moodle/admin/webservice/documentation.php )
      9. Assign a user 3 different roles in the test course

      Test - 1 - Using context ids

      1. Get context for a course using

        Print_object(context_course::instance($course->id);)
        

      2. Now call the api assign_role with userid, roleid and context id.
      3. Make sure the unassignment works

      Test 2 - Without context id

      1. Now call the api again with userid, a different role id, contextlevel set to course and instanceid set to course id.
      2. Make sure the unassignment works

      Test 3 - Exception testing

      1. Now call the api again with just a userid and a role id.
      2. Make sure you see a missing parameters error.
      Show
      Setup Testing requires database and code changes Run unit tests and make sure they all pass Setup webservices for the api core_roles_unassign_roles() http://docs.moodle.org/25/en/Using_web_services In the above setup make sure the user you are going to use for making ws calls is admin or as all the role:assign permissions Get your fav client from https://github.com/moodlehq/sample-ws-clients or use the one I use https://github.com/ankitagarwal/moodle-ws-client/blob/master/client.php Make sure you have few courses and users and roles (Users must be enrolled in the course, that we would use to test) Note the various roleids for different roles from database (mdl_role) Note the format of params to use for your unassign_roles api , based on your client protocol from (moodle/admin/webservice/documentation.php ) Assign a user 3 different roles in the test course Test - 1 - Using context ids Get context for a course using Print_object(context_course::instance($course->id);) Now call the api assign_role with userid, roleid and context id. Make sure the unassignment works Test 2 - Without context id Now call the api again with userid, a different role id, contextlevel set to course and instanceid set to course id. Make sure the unassignment works Test 3 - Exception testing Now call the api again with just a userid and a role id. Make sure you see a missing parameters error.
    • 5
    • BACKEND Sprint 1

      As per comment of Damyon Wiese to MDL-29472, "Context is considered internal to Moodle - and not exposed to webservices. It should not be sent as a parameter or returned in a response"

      FILE: enrol/externallib.php

      FUNCTION: unassign_roles_parameters()
      PARAMETER: 'contextid' => new external_value(PARAM_INT, 'The context to unassign the user role from'),

            ankit_frenz Ankit Agarwal
            andreabix Andrea Bicciolo
            Adrian Greeve Adrian Greeve
            Sam Hemelryk Sam Hemelryk
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Votes:
            1 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved:

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