mirror of
https://github.com/moodle/moodle.git
synced 2025-04-07 09:23:31 +02:00
Merge branch 'MDL-79971-404' of https://github.com/aanabit/moodle into MOODLE_404_STABLE
This commit is contained in:
commit
cf92d64a57
@ -1631,11 +1631,12 @@ class completion_info {
|
||||
$data->coursemoduleid = $data->cmvcoursemoduleid;
|
||||
$data->userid = $data->cmvuserid;
|
||||
}
|
||||
// When reseting all state in the completion, we need to keep current view state.
|
||||
// We cannot assume the activity has been viewed, so we should check if there is any course_modules_viewed already.
|
||||
$data->viewed = is_null($data->cmvuserid) ? 0 : 1;
|
||||
|
||||
unset($data->cmvcoursemoduleid);
|
||||
unset($data->cmvuserid);
|
||||
|
||||
// When reseting all state in the completion, we need to keep current view state.
|
||||
$data->viewed = 1;
|
||||
}
|
||||
|
||||
return (array)$data;
|
||||
|
@ -876,6 +876,7 @@ class completionlib_test extends advanced_testcase {
|
||||
* @covers ::get_completion_data
|
||||
*/
|
||||
public function test_get_completion_data(): void {
|
||||
$this->setAdminUser();
|
||||
$this->setup_data();
|
||||
$choicegenerator = $this->getDataGenerator()->get_plugin_generator('mod_choice');
|
||||
$choice = $choicegenerator->create_instance([
|
||||
@ -905,6 +906,11 @@ class completionlib_test extends advanced_testcase {
|
||||
$this->assertEquals(0, $completiondatabeforeview['viewed']);
|
||||
$this->assertEquals($cm->id, $completiondatabeforeview['coursemoduleid']);
|
||||
|
||||
// Mark as completed before viewing it.
|
||||
$completioninfo->update_state($cm, COMPLETION_COMPLETE, $this->user->id, true);
|
||||
$completiondatabeforeview = $completioninfo->get_completion_data($cm->id, $this->user->id, $defaultdata);
|
||||
$this->assertEquals(0, $completiondatabeforeview['viewed']);
|
||||
|
||||
// Set viewed.
|
||||
$completioninfo->set_module_viewed($cm, $this->user->id);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user