MDL-71401 core_completion: Fix completion status caching

When an automatic completion condition may have had its state change,
we now unset the cached value for the user's completion in the relevant
activity, so up-to-date values are re-fetched and available to students.
The previous behaviour was that custom conditions would remain cached
until the activity reached overall completion.
This commit is contained in:
Michael Hawkins
2021-05-04 12:22:36 +08:00
parent 6f48b4ab71
commit 2fdf71ffc7
2 changed files with 20 additions and 6 deletions
+1 -5
View File
@@ -143,6 +143,7 @@ class core_completionlib_testcase extends advanced_testcase {
$c->update_state($cm);
// Enabled, but current state is same as possible result, do nothing.
$cm->completion = COMPLETION_TRACKING_AUTOMATIC;
$c = $mockbuilder->getMock();
$current = (object)array('completionstate' => COMPLETION_COMPLETE, 'overrideby' => null);
$c->expects($this->once())
@@ -151,7 +152,6 @@ class core_completionlib_testcase extends advanced_testcase {
->will($this->returnValue(true));
$c->expects($this->once())
->method('get_data')
->with($cm, false, 0)
->will($this->returnValue($current));
$c->update_state($cm, COMPLETION_COMPLETE);
@@ -165,7 +165,6 @@ class core_completionlib_testcase extends advanced_testcase {
->will($this->returnValue(true));
$c->expects($this->once())
->method('get_data')
->with($cm, false, 0)
->will($this->returnValue($current));
$c->update_state($cm, COMPLETION_COMPLETE);
@@ -179,7 +178,6 @@ class core_completionlib_testcase extends advanced_testcase {
->will($this->returnValue(true));
$c->expects($this->once())
->method('get_data')
->with($cm, false, 0)
->will($this->returnValue($current));
$c->update_state($cm, COMPLETION_COMPLETE);
@@ -191,7 +189,6 @@ class core_completionlib_testcase extends advanced_testcase {
->will($this->returnValue(true));
$c->expects($this->once())
->method('get_data')
->with($cm, false, 0)
->will($this->returnValue($current));
$changed = clone($current);
$changed->timemodified = time();
@@ -213,7 +210,6 @@ class core_completionlib_testcase extends advanced_testcase {
->will($this->returnValue(true));
$c->expects($this->once())
->method('get_data')
->with($cm, false, 0)
->will($this->returnValue($current));
$c->expects($this->once())
->method('internal_get_state')