Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
core\analytics\analyser\courses Class Reference

Courses analyser working at course level (insights for the course teachers). More...

Inheritance diagram for core\analytics\analyser\courses:
core_analytics\local\analyser\by_course core_analytics\local\analyser\base

Public Member Functions

 add_log ($string)
 Adds a register to the analysis log.
 
 check_indicator_requirements (\core_analytics\local\indicator\base $indicator)
 Checks that this analyser satisfies the provided indicator requirements.
 
 get_all_samples (\core_analytics\analysable $course)
 This will return just one course as we analyse 'by_course'.
 
 get_all_samples (\core_analytics\analysable $analysable)
 This function returns this analysable list of samples.
 
 get_analysables ()
 
 get_analysables_iterator (?string $action=null, array $contexts=[])
 Return the list of courses to analyse.
 
 get_indicators ()
 Getter for indicators.
 
 get_labelled_data (array $contexts=[])
 Returns labelled data (training and evaluation).
 
 get_logs ()
 Returns the analysis logs.
 
 get_modelid ()
 Model id getter.
 
 get_options ()
 Options getter.
 
 get_sample_analysable ($sampleid)
 Returns the analysable of a sample.
 
 get_samples ($sampleids)
 Returns samples data from sample ids.
 
 get_samples_origin ()
 Samples origin is course table.
 
 get_static_data (array $contexts=[])
 Returns indicator calculations as an array.
 
 get_target ()
 Returns the analysed target.
 
 get_timesplittings ()
 Getter for time splittings.
 
 get_unlabelled_data (array $contexts=[])
 Returns unlabelled data (prediction).
 
 instantiate_indicators ()
 Instantiate the indicators.
 
 join_sample_user ($sampletablealias)
 SQL JOIN from a sample to users table.
 
 processes_user_data ()
 Whether the plugin needs user data clearing or not.
 
 sample_access_context ($sampleid)
 Returns the context of a sample.
 
 sample_description ($sampleid, $contextid, $sampledata)
 Returns the sample description.
 

Static Public Member Functions

static context_restriction_support ()
 Can be limited to course categories or specific courses.
 
static one_sample_per_analysable ()
 Just one sample per analysable.
 
static potential_context_restrictions (string $query=null)
 Returns the possible contexts used by the analyser.
 

Protected Member Functions

 check_indicators_requirements ()
 Checks if the analyser satisfies all the model indicators requirements.
 
 get_iterator_sql (string $tablename, int $contextlevel, ?string $action=null, ?string $tablealias=null, array $contexts=[])
 Get the sql of a default implementation of the iterator.
 
 order_sql (?string $fieldname=null, string $order='ASC', ?string $tablealias=null)
 Returns the order by clause.
 
 provided_sample_data ()
 This provides samples' course and context.
 

Protected Attributes

core_analytics local indicator base[] $indicators
 The model indicators.
 
string[] $log
 Simple log array.
 
int $modelid
 
array $options
 Execution options.
 
core_analytics local target base $target
 The model target.
 
core_analytics local time_splitting base[] $timesplittings
 Time splitting methods to use.
 

Detailed Description

Courses analyser working at course level (insights for the course teachers).

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

Member Function Documentation

◆ add_log()

core_analytics\local\analyser\base::add_log ( $string)
inherited

Adds a register to the analysis log.

Parameters
string$string
Return values
void

◆ check_indicator_requirements()

core_analytics\local\analyser\base::check_indicator_requirements ( \core_analytics\local\indicator\base $indicator)
inherited

Checks that this analyser satisfies the provided indicator requirements.

Parameters
core_analytics\local\indicator\base$indicator
Return values
true|string[]True if all good, missing requirements list otherwise

◆ check_indicators_requirements()

core_analytics\local\analyser\base::check_indicators_requirements ( )
protectedinherited

Checks if the analyser satisfies all the model indicators requirements.

Exceptions
core_analytics\requirements_exception
Return values
void

◆ context_restriction_support()

static core_analytics\local\analyser\by_course::context_restriction_support ( )
staticinherited

Can be limited to course categories or specific courses.

Return values
array

Reimplemented from core_analytics\local\analyser\base.

◆ get_all_samples() [1/2]

core\analytics\analyser\courses::get_all_samples ( \core_analytics\analysable $course)

This will return just one course as we analyse 'by_course'.

Parameters
core_analytics\analysable$course
Return values
array

◆ get_all_samples() [2/2]

core_analytics\local\analyser\base::get_all_samples ( \core_analytics\analysable $analysable)
abstractinherited

This function returns this analysable list of samples.

Parameters
core_analytics\analysable$analysable
Return values
arrayarray[0] = int[] (sampleids) and array[1] = array (samplesdata)

◆ get_analysables()

core_analytics\local\analyser\base::get_analysables ( )
inherited
Deprecated
since Moodle 3.7

◆ get_analysables_iterator()

core_analytics\local\analyser\by_course::get_analysables_iterator ( ?string $action = null,
array $contexts = [] )
inherited

Return the list of courses to analyse.

Parameters
string | null$action'prediction', 'training' or null if no specific action needed.
context[]$contextsOnly analysables that depend on the provided contexts. All analysables in the system if empty.
Return values
Iterator

Reimplemented from core_analytics\local\analyser\base.

◆ get_indicators()

core_analytics\local\analyser\base::get_indicators ( )
inherited

Getter for indicators.

Return values
core_analytics\local\indicator\base

◆ get_iterator_sql()

core_analytics\local\analyser\base::get_iterator_sql ( string $tablename,
int $contextlevel,
?string $action = null,
?string $tablealias = null,
array $contexts = [] )
protectedinherited

Get the sql of a default implementation of the iterator.

This method only works for analysers that return analysable elements which ids map to a context instance ids.

Parameters
string$tablenameThe name of the table
int$contextlevelThe context level of the analysable
string | null$action
string | null$tablealiasThe table alias
context[]$contextsOnly analysables that depend on the provided contexts. All analysables if empty.
Return values
array[0] => sql and [1] => params array

◆ get_labelled_data()

core_analytics\local\analyser\base::get_labelled_data ( array $contexts = [])
inherited

Returns labelled data (training and evaluation).

Parameters
context[]$contextsRestrict the analysis to these contexts. No context restrictions if null.
Return values
stored_file[]

◆ get_logs()

core_analytics\local\analyser\base::get_logs ( )
inherited

Returns the analysis logs.

Return values
string[]

◆ get_modelid()

core_analytics\local\analyser\base::get_modelid ( )
inherited

Model id getter.

Return values
int

◆ get_options()

core_analytics\local\analyser\base::get_options ( )
inherited

Options getter.

Return values
array

◆ get_sample_analysable()

core\analytics\analyser\courses::get_sample_analysable ( $sampleid)

Returns the analysable of a sample.

Parameters
int$sampleid
Return values
core_analytics\analysable

Reimplemented from core_analytics\local\analyser\base.

◆ get_samples()

core\analytics\analyser\courses::get_samples ( $sampleids)

Returns samples data from sample ids.

Parameters
int[]$sampleids
Return values
array

Reimplemented from core_analytics\local\analyser\base.

◆ get_samples_origin()

core\analytics\analyser\courses::get_samples_origin ( )

Samples origin is course table.

Return values
string

Reimplemented from core_analytics\local\analyser\base.

◆ get_static_data()

core_analytics\local\analyser\base::get_static_data ( array $contexts = [])
inherited

Returns indicator calculations as an array.

Parameters
context[]$contextsRestrict the analysis to these contexts. No context restrictions if null.
Return values
array

◆ get_target()

core_analytics\local\analyser\base::get_target ( )
inherited

Returns the analysed target.

Return values
core_analytics\local\target\base

◆ get_timesplittings()

core_analytics\local\analyser\base::get_timesplittings ( )
inherited

Getter for time splittings.

Return values
core_analytics\local\time_splitting\base

◆ get_unlabelled_data()

core_analytics\local\analyser\base::get_unlabelled_data ( array $contexts = [])
inherited

Returns unlabelled data (prediction).

Parameters
context[]$contextsRestrict the analysis to these contexts. No context restrictions if null.
Return values
stored_file[]

◆ instantiate_indicators()

core_analytics\local\analyser\base::instantiate_indicators ( )
inherited

Instantiate the indicators.

Return values
core_analytics\local\indicator\base[]

◆ join_sample_user()

core_analytics\local\analyser\base::join_sample_user ( $sampletablealias)
inherited

SQL JOIN from a sample to users table.

This function should be defined if static\processes_user_data returns true and it is related to analytics API privacy API implementation. It allows the analytics API to identify data associated to users that needs to be deleted or exported.

This function receives the alias of a table with a 'sampleid' field and it should return a SQL join with static\get_samples_origin and with 'user' table. Note that:

  • The function caller expects the returned 'user' table to be aliased as 'u' (defacto standard in moodle).
  • You can join with other tables if your samples origin table does not contain a 'userid' field (if that would be a requirement this solution would be automated for you) you can't though use the following aliases: 'ap', 'apa', 'aic' and 'am'.

Some examples:

static\get_samples_origin() === 'user': JOIN {user} u ON {$sampletablealias}.sampleid = u.id

static\get_samples_origin() === 'role_assignments': JOIN {role_assignments} ra ON {$sampletablealias}.sampleid = ra.userid JOIN {user} u ON u.id = ra.userid

static\get_samples_origin() === 'user_enrolments': JOIN {user_enrolments} ue ON {$sampletablealias}.sampleid = ue.userid JOIN {user} u ON u.id = ue.userid

Exceptions
coding_exception
Parameters
string$sampletablealiasThe alias of the table with a sampleid field that will join with this SQL string
Return values
string

Reimplemented in core\analytics\analyser\student_enrolments, and core\analytics\analyser\users.

◆ one_sample_per_analysable()

static core\analytics\analyser\courses::one_sample_per_analysable ( )
static

Just one sample per analysable.

Return values
bool

Reimplemented from core_analytics\local\analyser\base.

◆ order_sql()

core_analytics\local\analyser\base::order_sql ( ?string $fieldname = null,
string $order = 'ASC',
?string $tablealias = null )
protectedinherited

Returns the order by clause.

Parameters
string | null$fieldnameThe field name
string$order'ASC' or 'DESC'
string | null$tablealiasThe table alias of the field
Return values
string

◆ potential_context_restrictions()

static core_analytics\local\analyser\base::potential_context_restrictions ( string $query = null)
staticinherited

Returns the possible contexts used by the analyser.

This method uses separate logic for each context level because to iterate through the list of contexts calling get_context_name for each of them would be expensive in performance terms.

This generic implementation returns all the contexts in the site for the provided context level. Overwrite it for specific restrictions in your analyser.

Parameters
string | null$queryContext name filter.
Return values
int[]

◆ processes_user_data()

core_analytics\local\analyser\base::processes_user_data ( )
inherited

Whether the plugin needs user data clearing or not.

This is related to privacy. Override this method if your analyser samples have any relation to the 'user' database entity. We need to clean the site from all user-related data if a user request their data to be deleted from the system. A static\provided_sample_data returning 'user' is an indicator that you should be returning true.

Return values
bool

Reimplemented in core\analytics\analyser\student_enrolments, and core\analytics\analyser\users.

◆ provided_sample_data()

core\analytics\analyser\courses::provided_sample_data ( )
protected

This provides samples' course and context.

Return values
string[]

Reimplemented from core_analytics\local\analyser\base.

◆ sample_access_context()

core\analytics\analyser\courses::sample_access_context ( $sampleid)

Returns the context of a sample.

Parameters
int$sampleid
Return values
context

Reimplemented from core_analytics\local\analyser\base.

◆ sample_description()

core\analytics\analyser\courses::sample_description ( $sampleid,
$contextid,
$sampledata )

Returns the sample description.

Parameters
int$sampleid
int$contextid
array$sampledata
Return values
arrayarray(string, renderable)

Reimplemented from core_analytics\local\analyser\base.

Member Data Documentation

◆ $timesplittings

core_analytics local time_splitting base [] core_analytics\local\analyser\base::$timesplittings
protectedinherited

Time splitting methods to use.

Multiple time splitting methods during evaluation and 1 single time splitting method once the model is enabled.


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