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

get_forums_by_courses external function should return the number of discussions in each forum

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.8
    • Fix Version/s: 2.8
    • Component/s: Forum, Web Services
    • Labels:
    • Testing Instructions:
      Hide
      1. Inside a course create a couple of forums (general) with a 1 or 2 discussions each one
      2. Enable "Mobile services": Plugins ► Web Services ► External services
      3. Create a Token:
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      4. Click add, select user and service (Mobile Service)
      5. Next, you can do a CURL REST call simulating a WS client:
        • You need to replace the courseids value (4) to your course id.
        • You also need to replace the wstoken and the URL of your moodle instance

          curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' -H 'Pragma: no-cache' -H 'Origin: file://' -H 'Accept-Encoding: gzip,deflate,sdch' -H 'Accept-Language: es,en;q=0.8,de-DE;q=0.6,de;q=0.4' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1798.0 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Cache-Control: no-cache' -H 'Connection: keep-alive' --data 'courseids%5B0%5D=4&wsfunction=mod_forum_get_forums_by_courses&wstoken=6137368848c2710566a04917efd5d74d' --compressed
          

      6. Confirm that:
        • The result of that curl call list all your forums in the course with the correct number of discussions:
          You can use this online tool http://jsonlint.com/ to format the JSON returned by the curl call
      Show
      Inside a course create a couple of forums (general) with a 1 or 2 discussions each one Enable "Mobile services": Plugins ► Web Services ► External services Create a Token: Click on Site administration ► Plugins ► Web services ► Manage tokens Click add, select user and service (Mobile Service) Next, you can do a CURL REST call simulating a WS client: You need to replace the courseids value (4) to your course id. You also need to replace the wstoken and the URL of your moodle instance curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' -H 'Pragma: no-cache' -H 'Origin: file://' -H 'Accept-Encoding: gzip,deflate,sdch' -H 'Accept-Language: es,en;q=0.8,de-DE;q=0.6,de;q=0.4' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1798.0 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Cache-Control: no-cache' -H 'Connection: keep-alive' --data 'courseids%5B0%5D=4&wsfunction=mod_forum_get_forums_by_courses&wstoken=6137368848c2710566a04917efd5d74d' --compressed Confirm that: The result of that curl call list all your forums in the course with the correct number of discussions: You can use this online tool http://jsonlint.com/ to format the JSON returned by the curl call
    • Affected Branches:
      MOODLE_28_STABLE
    • Fixed Branches:
      MOODLE_28_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-47389-master

      Description

      If we want to display a paginated list of discussions we need to be able to retrieve the num of discussions of each forum

      Currently, exists a function that returns the number of discussions in a forum that implements a static request cache (no MUC).

       forum_count_discussions($forum, $cm, $course) 
      

      This is consistent with what the forum listing page does in a course (/mod/forum/index.php?id=X)

        Attachments

          Activity

            People

            • Assignee:
              jleyva Juan Leyva
              Reporter:
              jleyva Juan Leyva
              Peer reviewer:
              Damyon Wiese
              Integrator:
              Dan Poltawski
              Tester:
              Mark Nelson
              Participants:
              Component watchers:
              Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze, Juan Leyva, Jake Dallimore, Jun Pataleta
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                10/Nov/14