Merge branch 'MDL-59779_master' of git://github.com/dmonllao/moodle
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Tue, 29 Aug 2017 23:09:20 +0000 (01:09 +0200)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Tue, 29 Aug 2017 23:09:20 +0000 (01:09 +0200)
1  2 
analytics/classes/local/indicator/base.php
analytics/classes/local/indicator/community_of_inquiry_activity.php
analytics/classes/local/target/base.php
analytics/classes/local/time_splitting/base.php
analytics/classes/model.php

@@@ -60,16 -60,20 +60,30 @@@ abstract class community_of_inquiry_act
       */
      const INDICATOR_SOCIAL = "social";
  
 +    /**
 +     * Max cognitive depth level accepted.
 +     */
 +    const MAX_COGNITIVE_LEVEL = 5;
 +
 +    /**
 +     * Max social breadth level accepted.
 +     */
 +    const MAX_SOCIAL_LEVEL = 5;
 +
+     /**
+      * Fetch the course grades of this activity type instances.
+      *
+      * @param \core_analytics\analysable $analysable
+      * @return void
+      */
+     public function fill_per_analysable_caches(\core_analytics\analysable $analysable) {
+         // Better to check it, we can not be 100% it will be a \core_analytics\course object.
+         if ($analysable instanceof \core_analytics\course) {
+             $this->fetch_student_grades($analysable);
+         }
+     }
      /**
       * Returns the activity type. No point in changing this class in children classes.
       *
@@@ -223,18 -198,12 +223,21 @@@ abstract class base 
  
          $dataset = array();
  
 +        // Faster to run 1 db query per range.
 +        $existingcalculations = array();
 +        foreach ($ranges as $rangeindex => $range) {
 +            // Load existing calculations.
 +            $existingcalculations[$rangeindex] = \core_analytics\manager::get_indicator_calculations($this->analysable,
 +                $range['start'], $range['end'], $samplesorigin);
 +        }
 +
          // Fill the dataset samples with indicators data.
 +        $newcalculations = array();
          foreach ($indicators as $indicator) {
  
+             // Hook to allow indicators to store analysable-dependant data.
+             $indicator->fill_per_analysable_caches($this->analysable);
              // Per-range calculations.
              foreach ($ranges as $rangeindex => $range) {
  
Simple merge