Skip to content

Commit

Permalink
remove backport of class cm_completion_details which was introduced i…
Browse files Browse the repository at this point in the history
…n Moodle 4.3
  • Loading branch information
Glutamat42 committed Oct 18, 2024
1 parent 35dc785 commit 2703fde
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 80 deletions.
3 changes: 1 addition & 2 deletions classes/adler_score.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use cm_info;
use context_course;
use dml_exception;
use local_adler\local\backport\backport_cm_completion_details;
use local_adler\local\db\adler_course_module_repository;
use local_adler\local\exceptions\not_an_adler_cm_exception;
use local_adler\local\exceptions\user_not_enrolled_exception;
Expand Down Expand Up @@ -66,7 +65,7 @@ public function __construct(cm_info $course_module, int $user_id = null) {
* @throws moodle_exception If completion is not enabled for the course module.
*/
public function get_score_by_completion_state(): float {
$cm_completion_details = backport_cm_completion_details::get_instance(
$cm_completion_details = cm_completion_details::get_instance(
get_fast_modinfo($this->course_module->course)->get_cm($this->course_module->id),
$this->user_id
);
Expand Down
71 changes: 0 additions & 71 deletions classes/local/backport/backport_cm_completion_details.php

This file was deleted.

5 changes: 2 additions & 3 deletions tests/external/trigger_event_cm_viewed_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@


use local_adler\lib\adler_externallib_testcase;
use local_adler\local\backport\backport_cm_completion_details;
use local_adler\local\exceptions\not_an_adler_cm_exception;
use local_adler\local\exceptions\not_an_adler_course_exception;
use stdClass;
Expand Down Expand Up @@ -87,12 +86,12 @@ public function test_execute_integration() {

// assert both modules are marked as viewed
$resource_cm_info = get_fast_modinfo($this->course->id)->get_cm($this->resource_module->cmid);
$resource_view_state = backport_cm_completion_details::get_instance($resource_cm_info, $this->user->id);
$resource_view_state = cm_completion_details::get_instance($resource_cm_info, $this->user->id);
$this->assertEquals(1, $resource_view_state->get_details()['completionview']->status);
$this->assertTrue($resource_view_state->is_overall_complete());

$h5p_cm_info = get_fast_modinfo($this->course->id)->get_cm($this->h5p_module->cmid);
$h5p_view_state = backport_cm_completion_details::get_instance($h5p_cm_info, $this->user->id);
$h5p_view_state = cm_completion_details::get_instance($h5p_cm_info, $this->user->id);
// $this->assertEquals(1, $h5p_view_state->get_details()['completionview']->status); // "viewed" is not tracked if it is not a completion criteria
$this->assertFalse($h5p_view_state->is_overall_complete());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
global $CFG;

use local_adler\lib\adler_testcase;
use local_adler\local\backport\backport_cm_completion_details;
use local_adler\local\exceptions\not_an_adler_course_exception;
use local_adler\local\upgrade\upgrade_3_2_0_to_4_0_0_completionlib;

Expand Down Expand Up @@ -146,7 +145,7 @@ public function test_with_user_attempt() {
$completion = new completion_info($course);
$completion->update_state(get_fast_modinfo($course)->get_cm($module->cmid), COMPLETION_COMPLETE, $user->id);
// verify element is completed for user
$h5p_completion_state = backport_cm_completion_details::get_instance(
$h5p_completion_state = cm_completion_details::get_instance(
get_fast_modinfo($course)->get_cm($module->cmid),
$user->id
);
Expand All @@ -162,7 +161,7 @@ public function test_with_user_attempt() {
$this->assertEquals(0, $cm->completionview);

// verify element is still completed
$h5p_completion_state = backport_cm_completion_details::get_instance( // has to be recreated to reflect completion state change
$h5p_completion_state = cm_completion_details::get_instance( // has to be recreated to reflect completion state change
get_fast_modinfo($course)->get_cm($module->cmid),
$user->id
);
Expand All @@ -171,7 +170,7 @@ public function test_with_user_attempt() {
// create attempt
$this->create_h5p_attempt($module, $course->id, $user->id);
// verify element is still completed
$h5p_completion_state = backport_cm_completion_details::get_instance( // has to be recreated to reflect completion state change
$h5p_completion_state = cm_completion_details::get_instance( // has to be recreated to reflect completion state change
get_fast_modinfo($course)->get_cm($module->cmid),
$user->id
);
Expand Down

0 comments on commit 2703fde

Please sign in to comment.