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

core_enrol_get_enrolled_users web service should limit the number of participants

    Details

    • Testing Instructions:
      Hide

      Take the demo REST client and edit it this way:

      <?php
      /**
       * REST client for Moodle 2
       * Return JSON or XML format
       *
       * @authorr Jerome Mouneyrac
       */
      
      /// SETUP - NEED TO BE CHANGED
      $token = 'f95fe8ce5f6a4f01dc24ccdf333bba22';
      $domainname = 'http://jerome.moodle.local/~jerome/Moodle_HEAD';
      
      $functionname = 'core_enrol_get_enrolled_users';
      
      // REST RETURNED VALUES FORMAT
      $restformat = 'json'; //Also possible in Moodle 2.2 and later: 'json'
                           //Setting it to 'json' will fail all calls on earlier Moodle version
      
      //////// moodle_user_create_users ////////
      
      /// PARAMETERS - NEED TO BE CHANGED TO TEST DIFFERENT CASES
      $params = array('courseid' => 2, //CHANGE IT
                      'options' => array(
                                          array('name' => 'limitfrom', 'value' => 5), //CHANGE VALUE, REMOVE OPTION
                                          array('name' => 'limitnumber', 'value' => 4) //CHANGE VALUE, REMOVE OPTION
                                   )
                );
      
      /// REST CALL
      header('Content-Type: text/plain');
      $serverurl = $domainname . '/webservice/rest/server.php'. '?wstoken=' . $token . '&wsfunction='.$functionname;
      require_once('./curl.php');
      $curl = new curl;
      //if rest format == 'xml', then we do not add the param for backward compatibility with Moodle < 2.2
      $restformat = ($restformat == 'json')?'&moodlewsrestformat=' . $restformat:'';
      $resp = $curl->post($serverurl . $restformat, $params);
      print_r($resp);
      

      Without 'limitfrom' and 'limitnumber' the web service function should return all enrolled users in the course. With limitfrom and limitnumber you should be able to limit the number of returned users.

      Show
      Take the demo REST client and edit it this way: <?php /** * REST client for Moodle 2 * Return JSON or XML format * * @authorr Jerome Mouneyrac */ /// SETUP - NEED TO BE CHANGED $token = 'f95fe8ce5f6a4f01dc24ccdf333bba22'; $domainname = 'http: //jerome.moodle.local/~jerome/Moodle_HEAD'; $functionname = 'core_enrol_get_enrolled_users'; // REST RETURNED VALUES FORMAT $restformat = 'json'; //Also possible in Moodle 2.2 and later: 'json' //Setting it to 'json' will fail all calls on earlier Moodle version //////// moodle_user_create_users //////// /// PARAMETERS - NEED TO BE CHANGED TO TEST DIFFERENT CASES $params = array('courseid' => 2, //CHANGE IT 'options' => array( array('name' => 'limitfrom', 'value' => 5), //CHANGE VALUE, REMOVE OPTION array('name' => 'limitnumber', 'value' => 4) //CHANGE VALUE, REMOVE OPTION ) ); /// REST CALL header('Content-Type: text/plain'); $serverurl = $domainname . '/webservice/ rest /server.php'. '?wstoken=' . $token . '&wsfunction='.$functionname; require_once('./curl.php'); $curl = new curl; // if rest format == 'xml', then we do not add the param for backward compatibility with Moodle < 2.2 $restformat = ($restformat == 'json')?'&moodlewsrestformat=' . $restformat:''; $resp = $curl->post($serverurl . $restformat, $params); print_r($resp); Without 'limitfrom' and 'limitnumber' the web service function should return all enrolled users in the course. With limitfrom and limitnumber you should be able to limit the number of returned users.
    • Affected Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_22_STABLE
    • Pull Master Branch:

      Description

      get_users_by_courseid web service should limit the number of participants and it should have `limitnumber` and `limitfrom` options.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

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

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    12/Mar/12