-
Bug
-
Resolution: Fixed
-
Major
-
3.5.5, 3.6.3, 3.7
-
MOODLE_35_STABLE, MOODLE_36_STABLE, MOODLE_37_STABLE
-
MOODLE_36_STABLE, MOODLE_37_STABLE
-
MDL-65067_master -
Easy
-
In /analytics/classes/local/community_of_inquiry_activity.php, at line 836; the format_weeks is detected using the mere existance of the 'get_section_dates' method:
// When the course is using format weeks we use the week's end date. |
$format = course_get_format($activity->get_modinfo()->get_course()); |
// We should change this in MDL-60702. |
if (method_exists($format, 'get_section_dates')) { |
$dates = $format->get_section_dates($section); |
When format_topcoll is also installed, the get_section_dates($section) call will fail because format_topcoll's get_section_dates() takes three arguments:
public function get_section_dates($section, $course, $tcsettings) { |
So what happened here is that:
- format_base does not declare the get_section_dates() method; it's therefore OK for both format_weeks and format_topcoll to declare it, with any public interface as they see fit. (Point is, they take different inputs and output differently too).
- the community_of_inquiry_activity class tries to detect format_weeks' presence by checking if the method exist. When the method exist, it will call it, with only one argument; and this breaks when the format implements it with a different API (such as format_topcoll).
What can be done?
- the detection of format_weeks in the community_of_inquiry_activity class should be changed to also check that the format is the expected one.
- format_base could declare a new non-abstract get_section_dates() method.
A symptom of that problem was that any run of the tool_analytics\task\train_models scheduled task threw a coding error:
A lock was created but not released at:
|
[dirroot]/analytics/classes/dataset_manager.php on line 133
|
|
Code should look like:
|
$factory = \core\lock\lock_config::get_lock_factory('type'); |
$lock = $factory->get_lock(503195); |
$lock->release(); // Locks must ALWAYS be released like this. |
The lock was not released because the function call just exploded.