Quantcast
Channel: Web services
Viewing all articles
Browse latest Browse all 2361

Web Service Requires Guest User to be Enabled

$
0
0
by Michael Backus.  

I recently wrote an app to update grades using Moodle's REST protocol. Here are the steps I took to get the token:

    a) Go to: Site administration > Users > Permissions > Define roles
    b) Click the "Add a new role" button
    c) Click the "Continue" button to define a new role
    d) Name the custom role "App"
    e) In the context part, choose System to assign this role from everywhere in the system
    f) Search in the "Filter" search box for the following and check "Allow"
        - Edit grades
        - Use REST protocol
    g) Go to:  Site administration > Plugins > Web services > External services
    h) Click "Add"
    i) On the "External service" page, fill in the details as follows
        - Name: GradeQR Web Service
        - Short Name: GradeQR
        - Click "Add service"
    j) Click "Add functions"
    k) Search for and add "core_grades_update_grades"
    l) Click "Add functions"
    m) Create a user named "GradeQR App"
    n) Go to Site administrator > Users > Permissions > Assign system roles
    o) Click on "App"
    p) Add the "GradeQR App" user to the "Existing users" list
    q) Go to Site administrator > Web services > Manage protocals and enable the REST protocol
    r) Go to Site administrator > Web services > Manage tokens and click "Add"
        - User: GradeQR App
        - Service: GradeQR Web Service
        - Click "Save changes

The token allows me to enter/edit a grade as long as I have the guest enrollment method enabled. However, if I disable the guest enrollment method, then I get the following error:

{"exception":"moodle_exception","errorcode":"errorcoursecontextnotvalid","message":"You cannot execute functions in the course context (course id:5). The context error message was: Course or activity not accessible."}

Seems like I must not have enabled something that is automatically enabled when the guest enrollment method is turned on, but I am having a hard time figuring out what it is. Any ideas?


Viewing all articles
Browse latest Browse all 2361

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>