Skip to content

Commit

Permalink
MDL-59204 analytics: changed get_name so that it returns a lang_string
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mdjnelson committed Aug 18, 2017
1 parent 952cbce commit 7e00aa7
Show file tree
Hide file tree
Showing 65 changed files with 449 additions and 240 deletions.
10 changes: 4 additions & 6 deletions analytics/classes/calculable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
13 changes: 7 additions & 6 deletions analytics/classes/local/time_splitting/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
14 changes: 14 additions & 0 deletions analytics/tests/fixtures/test_indicator_fullname.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,20 @@
*/
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
*
Expand Down
14 changes: 14 additions & 0 deletions analytics/tests/fixtures/test_indicator_max.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,20 @@
*/
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
*
Expand Down
14 changes: 14 additions & 0 deletions analytics/tests/fixtures/test_indicator_min.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,20 @@
*/
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
*
Expand Down
14 changes: 14 additions & 0 deletions analytics/tests/fixtures/test_indicator_random.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,20 @@
*/
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
*
Expand Down
14 changes: 14 additions & 0 deletions analytics/tests/fixtures/test_static_target_shortname.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@
*/
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
*
Expand Down
14 changes: 14 additions & 0 deletions analytics/tests/fixtures/test_target_shortname.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,20 @@
*/
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
*
Expand Down
10 changes: 6 additions & 4 deletions course/classes/analytics/indicator/no_teacher.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

/**
Expand Down
10 changes: 6 additions & 4 deletions lib/classes/analytics/indicator/any_access_after_end.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@
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');
}

/**
Expand Down
10 changes: 6 additions & 4 deletions lib/classes/analytics/indicator/any_access_before_start.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@
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');
}

/**
Expand Down
10 changes: 6 additions & 4 deletions lib/classes/analytics/indicator/any_write_action.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@
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');
}

/**
Expand Down
10 changes: 6 additions & 4 deletions lib/classes/analytics/indicator/read_actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@
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');
}

/**
Expand Down
10 changes: 6 additions & 4 deletions lib/classes/analytics/target/course_dropout.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@
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');
}

/**
Expand Down
10 changes: 6 additions & 4 deletions lib/classes/analytics/target/no_teaching.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,14 @@ public static function based_on_assumptions() {
}

/**
* 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');
}

/**
Expand Down
12 changes: 8 additions & 4 deletions lib/classes/analytics/time_splitting/deciles.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,16 @@
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');
}

/**
Expand Down
12 changes: 8 additions & 4 deletions lib/classes/analytics/time_splitting/deciles_accum.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,16 @@
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');
}

/**
Expand Down
12 changes: 8 additions & 4 deletions lib/classes/analytics/time_splitting/no_splitting.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,16 @@
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');
}

/**
Expand Down
12 changes: 8 additions & 4 deletions lib/classes/analytics/time_splitting/quarters.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,16 @@
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');
}

/**
Expand Down
Loading

0 comments on commit 7e00aa7

Please sign in to comment.