Commit 7e00aa72 authored by Mark Nelson's avatar Mark Nelson
Browse files

MDL-59204 analytics: changed get_name so that it returns a lang_string

This was done for indicators, targets and time splitting methods so that we
can get the string identifier and component in order to display a help_icon.

The functions were also made abstract, removing the default implementation.
Indicators, targets and time splitting methods should define this function.
parent 952cbce2
......@@ -66,17 +66,15 @@ abstract class calculable {
protected $sampledata = array();
/**
* Returns a visible name for the indicator.
* Returns a lang_string object representing the name for the indicator or target.
*
* Used as column identificator.
*
* Defaults to the indicator class name.
* If there is a corresponding '_help' string this will be shown as well.
*
* @return string
* @return \lang_string
*/
public static function get_name() {
return '\\' . get_called_class();
}
public static abstract function get_name() : \lang_string;
/**
* The class id is the calculable class full qualified class name.
......
......@@ -77,14 +77,15 @@ abstract class base {
abstract protected function define_ranges();
/**
* The time splitting method name.
* Returns a lang_string object representing the name for the time splitting method.
*
* It is very recommendable to overwrite this method as this name appears in the UI.
* @return string
* Used as column identificator.
*
* If there is a corresponding '_help' string this will be shown as well.
*
* @return \lang_string
*/
public function get_name() {
return $this->get_id();
}
public static abstract function get_name() : \lang_string;
/**
* Returns the time splitting method id.
......
......@@ -33,6 +33,20 @@ defined('MOODLE_INTERNAL') || die();
*/
class test_indicator_fullname extends \core_analytics\local\indicator\linear {
/**
* Returns a lang_string object representing the name for the indicator.
*
* Used as column identificator.
*
* If there is a corresponding '_help' string this will be shown as well.
*
* @return \lang_string
*/
public static function get_name() : \lang_string {
// Using a string that exists and contains a corresponding '_help' string.
return new \lang_string('allowstealthmodules');
}
/**
* include_averages
*
......
......@@ -33,6 +33,20 @@ defined('MOODLE_INTERNAL') || die();
*/
class test_indicator_max extends \core_analytics\local\indicator\binary {
/**
* Returns a lang_string object representing the name for the indicator.
*
* Used as column identificator.
*
* If there is a corresponding '_help' string this will be shown as well.
*
* @return \lang_string
*/
public static function get_name() : \lang_string {
// Using a string that exists and contains a corresponding '_help' string.
return new \lang_string('allowstealthmodules');
}
/**
* calculate_sample
*
......
......@@ -33,6 +33,20 @@ defined('MOODLE_INTERNAL') || die();
*/
class test_indicator_min extends \core_analytics\local\indicator\binary {
/**
* Returns a lang_string object representing the name for the indicator.
*
* Used as column identificator.
*
* If there is a corresponding '_help' string this will be shown as well.
*
* @return \lang_string
*/
public static function get_name() : \lang_string {
// Using a string that exists and contains a corresponding '_help' string.
return new \lang_string('allowstealthmodules');
}
/**
* calculate_sample
*
......
......@@ -33,6 +33,20 @@ defined('MOODLE_INTERNAL') || die();
*/
class test_indicator_random extends \core_analytics\local\indicator\binary {
/**
* Returns a lang_string object representing the name for the indicator.
*
* Used as column identificator.
*
* If there is a corresponding '_help' string this will be shown as well.
*
* @return \lang_string
*/
public static function get_name() : \lang_string {
// Using a string that exists and contains a corresponding '_help' string.
return new \lang_string('allowstealthmodules');
}
/**
* calculate_sample
*
......
......@@ -38,6 +38,20 @@ require_once(__DIR__ . '/test_target_shortname.php');
*/
class test_static_target_shortname extends test_target_shortname {
/**
* Returns a lang_string object representing the name for the indicator.
*
* Used as column identificator.
*
* If there is a corresponding '_help' string this will be shown as well.
*
* @return \lang_string
*/
public static function get_name() : \lang_string {
// Using a string that exists and contains a corresponding '_help' string.
return new \lang_string('allowstealthmodules');
}
/**
* based_on_assumptions
*
......
......@@ -33,6 +33,20 @@ defined('MOODLE_INTERNAL') || die();
*/
class test_target_shortname extends \core_analytics\local\target\binary {
/**
* Returns a lang_string object representing the name for the indicator.
*
* Used as column identificator.
*
* If there is a corresponding '_help' string this will be shown as well.
*
* @return \lang_string
*/
public static function get_name() : \lang_string {
// Using a string that exists and contains a corresponding '_help' string.
return new \lang_string('allowstealthmodules');
}
/**
* predictions
*
......
......@@ -43,12 +43,14 @@ class no_teacher extends \core_analytics\local\indicator\binary {
protected $teacherroleids = null;
/**
* get_name
* Returns the name.
*
* @return string
* If there is a corresponding '_help' string this will be shown as well.
*
* @return \lang_string
*/
public static function get_name() {
return get_string('indicator:noteacher', 'moodle');
public static function get_name() : \lang_string {
return new \lang_string('indicator:noteacher', 'moodle');
}
/**
......
......@@ -36,12 +36,14 @@ defined('MOODLE_INTERNAL') || die();
class any_access_after_end extends \core_analytics\local\indicator\binary {
/**
* get_name
* Returns the name.
*
* @return string
* If there is a corresponding '_help' string this will be shown as well.
*
* @return \lang_string
*/
public static function get_name() {
return get_string('indicator:accessesafterend');
public static function get_name() : \lang_string {
return new \lang_string('indicator:accessesafterend');
}
/**
......
......@@ -36,12 +36,14 @@ defined('MOODLE_INTERNAL') || die();
class any_access_before_start extends \core_analytics\local\indicator\binary {
/**
* get_name
* Returns the name.
*
* @return string
* If there is a corresponding '_help' string this will be shown as well.
*
* @return \lang_string
*/
public static function get_name() {
return get_string('indicator:accessesbeforestart');
public static function get_name() : \lang_string {
return new \lang_string('indicator:accessesbeforestart');
}
/**
......
......@@ -36,12 +36,14 @@ defined('MOODLE_INTERNAL') || die();
class any_write_action extends \core_analytics\local\indicator\binary {
/**
* get_name
* Returns the name.
*
* @return string
* If there is a corresponding '_help' string this will be shown as well.
*
* @return \lang_string
*/
public static function get_name() {
return get_string('indicator:anywrite');
public static function get_name() : \lang_string {
return new \lang_string('indicator:anywrite');
}
/**
......
......@@ -36,12 +36,14 @@ defined('MOODLE_INTERNAL') || die();
class read_actions extends \core_analytics\local\indicator\linear {
/**
* get_name
* Returns the name.
*
* @return string
* If there is a corresponding '_help' string this will be shown as well.
*
* @return \lang_string
*/
public static function get_name() {
return get_string('indicator:readactions');
public static function get_name() : \lang_string {
return new \lang_string('indicator:readactions');
}
/**
......
......@@ -41,12 +41,14 @@ require_once($CFG->dirroot . '/completion/completion_completion.php');
class course_dropout extends \core_analytics\local\target\binary {
/**
* get_name
* Returns the name.
*
* @return string
* If there is a corresponding '_help' string this will be shown as well.
*
* @return \lang_string
*/
public static function get_name() {
return get_string('target:coursedropout');
public static function get_name() : \lang_string {
return new \lang_string('target:coursedropout');
}
/**
......
......@@ -45,12 +45,14 @@ class no_teaching extends \core_analytics\local\target\binary {
}
/**
* get_name
* Returns the name.
*
* @return string
* If there is a corresponding '_help' string this will be shown as well.
*
* @return \lang_string
*/
public static function get_name() {
return get_string('target:noteachingactivity');
public static function get_name() : \lang_string {
return new \lang_string('target:noteachingactivity');
}
/**
......
......@@ -36,12 +36,16 @@ defined('MOODLE_INTERNAL') || die();
class deciles extends \core_analytics\local\time_splitting\equal_parts {
/**
* get_name
* Returns a lang_string object representing the name for the time splitting method.
*
* @return string
* Used as column identificator.
*
* If there is a corresponding '_help' string this will be shown as well.
*
* @return \lang_string
*/
public function get_name() {
return get_string('timesplitting:deciles');
public static function get_name() : \lang_string {
return new \lang_string('timesplitting:deciles');
}
/**
......
......@@ -36,12 +36,16 @@ defined('MOODLE_INTERNAL') || die();
class deciles_accum extends \core_analytics\local\time_splitting\accumulative_parts {
/**
* get_name
* Returns a lang_string object representing the name for the time splitting method.
*
* @return string
* Used as column identificator.
*
* If there is a corresponding '_help' string this will be shown as well.
*
* @return \lang_string
*/
public function get_name() {
return get_string('timesplitting:decilesaccum');
public static function get_name() : \lang_string {
return new \lang_string('timesplitting:decilesaccum');
}
/**
......
......@@ -40,12 +40,16 @@ defined('MOODLE_INTERNAL') || die();
class no_splitting extends \core_analytics\local\time_splitting\base {
/**
* get_name
* Returns a lang_string object representing the name for the time splitting method.
*
* @return string
* Used as column identificator.
*
* If there is a corresponding '_help' string this will be shown as well.
*
* @return \lang_string
*/
public function get_name() {
return get_string('timesplitting:nosplitting');
public static function get_name() : \lang_string {
return new \lang_string('timesplitting:nosplitting');
}
/**
......
......@@ -36,12 +36,16 @@ defined('MOODLE_INTERNAL') || die();
class quarters extends \core_analytics\local\time_splitting\equal_parts {
/**
* get_name
* Returns a lang_string object representing the name for the time spliting method.
*
* @return string
* Used as column identificator.
*
* If there is a corresponding '_help' string this will be shown as well.
*
* @return \lang_string
*/
public function get_name() {
return get_string('timesplitting:quarters');
public static function get_name() : \lang_string {
return new \lang_string('timesplitting:quarters');
}
/**
......
......@@ -36,12 +36,16 @@ defined('MOODLE_INTERNAL') || die();
class quarters_accum extends \core_analytics\local\time_splitting\accumulative_parts {
/**
* get_name
* Returns a lang_string object representing the name for the time spliting method.
*
* @return string
* Used as column identificator.
*
* If there is a corresponding '_help' string this will be shown as well.
*
* @return \lang_string
*/
public function get_name() {
return get_string('timesplitting:quartersaccum');
public static function get_name() : \lang_string {
return new \lang_string('timesplitting:quartersaccum');
}
/**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment