diff --git a/course/format/tests/behat/courseindex_completion.feature b/course/format/tests/behat/courseindex_completion.feature index 74e2e52d531..c3e8fc496ee 100644 --- a/course/format/tests/behat/courseindex_completion.feature +++ b/course/format/tests/behat/courseindex_completion.feature @@ -150,47 +150,3 @@ Feature: Course index completion icons | 1 | False | When I am on the "C1" "Course" page logged in as "student1" And "Done" "icon" should exist in the "courseindex-content" "region" - - @javascript - Scenario: Activities with custom completion rules could fail - Given the following "activity" exists: - | activity | scorm | - | course | C1 | - | name | Music history | - | packagefilepath | mod/scorm/tests/packages/RuntimeMinimumCalls_SCORM12-mini.zip | - | maxattempt | 1 | - | latattemptlock | 1 | - # Add requirements - | completion | 2 | - | completionscorerequired | 90 | - Given I am on the "Music history" "scorm activity" page logged in as student1 - # We need a little taller window because Firefox is, apparently, unable to auto-scroll within - # an iframe, so we need to ensure that the "Save changes" button is visible in the viewport. - And I change window size to "large" - And I press "Enter" - And I switch to the main frame - And I click on "Par?" "list_item" - And I switch to "scorm_object" iframe - And I wait until the page is ready - And I switch to the main frame - And I click on "Keeping Score" "list_item" - And I switch to "scorm_object" iframe - And I wait until the page is ready - And I switch to the main frame - And I click on "Other Scoring Systems" "list_item" - And I switch to "scorm_object" iframe - And I wait until the page is ready - And I switch to the main frame - And I click on "The Rules of Golf" "list_item" - And I switch to "scorm_object" iframe - And I wait until the page is ready - And I switch to the main frame - And I click on "Playing Golf Quiz" "list_item" - And I switch to "scorm_object" iframe - And I wait until the page is ready - And I click on "[id='question_com.scorm.golfsamples.interactions.playing_1_1']" "css_element" - And I press "Submit Answers" - And I wait until "Score: 20" "text" exists - And I switch to the main frame - And I click on "Exit activity" "link" - And "Failed" "icon" should exist in the "courseindex-content" "region" diff --git a/mod/scorm/classes/completion/custom_completion.php b/mod/scorm/classes/completion/custom_completion.php index 92e41feb310..074a6e9bdec 100644 --- a/mod/scorm/classes/completion/custom_completion.php +++ b/mod/scorm/classes/completion/custom_completion.php @@ -148,16 +148,6 @@ class custom_completion extends activity_custom_completion { break; } - // If not yet meeting the requirement and no attempts remain to complete it, mark it as failed. - if ($status === COMPLETION_INCOMPLETE) { - $scorm = $DB->get_record('scorm', ['id' => $this->cm->instance]); - $attemptcount = scorm_get_attempt_count($this->userid, $scorm); - - if ($scorm->maxattempt > 0 && $attemptcount >= $scorm->maxattempt) { - $status = COMPLETION_COMPLETE_FAIL; - } - } - return $status; } @@ -217,4 +207,3 @@ class custom_completion extends activity_custom_completion { ]; } } - diff --git a/mod/scorm/tests/behat/scorm_activity_completion.feature b/mod/scorm/tests/behat/scorm_activity_completion.feature index c460f0a478e..9ee16648d0f 100644 --- a/mod/scorm/tests/behat/scorm_activity_completion.feature +++ b/mod/scorm/tests/behat/scorm_activity_completion.feature @@ -110,8 +110,9 @@ Feature: View activity completion in the SCORM activity And I switch to the main frame When I am on the "Music history" "scorm activity" page Then the "View" completion condition of "Music history" is displayed as "done" - # Conditions that are not possible to achieve (eg score below requirement but all attempts used) are marked as failed. - And the "Receive a score of 3 or more" completion condition of "Music history" is displayed as "failed" + # Conditions that are not possible to achieve (eg score below requirement but all attempts used) are still marked as todo. + # this is because the SCORM does not return a score and also that the completion is not possible anymore (as all attempts are used). + And the "Receive a score of 3 or more" completion condition of "Music history" is displayed as "todo" And the "Do all parts of this activity" completion condition of "Music history" is displayed as "done" And the "Receive a grade" completion condition of "Music history" is displayed as "done" And the "Complete or pass the activity" completion condition of "Music history" is displayed as "done" diff --git a/mod/scorm/tests/custom_completion_test.php b/mod/scorm/tests/custom_completion_test.php index 8f0add11d4b..3947f7f6f70 100644 --- a/mod/scorm/tests/custom_completion_test.php +++ b/mod/scorm/tests/custom_completion_test.php @@ -84,67 +84,67 @@ final class custom_completion_test extends advanced_testcase { return [ 'Undefined completion requirement' => [ - 'somenonexistentrule', COMPLETION_ENABLED, [$completionincomplete], 0, null, coding_exception::class + 'somenonexistentrule', COMPLETION_ENABLED, [$completionincomplete], 0, null, coding_exception::class, ], 'Completion status requirement not available' => [ - 'completionstatusrequired', COMPLETION_DISABLED, [$completionincomplete], 0, null, moodle_exception::class + 'completionstatusrequired', COMPLETION_DISABLED, [$completionincomplete], 0, null, moodle_exception::class, ], 'Completion status Passed required, user has no completion status recorded' => [ - 'completionstatusrequired', 2, [], 0, COMPLETION_INCOMPLETE, null + 'completionstatusrequired', 2, [], 0, COMPLETION_INCOMPLETE, null, ], 'Completion status Passed required, user has not passed, can make another attempt' => [ - 'completionstatusrequired', 2, [$completionincomplete], 0, COMPLETION_INCOMPLETE, null + 'completionstatusrequired', 2, [$completionincomplete], 0, COMPLETION_INCOMPLETE, null, ], 'Completion status Passed required, user has passed' => [ - 'completionstatusrequired', 2, [$completionpassed], 0, COMPLETION_COMPLETE, null + 'completionstatusrequired', 2, [$completionpassed], 0, COMPLETION_COMPLETE, null, ], 'Completion status Completed required, user has not completed, can make another attempt' => [ - 'completionstatusrequired', 4, [$completionincomplete], 2, COMPLETION_INCOMPLETE, null + 'completionstatusrequired', 4, [$completionincomplete], 2, COMPLETION_INCOMPLETE, null, ], 'Completion status Completed required, user has completed' => [ - 'completionstatusrequired', 4, [$completioncompleted], 1, COMPLETION_COMPLETE, null + 'completionstatusrequired', 4, [$completioncompleted], 1, COMPLETION_COMPLETE, null, ], 'Completion status Passed or Completed required, user has only completed, can make another attempt' => [ - 'completionstatusrequired', 6, [$completioncompleted], 0, COMPLETION_COMPLETE, null + 'completionstatusrequired', 6, [$completioncompleted], 0, COMPLETION_COMPLETE, null, ], 'Completion status Passed or Completed required, user has completed and passed' => [ - 'completionstatusrequired', 6, [$completionpassed, $completioncompleted], 0, COMPLETION_COMPLETE, null + 'completionstatusrequired', 6, [$completionpassed, $completioncompleted], 0, COMPLETION_COMPLETE, null, ], 'Completion status Passed or Completed required, user has not passed or completed, but has another attempt' => [ - 'completionstatusrequired', 6, [$completionincomplete], 2, COMPLETION_INCOMPLETE, null + 'completionstatusrequired', 6, [$completionincomplete], 2, COMPLETION_INCOMPLETE, null, ], 'Completion status Passed or Completed required, user has used all attempts, but not passed or completed' => [ - 'completionstatusrequired', 6, [$completionincomplete], 1, COMPLETION_COMPLETE_FAIL, null + 'completionstatusrequired', 6, [$completionincomplete], 1, COMPLETION_INCOMPLETE, null, ], 'Completion status Passed required, user has used all attempts and completed, but not passed' => [ - 'completionstatusrequired', 2, [$completioncompleted], 1, COMPLETION_COMPLETE_FAIL, null + 'completionstatusrequired', 2, [$completioncompleted], 1, COMPLETION_INCOMPLETE, null, ], 'Completion status Completed required, user has used all attempts, but not completed' => [ - 'completionstatusrequired', 4, [$completionincomplete], 1, COMPLETION_COMPLETE_FAIL, null + 'completionstatusrequired', 4, [$completionincomplete], 1, COMPLETION_INCOMPLETE, null, ], 'Completion status Passed or Completed required, user has used all attempts, but not passed' => [ - 'completionstatusrequired', 6, [$completionincomplete, $completioncompleted], 2, COMPLETION_COMPLETE, null + 'completionstatusrequired', 6, [$completionincomplete, $completioncompleted], 2, COMPLETION_COMPLETE, null, ], 'Completion score required, user has no score' => [ - 'completionscorerequired', 80, [], 0, COMPLETION_INCOMPLETE, null + 'completionscorerequired', 80, [], 0, COMPLETION_INCOMPLETE, null, ], 'Completion score required, user score does not meet requirement, can make another attempt' => [ - 'completionscorerequired', 80, [$completionscorefail], 0, COMPLETION_INCOMPLETE, null + 'completionscorerequired', 80, [$completionscorefail], 0, COMPLETION_INCOMPLETE, null, ], 'Completion score required, user has used all attempts, but not reached the score' => [ - 'completionscorerequired', 80, [$completionscorefail], 1, COMPLETION_COMPLETE_FAIL, null + 'completionscorerequired', 80, [$completionscorefail], 1, COMPLETION_INCOMPLETE, null, ], 'Completion score required, user score meets requirement' => [ - 'completionscorerequired', 80, [$completionscorepass], 0, COMPLETION_COMPLETE, null + 'completionscorerequired', 80, [$completionscorepass], 0, COMPLETION_COMPLETE, null, ], 'Completion of all scos required, user has not completed, can make another attempt' => [ - 'completionstatusallscos', 1, [$completionincomplete, $completioncompleted], 3, COMPLETION_INCOMPLETE, null + 'completionstatusallscos', 1, [$completionincomplete, $completioncompleted], 3, COMPLETION_INCOMPLETE, null, ], 'Completion of all scos required, user has completed' => [ - 'completionstatusallscos', 1, [$completionpassed, $completioncompleted], 2, COMPLETION_COMPLETE, null + 'completionstatusallscos', 1, [$completionpassed, $completioncompleted], 2, COMPLETION_COMPLETE, null, ], 'Completion of all scos required, user has used all attempts, but not completed all scos' => [ - 'completionstatusallscos', 1, [$completionincomplete, $completioncompleted], 2, COMPLETION_COMPLETE_FAIL, null + 'completionstatusallscos', 1, [$completionincomplete, $completioncompleted], 2, COMPLETION_INCOMPLETE, null, ], ]; }