Moodle PHP Documentation 4.4
Moodle 4.4.1 (Build: 20240610) (db07c09afc5)
|
Linear values target. More...
Public Member Functions | |
add_bulk_actions_js () | |
Adds the JS required to run the bulk actions. | |
add_sample_data ($data) | |
add_sample_data | |
always_update_analysis_time () | |
Update the last analysis time on analysable processed or always. | |
bulk_actions (array $predictions) | |
Suggested bulk actions for a user. | |
calculate ($sampleids, core_analytics\analysable $analysable, $starttime=false, $endtime=false) | |
Calculates the target. | |
can_use_timesplitting (\core_analytics\local\time_splitting\base $timesplitting) | |
Can the provided time-splitting method be used on this target?. | |
clear_sample_data () | |
clear_sample_data | |
filter_out_invalid_samples (&$sampleids, core_analytics\analysable $analysable, $fortraining=true) | |
Filters out invalid samples for training. | |
generate_insight_notifications ($modelid, $samplecontexts, array $predictions=[]) | |
Generates insights notifications. | |
get_analyser_class () | |
Returns the analyser class that should be used along with this target. | |
get_calculation_outcome ($value, $ignoredsubtype=false) | |
How positive is this calculated value? | |
get_display_value ($value, $subtype=false) | |
Returns the visible value of the calculated value. | |
get_id () | |
The class id is the calculable class full qualified class name. | |
get_insight_body (\context $context, string $contextname, stdClass $user, moodle_url $insighturl) | |
Returns the body message for an insight with multiple predictions. | |
get_insight_body_for_prediction (\context $context, stdClass $user, core_analytics\prediction $prediction, array &$actions) | |
Returns the body message for an insight for a single prediction. | |
get_insight_context_url ($modelid, $context) | |
URL to the insight. | |
get_insight_subject (int $modelid, context $context) | |
The insight notification subject. | |
get_insights_users (\context $context) | |
Returns the list of users that will receive insights notifications. | |
is_linear () | |
Are the calculated values this target returns linear values? | |
is_valid_analysable (\core_analytics\analysable $analysable, $fortraining=true) | |
Allows the target to verify that the analysable is a good candidate. | |
is_valid_sample ($sampleid, core_analytics\analysable $analysable, $fortraining=true) | |
Is this sample from the $analysable valid? | |
link_insights_report () | |
Should the insights of this model be linked from reports? | |
prediction_actions (\core_analytics\prediction $prediction, $includedetailsaction=false, $isinsightuser=false) | |
Suggested actions for a user. | |
prediction_callback ($modelid, $sampleid, $rangeindex, context $samplecontext, $prediction, $predictionscore) | |
Callback to execute once a prediction has been returned from the predictions processor. | |
save_calculation_info (\core_analytics\local\time_splitting\base $timesplitting, int $rangeindex) | |
Stores in MUC the previously added data and it associates it to the provided $calculable. | |
triggers_callback ($predictedvalue, $predictionscore) | |
This method determines if a prediction is interesing for the model or not. | |
Static Public Member Functions | |
static | based_on_assumptions () |
Based on facts (processed by machine learning backends) by default. | |
static | get_max_value () |
Gets the maximum value for this target. | |
static | get_min_value () |
Gets the minimum value for this target. | |
static | get_name () |
Returns a lang_string object representing the name for the indicator or target. | |
static | instance () |
Returns an instance of the child class. | |
static | uses_insights () |
Is this target generating insights? | |
Protected Member Functions | |
add_shared_calculation_info (int $sampleid, array $info) | |
Adds info related to the current calculation for later use when generating insights. | |
calculate_sample ($sampleid, core_analytics\analysable $analysable, $starttime=false, $endtime=false) | |
Calculates this target for the provided samples. | |
classify_value ($value, $ranges) | |
Classifies the provided value into the provided range according to the ranges predicates. | |
get_callback_boundary () | |
Returns the minimum value that triggers the callback. | |
get_time_range_weeks_number ($starttime, $endtime) | |
Returns the number of weeks a time range contains. | |
limit_value ($calculatedvalue) | |
Limits the calculated value to the minimum and maximum values. | |
min_prediction_score () | |
Defines a boundary to ignore predictions below the specified prediction score. | |
retrieve ($elementname, $sampleid) | |
Retrieve the specified element associated to $sampleid. | |
Protected Attributes | |
core_analytics calculation_info null | $calculationinfo = null |
array[] | $sampledata = array() |
Linear values target.
|
inherited |
Adds the JS required to run the bulk actions.
Reimplemented in core_course\analytics\target\course_enrolments.
|
inherited |
add_sample_data
array | $data |
void |
|
finalprotectedinherited |
Adds info related to the current calculation for later use when generating insights.
Note that the data in $info array is reused across multiple samples, if you want to add data just for this sample you can use the sample id as key.
Please, note that you should be careful with how much data you add here as it can kill the server memory.
int | $sampleid | The sample id this data is associated with |
array | $info | The data. Indexed by an id unique across the site. E.g. an activity id. |
null |
|
inherited |
Update the last analysis time on analysable processed or always.
If you overwrite this method to return false the last analysis time will only be recorded in DB when the element successfully analysed. You can safely return false for lightweight targets.
bool |
Reimplemented in core_user\analytics\target\upcoming_activities_due.
|
staticinherited |
Based on facts (processed by machine learning backends) by default.
bool |
Reimplemented in core_course\analytics\target\no_recent_accesses, core_course\analytics\target\no_teaching, and core_user\analytics\target\upcoming_activities_due.
|
inherited |
Suggested bulk actions for a user.
core_analytics\prediction[] | $predictions | List of predictions suitable for the bulk actions to use. |
core_analytics\bulk_action[] | The list of bulk actions. |
Reimplemented in core_course\analytics\target\course_enrolments.
|
inherited |
Calculates the target.
Returns an array of values which size matches $sampleids size.
Rows with null values will be skipped as invalid by time splitting methods.
array | $sampleids | |
core_analytics\analysable | $analysable | |
int | $starttime | |
int | $endtime |
array | The format to follow is [userid] = scalar|null |
|
abstractprotectedinherited |
Calculates this target for the provided samples.
In case there are no values to return or the provided sample is not applicable just return null.
int | $sampleid | |
core_analytics\analysable | $analysable | |
int | false | $starttime | Limit calculations to start time |
int | false | $endtime | Limit calculations to end time |
float|null |
|
abstractinherited |
Can the provided time-splitting method be used on this target?.
Time-splitting methods not matching the target requirements will not be selectable by models based on this target.
core_analytics\local\time_splitting\base | $timesplitting |
bool |
|
protectedinherited |
Classifies the provided value into the provided range according to the ranges predicates.
Use:
coding_exception |
int | float | $value | |
array | $ranges | e.g. [ ['lt', 20], ['ge', 20] ] |
float |
|
inherited |
clear_sample_data
void |
|
inherited |
Filters out invalid samples for training.
int[] | $sampleids | |
core_analytics\analysable | $analysable | |
bool | $fortraining |
void |
|
inherited |
Generates insights notifications.
int | $modelid | |
context[] | $samplecontexts | |
core_analytics\prediction[] | $predictions |
void |
|
abstractinherited |
Returns the analyser class that should be used along with this target.
string | The full class name as a string |
Reimplemented in core_course\analytics\target\course_enrolments, core_course\analytics\target\no_teaching, and core_user\analytics\target\upcoming_activities_due.
core_analytics\local\target\linear::get_calculation_outcome | ( | $value, | |
$ignoredsubtype = false ) |
How positive is this calculated value?
float | $value | |
string | $ignoredsubtype |
int |
Reimplemented from core_analytics\calculable.
|
protected |
Returns the minimum value that triggers the callback.
float |
|
inherited |
Returns the visible value of the calculated value.
float | $value | |
string | false | $subtype |
string |
Reimplemented in core_analytics\local\indicator\binary, core_analytics\local\indicator\discrete, core_analytics\local\indicator\linear, and core_analytics\local\target\discrete.
|
inherited |
The class id is the calculable class full qualified class name.
string |
|
inherited |
Returns the body message for an insight with multiple predictions.
This default method is executed when the analysable used by the model generates multiple insight for each analysable (one_sample_per_analysable === false)
context | $context | |
string | $contextname | |
stdClass | $user | |
moodle_url | $insighturl |
string[] | The plain text message and the HTML message |
Reimplemented in core_course\analytics\target\course_enrolments, core_course\analytics\target\no_access_since_course_start, core_course\analytics\target\no_recent_accesses, and core_course\analytics\target\no_teaching.
|
inherited |
Returns the body message for an insight for a single prediction.
This default method is executed when the analysable used by the model generates one insight for each analysable (one_sample_per_analysable === true)
context | $context | |
stdClass | $user | |
core_analytics\prediction | $prediction | |
core_analytics\action[] | $actions | Passed by reference to remove duplicate links to actions. |
array | Plain text msg, HTML message and the main URL for this insight (you can return null if you are happy with the default insight URL calculated in prediction_info()) |
|
inherited |
|
inherited |
The insight notification subject.
This is just a default message, you should overwrite it for a custom insight message.
int | $modelid | |
context | $context |
string |
Reimplemented in core_course\analytics\target\course_enrolments, core_course\analytics\target\no_teaching, and core_user\analytics\target\upcoming_activities_due.
|
inherited |
Returns the list of users that will receive insights notifications.
Feel free to overwrite if you need to but keep in mind that moodle/analytics:listinsights or moodle/analytics:listowninsights capability is required to access the list of insights.
context | $context |
array |
|
static |
Gets the maximum value for this target.
float |
|
static |
Gets the minimum value for this target.
float |
|
staticabstractinherited |
Returns a lang_string object representing the name for the indicator or target.
Used as column identificator.
If there is a corresponding '_help' string this will be shown as well.
lang_string |
Reimplemented in core\analytics\indicator\any_access_after_end, core\analytics\indicator\any_access_before_start, core\analytics\indicator\any_course_access, core\analytics\indicator\any_write_action, core\analytics\indicator\any_write_action_in_course, core\analytics\indicator\read_actions, core_course\analytics\indicator\activities_due, core_course\analytics\indicator\completion_enabled, core_course\analytics\indicator\no_student, core_course\analytics\indicator\no_teacher, core_course\analytics\indicator\potential_cognitive_depth, core_course\analytics\indicator\potential_social_breadth, core_course\analytics\target\course_competencies, core_course\analytics\target\course_completion, core_course\analytics\target\course_dropout, core_course\analytics\target\course_gradetopass, core_course\analytics\target\no_access_since_course_start, core_course\analytics\target\no_recent_accesses, core_course\analytics\target\no_teaching, core_user\analytics\indicator\user_profile_set, core_user\analytics\indicator\user_track_forums, core_user\analytics\target\upcoming_activities_due, mod_assign\analytics\indicator\cognitive_depth, mod_assign\analytics\indicator\social_breadth, mod_bigbluebuttonbn\analytics\indicator\cognitive_depth, mod_bigbluebuttonbn\analytics\indicator\social_breadth, mod_book\analytics\indicator\cognitive_depth, mod_book\analytics\indicator\social_breadth, mod_chat\analytics\indicator\cognitive_depth, mod_chat\analytics\indicator\social_breadth, mod_choice\analytics\indicator\cognitive_depth, mod_choice\analytics\indicator\social_breadth, mod_data\analytics\indicator\cognitive_depth, mod_data\analytics\indicator\social_breadth, mod_feedback\analytics\indicator\cognitive_depth, mod_feedback\analytics\indicator\social_breadth, mod_folder\analytics\indicator\cognitive_depth, mod_folder\analytics\indicator\social_breadth, mod_forum\analytics\indicator\cognitive_depth, mod_forum\analytics\indicator\social_breadth, mod_glossary\analytics\indicator\cognitive_depth, mod_glossary\analytics\indicator\social_breadth, mod_imscp\analytics\indicator\cognitive_depth, mod_imscp\analytics\indicator\social_breadth, mod_label\analytics\indicator\cognitive_depth, mod_label\analytics\indicator\social_breadth, mod_lesson\analytics\indicator\cognitive_depth, mod_lesson\analytics\indicator\social_breadth, mod_lti\analytics\indicator\cognitive_depth, mod_lti\analytics\indicator\social_breadth, mod_page\analytics\indicator\cognitive_depth, mod_page\analytics\indicator\social_breadth, mod_quiz\analytics\indicator\cognitive_depth, mod_quiz\analytics\indicator\social_breadth, mod_resource\analytics\indicator\cognitive_depth, mod_resource\analytics\indicator\social_breadth, mod_scorm\analytics\indicator\cognitive_depth, mod_scorm\analytics\indicator\social_breadth, mod_survey\analytics\indicator\cognitive_depth, mod_survey\analytics\indicator\social_breadth, mod_url\analytics\indicator\cognitive_depth, mod_url\analytics\indicator\social_breadth, mod_wiki\analytics\indicator\cognitive_depth, mod_wiki\analytics\indicator\social_breadth, mod_workshop\analytics\indicator\cognitive_depth, and mod_workshop\analytics\indicator\social_breadth.
|
protectedinherited |
Returns the number of weeks a time range contains.
Useful for calculations that depend on the time range duration. Note that it returns a float, rounding the float may lead to inaccurate results.
int | $starttime | |
int | $endtime |
float |
|
staticinherited |
Returns an instance of the child class.
Useful to reset cached data.
core_analytics\base\target |
core_analytics\local\target\linear::is_linear | ( | ) |
Are the calculated values this target returns linear values?
bool |
Reimplemented from core_analytics\local\target\base.
|
abstractinherited |
Allows the target to verify that the analysable is a good candidate.
This method can be used as a quick way to discard invalid analysables. e.g. Imagine that your analysable don't have students and you need them.
core_analytics\analysable | $analysable | |
bool | $fortraining |
true|string |
|
abstractinherited |
Is this sample from the $analysable valid?
int | $sampleid | |
core_analytics\analysable | $analysable | |
bool | $fortraining |
bool |
|
protectedinherited |
Limits the calculated value to the minimum and maximum values.
float | $calculatedvalue |
float|null |
|
inherited |
Should the insights of this model be linked from reports?
bool |
Reimplemented in core_user\analytics\target\upcoming_activities_due.
|
protectedinherited |
Defines a boundary to ignore predictions below the specified prediction score.
Value should go from 0 to 1.
float |
|
inherited |
Suggested actions for a user.
core_analytics\prediction | $prediction | |
bool | $includedetailsaction | |
bool | $isinsightuser | Force all the available actions to be returned as it the user who receives the insight is the one logged in. |
core_analytics\prediction_action[] |
|
inherited |
Callback to execute once a prediction has been returned from the predictions processor.
Note that the analytics_predictions db record is not yet inserted.
int | $modelid | |
int | $sampleid | |
int | $rangeindex | |
context | $samplecontext | |
float | int | $prediction | |
float | $predictionscore |
void |
|
protectedinherited |
Retrieve the specified element associated to $sampleid.
string | $elementname | |
int | $sampleid |
stdClass|false | An stdClass object or false if it can not be found. |
|
finalinherited |
Stores in MUC the previously added data and it associates it to the provided $calculable.
Flagged as final as we don't want people to extend this, it is likely to be moved to core_analytics\calculable
core_analytics\local\time_splitting\base | $timesplitting | |
int | $rangeindex |
null |
core_analytics\local\target\linear::triggers_callback | ( | $predictedvalue, | |
$predictionscore ) |
This method determines if a prediction is interesing for the model or not.
mixed | $predictedvalue | |
float | $predictionscore |
bool |
Reimplemented from core_analytics\local\target\base.
|
staticinherited |
Is this target generating insights?
Defaults to true.
bool |