mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
MDL-59779 analytics: Reduce community of inquiry indicators db queries
This commit is contained in:
parent
05c3727674
commit
fbc889a268
@ -121,6 +121,22 @@ abstract class base extends \core_analytics\calculable {
|
||||
return self::MIN_VALUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook to allow indicators to pre-fill data that is shared accross time range calculations.
|
||||
*
|
||||
* Useful to fill analysable-dependant data that does not depend on the time ranges. Use
|
||||
* instance vars to cache data that can be re-used across samples calculations but changes
|
||||
* between time ranges (indicator instances are reset between time ranges to avoid unexpected
|
||||
* problems).
|
||||
*
|
||||
* You are also responsible of emptying previous analysable caches.
|
||||
*
|
||||
* @param \core_analytics\analysable $analysable
|
||||
* @return void
|
||||
*/
|
||||
public function fill_per_analysable_caches(\core_analytics\analysable $analysable) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the indicator.
|
||||
*
|
||||
|
@ -60,6 +60,20 @@ abstract class community_of_inquiry_activity extends linear {
|
||||
*/
|
||||
const INDICATOR_SOCIAL = "social";
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
@ -396,8 +410,8 @@ abstract class community_of_inquiry_activity extends linear {
|
||||
}
|
||||
|
||||
if ($this->grades === null) {
|
||||
$courseactivities = $this->course->get_all_activities($this->get_activity_type());
|
||||
$this->grades = $this->course->get_student_grades($courseactivities);
|
||||
// Even if this is probably already filled during fill_per_analysable_caches.
|
||||
$this->fetch_student_grades($this->course);
|
||||
}
|
||||
|
||||
if ($cm = $this->retrieve('cm', $sampleid)) {
|
||||
@ -645,6 +659,17 @@ abstract class community_of_inquiry_activity extends linear {
|
||||
throw new \coding_exception("Indicator type is invalid.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the course student grades.
|
||||
*
|
||||
* @param \core_analytics\course $course
|
||||
* @return void
|
||||
*/
|
||||
protected function fetch_student_grades(\core_analytics\course $course) {
|
||||
$courseactivities = $course->get_all_activities($this->get_activity_type());
|
||||
$this->grades = $course->get_student_grades($courseactivities);
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines indicator type.
|
||||
*
|
||||
|
@ -201,6 +201,9 @@ abstract class base {
|
||||
// Fill the dataset samples with indicators data.
|
||||
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) {
|
||||
|
||||
|
@ -34,4 +34,13 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
abstract class activity_base extends \core_analytics\local\indicator\community_of_inquiry_activity {
|
||||
|
||||
/**
|
||||
* No need to fetch grades for resources.
|
||||
*
|
||||
* @param \core_analytics\course $course
|
||||
* @return void
|
||||
*/
|
||||
public function fetch_student_grades(\core_analytics\course $course) {
|
||||
}
|
||||
}
|
||||
|
@ -34,4 +34,13 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
abstract class activity_base extends \core_analytics\local\indicator\community_of_inquiry_activity {
|
||||
|
||||
/**
|
||||
* No need to fetch grades for resources.
|
||||
*
|
||||
* @param \core_analytics\course $course
|
||||
* @return void
|
||||
*/
|
||||
public function fetch_student_grades(\core_analytics\course $course) {
|
||||
}
|
||||
}
|
||||
|
@ -34,4 +34,13 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
abstract class activity_base extends \core_analytics\local\indicator\community_of_inquiry_activity {
|
||||
|
||||
/**
|
||||
* No need to fetch grades for resources.
|
||||
*
|
||||
* @param \core_analytics\course $course
|
||||
* @return void
|
||||
*/
|
||||
public function fetch_student_grades(\core_analytics\course $course) {
|
||||
}
|
||||
}
|
||||
|
@ -34,4 +34,13 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
abstract class activity_base extends \core_analytics\local\indicator\community_of_inquiry_activity {
|
||||
|
||||
/**
|
||||
* No need to fetch grades for resources.
|
||||
*
|
||||
* @param \core_analytics\course $course
|
||||
* @return void
|
||||
*/
|
||||
public function fetch_student_grades(\core_analytics\course $course) {
|
||||
}
|
||||
}
|
||||
|
@ -34,4 +34,13 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
abstract class activity_base extends \core_analytics\local\indicator\community_of_inquiry_activity {
|
||||
|
||||
/**
|
||||
* No need to fetch grades for resources.
|
||||
*
|
||||
* @param \core_analytics\course $course
|
||||
* @return void
|
||||
*/
|
||||
public function fetch_student_grades(\core_analytics\course $course) {
|
||||
}
|
||||
}
|
||||
|
@ -34,4 +34,13 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
abstract class activity_base extends \core_analytics\local\indicator\community_of_inquiry_activity {
|
||||
|
||||
/**
|
||||
* No need to fetch grades for resources.
|
||||
*
|
||||
* @param \core_analytics\course $course
|
||||
* @return void
|
||||
*/
|
||||
public function fetch_student_grades(\core_analytics\course $course) {
|
||||
}
|
||||
}
|
||||
|
@ -34,4 +34,13 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
abstract class activity_base extends \core_analytics\local\indicator\community_of_inquiry_activity {
|
||||
|
||||
/**
|
||||
* No need to fetch grades.
|
||||
*
|
||||
* @param \core_analytics\course $course
|
||||
* @return void
|
||||
*/
|
||||
public function fetch_student_grades(\core_analytics\course $course) {
|
||||
}
|
||||
}
|
||||
|
@ -34,4 +34,13 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
abstract class activity_base extends \core_analytics\local\indicator\community_of_inquiry_activity {
|
||||
|
||||
/**
|
||||
* No need to fetch grades for resources.
|
||||
*
|
||||
* @param \core_analytics\course $course
|
||||
* @return void
|
||||
*/
|
||||
public function fetch_student_grades(\core_analytics\course $course) {
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user