Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
|
A service implementing LTI Gradebook Services. More...
Public Member Functions | |
__construct () | |
Class constructor. | |
add_standalone_lineitem (string $courseid, string $label, float $maximumscore, string $baseurl, ?int $ltilinkid, ?string $resourceid, ?string $tag, int $typeid, int $toolproxyid=null) | |
Adds a decoupled (standalone) line item. | |
check_tool ($typeid, $body=null, $scopes=null) | |
Check that the request has been properly signed and is permitted. | |
check_tool_proxy ($toolproxyguid, $body=null) | |
Check that the request has been properly signed. | |
check_type ($typeid, $courseid, $body=null) | |
Check that the request has been properly signed. | |
get_component_id () | |
Get the service compoent ID. | |
get_configuration_options (&$mform) | |
Adds form elements for gradebook sync add/edit page. | |
get_configuration_parameter_names () | |
Return an array with the names of the parameters that the service will be saving in the configuration. | |
get_id () | |
Get the service ID. | |
get_jwt_claim_mappings () | |
Return an array of key/claim mapping allowing LTI 1.1 custom parameters to be transformed to LTI 1.3 claims. | |
get_launch_parameters ($messagetype, $courseid, $user, $typeid, $modlti=null) | |
Return an array of key/values to add to the launch parameters. | |
get_lineitem ($courseid, $itemid, $typeid) | |
Fetch a lineitem instance. | |
get_lineitems ($courseid, $resourceid, $ltilinkid, $tag, $limitfrom, $limitnum, $typeid) | |
Fetch the lineitem instances. | |
get_name () | |
Get the service name. | |
get_permitted_scopes () | |
Get the scope(s) permitted for this service. | |
get_resources () | |
Get the resources for this service. | |
get_scopes () | |
Get the scopes defined by this service. | |
get_tool_proxy () | |
Get the tool proxy object. | |
get_type () | |
Get the type object. | |
get_typeconfig () | |
Get the type config array. | |
instance_added (object $lti) | |
Called when a new LTI Instance is added. | |
instance_deleted (int $id) | |
Called when a new LTI Instance is deleted. | |
instance_updated (object $lti) | |
Called when a new LTI Instance is updated. | |
is_allowed_in_context ($typeid, $courseid) | |
Checks if there is a site tool or a course tool for this site. | |
is_unsigned () | |
Get whether the service requests need to be signed. | |
is_used_in_context ($typeid, $courseid) | |
Default implementation will check for the existence of at least one mod_lti entry for that tool and context. | |
override_endpoint (string $messagetype, string $targetlinkuri, ?string $customstr, int $courseid, ?object $lti=null) | |
For submission review, if there is a dedicated URL, use it as the target link. | |
parse_value ($value) | |
Parse a string for custom substitution parameter variables supported by this service's resources. | |
save_grade_item ($gradeitem, $score, $userid) | |
Saves a score received from the LTI tool. | |
set_instance_form_values (object $defaultvalues) | |
Set the form data when displaying the LTI Instance form. | |
stdClass | set_tool_proxy ($toolproxy) |
Set the tool proxy object. | |
stdClass | set_type ($type) |
Set the LTI type object. | |
array | set_typeconfig ($typeconfig) |
Set the LTI type config object. | |
Static Public Member Functions | |
static | check_lti_1x_id ($linkid, $course, $typeid) |
Check if an LTI id is valid when we are in a LTI 1.x case. | |
static | check_lti_id ($linkid, $course, $toolproxy) |
Check if an LTI id is valid. | |
static | delete_orphans_ltiservice_gradebookservices_rows () |
Deletes orphaned rows from the 'ltiservice_gradebookservices' table. | |
static | find_ltiservice_gradebookservice_for_lineitem ($lineitemid) |
Find the right element in the ltiservice_gradebookservice table for a lineitem. | |
static | find_ltiservice_gradebookservice_for_lti ($instanceid) |
Find the right element in the ltiservice_gradebookservice table for an lti instance. | |
static | get_service_path () |
Get the path for service requests. | |
static | is_user_gradable_in_course ($courseid, $userid) |
Check if a user can be graded in a course. | |
static | item_for_json ($item, $endpoint, $typeid) |
Get the json object representation of the grade item. | |
static | result_for_json ($grade, $endpoint, $typeid) |
Get the object matching the JSON representation of the result. | |
static | save_score ($gradeitem, $score, $userid) |
Set a grade item. | |
static | update_coupled_gradebookservices (object $ltiinstance, ?string $resourceid, ?string $tag, ?\moodle_url $subreviewurl, ?string $subreviewparams) |
Updates the tag, resourceid and submission review values for a grade item coupled to an lti link instance. | |
static | validate_iso8601_date ($date) |
Validates specific ISO 8601 format of the timestamps. | |
Public Attributes | |
const | GRADEBOOKSERVICES_FULL = 2 |
Full access to Gradebook services. | |
const | GRADEBOOKSERVICES_READ = 1 |
Read-only access to Gradebook services. | |
const | LTI_VERSION2P0 = 'LTI-2p0' |
Label representing an LTI 2 message type. | |
const | SCOPE_GRADEBOOKSERVICES_LINEITEM = 'https://purl.imsglobal.org/spec/lti-ags/scope/lineitem' |
Scope for full access to Lineitem service. | |
const | SCOPE_GRADEBOOKSERVICES_LINEITEM_READ = 'https://purl.imsglobal.org/spec/lti-ags/scope/lineitem.readonly' |
Scope for full access to Lineitem service. | |
const | SCOPE_GRADEBOOKSERVICES_RESULT_READ = 'https://purl.imsglobal.org/spec/lti-ags/scope/result.readonly' |
Scope for access to Result service. | |
const | SCOPE_GRADEBOOKSERVICES_SCORE = 'https://purl.imsglobal.org/spec/lti-ags/scope/score' |
Scope for access to Score service. | |
const | SERVICE_ENABLED = 1 |
Service enabled. | |
A service implementing LTI Gradebook Services.
ltiservice_gradebookservices\local\service\gradebookservices::__construct | ( | ) |
Class constructor.
Reimplemented from mod_lti\local\ltiservice\service_base.
ltiservice_gradebookservices\local\service\gradebookservices::add_standalone_lineitem | ( | string | $courseid, |
string | $label, | ||
float | $maximumscore, | ||
string | $baseurl, | ||
?int | $ltilinkid, | ||
?string | $resourceid, | ||
?string | $tag, | ||
int | $typeid, | ||
int | $toolproxyid = null ) |
Adds a decoupled (standalone) line item.
Decoupled line items are not directly attached to an lti instance activity. They are recorded in the gradebook as manual activities and the gradebookservices is used to associate that manual column with the tool in addition to storing the LTI related metadata (resource id, tag).
string | $courseid | ID of course |
string | $label | label of lineitem |
float | $maximumscore | maximum score of lineitem |
string | $baseurl | |
int | null | $ltilinkid | id of lti instance this line item is associated with |
string | null | $resourceid | resource id of lineitem |
string | null | $tag | tag of lineitem |
int | $typeid | lti type to which this line item is associated with |
int | null | $toolproxyid | lti2 tool proxy to which this lineitem is associated to |
int | id of the created gradeitem |
|
static |
Check if an LTI id is valid when we are in a LTI 1.x case.
string | $linkid | The lti id |
string | $course | The course |
string | $typeid | The lti type id |
boolean |
|
static |
Check if an LTI id is valid.
string | $linkid | The lti id |
string | $course | The course |
string | $toolproxy | The tool proxy id |
boolean |
|
inherited |
Check that the request has been properly signed and is permitted.
string | $typeid | LTI type ID |
string | $body | Request body (null if none) |
string[] | $scopes | Array of required scope(s) for incoming request |
boolean |
|
inherited |
Check that the request has been properly signed.
string | $toolproxyguid | Tool Proxy GUID |
string | $body | Request body (null if none) |
boolean |
|
inherited |
Check that the request has been properly signed.
int | $typeid | The tool id |
int | $courseid | The course we are at |
string | $body | Request body (null if none) |
bool |
|
static |
Deletes orphaned rows from the 'ltiservice_gradebookservices' table.
Sometimes, if a gradebook entry is deleted and it was a lineitem the row in the table ltiservice_gradebookservices can become an orphan This method will clean these orphans. It will happens based on a task because it is not urgent and we don't want to slow the service
|
static |
Find the right element in the ltiservice_gradebookservice table for a lineitem.
string | $lineitemid | The lineitem (gradeitem) id |
object | gradebookservice if it exists |
|
static |
Find the right element in the ltiservice_gradebookservice table for an lti instance.
string | $instanceid | The LTI module instance id |
object | gradebookservice for this line item |
|
inherited |
Get the service compoent ID.
string |
ltiservice_gradebookservices\local\service\gradebookservices::get_configuration_options | ( | & | $mform | ) |
Adds form elements for gradebook sync add/edit page.
MoodleQuickForm | $mform | Moodle quickform object definition |
Reimplemented from mod_lti\local\ltiservice\service_base.
|
inherited |
Return an array with the names of the parameters that the service will be saving in the configuration.
array | Names list of the parameters that the service will be saving in the configuration |
|
inherited |
Get the service ID.
string |
ltiservice_gradebookservices\local\service\gradebookservices::get_jwt_claim_mappings | ( | ) |
Return an array of key/claim mapping allowing LTI 1.1 custom parameters to be transformed to LTI 1.3 claims.
array | Key/value pairs of params to claim mapping. |
Reimplemented from mod_lti\local\ltiservice\service_base.
ltiservice_gradebookservices\local\service\gradebookservices::get_launch_parameters | ( | $messagetype, | |
$courseid, | |||
$user, | |||
$typeid, | |||
$modlti = null ) |
Return an array of key/values to add to the launch parameters.
string | $messagetype | 'basic-lti-launch-request' or 'ContentItemSelectionRequest'. |
string | $courseid | the course id. |
object | $user | The user id. |
string | $typeid | The tool lti type id. |
string | $modlti | The id of the lti activity. |
The type is passed to check the configuration and not return parameters for services not used.
array | of key/value pairs to add as launch parameters. |
Reimplemented from mod_lti\local\ltiservice\service_base.
ltiservice_gradebookservices\local\service\gradebookservices::get_lineitem | ( | $courseid, | |
$itemid, | |||
$typeid ) |
Fetch a lineitem instance.
Returns the lineitem instance if found, otherwise false.
string | $courseid | ID of course |
string | $itemid | ID of lineitem |
string | $typeid |
ltiservice_gradebookservices\local\resources\lineitem|bool |
ltiservice_gradebookservices\local\service\gradebookservices::get_lineitems | ( | $courseid, | |
$resourceid, | |||
$ltilinkid, | |||
$tag, | |||
$limitfrom, | |||
$limitnum, | |||
$typeid ) |
Fetch the lineitem instances.
string | $courseid | ID of course |
string | $resourceid | Resource identifier used for filtering, may be null |
string | $ltilinkid | Resource Link identifier used for filtering, may be null |
string | $tag | |
int | $limitfrom | Offset for the first line item to include in a paged set |
int | $limitnum | Maximum number of line items to include in the paged set |
string | $typeid |
array |
Exception |
|
inherited |
Get the service name.
string |
ltiservice_gradebookservices\local\service\gradebookservices::get_permitted_scopes | ( | ) |
Get the scope(s) permitted for this service.
array |
Reimplemented from mod_lti\local\ltiservice\service_base.
ltiservice_gradebookservices\local\service\gradebookservices::get_resources | ( | ) |
Get the resources for this service.
resource_base[] |
Reimplemented from mod_lti\local\ltiservice\service_base.
ltiservice_gradebookservices\local\service\gradebookservices::get_scopes | ( | ) |
Get the scopes defined by this service.
array |
Reimplemented from mod_lti\local\ltiservice\service_base.
|
staticinherited |
Get the path for service requests.
string |
|
inherited |
Get the tool proxy object.
stdClass |
|
inherited |
Get the type object.
stdClass |
|
inherited |
Get the type config array.
array|null |
ltiservice_gradebookservices\local\service\gradebookservices::instance_added | ( | object | $lti | ) |
Called when a new LTI Instance is added.
object | $lti | LTI Instance. |
Reimplemented from mod_lti\local\ltiservice\service_base.
|
inherited |
Called when a new LTI Instance is deleted.
int | $id | LTI Instance. |
ltiservice_gradebookservices\local\service\gradebookservices::instance_updated | ( | object | $lti | ) |
Called when a new LTI Instance is updated.
object | $lti | LTI Instance. |
Reimplemented from mod_lti\local\ltiservice\service_base.
|
inherited |
Checks if there is a site tool or a course tool for this site.
int | $typeid | The tool lti type id. |
int | $courseid | The course id. |
bool | returns True if tool is allowed in context, false otherwise. |
|
inherited |
Get whether the service requests need to be signed.
boolean |
|
inherited |
Default implementation will check for the existence of at least one mod_lti entry for that tool and context.
It may be overridden if other inferences can be done.
Ideally a Site Tool should be explicitly engaged with a course, the check on the presence of a link is a proxy to infer a Site Tool engagement until an explicit Site Tool - Course relationship exists.
int | $typeid | The tool lti type id. |
int | $courseid | The course id. |
bool | returns True if tool is used in context, false otherwise. |
|
static |
Check if a user can be graded in a course.
int | $courseid | The course |
int | $userid | The user |
bool |
|
static |
Get the json object representation of the grade item.
object | $item | Grade Item record |
string | $endpoint | Endpoint for lineitems container request |
string | $typeid |
object |
ltiservice_gradebookservices\local\service\gradebookservices::override_endpoint | ( | string | $messagetype, |
string | $targetlinkuri, | ||
?string | $customstr, | ||
int | $courseid, | ||
?object | $lti = null ) |
For submission review, if there is a dedicated URL, use it as the target link.
string | $messagetype | message type for this launch |
string | $targetlinkuri | current target link uri |
string | null | $customstr | concatenated list of custom parameters |
int | $courseid | |
null | object | $lti | LTI Instance. |
array | containing the target link URL and the custom params string to use. |
Reimplemented from mod_lti\local\ltiservice\service_base.
|
inherited |
Parse a string for custom substitution parameter variables supported by this service's resources.
string | $value | Value to be parsed |
string |
|
static |
Get the object matching the JSON representation of the result.
object | $grade | Grade record |
string | $endpoint | Endpoint for lineitem |
int | $typeid | The id of the type to include in the result url. |
object |
ltiservice_gradebookservices\local\service\gradebookservices::save_grade_item | ( | $gradeitem, | |
$score, | |||
$userid ) |
|
static |
Set a grade item.
object | $gradeitem | Grade Item record |
object | $score | Result object |
int | $userid | User ID |
Exception |
ltiservice_gradebookservices\local\service\gradebookservices::set_instance_form_values | ( | object | $defaultvalues | ) |
Set the form data when displaying the LTI Instance form.
object | $defaultvalues | Default form values. |
Reimplemented from mod_lti\local\ltiservice\service_base.
|
inherited |
Set the tool proxy object.
object | $toolproxy | The tool proxy for this service request |
|
inherited |
Set the LTI type object.
object | $type | The LTI type for this service request |
|
inherited |
Set the LTI type config object.
array | $typeconfig | The LTI type config for this service request |
|
static |
Updates the tag, resourceid and submission review values for a grade item coupled to an lti link instance.
object | $ltiinstance | The lti instance to which the grade item is coupled to |
string | null | $resourceid | The resourceid to apply to the lineitem. If empty string which will be stored as null. |
string | null | $tag | The tag to apply to the lineitem. If empty string which will be stored as null. |
moodle_url | null | $subreviewurl | The submission review target link URL |
string | null | $subreviewparams | The submission review custom parameters. |
|
static |
Validates specific ISO 8601 format of the timestamps.
string | $date | The timestamp to check. |
boolean | true or false if the date matches the format. |