Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Class: sync_grades_test  - X-Ref

Tests for the enrol_lti\local\ltiadvantage\task\sync_grades scheduled task.

get_task_with_mocked_grade_service($statuscode = '200', $mockexception = false)   X-Ref
Get a task which has a mocked ags instance injected, meaning no real calls will be made to the platform.

This allows us to test the behaviour of the task (in terms of which users are in scope and which grades are sent)
without needing to deal with any auth.

param: string $statuscode the HTTP status code to simulate.
param: bool $mockexception whether to simulate an exception during the service call or not.
return: sync_grades instance of the task with a mocked ags instance inside.

set_user_grade_for_resource(int $userid, float $grade, \stdClass $resource)   X-Ref
Helper function to set a grade for a user.

param: int $userid the id of the user being graded.
param: float $grade the grade value, out of 100, to set for the user.
param: \stdClass $resource the published resource object.
return: float the fractional grade value expected to be used during sync.

override_resource_completion_status_for_user(\stdClass $resource, int $userid,bool $complete)   X-Ref
Helper to set the completion status for published course or module.

param: \stdClass $resource the resource - either a course or module.
param: int $userid the id of the user to override the completion status for.
param: bool $complete whether the resource is deemed complete or not.

grade_sync_positive_cases()   X-Ref
Data provider for test_grade_sync_positive_case.

return: array

test_grade_sync_positive_case($statuscode)   X-Ref
Test the sync grades task works correct when platform responses with given status code.

param: string $statuscode the response status code with which the job should work correctly

test_get_name()   X-Ref
Test confirming task name.


test_grade_sync_chronological_syncs()   X-Ref
Test the sync grades task during several runs and for a series of grade changes.


test_grade_sync_multiple_resource_links()   X-Ref
Test a grade sync when there are more than one resource link for the resource.


test_sync_grades_gradesync_disabled()   X-Ref
Test grade sync when the resource has syncgrades disabled.


test_sync_grades_auth_plugin_disabled()   X-Ref
Test the grade sync task when the auth_lti plugin is disabled.


test_sync_grades_enrol_plugin_disabled()   X-Ref
Test the grade sync task when the enrol_lti plugin is disabled.


test_sync_grades_no_service_endpoint()   X-Ref
Test the grade sync task when the launch data doesn't include the AGS support.


test_sync_grades_disabled_instance()   X-Ref
Test syncing grades when the enrolment instance is disabled.


test_sync_grades_deleted_context()   X-Ref
Test the grade sync when the context has been deleted in between launch and when the grade sync task is run.


test_sync_grades_completion_required()   X-Ref
Test grade sync when completion is required for the activity before sync takes place.


test_sync_grades_failed_service_call()   X-Ref
Test grade sync when the attempt to call the service returns an exception or a bad HTTP response code.


test_sync_grades_coupled_lineitem()   X-Ref
Test the sync when only the lineitem URL is provided and when lineitem creation/query isn't expected.


test_sync_grades_none_or_many_lineitems_activity_context()   X-Ref
Test the sync for an activity context when only the lineitems URL is provided and when line item creation/query is expected.


test_sync_grades_none_or_many_lineitems_course_context()   X-Ref
Test the sync for a course context when only the lineitems URL is provided and when line item creation/query is expected.