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

Add completion_value_used to web services returning completion statuses

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Minor Minor
    • 3.7
    • 3.5.3
    • Web Services
    • MOODLE_35_STABLE
    • MOODLE_37_STABLE
    • MDL-64123_master
    • Hide
      1. Ensure Completion tracking is enabled in Site Administration > Advanced features
      2. Create a new course with completion tracking enabled.
      3. Add 3 new labels to the course:
        1. "Label 1" with Completion tracking set to "Student can manually mark..."
        2. "Label 2" with Completion tracking set to "Student can manually mark..."
        3. "Label 3" with Completion tracking set to "Do not indicate", and "Access restrictions" set to: Student must match; Activity completion Label 2 must be marked completed.
      4. Enrol a user as student in the course
      5. Enable "Mobile services": Site administration ► Mobile app ► Mobile settings
      6. Create a Token in the mobile app service for the student user you just enroled in the course
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      7. Open the system console an execute this new curl request (or use another method for making HTTP requests and viewing the result as JSON), replacing wstoken with the token you just created and the site url with yours. Remember to replace the courseid also with the id of the course you created or used.

        curl 'http://localhost/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseid=2&wsfunction=core_course_get_contents&wstoken=3af67232a7596ceb658df4db329e5ad6' --compressed | python -m "json.tool"

      1. Now check that:
        •  In the returned JSON data, the module with the name "Label 1" has the following completiondata: {"overrideby": null, "state": 0, "timecompleted": 0, "valueused": false}
        •  In the returned JSON data, the module with the name "Label 2" has the following completiondata: {"overrideby": null, "state": 0, "timecompleted": 0, "valueused": true}
        •  In the returned JSON data, the module with the name "Label 3" has no completiondata.
      2. Now run the following request, replacing the course ID with the one you created, the user ID with the user you enrolled, the wstoken with the one you created, and the site URL with yours:

      curl 'http://localhost/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseid=2&userid=4&wsfunction=core_completion_get_activities_complet ion_status&wstoken=69eeadec533bff8b5eb5a59928967ea1' --compressed | python -m "json.tool"

      1. Now check that:
        • In the "statuses" array, the object with the cmid corresponding to the id "Label 1" from the first request has "valueused" set to false.
        • the object with the cmid corresponding to the id "Label 2" from the first request has "valueused" set to true.
        • There is no object with a cmid corresponding to the id of "Label 3" from the first request.
      Show
      Ensure Completion tracking is enabled in Site Administration > Advanced features Create a new course with completion tracking enabled. Add 3 new labels to the course: "Label 1" with Completion tracking set to "Student can manually mark..." "Label 2" with Completion tracking set to "Student can manually mark..." "Label 3" with Completion tracking set to "Do not indicate", and "Access restrictions" set to: Student must match; Activity completion Label 2 must be marked completed. Enrol a user as student in the course Enable "Mobile services": Site administration ► Mobile app ► Mobile settings Create a Token in the mobile app service for the student user you just enroled in the course Click on Site administration ► Plugins ► Web services ► Manage tokens Open the system console an execute this new curl request (or use another method for making HTTP requests and viewing the result as JSON), replacing wstoken with the token you just created and the site url with yours. Remember to replace the courseid also with the id of the course you created or used. curl 'http://localhost/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseid=2&wsfunction=core_course_get_contents&wstoken=3af67232a7596ceb658df4db329e5ad6' --compressed | python -m "json.tool" Now check that:  In the returned JSON data, the module with the name "Label 1" has the following completiondata: {"overrideby": null, "state": 0, "timecompleted": 0, "valueused": false}  In the returned JSON data, the module with the name "Label 2" has the following completiondata: {"overrideby": null, "state": 0, "timecompleted": 0, "valueused": true}  In the returned JSON data, the module with the name "Label 3" has no completiondata. Now run the following request, replacing the course ID with the one you created, the user ID with the user you enrolled, the wstoken with the one you created, and the site URL with yours: curl 'http://localhost/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseid=2&userid=4&wsfunction=core_completion_get_activities_complet ion_status&wstoken=69eeadec533bff8b5eb5a59928967ea1' --compressed | python -m "json.tool" Now check that: In the "statuses" array, the object with the cmid corresponding to the id "Label 1" from the first request has "valueused" set to false. the object with the cmid corresponding to the id "Label 2" from the first request has "valueused" set to true. There is no object with a cmid corresponding to the id of "Label 3" from the first request.

      core_availability\info::completion_value_used() tells us whether changing the completion status of a course module will affect the availability of other course modules.  If we include this data in the core_completion_get_activities_completion_status web service function, we can use it in the app to optimise performance of completion checkboxes.

            marxjohnson Mark Johnson
            marxjohnson Mark Johnson
            Juan Leyva Juan Leyva
            Sara Arjona (@sarjona) Sara Arjona (@sarjona)
            David Mudrák (@mudrd8mz) David Mudrák (@mudrd8mz)
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.