Merge branch 'MDL-59950_master' of git://github.com/dmonllao/moodle
authorDamyon Wiese <damyon@moodle.com>
Thu, 2 Nov 2017 06:39:32 +0000 (14:39 +0800)
committerDamyon Wiese <damyon@moodle.com>
Thu, 2 Nov 2017 06:39:32 +0000 (14:39 +0800)
43 files changed:
analytics/classes/local/indicator/community_of_inquiry_activity.php
mod/assign/classes/analytics/indicator/cognitive_depth.php
mod/assign/classes/analytics/indicator/social_breadth.php
mod/book/classes/analytics/indicator/cognitive_depth.php
mod/book/classes/analytics/indicator/social_breadth.php
mod/chat/classes/analytics/indicator/cognitive_depth.php
mod/chat/classes/analytics/indicator/social_breadth.php
mod/choice/classes/analytics/indicator/cognitive_depth.php
mod/choice/classes/analytics/indicator/social_breadth.php
mod/data/classes/analytics/indicator/cognitive_depth.php
mod/data/classes/analytics/indicator/social_breadth.php
mod/feedback/classes/analytics/indicator/cognitive_depth.php
mod/feedback/classes/analytics/indicator/social_breadth.php
mod/folder/classes/analytics/indicator/cognitive_depth.php
mod/folder/classes/analytics/indicator/social_breadth.php
mod/forum/classes/analytics/indicator/cognitive_depth.php
mod/forum/classes/analytics/indicator/social_breadth.php
mod/glossary/classes/analytics/indicator/cognitive_depth.php
mod/glossary/classes/analytics/indicator/social_breadth.php
mod/imscp/classes/analytics/indicator/cognitive_depth.php
mod/imscp/classes/analytics/indicator/social_breadth.php
mod/label/classes/analytics/indicator/cognitive_depth.php
mod/label/classes/analytics/indicator/social_breadth.php
mod/lesson/classes/analytics/indicator/cognitive_depth.php
mod/lesson/classes/analytics/indicator/social_breadth.php
mod/lti/classes/analytics/indicator/cognitive_depth.php
mod/lti/classes/analytics/indicator/social_breadth.php
mod/page/classes/analytics/indicator/cognitive_depth.php
mod/page/classes/analytics/indicator/social_breadth.php
mod/quiz/classes/analytics/indicator/cognitive_depth.php
mod/quiz/classes/analytics/indicator/social_breadth.php
mod/resource/classes/analytics/indicator/cognitive_depth.php
mod/resource/classes/analytics/indicator/social_breadth.php
mod/scorm/classes/analytics/indicator/cognitive_depth.php
mod/scorm/classes/analytics/indicator/social_breadth.php
mod/survey/classes/analytics/indicator/cognitive_depth.php
mod/survey/classes/analytics/indicator/social_breadth.php
mod/url/classes/analytics/indicator/cognitive_depth.php
mod/url/classes/analytics/indicator/social_breadth.php
mod/wiki/classes/analytics/indicator/cognitive_depth.php
mod/wiki/classes/analytics/indicator/social_breadth.php
mod/workshop/classes/analytics/indicator/cognitive_depth.php
mod/workshop/classes/analytics/indicator/social_breadth.php

index 8a886eb..1e7da1d 100644 (file)
@@ -60,6 +60,56 @@ abstract class community_of_inquiry_activity extends linear {
      */
     const INDICATOR_SOCIAL = "social";
 
+    /**
+     * Constant for this cognitive level.
+     */
+    const COGNITIVE_LEVEL_1 = 1;
+
+    /**
+     * Constant for this cognitive level.
+     */
+    const COGNITIVE_LEVEL_2 = 2;
+
+    /**
+     * Constant for this cognitive level.
+     */
+    const COGNITIVE_LEVEL_3 = 3;
+
+    /**
+     * Constant for this cognitive level.
+     */
+    const COGNITIVE_LEVEL_4 = 4;
+
+    /**
+     * Constant for this cognitive level.
+     */
+    const COGNITIVE_LEVEL_5 = 5;
+
+    /**
+     * Constant for this social level.
+     */
+    const SOCIAL_LEVEL_1 = 1;
+
+    /**
+     * Constant for this social level.
+     */
+    const SOCIAL_LEVEL_2 = 2;
+
+    /**
+     * Constant for this social level.
+     */
+    const SOCIAL_LEVEL_3 = 3;
+
+    /**
+     * Constant for this social level.
+     */
+    const SOCIAL_LEVEL_4 = 4;
+
+    /**
+     * Constant for this social level.
+     */
+    const SOCIAL_LEVEL_5 = 5;
+
     /**
      * Max cognitive depth level accepted.
      */
@@ -530,13 +580,15 @@ 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 > self::MAX_COGNITIVE_LEVEL || $potentiallevel < 1) {
+            if (!is_int($potentiallevel)
+                    || $potentiallevel > self::MAX_COGNITIVE_LEVEL
+                    || $potentiallevel < self::COGNITIVE_LEVEL_1) {
                 throw new \coding_exception('Activities\' potential cognitive depth go from 1 to 5.');
             }
             $scoreperlevel = $scoreperactivity / $potentiallevel;
 
             switch ($potentiallevel) {
-                case 5:
+                case self::COGNITIVE_LEVEL_5:
                     // Cognitive level 5 is to submit after feedback.
                     if ($this->any_feedback('submitted', $cm, $contextid, $user)) {
                         $score += $scoreperlevel * 5;
@@ -544,7 +596,7 @@ abstract class community_of_inquiry_activity extends linear {
                     }
                     // The user didn't reach the activity max cognitive depth, continue with level 2.
 
-                case 4:
+                case self::COGNITIVE_LEVEL_4:
                     // Cognitive level 4 is to comment on feedback.
                     if ($this->any_feedback('replied', $cm, $contextid, $user)) {
                         $score += $scoreperlevel * 4;
@@ -552,7 +604,7 @@ abstract class community_of_inquiry_activity extends linear {
                     }
                     // The user didn't reach the activity max cognitive depth, continue with level 2.
 
-                case 3:
+                case self::COGNITIVE_LEVEL_3:
                     // Cognitive level 3 is to view feedback.
 
                     if ($this->any_feedback('viewed', $cm, $contextid, $user)) {
@@ -562,7 +614,7 @@ abstract class community_of_inquiry_activity extends linear {
                     }
                     // The user didn't reach the activity max cognitive depth, continue with level 2.
 
-                case 2:
+                case self::COGNITIVE_LEVEL_2:
                     // Cognitive depth level 2 is to submit content.
 
                     if ($this->any_write_log($contextid, $user)) {
@@ -571,7 +623,7 @@ abstract class community_of_inquiry_activity extends linear {
                     }
                     // The user didn't reach the activity max cognitive depth, continue with level 1.
 
-                case 1:
+                case self::COGNITIVE_LEVEL_1:
                     // Cognitive depth level 1 is just accessing the activity.
 
                     if ($this->any_log($contextid, $user)) {
@@ -617,16 +669,18 @@ 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 > self::MAX_SOCIAL_LEVEL || $potentiallevel < 1) {
+            if (!is_int($potentiallevel)
+                    || $potentiallevel > self::MAX_SOCIAL_LEVEL
+                    || $potentiallevel < self::SOCIAL_LEVEL_1) {
                 throw new \coding_exception('Activities\' potential social breadth go from 1 to ' .
                     community_of_inquiry_activity::MAX_SOCIAL_LEVEL . '.');
             }
             $scoreperlevel = $scoreperactivity / $potentiallevel;
             switch ($potentiallevel) {
-                case 2:
-                case 3:
-                case 4:
-                case 5:
+                case self::SOCIAL_LEVEL_2:
+                case self::SOCIAL_LEVEL_3:
+                case self::SOCIAL_LEVEL_4:
+                case self::SOCIAL_LEVEL_5:
                     // Core activities social breadth only reaches level 2, until core activities social
                     // breadth do not reach level 5 we limit it to what we currently support, which is level 2.
 
@@ -639,7 +693,7 @@ abstract class community_of_inquiry_activity extends linear {
                     }
                     // The user didn't reach the activity max social breadth, continue with level 1.
 
-                case 1:
+                case self::SOCIAL_LEVEL_1:
                     // Social breadth level 1 is just accessing the activity.
                     if ($this->any_log($contextid, $user)) {
                         $score += $scoreperlevel;
index f75dd47..08fbf49 100644 (file)
@@ -51,7 +51,7 @@ class cognitive_depth extends activity_base {
     }
 
     public function get_cognitive_depth_level(\cm_info $cm) {
-        return 5;
+        return self::COGNITIVE_LEVEL_5;
     }
 
     /**
index 66f0d48..fa37905 100644 (file)
@@ -51,6 +51,6 @@ class social_breadth extends activity_base {
     }
 
     public function get_social_breadth_level(\cm_info $cm) {
-        return 2;
+        return self::SOCIAL_LEVEL_2;
     }
 }
index 0fdf7c9..ff5dc90 100644 (file)
@@ -51,6 +51,6 @@ class cognitive_depth extends activity_base {
     }
 
     public function get_cognitive_depth_level(\cm_info $cm) {
-        return 1;
+        return self::COGNITIVE_LEVEL_1;
     }
 }
index e58e6a0..279fa03 100644 (file)
@@ -51,6 +51,6 @@ class social_breadth extends activity_base {
     }
 
     public function get_social_breadth_level(\cm_info $cm) {
-        return 1;
+        return self::SOCIAL_LEVEL_1;
     }
 }
index 4890052..dc25e0b 100644 (file)
@@ -51,6 +51,6 @@ class cognitive_depth extends activity_base {
     }
 
     public function get_cognitive_depth_level(\cm_info $cm) {
-        return 4;
+        return self::COGNITIVE_LEVEL_4;
     }
 }
index 620e6a8..97b2cf4 100644 (file)
@@ -51,6 +51,6 @@ class social_breadth extends activity_base {
     }
 
     public function get_social_breadth_level(\cm_info $cm) {
-        return 2;
+        return self::SOCIAL_LEVEL_2;
     }
 }
index 6517393..48cec07 100644 (file)
@@ -55,9 +55,9 @@ class cognitive_depth extends activity_base {
 
         if ($this->choicedata[$cm->instance]->showresults == 0 || $this->choicedata[$cm->instance]->showresults == 4) {
             // Results are not shown to students or are always shown.
-            return 2;
+            return self::COGNITIVE_LEVEL_2;
         }
 
-        return 3;
+        return self::COGNITIVE_LEVEL_3;
     }
 }
index 8d119ca..26c0a7d 100644 (file)
@@ -52,6 +52,6 @@ class social_breadth extends activity_base {
 
     public function get_social_breadth_level(\cm_info $cm) {
         $this->fill_choice_data($cm);
-        return 2;
+        return self::SOCIAL_LEVEL_2;
     }
 }
index a527838..8ac7fdb 100644 (file)
@@ -51,6 +51,6 @@ class cognitive_depth extends activity_base {
     }
 
     public function get_cognitive_depth_level(\cm_info $cm) {
-        return 2;
+        return self::COGNITIVE_LEVEL_2;
     }
 }
index 2309c69..3f3cce2 100644 (file)
@@ -51,6 +51,6 @@ class social_breadth extends activity_base {
     }
 
     public function get_social_breadth_level(\cm_info $cm) {
-        return 1;
+        return self::SOCIAL_LEVEL_1;
     }
 }
index cf5403f..0890982 100644 (file)
@@ -55,8 +55,8 @@ class cognitive_depth extends activity_base {
 
         if (!empty($this->publishstats[$cm->instance])) {
             // If stats are published we count that the user viewed feedback.
-            return 3;
+            return self::COGNITIVE_LEVEL_3;
         }
-        return 2;
+        return self::COGNITIVE_LEVEL_2;
     }
 }
index 64ba678..d1c7e27 100644 (file)
@@ -53,6 +53,6 @@ class social_breadth extends activity_base {
     public function get_social_breadth_level(\cm_info $cm) {
         $this->fill_publishstats($cm);
 
-        return 2;
+        return self::SOCIAL_LEVEL_2;
     }
 }
index 39d6207..6b1f558 100644 (file)
@@ -51,6 +51,6 @@ class cognitive_depth extends activity_base {
     }
 
     public function get_cognitive_depth_level(\cm_info $cm) {
-        return 1;
+        return self::COGNITIVE_LEVEL_1;
     }
 }
index 5572822..2d84c0a 100644 (file)
@@ -51,6 +51,6 @@ class social_breadth extends activity_base {
     }
 
     public function get_social_breadth_level(\cm_info $cm) {
-        return 1;
+        return self::SOCIAL_LEVEL_1;
     }
 }
index 3641ccf..eddfa7e 100644 (file)
@@ -51,7 +51,7 @@ class cognitive_depth extends activity_base {
     }
 
     public function get_cognitive_depth_level(\cm_info $cm) {
-        return 4;
+        return self::COGNITIVE_LEVEL_4;
     }
 
     /**
index e74c272..d1d1d13 100644 (file)
@@ -51,6 +51,6 @@ class social_breadth extends activity_base {
     }
 
     public function get_social_breadth_level(\cm_info $cm) {
-        return 2;
+        return self::SOCIAL_LEVEL_2;
     }
 }
index 312f153..379dd86 100644 (file)
@@ -51,6 +51,6 @@ class cognitive_depth extends activity_base {
     }
 
     public function get_cognitive_depth_level(\cm_info $cm) {
-        return 2;
+        return self::COGNITIVE_LEVEL_2;
     }
 }
index b47bf00..4c669aa 100644 (file)
@@ -51,6 +51,6 @@ class social_breadth extends activity_base {
     }
 
     public function get_social_breadth_level(\cm_info $cm) {
-        return 1;
+        return self::SOCIAL_LEVEL_1;
     }
 }
index c7388d2..5c85527 100644 (file)
@@ -51,7 +51,7 @@ class cognitive_depth extends activity_base {
     }
 
     public function get_cognitive_depth_level(\cm_info $cm) {
-        return 1;
+        return self::COGNITIVE_LEVEL_1;
     }
 
 }
index 50ffd0a..c933510 100644 (file)
@@ -51,6 +51,6 @@ class social_breadth extends activity_base {
     }
 
     public function get_social_breadth_level(\cm_info $cm) {
-        return 1;
+        return self::SOCIAL_LEVEL_1;
     }
 }
index adacede..fc1f3c4 100644 (file)
@@ -51,7 +51,7 @@ class cognitive_depth extends activity_base {
     }
 
     public function get_cognitive_depth_level(\cm_info $cm) {
-        return 1;
+        return self::COGNITIVE_LEVEL_1;
     }
 
 }
index 86452ec..a59263e 100644 (file)
@@ -51,6 +51,6 @@ class social_breadth extends activity_base {
     }
 
     public function get_social_breadth_level(\cm_info $cm) {
-        return 1;
+        return self::SOCIAL_LEVEL_1;
     }
 }
index 838f30d..24ca8e2 100644 (file)
@@ -51,7 +51,7 @@ class cognitive_depth extends activity_base {
     }
 
     public function get_cognitive_depth_level(\cm_info $cm) {
-        return 5;
+        return self::COGNITIVE_LEVEL_5;
     }
 
     /**
index cd3c970..f073715 100644 (file)
@@ -51,6 +51,6 @@ class social_breadth extends activity_base {
     }
 
     public function get_social_breadth_level(\cm_info $cm) {
-        return 2;
+        return self::SOCIAL_LEVEL_2;
     }
 }
index a600f88..feb31ff 100644 (file)
@@ -51,7 +51,7 @@ class cognitive_depth extends activity_base {
     }
 
     public function get_cognitive_depth_level(\cm_info $cm) {
-        return 3;
+        return self::COGNITIVE_LEVEL_3;
     }
 
 }
index bd20137..896d294 100644 (file)
@@ -51,6 +51,6 @@ class social_breadth extends activity_base {
     }
 
     public function get_social_breadth_level(\cm_info $cm) {
-        return 2;
+        return self::SOCIAL_LEVEL_2;
     }
 }
index 4e3eaca..0874f77 100644 (file)
@@ -51,6 +51,6 @@ class cognitive_depth extends activity_base {
     }
 
     public function get_cognitive_depth_level(\cm_info $cm) {
-        return 1;
+        return self::COGNITIVE_LEVEL_1;
     }
 }
index 1d27c5c..b9542e9 100644 (file)
@@ -51,6 +51,6 @@ class social_breadth extends activity_base {
     }
 
     public function get_social_breadth_level(\cm_info $cm) {
-        return 1;
+        return self::SOCIAL_LEVEL_1;
     }
 }
index 3c7d0a9..7e3fbfd 100644 (file)
@@ -51,7 +51,7 @@ class cognitive_depth extends activity_base {
     }
 
     public function get_cognitive_depth_level(\cm_info $cm) {
-        return 5;
+        return self::COGNITIVE_LEVEL_5;
     }
 
     /**
index 4dd2a5c..14b45b6 100644 (file)
@@ -51,6 +51,6 @@ class social_breadth extends activity_base {
     }
 
     public function get_social_breadth_level(\cm_info $cm) {
-        return 2;
+        return self::SOCIAL_LEVEL_2;
     }
 }
index 995b63b..e91986c 100644 (file)
@@ -51,6 +51,6 @@ class cognitive_depth extends activity_base {
     }
 
     public function get_cognitive_depth_level(\cm_info $cm) {
-        return 1;
+        return self::COGNITIVE_LEVEL_1;
     }
 }
index 4dad871..33fbbcb 100644 (file)
@@ -51,6 +51,6 @@ class social_breadth extends activity_base {
     }
 
     public function get_social_breadth_level(\cm_info $cm) {
-        return 1;
+        return self::SOCIAL_LEVEL_1;
     }
 }
index 4dc11eb..42f37e2 100644 (file)
@@ -51,6 +51,6 @@ class cognitive_depth extends activity_base {
     }
 
     public function get_cognitive_depth_level(\cm_info $cm) {
-        return 3;
+        return self::COGNITIVE_LEVEL_3;
     }
 }
index 1ea6049..a4ba3a6 100644 (file)
@@ -51,6 +51,6 @@ class social_breadth extends activity_base {
     }
 
     public function get_social_breadth_level(\cm_info $cm) {
-        return 2;
+        return self::SOCIAL_LEVEL_2;
     }
 }
index f2958f6..1065cd2 100644 (file)
@@ -51,6 +51,6 @@ class cognitive_depth extends activity_base {
     }
 
     public function get_cognitive_depth_level(\cm_info $cm) {
-        return 2;
+        return self::COGNITIVE_LEVEL_2;
     }
 }
index 958c088..5673b0e 100644 (file)
@@ -51,6 +51,6 @@ class social_breadth extends activity_base {
     }
 
     public function get_social_breadth_level(\cm_info $cm) {
-        return 1;
+        return self::SOCIAL_LEVEL_1;
     }
 }
index 784510e..8bcfca1 100644 (file)
@@ -51,6 +51,6 @@ class cognitive_depth extends activity_base {
     }
 
     public function get_cognitive_depth_level(\cm_info $cm) {
-        return 1;
+        return self::COGNITIVE_LEVEL_1;
     }
 }
index 28020b1..458a2d8 100644 (file)
@@ -51,6 +51,6 @@ class social_breadth extends activity_base {
     }
 
     public function get_social_breadth_level(\cm_info $cm) {
-        return 1;
+        return self::SOCIAL_LEVEL_1;
     }
 }
index 973a25d..343ebec 100644 (file)
@@ -51,6 +51,6 @@ class cognitive_depth extends activity_base {
     }
 
     public function get_cognitive_depth_level(\cm_info $cm) {
-        return 2;
+        return self::COGNITIVE_LEVEL_2;
     }
 }
index ec5874c..aaf590f 100644 (file)
@@ -51,6 +51,6 @@ class social_breadth extends activity_base {
     }
 
     public function get_social_breadth_level(\cm_info $cm) {
-        return 1;
+        return self::SOCIAL_LEVEL_1;
     }
 }
index 85d35d0..0f0b437 100644 (file)
@@ -51,7 +51,7 @@ class cognitive_depth extends activity_base {
     }
 
     public function get_cognitive_depth_level(\cm_info $cm) {
-        return 5;
+        return self::COGNITIVE_LEVEL_5;
     }
 
     /**
index 6bc70d7..45a3d2d 100644 (file)
@@ -51,6 +51,6 @@ class social_breadth extends activity_base {
     }
 
     public function get_social_breadth_level(\cm_info $cm) {
-        return 2;
+        return self::SOCIAL_LEVEL_2;
     }
 }