Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Attributes | List of all members
ltiservice_gradebookservices\local\service\gradebookservices Class Reference

A service implementing LTI Gradebook Services. More...

Inheritance diagram for ltiservice_gradebookservices\local\service\gradebookservices:
mod_lti\local\ltiservice\service_base

Public Member Functions

 __construct ()
 Class constructor. More...
 
 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. More...
 
 check_tool ($typeid, $body=null, $scopes=null)
 Check that the request has been properly signed and is permitted. More...
 
 check_tool_proxy ($toolproxyguid, $body=null)
 Check that the request has been properly signed. More...
 
 check_type ($typeid, $courseid, $body=null)
 Check that the request has been properly signed. More...
 
 get_component_id ()
 Get the service compoent ID. More...
 
 get_configuration_options (&$mform)
 Adds form elements for gradebook sync add/edit page. More...
 
 get_configuration_parameter_names ()
 Return an array with the names of the parameters that the service will be saving in the configuration. More...
 
 get_id ()
 Get the service ID. More...
 
 get_launch_parameters ($messagetype, $courseid, $user, $typeid, $modlti=null)
 Return an array of key/values to add to the launch parameters. More...
 
 get_lineitem ($courseid, $itemid, $typeid)
 Fetch a lineitem instance. More...
 
 get_lineitems ($courseid, $resourceid, $ltilinkid, $tag, $limitfrom, $limitnum, $typeid)
 Fetch the lineitem instances. More...
 
 get_name ()
 Get the service name. More...
 
 get_permitted_scopes ()
 Get the scope(s) permitted for this service. More...
 
 get_resources ()
 Get the resources for this service. More...
 
 get_tool_proxy ()
 Get the tool proxy object. More...
 
 get_type ()
 Get the type object. More...
 
 get_typeconfig ()
 Get the type config array. More...
 
 instance_added (object $lti)
 Called when a new LTI Instance is added. More...
 
 instance_deleted (int $id)
 Called when a new LTI Instance is deleted. More...
 
 instance_updated (object $lti)
 Called when a new LTI Instance is updated. More...
 
 is_allowed_in_context ($typeid, $courseid)
 Checks if there is a site tool or a course tool for this site. More...
 
 is_unsigned ()
 Get whether the service requests need to be signed. More...
 
 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. More...
 
 parse_value ($value)
 Parse a string for custom substitution parameter variables supported by this service's resources. More...
 
 save_grade_item ($gradeitem, $score, $userid)
 Saves a score received from the LTI tool. More...
 
 set_instance_form_values (object $defaultvalues)
 Set the form data when displaying the LTI Instance form. More...
 
stdClass set_tool_proxy ($toolproxy)
 Set the tool proxy object. More...
 
stdClass set_type ($type)
 Set the LTI type object. More...
 
array set_typeconfig ($typeconfig)
 Set the LTI type config object. More...
 

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. More...
 
static check_lti_id ($linkid, $course, $toolproxy)
 Check if an LTI id is valid. More...
 
static delete_orphans_ltiservice_gradebookservices_rows ()
 Deletes orphaned rows from the 'ltiservice_gradebookservices' table. More...
 
static find_ltiservice_gradebookservice_for_lineitem ($lineitemid)
 Find the right element in the ltiservice_gradebookservice table for a lineitem. More...
 
static find_ltiservice_gradebookservice_for_lti ($instanceid)
 Find the right element in the ltiservice_gradebookservice table for an lti instance. More...
 
static get_service_path ()
 Get the path for service requests. More...
 
static is_user_gradable_in_course ($courseid, $userid)
 Check if a user can be graded in a course. More...
 
static item_for_json ($item, $endpoint, $typeid)
 Get the json object representation of the grade item. More...
 
static result_for_json ($grade, $endpoint, $typeid)
 Get the object matching the JSON representation of the result. More...
 
static save_score ($gradeitem, $score, $userid)
 Set a grade item. More...
 
static update_coupled_gradebookservices (object $ltiinstance, ?string $resourceid, ?string $tag)
 Updates the tag and resourceid values for a grade item coupled to an lti link instance. More...
 
static validate_iso8601_date ($date)
 Validates specific ISO 8601 format of the timestamps. More...
 

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.
 

Protected Attributes

string $id
 ID for the service.
 
string $name
 Human readable name for the service.
 
array $resources
 Instances of the resources associated with this service.
 
boolean $unsigned
 true if requests for this service do not need to be signed.
 

Detailed Description

A service implementing LTI Gradebook Services.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Constructor & Destructor Documentation

◆ __construct()

ltiservice_gradebookservices\local\service\gradebookservices::__construct ( )

Class constructor.

Reimplemented from mod_lti\local\ltiservice\service_base.

Member Function Documentation

◆ add_standalone_lineitem()

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).

Parameters
string$courseidID of course
string$labellabel of lineitem
float$maximumscoremaximum score of lineitem
string$baseurl
int | null$ltilinkidid of lti instance this line item is associated with
string | null$resourceidresource id of lineitem
string | null$tagtag of lineitem
int$typeidlti type to which this line item is associated with
int | null$toolproxyidlti2 tool proxy to which this lineitem is associated to
Return values
intid of the created gradeitem

◆ check_lti_1x_id()

static ltiservice_gradebookservices\local\service\gradebookservices::check_lti_1x_id (   $linkid,
  $course,
  $typeid 
)
static

Check if an LTI id is valid when we are in a LTI 1.x case.

Parameters
string$linkidThe lti id
string$courseThe course
string$typeidThe lti type id
Return values
boolean

◆ check_lti_id()

static ltiservice_gradebookservices\local\service\gradebookservices::check_lti_id (   $linkid,
  $course,
  $toolproxy 
)
static

Check if an LTI id is valid.

Parameters
string$linkidThe lti id
string$courseThe course
string$toolproxyThe tool proxy id
Return values
boolean

◆ check_tool()

mod_lti\local\ltiservice\service_base::check_tool (   $typeid,
  $body = null,
  $scopes = null 
)
inherited

Check that the request has been properly signed and is permitted.

Parameters
string$typeidLTI type ID
string$bodyRequest body (null if none)
string[]$scopesArray of required scope(s) for incoming request
Return values
boolean

◆ check_tool_proxy()

mod_lti\local\ltiservice\service_base::check_tool_proxy (   $toolproxyguid,
  $body = null 
)
inherited

Check that the request has been properly signed.

Parameters
string$toolproxyguidTool Proxy GUID
string$bodyRequest body (null if none)
Return values
boolean
Deprecated:
since Moodle 3.7 MDL-62599 - please do not use this function any more.
See also
service_base::check_tool()

◆ check_type()

mod_lti\local\ltiservice\service_base::check_type (   $typeid,
  $courseid,
  $body = null 
)
inherited

Check that the request has been properly signed.

Parameters
int$typeidThe tool id
int$courseidThe course we are at
string$bodyRequest body (null if none)
Return values
bool
Deprecated:
since Moodle 3.7 MDL-62599 - please do not use this function any more.
See also
service_base::check_tool()

◆ delete_orphans_ltiservice_gradebookservices_rows()

static ltiservice_gradebookservices\local\service\gradebookservices::delete_orphans_ltiservice_gradebookservices_rows ( )
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

◆ find_ltiservice_gradebookservice_for_lineitem()

static ltiservice_gradebookservices\local\service\gradebookservices::find_ltiservice_gradebookservice_for_lineitem (   $lineitemid)
static

Find the right element in the ltiservice_gradebookservice table for a lineitem.

Parameters
string$lineitemidThe lineitem (gradeitem) id
Return values
objectgradebookservice if it exists

◆ find_ltiservice_gradebookservice_for_lti()

static ltiservice_gradebookservices\local\service\gradebookservices::find_ltiservice_gradebookservice_for_lti (   $instanceid)
static

Find the right element in the ltiservice_gradebookservice table for an lti instance.

Parameters
string$instanceidThe LTI module instance id
Return values
objectgradebookservice for this line item

◆ get_component_id()

mod_lti\local\ltiservice\service_base::get_component_id ( )
inherited

Get the service compoent ID.

Return values
string

◆ get_configuration_options()

ltiservice_gradebookservices\local\service\gradebookservices::get_configuration_options ( $mform)

Adds form elements for gradebook sync add/edit page.

Parameters
MoodleQuickForm$mformMoodle quickform object definition

Reimplemented from mod_lti\local\ltiservice\service_base.

◆ get_configuration_parameter_names()

mod_lti\local\ltiservice\service_base::get_configuration_parameter_names ( )
inherited

Return an array with the names of the parameters that the service will be saving in the configuration.

Return values
arrayNames list of the parameters that the service will be saving in the configuration
Deprecated:
since Moodle 3.7 - please do not use this function any more.

◆ get_id()

mod_lti\local\ltiservice\service_base::get_id ( )
inherited

Get the service ID.

Return values
string

◆ get_launch_parameters()

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.

Parameters
string$messagetype'basic-lti-launch-request' or 'ContentItemSelectionRequest'.
string$courseidthe course id.
object$userThe user id.
string$typeidThe tool lti type id.
string$modltiThe id of the lti activity.

The type is passed to check the configuration and not return parameters for services not used.

Return values
arrayof key/value pairs to add as launch parameters.

Reimplemented from mod_lti\local\ltiservice\service_base.

◆ get_lineitem()

ltiservice_gradebookservices\local\service\gradebookservices::get_lineitem (   $courseid,
  $itemid,
  $typeid 
)

Fetch a lineitem instance.

Returns the lineitem instance if found, otherwise false.

Parameters
string$courseidID of course
string$itemidID of lineitem
string$typeid
Return values
ltiservice_gradebookservices::local::resources::lineitem|bool

◆ get_lineitems()

ltiservice_gradebookservices\local\service\gradebookservices::get_lineitems (   $courseid,
  $resourceid,
  $ltilinkid,
  $tag,
  $limitfrom,
  $limitnum,
  $typeid 
)

Fetch the lineitem instances.

Parameters
string$courseidID of course
string$resourceidResource identifier used for filtering, may be null
string$ltilinkidResource Link identifier used for filtering, may be null
string$tag
int$limitfromOffset for the first line item to include in a paged set
int$limitnumMaximum number of line items to include in the paged set
string$typeid
Return values
array
Exceptions
Exception

◆ get_name()

mod_lti\local\ltiservice\service_base::get_name ( )
inherited

Get the service name.

Return values
string

◆ get_permitted_scopes()

ltiservice_gradebookservices\local\service\gradebookservices::get_permitted_scopes ( )

Get the scope(s) permitted for this service.

Return values
array

Reimplemented from mod_lti\local\ltiservice\service_base.

◆ get_resources()

ltiservice_gradebookservices\local\service\gradebookservices::get_resources ( )

Get the resources for this service.

Return values
resource_base[]

Reimplemented from mod_lti\local\ltiservice\service_base.

◆ get_service_path()

static mod_lti\local\ltiservice\service_base::get_service_path ( )
staticinherited

Get the path for service requests.

Return values
string

◆ get_tool_proxy()

mod_lti\local\ltiservice\service_base::get_tool_proxy ( )
inherited

Get the tool proxy object.

Return values
stdClass

◆ get_type()

mod_lti\local\ltiservice\service_base::get_type ( )
inherited

Get the type object.

Return values
stdClass

◆ get_typeconfig()

mod_lti\local\ltiservice\service_base::get_typeconfig ( )
inherited

Get the type config array.

Return values
array|null

◆ instance_added()

ltiservice_gradebookservices\local\service\gradebookservices::instance_added ( object  $lti)

Called when a new LTI Instance is added.

Parameters
object$ltiLTI Instance.

Reimplemented from mod_lti\local\ltiservice\service_base.

◆ instance_deleted()

mod_lti\local\ltiservice\service_base::instance_deleted ( int  $id)
inherited

Called when a new LTI Instance is deleted.

Parameters
int$idLTI Instance.

◆ instance_updated()

ltiservice_gradebookservices\local\service\gradebookservices::instance_updated ( object  $lti)

Called when a new LTI Instance is updated.

Parameters
object$ltiLTI Instance.

Reimplemented from mod_lti\local\ltiservice\service_base.

◆ is_allowed_in_context()

mod_lti\local\ltiservice\service_base::is_allowed_in_context (   $typeid,
  $courseid 
)
inherited

Checks if there is a site tool or a course tool for this site.

Parameters
int$typeidThe tool lti type id.
int$courseidThe course id.
Return values
boolreturns True if tool is allowed in context, false otherwise.

◆ is_unsigned()

mod_lti\local\ltiservice\service_base::is_unsigned ( )
inherited

Get whether the service requests need to be signed.

Return values
boolean

◆ is_used_in_context()

mod_lti\local\ltiservice\service_base::is_used_in_context (   $typeid,
  $courseid 
)
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.

Parameters
int$typeidThe tool lti type id.
int$courseidThe course id.
Return values
boolreturns True if tool is used in context, false otherwise.

◆ is_user_gradable_in_course()

static ltiservice_gradebookservices\local\service\gradebookservices::is_user_gradable_in_course (   $courseid,
  $userid 
)
static

Check if a user can be graded in a course.

Parameters
int$courseidThe course
int$useridThe user
Return values
bool

◆ item_for_json()

static ltiservice_gradebookservices\local\service\gradebookservices::item_for_json (   $item,
  $endpoint,
  $typeid 
)
static

Get the json object representation of the grade item.

Parameters
object$itemGrade Item record
string$endpointEndpoint for lineitems container request
string$typeid
Return values
object

◆ parse_value()

mod_lti\local\ltiservice\service_base::parse_value (   $value)
inherited

Parse a string for custom substitution parameter variables supported by this service's resources.

Parameters
string$valueValue to be parsed
Return values
string

◆ result_for_json()

static ltiservice_gradebookservices\local\service\gradebookservices::result_for_json (   $grade,
  $endpoint,
  $typeid 
)
static

Get the object matching the JSON representation of the result.

Parameters
object$gradeGrade record
string$endpointEndpoint for lineitem
int$typeidThe id of the type to include in the result url.
Return values
object

◆ save_grade_item()

ltiservice_gradebookservices\local\service\gradebookservices::save_grade_item (   $gradeitem,
  $score,
  $userid 
)

Saves a score received from the LTI tool.

Parameters
object$gradeitemGrade Item record
object$scoreResult object
int$useridUser ID
Exceptions
Exception

◆ save_score()

static ltiservice_gradebookservices\local\service\gradebookservices::save_score (   $gradeitem,
  $score,
  $userid 
)
static

Set a grade item.

Parameters
object$gradeitemGrade Item record
object$scoreResult object
int$useridUser ID
Exceptions
Exception
Deprecated:
since Moodle 3.7 MDL-62599 - please do not use this function any more.
See also
gradebookservices::save_grade_item($gradeitem, $score, $userid)

◆ set_instance_form_values()

ltiservice_gradebookservices\local\service\gradebookservices::set_instance_form_values ( object  $defaultvalues)

Set the form data when displaying the LTI Instance form.

Parameters
object$defaultvaluesDefault form values.

Reimplemented from mod_lti\local\ltiservice\service_base.

◆ set_tool_proxy()

stdClass mod_lti\local\ltiservice\service_base::set_tool_proxy (   $toolproxy)
inherited

Set the tool proxy object.

Parameters
object$toolproxyThe tool proxy for this service request

◆ set_type()

stdClass mod_lti\local\ltiservice\service_base::set_type (   $type)
inherited

Set the LTI type object.

Parameters
object$typeThe LTI type for this service request

◆ set_typeconfig()

array mod_lti\local\ltiservice\service_base::set_typeconfig (   $typeconfig)
inherited

Set the LTI type config object.

Parameters
array$typeconfigThe LTI type config for this service request

◆ update_coupled_gradebookservices()

static ltiservice_gradebookservices\local\service\gradebookservices::update_coupled_gradebookservices ( object  $ltiinstance,
?string  $resourceid,
?string  $tag 
)
static

Updates the tag and resourceid values for a grade item coupled to an lti link instance.

Parameters
object$ltiinstanceThe lti instance to which the grade item is coupled to
string | null$resourceidThe resourceid to apply to the lineitem. If empty string which will be stored as null.
string | null$tagThe tag to apply to the lineitem. If empty string which will be stored as null.

◆ validate_iso8601_date()

static ltiservice_gradebookservices\local\service\gradebookservices::validate_iso8601_date (   $date)
static

Validates specific ISO 8601 format of the timestamps.

Parameters
string$dateThe timestamp to check.
Return values
booleantrue or false if the date matches the format.

The documentation for this class was generated from the following file: