Error when connecting with mobile app

Error when connecting with mobile app

by Jean-Roch Meurisse -
Number of replies: 2
Picture of Core developers Picture of Plugin developers Picture of Testers

Hi there,

I get the following error when trying to connect to some of my moodle instances with the mobile app with moodle 3.5
"Call to undefined function course_get_format()

When using mobileapp.moodledemo.net here's what I'm getting

Preview tab

  1. {exception: "Error", errorcode: null, message: "Call to undefined function course_get_format()"}
    1. errorcode: null
    2. exception: "Error"
    3. message: "Call to undefined function course_get_format()"
Headers tab

    1. Request URL:
    2. Request Method:
      POST
    3. Status Code:
      200 OK
    4. Remote Address:
      138.48.227.28:443
    5. Referrer Policy:
      no-referrer-when-downgrade
  1. Response Headers
    1. Accept-Ranges:
      none
    2. Access-Control-Allow-Origin:
      *
    3. Cache-Control:
      private, must-revalidate, pre-check=0, post-check=0, max-age=0
    4. Connection:
      Keep-Alive
    5. Content-Length:
      97
    6. Content-Type:
      application/json
    7. Date:
      Wed, 26 Sep 2018 12:49:05 GMT
    8. Expires:
      Thu, 01 Jan 1970 00:00:00 GMT
    9. Keep-Alive:
      timeout=5, max=100
    10. Pragma:
      no-cache
    11. Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.0.26
    12. X-Powered-By:
      PHP/7.0.26
  2. Request Headers
    1. Provisional headers are shown
    2. Accept:
      application/json, text/plain, */*
    3. Content-Type:
      application/x-www-form-urlencoded
    4. Origin:
    5. Referer:
    6. User-Agent:
      Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36
  3. Query String Parametersview sourceview URL encoded
    1. moodlewsrestformat:
      json
  4. Form Dataview sourceview URL encoded
    1. field:
      ids
    2. value:
      78,73,206,2122,2,2115,978,2123,1
    3. moodlewssettingfilter:
      true
    4. moodlewssettingfileurl:
      true
    5. wsfunction:
      core_course_get_courses_by_field
    6. wstoken:
      61148f2324b6a0c2c7b50a34382f2aba


On another platform with the same plugins installed and same theme, everything is ok

Any hint?

thanks in advance

Average of ratings: -
In reply to Jean-Roch Meurisse

Re: Error when connecting with mobile app

by Jean-Roch Meurisse -
Picture of Core developers Picture of Plugin developers Picture of Testers

I found the problem.

If CFG->courseoverviewfileslimit is set to 0, course/lib.php is not loaded (see lib/coursecatlib.php) in function get_course_overviewfiles() and thus there is no "course_get_format" function available.

Moving line 3013 of coursecatlib up before the test on $CFG->courseoverviewfileslimit solves the problem

Regards