MDL-80209 mod_scorm: Save minimum score completion
This commit is contained in:
@@ -157,7 +157,7 @@ Feature: Allow teachers to edit the default activity completion rules in a cours
|
||||
And I set the following fields to these values:
|
||||
| id_completion_scorm_2 | 1 |
|
||||
| completionview_scorm | 0 |
|
||||
| completionscoredisabled | 1 |
|
||||
| completionscoreenabled_scorm | 1 |
|
||||
| completionscorerequired_scorm | 3 |
|
||||
| completionstatusrequired_scorm[2] | 1 |
|
||||
| completionstatusrequired_scorm[4] | 0 |
|
||||
@@ -187,14 +187,17 @@ Feature: Allow teachers to edit the default activity completion rules in a cours
|
||||
And the field "completionview_assign" matches value "0"
|
||||
And the field "completionusegrade_assign" matches value "0"
|
||||
And the field "completionsubmit_assign" matches value "1"
|
||||
And I click on "Expand Forum" "button"
|
||||
And the field "id_completion_forum_2" matches value "1"
|
||||
And the field "completionview_forum" matches value "0"
|
||||
And the field "completionpostsenabled_forum" matches value "1"
|
||||
And the field "completionposts_forum" matches value "3"
|
||||
And the field "completiondiscussionsenabled_forum" matches value "0"
|
||||
And the field "completionrepliesenabled_forum" matches value "0"
|
||||
And I click on "Expand SCORM package" "button"
|
||||
And the field "id_completion_scorm_2" matches value "1"
|
||||
And the field "completionview_scorm" matches value "0"
|
||||
And the field "completionscoreenabled_scorm" matches value "1"
|
||||
And the field "completionscorerequired_scorm" matches value "3"
|
||||
And the field "completionstatusrequired_scorm[2]" matches value "1"
|
||||
And the field "completionstatusrequired_scorm[4]" matches value "0"
|
||||
|
||||
@@ -81,10 +81,18 @@ class bulk_update_test extends \advanced_testcase {
|
||||
'resource-1' => ['resource', ['completion' => COMPLETION_TRACKING_AUTOMATIC, 'completionview' => 1]],
|
||||
'resource-2' => ['resource', ['completion' => COMPLETION_TRACKING_MANUAL]],
|
||||
'scorm-1' => ['scorm',
|
||||
['completion' => COMPLETION_TRACKING_AUTOMATIC, 'completionscorerequired' => 1,
|
||||
'completionstatusrequired' => [2 => 'passed']],
|
||||
['completion' => COMPLETION_TRACKING_AUTOMATIC, 'completionscorerequired' => 1,
|
||||
'completionstatusrequired' => 2]],
|
||||
[
|
||||
'completion' => COMPLETION_TRACKING_AUTOMATIC,
|
||||
'completionscoreenabled' => 1,
|
||||
'completionscorerequired' => 1,
|
||||
'completionstatusrequired' => [2 => 'passed'],
|
||||
],
|
||||
[
|
||||
'completion' => COMPLETION_TRACKING_AUTOMATIC,
|
||||
'completionscorerequired' => 1,
|
||||
'completionstatusrequired' => 2,
|
||||
],
|
||||
],
|
||||
'scorm-2' => ['scorm', ['completion' => COMPLETION_TRACKING_MANUAL]],
|
||||
'survey-1' => ['survey', ['completion' => COMPLETION_TRACKING_AUTOMATIC, 'completionsubmit' => 1]],
|
||||
'survey-2' => ['survey', ['completion' => COMPLETION_TRACKING_MANUAL]],
|
||||
|
||||
@@ -354,9 +354,9 @@ class mod_scorm_mod_form extends moodleform_mod {
|
||||
}
|
||||
|
||||
$completionscorerequiredel = 'completionscorerequired' . $suffix;
|
||||
if (!isset($defaultvalues[$completionscorerequiredel]) || !strlen($defaultvalues[$completionscorerequiredel])) {
|
||||
$completionscoredisabledel = 'completionscoredisabled' . $suffix;
|
||||
$defaultvalues[$completionscoredisabledel] = 1;
|
||||
if (isset($defaultvalues[$completionscorerequiredel])) {
|
||||
$completionscoreenabledel = 'completionscoreenabled' . $suffix;
|
||||
$defaultvalues[$completionscoreenabledel] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -507,9 +507,10 @@ class mod_scorm_mod_form extends moodleform_mod {
|
||||
// Require score.
|
||||
$group = [];
|
||||
$completionscorerequiredel = 'completionscorerequired' . $suffix;
|
||||
$completionscoreenabledel = 'completionscoreenabled' . $suffix;
|
||||
$group[] =& $mform->createElement(
|
||||
'checkbox',
|
||||
'completionscoredisabled',
|
||||
$completionscoreenabledel,
|
||||
null,
|
||||
get_string('completionscorerequired', 'scorm')
|
||||
);
|
||||
@@ -517,7 +518,7 @@ class mod_scorm_mod_form extends moodleform_mod {
|
||||
$mform->setType($completionscorerequiredel, PARAM_INT);
|
||||
$completionscoregroupel = 'completionscoregroup' . $suffix;
|
||||
$mform->addGroup($group, $completionscoregroupel, '', '', false);
|
||||
$mform->hideIf($completionscorerequiredel, 'completionscoredisabled', 'notchecked');
|
||||
$mform->hideIf($completionscorerequiredel, $completionscoreenabledel, 'notchecked');
|
||||
$mform->setDefault($completionscorerequiredel, 0);
|
||||
|
||||
$items[] = $completionscoregroupel;
|
||||
@@ -545,7 +546,7 @@ class mod_scorm_mod_form extends moodleform_mod {
|
||||
public function completion_rule_enabled($data) {
|
||||
$suffix = $this->get_suffix();
|
||||
$status = !empty($data['completionstatusrequired' . $suffix]);
|
||||
$score = empty($data['completionscoredisabled' . $suffix]) && strlen($data['completionscorerequired' . $suffix]);
|
||||
$score = !empty($data['completionscoreenabled' . $suffix]) && strlen($data['completionscorerequired' . $suffix]);
|
||||
|
||||
return $status || $score;
|
||||
}
|
||||
@@ -585,7 +586,7 @@ class mod_scorm_mod_form extends moodleform_mod {
|
||||
}
|
||||
// Else do nothing: completionstatusrequired has been already converted into a correct integer representation.
|
||||
|
||||
if (!empty($data->{'completionscoredisabled' . $suffix}) || !$autocompletion) {
|
||||
if (!(isset($data->{'completionscoreenabled' . $suffix}) && $autocompletion)) {
|
||||
$data->{'completionscorerequired' . $suffix} = null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user