Commit edee629d authored by David Monllaó's avatar David Monllaó
Browse files

MDL-59030 analytics: Expand community of inquiry mods public API

parent 9eb3c173
......@@ -60,12 +60,22 @@ abstract class community_of_inquiry_activity extends linear {
*/
const INDICATOR_SOCIAL = "social";
/**
* Max cognitive depth level accepted.
*/
const MAX_COGNITIVE_LEVEL = 5;
/**
* Max social breadth level accepted.
*/
const MAX_SOCIAL_LEVEL = 2;
/**
* Returns the activity type. No point in changing this class in children classes.
*
* @var string The activity name (e.g. assign or quiz)
*/
protected final function get_activity_type() {
public final function get_activity_type() {
$class = get_class($this);
$package = stristr($class, "\\", true);
$type = str_replace("mod_", "", $package);
......@@ -81,7 +91,7 @@ abstract class community_of_inquiry_activity extends linear {
* @param \cm_info $cm
* @return int
*/
protected function get_cognitive_depth_level(\cm_info $cm) {
public function get_cognitive_depth_level(\cm_info $cm) {
throw new \coding_exception('Overwrite get_cognitive_depth_level method to set your activity potential cognitive ' .
'depth level');
}
......@@ -92,7 +102,7 @@ abstract class community_of_inquiry_activity extends linear {
* @param \cm_info $cm
* @return int
*/
protected function get_social_breadth_level(\cm_info $cm) {
public function get_social_breadth_level(\cm_info $cm) {
throw new \coding_exception('Overwrite get_social_breadth_level method to set your activity potential social ' .
'breadth level');
}
......@@ -506,7 +516,7 @@ abstract class community_of_inquiry_activity extends linear {
foreach ($useractivities as $contextid => $cm) {
$potentiallevel = $this->get_cognitive_depth_level($cm);
if (!is_int($potentiallevel) || $potentiallevel > 5 || $potentiallevel < 1) {
if (!is_int($potentiallevel) || $potentiallevel > self::MAX_COGNITIVE_LEVEL || $potentiallevel < 1) {
throw new \coding_exception('Activities\' potential cognitive depth go from 1 to 5.');
}
$scoreperlevel = $scoreperactivity / $potentiallevel;
......@@ -593,8 +603,10 @@ abstract class community_of_inquiry_activity extends linear {
foreach ($useractivities as $contextid => $cm) {
$potentiallevel = $this->get_social_breadth_level($cm);
if (!is_int($potentiallevel) || $potentiallevel > 2 || $potentiallevel < 1) {
throw new \coding_exception('Activities\' potential social breadth go from 1 to 2.');
if (!is_int($potentiallevel) || $potentiallevel > self::MAX_SOCIAL_LEVEL || $potentiallevel < 1) {
throw new \coding_exception('Although social breadth levels can go from 1 to 5 at the moment Moodle core ' .
'can only accept social breadth levels between 1 and ' . self::MAX_SOCIAL_LEVEL . '. Sorry for the ' .
'inconvenience. This will change in future releases.');
}
$scoreperlevel = $scoreperactivity / $potentiallevel;
switch ($potentiallevel) {
......@@ -650,5 +662,5 @@ abstract class community_of_inquiry_activity extends linear {
*
* @return string
*/
abstract protected function get_indicator_type();
abstract public function get_indicator_type();
}
......@@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die();
/**
* No teacher indicator.
*
* @package core_analytics
* @package core_course
* @copyright 2016 David Monllao {@link http://www.davidmonllao.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
......
......@@ -1031,8 +1031,14 @@ $string['indicator:anywrite'] = 'Any write action';
$string['indicator:anywrite_help'] = '';
$string['indicator:completeduserprofile'] = 'User profile is completed';
$string['indicator:completeduserprofile_help'] = '';
$string['indicator:completionenabled'] = 'Completion enabled';
$string['indicator:completionenabled_help'] = '';
$string['indicator:noteacher'] = 'There are no teachers';
$string['indicator:noteacher_help'] = '';
$string['indicator:potentialcognitive'] = 'Potential cognitive depth';
$string['indicator:potentialcognitive_help'] = '';
$string['indicator:potentialsocial'] = 'Potential social breadth';
$string['indicator:potentialsocial_help'] = '';
$string['indicator:readactions'] = 'Read actions amount';
$string['indicator:readactions_help'] = '';
$string['indicator:userforumstracking'] = 'User is tracking forums';
......
......@@ -46,22 +46,11 @@ class cognitive_depth extends activity_base {
return new \lang_string('indicator:cognitivedepth', 'mod_assign');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_COGNITIVE;
}
/**
* get_cognitive_depth_level
*
* @param \cm_info $cm
* @return int
*/
protected function get_cognitive_depth_level(\cm_info $cm) {
public function get_cognitive_depth_level(\cm_info $cm) {
return 5;
}
......
......@@ -46,22 +46,11 @@ class social_breadth extends activity_base {
return new \lang_string('indicator:socialbreadth', 'mod_assign');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_SOCIAL;
}
/**
* get_social_breadth_level
*
* @param \cm_info $cm
* @return int
*/
protected function get_social_breadth_level(\cm_info $cm) {
public function get_social_breadth_level(\cm_info $cm) {
return 2;
}
}
......@@ -46,22 +46,11 @@ class cognitive_depth extends activity_base {
return new \lang_string('indicator:cognitivedepth', 'mod_book');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_COGNITIVE;
}
/**
* get_cognitive_depth_level
*
* @param \cm_info $cm
* @return int
*/
protected function get_cognitive_depth_level(\cm_info $cm) {
public function get_cognitive_depth_level(\cm_info $cm) {
return 1;
}
}
......@@ -46,22 +46,11 @@ class social_breadth extends activity_base {
return new \lang_string('indicator:socialbreadth', 'mod_book');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_SOCIAL;
}
/**
* get_social_breadth_level
*
* @param \cm_info $cm
* @return int
*/
protected function get_social_breadth_level(\cm_info $cm) {
public function get_social_breadth_level(\cm_info $cm) {
return 1;
}
}
......@@ -46,21 +46,10 @@ class cognitive_depth extends activity_base {
return new \lang_string('indicator:cognitivedepth', 'mod_chat');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_COGNITIVE;
}
/**
* get_cognitive_depth_level
*
* @param \cm_info $cm
* @return int
*/
public function get_cognitive_depth_level(\cm_info $cm) {
return 4;
}
......
......@@ -46,22 +46,11 @@ class social_breadth extends activity_base {
return new \lang_string('indicator:socialbreadth', 'mod_chat');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_SOCIAL;
}
/**
* get_social_breadth_level
*
* @param \cm_info $cm
* @return int
*/
protected function get_social_breadth_level(\cm_info $cm) {
public function get_social_breadth_level(\cm_info $cm) {
return 2;
}
}
......@@ -46,22 +46,11 @@ class cognitive_depth extends activity_base {
return new \lang_string('indicator:cognitivedepth', 'mod_choice');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_COGNITIVE;
}
/**
* get_cognitive_depth_level
*
* @param \cm_info $cm
* @return int
*/
protected function get_cognitive_depth_level(\cm_info $cm) {
public function get_cognitive_depth_level(\cm_info $cm) {
$this->fill_choice_data($cm);
if ($this->choicedata[$cm->instance]->showresults == 0 || $this->choicedata[$cm->instance]->showresults == 4) {
......
......@@ -46,22 +46,11 @@ class social_breadth extends activity_base {
return new \lang_string('indicator:socialbreadth', 'mod_choice');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_SOCIAL;
}
/**
* get_social_breadth_level
*
* @param \cm_info $cm
* @return int
*/
protected function get_social_breadth_level(\cm_info $cm) {
public function get_social_breadth_level(\cm_info $cm) {
$this->fill_choice_data($cm);
return 2;
}
......
......@@ -46,21 +46,10 @@ class cognitive_depth extends activity_base {
return new \lang_string('indicator:cognitivedepth', 'mod_data');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_COGNITIVE;
}
/**
* get_cognitive_depth_level
*
* @param \cm_info $cm
* @return int
*/
public function get_cognitive_depth_level(\cm_info $cm) {
return 2;
}
......
......@@ -46,22 +46,11 @@ class social_breadth extends activity_base {
return new \lang_string('indicator:socialbreadth', 'mod_data');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_SOCIAL;
}
/**
* get_social_breadth_level
*
* @param \cm_info $cm
* @return int
*/
protected function get_social_breadth_level(\cm_info $cm) {
public function get_social_breadth_level(\cm_info $cm) {
return 1;
}
}
......@@ -46,22 +46,11 @@ class cognitive_depth extends activity_base {
return new \lang_string('indicator:cognitivedepth', 'mod_feedback');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_COGNITIVE;
}
/**
* get_cognitive_depth_level
*
* @param \cm_info $cm
* @return int
*/
protected function get_cognitive_depth_level(\cm_info $cm) {
public function get_cognitive_depth_level(\cm_info $cm) {
$this->fill_publishstats($cm);
if (!empty($this->publishstats[$cm->instance])) {
......
......@@ -46,22 +46,11 @@ class social_breadth extends activity_base {
return new \lang_string('indicator:socialbreadth', 'mod_feedback');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_SOCIAL;
}
/**
* get_social_breadth_level
*
* @param \cm_info $cm
* @return int
*/
protected function get_social_breadth_level(\cm_info $cm) {
public function get_social_breadth_level(\cm_info $cm) {
$this->fill_publishstats($cm);
return 2;
......
......@@ -46,22 +46,11 @@ class cognitive_depth extends activity_base {
return new \lang_string('indicator:cognitivedepth', 'mod_folder');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_COGNITIVE;
}
/**
* get_cognitive_depth_level
*
* @param \cm_info $cm
* @return int
*/
protected function get_cognitive_depth_level(\cm_info $cm) {
public function get_cognitive_depth_level(\cm_info $cm) {
return 1;
}
}
......@@ -46,22 +46,11 @@ class social_breadth extends activity_base {
return new \lang_string('indicator:socialbreadth', 'mod_folder');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_SOCIAL;
}
/**
* get_social_breadth_level
*
* @param \cm_info $cm
* @return int
*/
protected function get_social_breadth_level(\cm_info $cm) {
public function get_social_breadth_level(\cm_info $cm) {
return 1;
}
}
......@@ -46,21 +46,10 @@ class cognitive_depth extends activity_base {
return new \lang_string('indicator:cognitivedepth', 'mod_forum');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_COGNITIVE;
}
/**
* get_cognitive_depth_level
*
* @param \cm_info $cm
* @return int
*/
public function get_cognitive_depth_level(\cm_info $cm) {
return 4;
}
......
......@@ -46,22 +46,11 @@ class social_breadth extends activity_base {
return new \lang_string('indicator:socialbreadth', 'mod_forum');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_SOCIAL;
}
/**
* get_social_breadth_level
*
* @param \cm_info $cm
* @return int
*/
protected function get_social_breadth_level(\cm_info $cm) {
public function get_social_breadth_level(\cm_info $cm) {
return 2;
}
}
......@@ -46,21 +46,10 @@ class cognitive_depth extends activity_base {
return new \lang_string('indicator:cognitivedepth', 'mod_glossary');
}
/**
* get_indicator_type
*
* @return string
*/
protected function get_indicator_type() {
public function get_indicator_type() {
return self::INDICATOR_COGNITIVE;
}
/**
* get_cognitive_depth_level
*
* @param \cm_info $cm
* @return int
*/
public function get_cognitive_depth_level(\cm_info $cm) {
return 2;
}
......
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