mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 20:42:22 +02:00
MDL-71796 mod_scorm: fix custom completion logic
AMOS BEGIN MOV [completiondetail:completionstatuscompletedandpassed,mod_scorm],[completiondetail:completionstatuscompletedorpassed,mod_scorm] AMOS END
This commit is contained in:
parent
3610f1ee3b
commit
f7155953f4
@ -67,18 +67,14 @@ class custom_completion extends activity_custom_completion {
|
||||
|
||||
// Get available status list.
|
||||
$statuses = array_flip(\scorm_status_options());
|
||||
$statusbits = 0;
|
||||
|
||||
$requiredcompletionstatusid = $this->cm->customdata['customcompletionrules']['completionstatusrequired'] ?? 0;
|
||||
$isanystatus = ($requiredcompletionstatusid == array_sum($statuses));
|
||||
|
||||
// Check at least one track meets the required completion status value(s).
|
||||
foreach ($tracks as $track) {
|
||||
if (array_key_exists($track->value, $statuses)) {
|
||||
$statusbits |= $statuses[$track->value];
|
||||
}
|
||||
|
||||
// All completion status requirements met.
|
||||
if ($statusbits == $requiredcompletionstatusid) {
|
||||
if (array_key_exists($track->value, $statuses)
|
||||
&& ($isanystatus || $statuses[$track->value] == $requiredcompletionstatusid)) {
|
||||
$status = COMPLETION_COMPLETE;
|
||||
break;
|
||||
}
|
||||
@ -193,7 +189,7 @@ class custom_completion extends activity_custom_completion {
|
||||
$statusrequired = $statusstrings[$completionstatusid];
|
||||
} else {
|
||||
// All statuses required.
|
||||
$statusrequired = 'completedandpassed';
|
||||
$statusrequired = 'completedorpassed';
|
||||
}
|
||||
|
||||
return [
|
||||
|
@ -83,7 +83,7 @@ $string['compatibilitysettings'] = 'Compatibility settings';
|
||||
$string['completed'] = 'Completed';
|
||||
$string['completiondetail:completionstatuspassed'] = 'Pass the activity';
|
||||
$string['completiondetail:completionstatuscompleted'] = 'Complete the activity';
|
||||
$string['completiondetail:completionstatuscompletedandpassed'] = 'Complete and pass the activity';
|
||||
$string['completiondetail:completionstatuscompletedorpassed'] = 'Complete or pass the activity';
|
||||
$string['completiondetail:completionscore'] = 'Receive a score of {$a} or more';
|
||||
$string['completiondetail:allscos'] = 'Do all parts of this activity';
|
||||
$string['completionscorerequired'] = 'Require minimum score';
|
||||
|
@ -50,7 +50,7 @@ Feature: View activity completion in the SCORM activity
|
||||
And "Music history" should have the "Receive a score of 3 or more" completion condition
|
||||
And "Music history" should have the "Do all parts of this activity" completion condition
|
||||
And "Music history" should have the "Receive a grade" completion condition
|
||||
And "Music history" should have the "Complete and pass the activity" completion condition
|
||||
And "Music history" should have the "Complete or pass the activity" completion condition
|
||||
|
||||
@javascript
|
||||
Scenario: View automatic completion items as a student
|
||||
@ -61,7 +61,7 @@ Feature: View activity completion in the SCORM activity
|
||||
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 "todo"
|
||||
And the "Receive a grade" completion condition of "Music history" is displayed as "todo"
|
||||
And the "Complete and pass the activity" completion condition of "Music history" is displayed as "todo"
|
||||
And the "Complete or pass the activity" completion condition of "Music history" is displayed as "todo"
|
||||
And I press "Enter"
|
||||
And I switch to the main frame
|
||||
And I click on "Par?" "list_item"
|
||||
@ -93,7 +93,7 @@ Feature: View activity completion in the SCORM activity
|
||||
And the "Receive a score of 3 or more" completion condition of "Music history" is displayed as "failed"
|
||||
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 and pass the activity" completion condition of "Music history" is displayed as "failed"
|
||||
And the "Complete or pass the activity" completion condition of "Music history" is displayed as "done"
|
||||
|
||||
@javascript
|
||||
Scenario: Use manual completion
|
||||
|
@ -104,20 +104,26 @@ class custom_completion_test extends advanced_testcase {
|
||||
'Completion status Completed required, user has completed' => [
|
||||
'completionstatusrequired', 4, [$completioncompleted], 1, COMPLETION_COMPLETE, null
|
||||
],
|
||||
'Completion status Passed and Completed required, user has only completed, can make another attempt' => [
|
||||
'completionstatusrequired', 6, [$completioncompleted], 0, COMPLETION_INCOMPLETE, null
|
||||
'Completion status Passed or Completed required, user has only completed, can make another attempt' => [
|
||||
'completionstatusrequired', 6, [$completioncompleted], 0, COMPLETION_COMPLETE, null
|
||||
],
|
||||
'Completion status Passed and Completed required, user has completed and passed' => [
|
||||
'Completion status Passed or Completed required, user has completed and passed' => [
|
||||
'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
|
||||
],
|
||||
'Completion status Passed or Completed required, user has used all attempts, but not passed or completed' => [
|
||||
'completionstatusrequired', 6, [$completionincomplete], 1, COMPLETION_COMPLETE_FAIL, null
|
||||
],
|
||||
'Completion status Passed required, user has used all attempts and completed, but not passed' => [
|
||||
'completionstatusrequired', 2, [$completioncompleted], 1, COMPLETION_COMPLETE_FAIL, null
|
||||
],
|
||||
'Completion status Completed required, user has used all attempts, but not completed' => [
|
||||
'completionstatusrequired', 4, [$completionincomplete], 1, COMPLETION_COMPLETE_FAIL, null
|
||||
],
|
||||
'Completion status Passed and Completed required, user has used all attempts, but not passed' => [
|
||||
'completionstatusrequired', 6, [$completionincomplete, $completioncompleted], 2, COMPLETION_COMPLETE_FAIL, null
|
||||
'Completion status Passed or Completed required, user has used all attempts, but not passed' => [
|
||||
'completionstatusrequired', 6, [$completionincomplete, $completioncompleted], 2, COMPLETION_COMPLETE, null
|
||||
],
|
||||
'Completion score required, user has no score' => [
|
||||
'completionscorerequired', 80, [], 0, COMPLETION_INCOMPLETE, null
|
||||
|
Loading…
x
Reference in New Issue
Block a user