Skip to content

Commit

Permalink
MDL-59030 analytics: Expand community of inquiry mods public API
Browse files Browse the repository at this point in the history
  • Loading branch information
David Monllao committed Aug 29, 2017
1 parent 9eb3c17 commit edee629
Show file tree
Hide file tree
Showing 45 changed files with 101 additions and 545 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -81,7 +91,7 @@ protected final function get_activity_type() {
* @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');
}
Expand All @@ -92,7 +102,7 @@ protected function get_cognitive_depth_level(\cm_info $cm) {
* @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');
}
Expand Down Expand Up @@ -506,7 +516,7 @@ protected function cognitive_calculate_sample($sampleid, $tablename, $starttime
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;
Expand Down Expand Up @@ -593,8 +603,10 @@ protected function social_calculate_sample($sampleid, $tablename, $starttime = f
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) {
Expand Down Expand Up @@ -650,5 +662,5 @@ protected function calculate_sample($sampleid, $tablename, $starttime = false, $
*
* @return string
*/
abstract protected function get_indicator_type();
abstract public function get_indicator_type();
}
2 changes: 1 addition & 1 deletion course/classes/analytics/indicator/no_teacher.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
/**
* 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
*/
Expand Down
6 changes: 6 additions & 0 deletions lang/en/moodle.php
Original file line number Diff line number Diff line change
Expand Up @@ -1031,8 +1031,14 @@
$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';
Expand Down
15 changes: 2 additions & 13 deletions mod/assign/classes/analytics/indicator/cognitive_depth.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,11 @@ public static function get_name() : \lang_string {
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;
}

Expand Down
15 changes: 2 additions & 13 deletions mod/assign/classes/analytics/indicator/social_breadth.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,11 @@ public static function get_name() : \lang_string {
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;
}
}
15 changes: 2 additions & 13 deletions mod/book/classes/analytics/indicator/cognitive_depth.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,11 @@ public static function get_name() : \lang_string {
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;
}
}
15 changes: 2 additions & 13 deletions mod/book/classes/analytics/indicator/social_breadth.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,11 @@ public static function get_name() : \lang_string {
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;
}
}
13 changes: 1 addition & 12 deletions mod/chat/classes/analytics/indicator/cognitive_depth.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,10 @@ public static function get_name() : \lang_string {
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;
}
Expand Down
15 changes: 2 additions & 13 deletions mod/chat/classes/analytics/indicator/social_breadth.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,11 @@ public static function get_name() : \lang_string {
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;
}
}
15 changes: 2 additions & 13 deletions mod/choice/classes/analytics/indicator/cognitive_depth.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,11 @@ public static function get_name() : \lang_string {
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) {
Expand Down
15 changes: 2 additions & 13 deletions mod/choice/classes/analytics/indicator/social_breadth.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,11 @@ public static function get_name() : \lang_string {
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;
}
Expand Down
13 changes: 1 addition & 12 deletions mod/data/classes/analytics/indicator/cognitive_depth.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,10 @@ public static function get_name() : \lang_string {
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;
}
Expand Down
15 changes: 2 additions & 13 deletions mod/data/classes/analytics/indicator/social_breadth.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,11 @@ public static function get_name() : \lang_string {
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;
}
}
15 changes: 2 additions & 13 deletions mod/feedback/classes/analytics/indicator/cognitive_depth.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,11 @@ public static function get_name() : \lang_string {
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])) {
Expand Down
15 changes: 2 additions & 13 deletions mod/feedback/classes/analytics/indicator/social_breadth.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,11 @@ public static function get_name() : \lang_string {
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;
Expand Down
Loading

0 comments on commit edee629

Please sign in to comment.