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

core_role_assign_roles ws function contains contextid as parameter, which is not correct

XMLWordPrintable

    • MOODLE_24_STABLE
    • MOODLE_26_STABLE
    • MDL-39152-master
    • Hide

      Setup

      1. Testing requires messing around with code a bit
      2. Run unit tests and make sure they all pass
      3. Setup webservices for the api assign_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 has all the role:assign permissions
      5. Get your fav client from https://github.com/moodlehq/sample-ws-clients or write/use your own.
      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 assign_roles api , based on your client protocol from (moodle/admin/webservice/documentation.php )

      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 assignment 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 assignment 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 messing around with code a bit Run unit tests and make sure they all pass Setup webservices for the api assign_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 has all the role:assign permissions Get your fav client from https://github.com/moodlehq/sample-ws-clients or write/use your own. 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 assign_roles api , based on your client protocol from (moodle/admin/webservice/documentation.php ) 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 assignment 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 assignment 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.
    • 13
    • 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: assign_roles_parameters()
      PARAMETER: 'contextid' => new external_value(PARAM_INT, 'The context to assign the user role in')

            ankit_frenz Ankit Agarwal
            andreabix Andrea Bicciolo
            Adrian Greeve Adrian Greeve
            Sam Hemelryk Sam Hemelryk
            David Monllaó David Monllaó
            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.