Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
core_course\analytics\target\course_gradetopass Class Reference

Getting the minimum grade to pass target. More...

Inheritance diagram for core_course\analytics\target\course_gradetopass:
core_course\analytics\target\course_enrolments core_analytics\local\target\binary core_analytics\local\target\discrete core_analytics\local\target\base core_analytics\calculable

Public Member Functions

 add_bulk_actions_js ()
 Adds the JS required to run the bulk actions.
 
 add_sample_data ($data)
 add_sample_data More...
 
 always_update_analysis_time ()
 Update the last analysis time on analysable processed or always. More...
 
 bulk_actions (array $predictions)
 Suggested bulk actions for a user. More...
 
 calculate ($sampleids, core_analytics\analysable $analysable, $starttime=false, $endtime=false)
 Calculates the target. More...
 
 can_use_timesplitting (\core_analytics\local\time_splitting\base $timesplitting)
 Can the provided time-splitting method be used on this target?. More...
 
 can_use_timesplitting (\core_analytics\local\time_splitting\base $timesplitting)
 Only past stuff. More...
 
 clear_sample_data ()
 clear_sample_data More...
 
 filter_out_invalid_samples (&$sampleids, core_analytics\analysable $analysable, $fortraining=true)
 Filters out invalid samples for training. More...
 
 generate_insight_notifications ($modelid, $samplecontexts, array $predictions=[])
 Generates insights notifications. More...
 
 get_analyser_class ()
 Returns the analyser class that should be used along with this target. More...
 
 get_calculation_outcome ($value, $ignoredsubtype=false)
 Is the calculated value a positive outcome of this target? More...
 
 get_display_value ($value, $ignoredsubtype=false)
 get_display_value More...
 
 get_id ()
 The class id is the calculable class full qualified class name. More...
 
 get_insight_body (\context $context, string $contextname, stdClass $user, moodle_url $insighturl)
 Returns the body message for the insight. More...
 
 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. More...
 
 get_insight_context_url ($modelid, $context)
 URL to the insight. More...
 
 get_insight_subject (int $modelid, context $context)
 Overwritten to show a simpler language string. More...
 
 get_insights_users (\context $context)
 Returns the list of users that will receive insights notifications. More...
 
 ignored_predicted_classes ()
 Returns the predicted classes that will be ignored. More...
 
 is_linear ()
 is_linear More...
 
 is_valid_analysable (\core_analytics\analysable $analysable, $fortraining=true)
 Allows the target to verify that the analysable is a good candidate. More...
 
 is_valid_analysable (\core_analytics\analysable $course, $fortraining=true)
 Discards courses that are not yet ready to be used for training or prediction. More...
 
 is_valid_sample ($sampleid, core_analytics\analysable $analysable, $fortraining=true)
 Is this sample from the $analysable valid? More...
 
 is_valid_sample ($sampleid, core_analytics\analysable $course, $fortraining=true)
 Discard student enrolments that are invalid. More...
 
 link_insights_report ()
 Should the insights of this model be linked from reports? More...
 
 prediction_actions (\core_analytics\prediction $prediction, $includedetailsaction=false, $isinsightuser=false)
 Suggested actions for a user. More...
 
 prediction_actions (\core_analytics\prediction $prediction, $includedetailsaction=false, $isinsightuser=false)
 prediction_actions More...
 
 prediction_callback ($modelid, $sampleid, $rangeindex, context $samplecontext, $prediction, $predictionscore)
 Callback to execute once a prediction has been returned from the predictions processor. More...
 
 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. More...
 
 triggers_callback ($predictedvalue, $predictionscore)
 This method determines if a prediction is interesing for the model or not. More...
 

Static Public Member Functions

static based_on_assumptions ()
 Based on facts (processed by machine learning backends) by default. More...
 
static get_classes ()
 Returns the target discrete values. More...
 
static get_name ()
 Returns the name. More...
 
static instance ()
 Returns an instance of the child class. More...
 
static uses_insights ()
 Is this target generating insights? More...
 

Public Attributes

float const ENROL_ACTIVE_PERCENT_REQUIRED = 0.7
 
string const MESSAGE_ACTION_NAME = 'studentmessage'
 
const OUTCOME_NEGATIVE = 3
 Negative calculation outcome.
 
const OUTCOME_NEUTRAL = 0
 Neutral calculation outcome.
 
const OUTCOME_OK = 2
 Positive calculation outcome.
 
const OUTCOME_VERY_NEGATIVE = 4
 Very negative calculation outcome.
 
const OUTCOME_VERY_POSITIVE = 1
 Very positive calculation outcome.
 

Protected Member Functions

 add_shared_calculation_info (int $sampleid, array $info)
 Adds info related to the current calculation for later use when generating insights. More...
 
 calculate_sample ($sampleid, core_analytics\analysable $analysable, $starttime=false, $endtime=false)
 Calculates this target for the provided samples. More...
 
 calculate_sample ($sampleid, core_analytics\analysable $course, $starttime=false, $endtime=false)
 The user's grade in the course sets the target value. More...
 
 classify_value ($value, $ranges)
 Classifies the provided value into the provided range according to the ranges predicates. More...
 
 enrolment_active_during_analysis_time (int $sampleid, int $starttime, int $endtime)
 Is/was this user enrolment active during most of the analysis interval? More...
 
 get_course_gradetopass ($courseid)
 Returns the grade to pass a course. More...
 
 get_time_range_weeks_number ($starttime, $endtime)
 Returns the number of weeks a time range contains. More...
 
 get_user_grade ($courseitemid, $userid)
 Returns the grade of a user in a course. More...
 
 limit_value ($calculatedvalue)
 Limits the calculated value to the minimum and maximum values. More...
 
 min_prediction_score ()
 Defines a boundary to ignore predictions below the specified prediction score. More...
 
 retrieve ($elementname, $sampleid)
 Retrieve the specified element associated to $sampleid. More...
 

Static Protected Member Functions

static classes_description ()
 Returns descriptions for each of the values the target calculation can return. More...
 
static is_a_class ($class)
 Is the provided class one of this target valid classes? More...
 

Protected Attributes

core_analytics calculation_info null $calculationinfo = null
 
mixed[] $coursesgrades = array()
 Courses grades.
 
mixed[] $coursesgradetopass = array()
 Courses grades to pass.
 
array[] $sampledata = array()
 
int[] $students
 Students in the course.
 

Detailed Description

Getting the minimum grade to pass target.

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

Member Function Documentation

◆ add_sample_data()

core_analytics\calculable::add_sample_data (   $data)
inherited

add_sample_data

Parameters
array$data
Return values
void

◆ add_shared_calculation_info()

core_analytics\calculable::add_shared_calculation_info ( int  $sampleid,
array  $info 
)
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.

Parameters
int$sampleidThe sample id this data is associated with
array$infoThe data. Indexed by an id unique across the site. E.g. an activity id.
Return values
null

◆ always_update_analysis_time()

core_analytics\local\target\base::always_update_analysis_time ( )
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.

Return values
bool

Reimplemented in core_user\analytics\target\upcoming_activities_due.

◆ based_on_assumptions()

static core_analytics\local\target\base::based_on_assumptions ( )
staticinherited

Based on facts (processed by machine learning backends) by default.

Return values
bool

Reimplemented in core_user\analytics\target\upcoming_activities_due, core_course\analytics\target\no_teaching, and core_course\analytics\target\no_recent_accesses.

◆ bulk_actions()

core_course\analytics\target\course_enrolments::bulk_actions ( array  $predictions)
inherited

Suggested bulk actions for a user.

Parameters
core_analytics\prediction[]$predictionsList of predictions suitable for the bulk actions to use.
Return values
core_analytics

Reimplemented from core_analytics\local\target\base.

◆ calculate()

core_analytics\local\target\base::calculate (   $sampleids,
core_analytics\analysable  $analysable,
  $starttime = false,
  $endtime = false 
)
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.

Parameters
array$sampleids
core_analytics\analysable$analysable
int$starttime
int$endtime
Return values
arrayThe format to follow is [userid] = scalar|null

◆ calculate_sample() [1/2]

core_analytics\local\target\base::calculate_sample (   $sampleid,
core_analytics\analysable  $analysable,
  $starttime = false,
  $endtime = false 
)
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.

Parameters
int$sampleid
core_analytics\analysable$analysable
int | false$starttimeLimit calculations to start time
int | false$endtimeLimit calculations to end time
Return values
float|null

◆ calculate_sample() [2/2]

core_course\analytics\target\course_gradetopass::calculate_sample (   $sampleid,
core_analytics\analysable  $course,
  $starttime = false,
  $endtime = false 
)
protected

The user's grade in the course sets the target value.

Parameters
int$sampleid
core_analytics\analysable$course
int$starttime
int$endtime
Return values
float|null0 -> course grade to pass achieved, 1 -> course grade to pass not achieved

◆ can_use_timesplitting() [1/2]

core_analytics\local\target\base::can_use_timesplitting ( \core_analytics\local\time_splitting\base  $timesplitting)
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.

Parameters
core_analytics\local\time_splitting\base$timesplitting
Return values
bool

◆ can_use_timesplitting() [2/2]

core_course\analytics\target\course_enrolments::can_use_timesplitting ( \core_analytics\local\time_splitting\base  $timesplitting)
inherited

Only past stuff.

Parameters
core_analytics\local\time_splitting\base$timesplitting
Return values
bool

Reimplemented in core_course\analytics\target\no_recent_accesses, and core_course\analytics\target\no_access_since_course_start.

◆ classes_description()

static core_course\analytics\target\course_gradetopass::classes_description ( )
staticprotected

Returns descriptions for each of the values the target calculation can return.

Return values
string[]

Reimplemented from core_analytics\local\target\binary.

◆ classify_value()

core_analytics\calculable::classify_value (   $value,
  $ranges 
)
protectedinherited

Classifies the provided value into the provided range according to the ranges predicates.

Use:

  • eq as 'equal'
  • ne as 'not equal'
  • lt as 'lower than'
  • le as 'lower or equal than'
  • gt as 'greater than'
  • ge as 'greater or equal than'
Exceptions
coding_exception
Parameters
int | float$value
array$rangese.g. [ ['lt', 20], ['ge', 20] ]
Return values
float

◆ clear_sample_data()

core_analytics\calculable::clear_sample_data ( )
inherited

clear_sample_data

Return values
void

◆ enrolment_active_during_analysis_time()

core_course\analytics\target\course_enrolments::enrolment_active_during_analysis_time ( int  $sampleid,
int  $starttime,
int  $endtime 
)
protectedinherited

Is/was this user enrolment active during most of the analysis interval?

This method discards enrolments that were not active during most of the analysis interval. It is important to discard these enrolments because the indicator calculations can lead to misleading results.

Note that this method assumes that the target is interested in enrolments that are/were active during the analysis interval. Targets interested in predicting students at risk before their enrolment start should not call this method. Similarly, targets interested in getting predictions for students whose enrolment already finished should not call this method either.

Parameters
int$sampleidThe id of the sample that is being calculated
int$starttimeThe analysis interval start time
int$endtimeThe analysis interval end time
Return values
bool

◆ filter_out_invalid_samples()

core_analytics\local\target\base::filter_out_invalid_samples ( $sampleids,
core_analytics\analysable  $analysable,
  $fortraining = true 
)
inherited

Filters out invalid samples for training.

Parameters
int[]$sampleids
core_analytics\analysable$analysable
bool$fortraining
Return values
void

◆ generate_insight_notifications()

core_analytics\local\target\base::generate_insight_notifications (   $modelid,
  $samplecontexts,
array  $predictions = [] 
)
inherited

Generates insights notifications.

Parameters
int$modelid
context[]$samplecontexts
core_analytics\prediction[]$predictions
Return values
void

◆ get_analyser_class()

core_course\analytics\target\course_enrolments::get_analyser_class ( )
inherited

Returns the analyser class that should be used along with this target.

Return values
stringThe full class name as a string

Reimplemented from core_analytics\local\target\base.

◆ get_calculation_outcome()

core_analytics\local\target\binary::get_calculation_outcome (   $value,
  $ignoredsubtype = false 
)
inherited

Is the calculated value a positive outcome of this target?

Parameters
string$value
string$ignoredsubtype
Return values
int

Reimplemented from core_analytics\local\target\discrete.

◆ get_classes()

static core_analytics\local\target\binary::get_classes ( )
staticfinalinherited

Returns the target discrete values.

Only useful for targets using discrete values, must be overwriten if it is the case.

Return values
array

Reimplemented from core_analytics\local\target\discrete.

◆ get_course_gradetopass()

core_course\analytics\target\course_gradetopass::get_course_gradetopass (   $courseid)
protected

Returns the grade to pass a course.

Save the value in $coursesgradetopass array to prevent new accesses to the database.

Parameters
int$courseidThe course id.
Return values
arrayThe courseitem id and the required grade to pass the course.

◆ get_display_value()

core_analytics\local\target\discrete::get_display_value (   $value,
  $ignoredsubtype = false 
)
inherited

get_display_value

Parameters
float$value
string$ignoredsubtype
Return values
string

Reimplemented from core_analytics\calculable.

◆ get_id()

core_analytics\calculable::get_id ( )
inherited

The class id is the calculable class full qualified class name.

Return values
string

◆ get_insight_body()

core_course\analytics\target\course_enrolments::get_insight_body ( \context  $context,
string  $contextname,
stdClass  $user,
moodle_url  $insighturl 
)
inherited

Returns the body message for the insight.

Parameters
context$context
string$contextname
stdClass$user
moodle_url$insighturl
Return values
string[]The plain text message and the HTML message

Reimplemented from core_analytics\local\target\base.

Reimplemented in core_course\analytics\target\no_recent_accesses, and core_course\analytics\target\no_access_since_course_start.

◆ get_insight_body_for_prediction()

core_analytics\local\target\base::get_insight_body_for_prediction ( \context  $context,
stdClass  $user,
core_analytics\prediction  $prediction,
array &  $actions 
)
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)

Parameters
context$context
stdClass$user
core_analytics\prediction$prediction
core_analytics\action[]$actionsPassed by reference to remove duplicate links to actions.
Return values
arrayPlain 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())

◆ get_insight_context_url()

core_analytics\local\target\base::get_insight_context_url (   $modelid,
  $context 
)
inherited

URL to the insight.

Parameters
int$modelid
context$context
Return values
moodle_url

◆ get_insight_subject()

core_course\analytics\target\course_enrolments::get_insight_subject ( int  $modelid,
context  $context 
)
inherited

Overwritten to show a simpler language string.

Parameters
int$modelid
context$context
Return values
string

Reimplemented from core_analytics\local\target\base.

◆ get_insights_users()

core_analytics\local\target\base::get_insights_users ( \context  $context)
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.

Parameters
context$context
Return values
array

◆ get_name()

static core_course\analytics\target\course_gradetopass::get_name ( )
static

Returns the name.

If there is a corresponding '_help' string this will be shown as well.

Return values
lang_string

Reimplemented from core_analytics\calculable.

◆ get_time_range_weeks_number()

core_analytics\calculable::get_time_range_weeks_number (   $starttime,
  $endtime 
)
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.

Parameters
int$starttime
int$endtime
Return values
float

◆ get_user_grade()

core_course\analytics\target\course_gradetopass::get_user_grade (   $courseitemid,
  $userid 
)
protected

Returns the grade of a user in a course.

Saves the grades of all course users in $coursesgrades array to prevent new accesses to the database.

Parameters
int$courseitemidThe course item id.
int$useridthe user whose grade is requested.
Return values
arrayThe courseitem id and the required grade to pass the course.

◆ ignored_predicted_classes()

core_analytics\local\target\binary::ignored_predicted_classes ( )
inherited

Returns the predicted classes that will be ignored.

Return values
array

Reimplemented from core_analytics\local\target\discrete.

Reimplemented in core_user\analytics\target\upcoming_activities_due.

◆ instance()

static core_analytics\local\target\base::instance ( )
staticinherited

Returns an instance of the child class.

Useful to reset cached data.

Return values
core_analytics

◆ is_a_class()

static core_analytics\local\target\discrete::is_a_class (   $class)
staticprotectedinherited

Is the provided class one of this target valid classes?

Parameters
mixed$class
Return values
bool

◆ is_linear()

core_analytics\local\target\binary::is_linear ( )
inherited

is_linear

Return values
bool

Reimplemented from core_analytics\local\target\discrete.

◆ is_valid_analysable() [1/2]

core_analytics\local\target\base::is_valid_analysable ( \core_analytics\analysable  $analysable,
  $fortraining = true 
)
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.

Parameters
core_analytics\analysable$analysable
bool$fortraining
Return values
true|string

◆ is_valid_analysable() [2/2]

core_course\analytics\target\course_gradetopass::is_valid_analysable ( \core_analytics\analysable  $course,
  $fortraining = true 
)

Discards courses that are not yet ready to be used for training or prediction.

Only courses with "value" grade type and grade to pass set are valid.

Parameters
core_analytics\analysable$course
bool$fortraining
Return values
true|string

Reimplemented from core_course\analytics\target\course_enrolments.

◆ is_valid_sample() [1/2]

core_analytics\local\target\base::is_valid_sample (   $sampleid,
core_analytics\analysable  $analysable,
  $fortraining = true 
)
abstractinherited

Is this sample from the $analysable valid?

Parameters
int$sampleid
core_analytics\analysable$analysable
bool$fortraining
Return values
bool

◆ is_valid_sample() [2/2]

core_course\analytics\target\course_enrolments::is_valid_sample (   $sampleid,
core_analytics\analysable  $course,
  $fortraining = true 
)
inherited

Discard student enrolments that are invalid.

Note that this method assumes that the target is only interested in enrolments that are/were active between the current course start and end times. Targets interested in predicting students at risk before their enrolment start and targets interested in getting predictions for students whose enrolment already finished should overwrite this method as these students are discarded by this method.

Parameters
int$sampleid
core_analytics\analysable$course
bool$fortraining
Return values
bool

◆ limit_value()

core_analytics\calculable::limit_value (   $calculatedvalue)
protectedinherited

Limits the calculated value to the minimum and maximum values.

Parameters
float$calculatedvalue
Return values
float|null

◆ link_insights_report()

core_analytics\local\target\base::link_insights_report ( )
inherited

Should the insights of this model be linked from reports?

Return values
bool

Reimplemented in core_user\analytics\target\upcoming_activities_due.

◆ min_prediction_score()

core_analytics\local\target\base::min_prediction_score ( )
protectedinherited

Defines a boundary to ignore predictions below the specified prediction score.

Value should go from 0 to 1.

Return values
float

◆ prediction_actions() [1/2]

core_analytics\local\target\base::prediction_actions ( \core_analytics\prediction  $prediction,
  $includedetailsaction = false,
  $isinsightuser = false 
)
inherited

Suggested actions for a user.

Parameters
core_analytics\prediction$prediction
bool$includedetailsaction
bool$isinsightuserForce all the available actions to be returned as it the user who receives the insight is the one logged in.
Return values
core_analytics

◆ prediction_actions() [2/2]

core_course\analytics\target\course_enrolments::prediction_actions ( \core_analytics\prediction  $prediction,
  $includedetailsaction = false,
  $isinsightuser = false 
)
inherited

prediction_actions

Parameters
core_analytics\prediction$prediction
bool$includedetailsaction
bool$isinsightuser
Return values
core_analytics

◆ prediction_callback()

core_analytics\local\target\base::prediction_callback (   $modelid,
  $sampleid,
  $rangeindex,
context  $samplecontext,
  $prediction,
  $predictionscore 
)
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.

Parameters
int$modelid
int$sampleid
int$rangeindex
context$samplecontext
float | int$prediction
float$predictionscore
Return values
void

◆ retrieve()

core_analytics\calculable::retrieve (   $elementname,
  $sampleid 
)
protectedinherited

Retrieve the specified element associated to $sampleid.

Parameters
string$elementname
int$sampleid
Return values
stdClass|falseAn stdClass object or false if it can not be found.

◆ save_calculation_info()

core_analytics\calculable::save_calculation_info ( \core_analytics\local\time_splitting\base  $timesplitting,
int  $rangeindex 
)
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

Parameters
core_analytics\local\time_splitting\base$timesplitting
int$rangeindex
Return values
null

◆ triggers_callback()

core_analytics\local\target\discrete::triggers_callback (   $predictedvalue,
  $predictionscore 
)
inherited

This method determines if a prediction is interesing for the model or not.

This method internally calls ignored_predicted_classes to skip classes flagged by the target as not important for users.

Parameters
mixed$predictedvalue
float$predictionscore
Return values
bool

Reimplemented from core_analytics\local\target\base.

◆ uses_insights()

static core_analytics\local\target\base::uses_insights ( )
staticinherited

Is this target generating insights?

Defaults to true.

Return values
bool

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