Moodle PHP Documentation 4.4
Moodle 4.4.1 (Build: 20240610) (db07c09afc5)
core\analytics\indicator\any_write_action Class Reference

Write actions indicator. More...

Inheritance diagram for core\analytics\indicator\any_write_action:
core_analytics\local\indicator\binary core_analytics\local\indicator\discrete core_analytics\local\indicator\base core_analytics\calculable

Public Member Functions

 add_sample_data ($data)
 add_sample_data
 
 calculate ($sampleids, $samplesorigin, $starttime=false, $endtime=false, $existingcalculations=array())
 Calculates the indicator.
 
 clear_sample_data ()
 clear_sample_data
 
 fill_per_analysable_caches (\core_analytics\analysable $analysable)
 Hook to allow indicators to pre-fill data that is shared accross time range calculations.
 
 get_calculation_outcome ($value, $subtype=false)
 get_calculation_outcome
 
 get_display_style ($ignoredvalue, $ignoredsubtype)
 get_display_style
 
 get_display_value ($value, $subtype=false)
 get_display_value
 
 get_id ()
 The class id is the calculable class full qualified class name.
 
 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.
 
 should_be_displayed ($value, $subtype)
 It should always be displayed.
 

Static Public Member Functions

static get_classes ()
 get_classes
 
static get_feature_headers ()
 get_feature_headers
 
static get_max_value ()
 Returns the maximum value an indicator calculation can return.
 
static get_min_value ()
 Returns the minimum value an indicator calculation can return.
 
static get_name ()
 Returns the name.
 
static instance ()
 Returns an instance of the indicator.
 
static required_sample_data ()
 required_sample_data
 

Public Attributes

const MAX_VALUE = 1
 Max value an indicator can return.
 
const MIN_VALUE = -1
 Min value an indicator can return.
 
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.
 
 calculate_sample ($sampleid, $sampleorigin, $starttime=false, $endtime=false)
 calculate_sample
 
 classify_value ($value, $ranges)
 Classifies the provided value into the provided range according to the ranges predicates.
 
 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.
 
 retrieve ($elementname, $sampleid)
 Retrieve the specified element associated to $sampleid.
 
 to_features ($calculatedvalues)
 to_features
 
 validate_calculated_value ($calculatedvalue)
 Validates the calculated value.
 

Protected Attributes

core_analytics calculation_info null $calculationinfo = null
 
array[] $sampledata = array()
 

Detailed Description

Write actions indicator.

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

◆ calculate()

core_analytics\local\indicator\base::calculate ( $sampleids,
$samplesorigin,
$starttime = false,
$endtime = false,
$existingcalculations = array() )
inherited

Calculates the indicator.

Returns an array of values which size matches $sampleids size.

Parameters
int[]$sampleids
string$samplesorigin
integer$starttimeLimit the calculation to this timestart
integer$endtimeLimit the calculation to this timeend
array$existingcalculationsExisting calculations of this indicator, indexed by sampleid.
Return values
array[0] = [$sampleid => int[]|float[]], [1] = [$sampleid => int|float], [2] = [$sampleid => $sampleid]

◆ calculate_sample()

core\analytics\indicator\any_write_action::calculate_sample ( $sampleid,
$sampleorigin,
$starttime = false,
$endtime = false )
protected

calculate_sample

Parameters
int$sampleid
string$sampleorigin
int$starttime
int$endtime
Return values
float

Reimplemented from core_analytics\local\indicator\base.

◆ 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

◆ fill_per_analysable_caches()

core_analytics\local\indicator\base::fill_per_analysable_caches ( \core_analytics\analysable $analysable)
inherited

Hook to allow indicators to pre-fill data that is shared accross time range calculations.

Useful to fill analysable-dependant data that does not depend on the time ranges. Use instance vars to cache data that can be re-used across samples calculations but changes between time ranges (indicator instances are reset between time ranges to avoid unexpected problems).

You are also responsible of emptying previous analysable caches.

Parameters
core_analytics\analysable$analysable
Return values
void

Reimplemented in core_analytics\local\indicator\community_of_inquiry_activity.

◆ get_calculation_outcome()

core_analytics\local\indicator\binary::get_calculation_outcome ( $value,
$subtype = false )
inherited

get_calculation_outcome

Parameters
float$value
string$subtype
Return values
int

Reimplemented from core_analytics\calculable.

◆ get_classes()

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

get_classes

Return values
array

Reimplemented from core_analytics\local\indicator\discrete.

◆ get_display_style()

core_analytics\local\indicator\discrete::get_display_style ( $ignoredvalue,
$ignoredsubtype )
inherited

get_display_style

Parameters
float$ignoredvalue
string$ignoredsubtype
Return values
int

◆ get_display_value()

core_analytics\local\indicator\binary::get_display_value ( $value,
$subtype = false )
inherited

get_display_value

Parameters
float$value
string$subtype
Return values
string

Reimplemented from core_analytics\local\indicator\discrete.

◆ get_feature_headers()

static core_analytics\local\indicator\binary::get_feature_headers ( )
staticinherited

get_feature_headers

Return values
array

Reimplemented from core_analytics\local\indicator\discrete.

◆ get_id()

core_analytics\calculable::get_id ( )
inherited

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

Return values
string

◆ get_max_value()

static core_analytics\local\indicator\base::get_max_value ( )
staticinherited

Returns the maximum value an indicator calculation can return.

Return values
float

◆ get_min_value()

static core_analytics\local\indicator\base::get_min_value ( )
staticinherited

Returns the minimum value an indicator calculation can return.

Return values
float

◆ get_name()

static core\analytics\indicator\any_write_action::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

◆ instance()

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

Returns an instance of the indicator.

Useful to reset cached data.

Return values
core_analytics\local\indicator\base

◆ 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

◆ required_sample_data()

static core\analytics\indicator\any_write_action::required_sample_data ( )
static

required_sample_data

Return values
string[]

Reimplemented from core_analytics\local\indicator\base.

◆ 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

◆ should_be_displayed()

core_analytics\local\indicator\binary::should_be_displayed ( $value,
$subtype )
inherited

It should always be displayed.

Binary values have no subtypes by default, please overwrite if your indicator is adding extra features.

Parameters
float$value
string$subtype
Return values
bool

Reimplemented from core_analytics\local\indicator\discrete.

◆ to_features()

core_analytics\local\indicator\binary::to_features ( $calculatedvalues)
protectedinherited

to_features

Parameters
array$calculatedvalues
Return values
array

Reimplemented from core_analytics\local\indicator\discrete.

◆ validate_calculated_value()

core_analytics\local\indicator\discrete::validate_calculated_value ( $calculatedvalue)
protectedinherited

Validates the calculated value.

Parameters
float$calculatedvalue
Return values
true

Reimplemented from core_analytics\local\indicator\base.


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