diff --git a/mod/assign/classes/output/assign_submission_status.php b/mod/assign/classes/output/assign_submission_status.php index 1ab6c02da35..7be979424df 100644 --- a/mod/assign/classes/output/assign_submission_status.php +++ b/mod/assign/classes/output/assign_submission_status.php @@ -87,9 +87,9 @@ class assign_submission_status implements \renderable { /** @var string gradingcontrollerpreview */ public $gradingcontrollerpreview = ''; /** @var string attemptreopenmethod */ - public $attemptreopenmethod = 'none'; + public $attemptreopenmethod; /** @var int maxattempts */ - public $maxattempts = -1; + public $maxattempts; /** @var string gradingstatus */ public $gradingstatus = ''; /** @var bool preventsubmissionnotingroup */ diff --git a/mod/assign/classes/output/renderer.php b/mod/assign/classes/output/renderer.php index 7e78350f1b4..b280f771ed5 100644 --- a/mod/assign/classes/output/renderer.php +++ b/mod/assign/classes/output/renderer.php @@ -675,7 +675,8 @@ class renderer extends \plugin_renderer_base { $this->add_table_row_tuple($t, $cell1content, $cell2content); } - if ($status->attemptreopenmethod != ASSIGN_ATTEMPT_REOPEN_METHOD_NONE) { + // If multiple attempts are allowed. + if ($status->maxattempts > 1 || $status->maxattempts == ASSIGN_UNLIMITED_ATTEMPTS) { $currentattempt = 1; if (!$status->teamsubmissionenabled) { if ($status->submission) { diff --git a/mod/assign/db/install.xml b/mod/assign/db/install.xml old mode 100644 new mode 100755 index 363c356f195..8d18486e143 --- a/mod/assign/db/install.xml +++ b/mod/assign/db/install.xml @@ -1,5 +1,5 @@ - @@ -30,8 +30,8 @@ - - + + diff --git a/mod/assign/db/upgrade.php b/mod/assign/db/upgrade.php index 1d99bf7f492..1d722b5bc2c 100644 --- a/mod/assign/db/upgrade.php +++ b/mod/assign/db/upgrade.php @@ -66,5 +66,48 @@ function xmldb_assign_upgrade($oldversion) { // Automatically generated Moodle v4.4.0 release upgrade line. // Put any upgrade step following this. + if ($oldversion < 2024042201) { + // The 'Never' ('none') option for the additional attempts (attemptreopenmethod) setting is no longer supported + // and needs to be updated in all relevant instances. + + // The default value for the 'attemptreopenmethod' field in the 'assign' database table is currently set to 'none', + // This needs to be updated to 'untilpass' to ensure the system functions correctly. Additionally, the default + // value for the 'maxattempts' field needs to be changed to '1' to prevent multiple attempts and maintain the + // original behavior. + $table = new xmldb_table('assign'); + $attemptreopenmethodfield = new xmldb_field('attemptreopenmethod', XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, + null, 'untilpass'); + $maxattemptsfield = new xmldb_field('maxattempts', XMLDB_TYPE_INTEGER, '6', null, XMLDB_NOTNULL, + null, '1'); + $dbman->change_field_default($table, $attemptreopenmethodfield); + $dbman->change_field_default($table, $maxattemptsfield); + + // If the current value for the 'attemptreopenmethod' global configuration in the assignment is set to 'none'. + if (get_config('assign', 'attemptreopenmethod') == 'none') { + // Reset the value to 'untilpass'. + set_config('attemptreopenmethod', 'untilpass', 'assign'); + // Also, setting the value for the 'maxattempts' global config in the assignment to '1' ensures that the + // original behaviour is preserved by disallowing any additional attempts by default. + set_config('maxattempts', 1, 'assign'); + } + + // Update all the current assignment instances that have their 'attemptreopenmethod' set to 'none'. + // By setting 'maxattempts' to 1, additional attempts are disallowed, preserving the original behavior. + $DB->execute( + 'UPDATE {assign} + SET attemptreopenmethod = :newattemptreopenmethod, + maxattempts = :maxattempts + WHERE attemptreopenmethod = :oldattemptreopenmethod', + [ + 'newattemptreopenmethod' => 'untilpass', + 'maxattempts' => 1, + 'oldattemptreopenmethod' => 'none', + ] + ); + + // Assign savepoint reached. + upgrade_mod_savepoint(true, 2024042201, 'assign'); + } + return true; } diff --git a/mod/assign/feedback/editpdf/tests/behat/view_previous_annotations.feature b/mod/assign/feedback/editpdf/tests/behat/view_previous_annotations.feature index e51a94c2c6e..2ecbff48824 100644 --- a/mod/assign/feedback/editpdf/tests/behat/view_previous_annotations.feature +++ b/mod/assign/feedback/editpdf/tests/behat/view_previous_annotations.feature @@ -28,6 +28,7 @@ Feature: In an assignment, teacher can view the feedback for a previous attempt. | assignsubmission_file_maxsizebytes | 102400 | | assignfeedback_editpdf_enabled | 1 | | submissiondrafts | 0 | + | maxattempts | -1 | | attemptreopenmethod | manual | And the following "mod_assign > submission" exists: | assign | Test assignment name | diff --git a/mod/assign/gradingbatchoperationsform.php b/mod/assign/gradingbatchoperationsform.php index a6386fc669c..b816e4b8f24 100644 --- a/mod/assign/gradingbatchoperationsform.php +++ b/mod/assign/gradingbatchoperationsform.php @@ -62,7 +62,10 @@ class mod_assign_grading_batch_operations_form extends moodleform { if ($instance['duedate'] && has_capability('mod/assign:grantextension', $instance['context'])) { $options['grantextension'] = get_string('grantextension', 'assign'); } - if ($instance['attemptreopenmethod'] == ASSIGN_ATTEMPT_REOPEN_METHOD_MANUAL) { + $multipleattemptsallowed = $instance['maxattempts'] > 1 || + $instance['maxattempts'] == ASSIGN_UNLIMITED_ATTEMPTS; + + if ($multipleattemptsallowed && $instance['attemptreopenmethod'] == ASSIGN_ATTEMPT_REOPEN_METHOD_MANUAL) { $options['addattempt'] = get_string('addattempt', 'assign'); } diff --git a/mod/assign/lang/en/assign.php b/mod/assign/lang/en/assign.php index 8a384234f3f..e8c0db01c83 100644 --- a/mod/assign/lang/en/assign.php +++ b/mod/assign/lang/en/assign.php @@ -89,14 +89,12 @@ $string['attemptheading'] = 'Attempt {$a->attemptnumber}: {$a->submissionsummary $string['attempthistory'] = 'Previous attempts'; $string['attemptnumber'] = 'Attempt number'; $string['attemptsettings'] = 'Attempt settings'; -$string['attemptreopenmethod'] = 'Additional attempts'; -$string['attemptreopenmethod_help'] = 'This setting determines whether a student can make additional attempts at the assignment. For each attempt, the grade and feedback are saved, and can be viewed by the teacher and the student. The available options are: +$string['attemptreopenmethod'] = 'Grant attempts'; +$string['attemptreopenmethod_help'] = 'This setting controls how students are granted attempts for this assignment. For each attempt, the grade and feedback are saved, and can be viewed by the teacher and the student. The available options are: -* Never - Only one attempt is possible. -* Manually - Additional attempts may be allowed by a teacher. -* Automatically until pass - Additional attempts are allowed automatically until the student achieves the grade to pass set in the gradebook for this assignment.'; +* Manually - After each attempt, you can grant the next one through the Submissions page or the Grader page. +* Automatically until pass - After each attempt, the next will be granted automatically, until the student achieves the passing grade.'; $string['attemptreopenmethod_manual'] = 'Manually'; -$string['attemptreopenmethod_none'] = 'Never'; $string['attemptreopenmethod_untilpass'] = 'Automatically until pass'; $string['availability'] = 'Availability'; $string['back'] = 'Back'; @@ -363,7 +361,7 @@ $string['markingworkflowstatenotmarked'] = 'Not marked'; $string['markingworkflowstatereadyforreview'] = 'Marking completed'; $string['markingworkflowstatereadyforrelease'] = 'Ready for release'; $string['markingworkflowstatereleased'] = 'Released'; -$string['maxattempts'] = 'Maximum attempts'; +$string['maxattempts'] = 'Allowed attempts'; $string['maxattempts_help'] = 'The maximum number of submission attempts that can be made by a student. After this number has been reached, the submission can no longer be reopened.'; $string['maxgrade'] = 'Maximum grade'; $string['maxgrade'] = 'Maximum Grade'; @@ -666,3 +664,6 @@ $string['viewsubmissiongradingtable'] = 'View submission grading table.'; $string['viewrevealidentitiesconfirm'] = 'View reveal student identities confirmation page.'; $string['workflowfilter'] = 'Workflow filter'; $string['xofy'] = '{$a->x} of {$a->y}'; + +// Deprecated since Moodle 4.4. +$string['attemptreopenmethod_none'] = 'Never'; diff --git a/mod/assign/lang/en/deprecated.txt b/mod/assign/lang/en/deprecated.txt new file mode 100644 index 00000000000..0ab4cd238d1 --- /dev/null +++ b/mod/assign/lang/en/deprecated.txt @@ -0,0 +1 @@ +attemptreopenmethod_none,mod_assign \ No newline at end of file diff --git a/mod/assign/locallib.php b/mod/assign/locallib.php index 88a310be431..04d4a0ea7c3 100644 --- a/mod/assign/locallib.php +++ b/mod/assign/locallib.php @@ -45,6 +45,12 @@ define('ASSIGN_FILTER_DRAFT', 'draft'); define('ASSIGN_MARKER_FILTER_NO_MARKER', -1); // Reopen attempt methods. +/** + * ASSIGN_ATTEMPT_REOPEN_METHOD_NONE - Reopening attempts is not allowed. + * + * @deprecated since Moodle 4.4 + * @todo MDL-81977 This will be deleted in Moodle 4.8. + */ define('ASSIGN_ATTEMPT_REOPEN_METHOD_NONE', 'none'); define('ASSIGN_ATTEMPT_REOPEN_METHOD_MANUAL', 'manual'); define('ASSIGN_ATTEMPT_REOPEN_METHOD_UNTILPASS', 'untilpass'); @@ -756,13 +762,8 @@ class assign { if (isset($formdata->hidegrader)) { $update->hidegrader = $formdata->hidegrader; } - $update->attemptreopenmethod = ASSIGN_ATTEMPT_REOPEN_METHOD_NONE; - if (!empty($formdata->attemptreopenmethod)) { - $update->attemptreopenmethod = $formdata->attemptreopenmethod; - } - if (!empty($formdata->maxattempts)) { - $update->maxattempts = $formdata->maxattempts; - } + $update->maxattempts = $formdata->maxattempts ?? 1; + $update->attemptreopenmethod = $formdata->attemptreopenmethod ?? ASSIGN_ATTEMPT_REOPEN_METHOD_UNTILPASS; if (isset($formdata->preventsubmissionnotingroup)) { $update->preventsubmissionnotingroup = $formdata->preventsubmissionnotingroup; } @@ -1531,13 +1532,8 @@ class assign { $update->hidegrader = $formdata->hidegrader; } $update->blindmarking = $formdata->blindmarking; - $update->attemptreopenmethod = ASSIGN_ATTEMPT_REOPEN_METHOD_NONE; - if (!empty($formdata->attemptreopenmethod)) { - $update->attemptreopenmethod = $formdata->attemptreopenmethod; - } - if (!empty($formdata->maxattempts)) { - $update->maxattempts = $formdata->maxattempts; - } + $update->maxattempts = $formdata->maxattempts ?? 1; + $update->attemptreopenmethod = $formdata->attemptreopenmethod ?? ASSIGN_ATTEMPT_REOPEN_METHOD_UNTILPASS; if (isset($formdata->preventsubmissionnotingroup)) { $update->preventsubmissionnotingroup = $formdata->preventsubmissionnotingroup; } @@ -4522,6 +4518,7 @@ class assign { $batchformparams = array('cm'=>$cmid, 'submissiondrafts'=>$this->get_instance()->submissiondrafts, 'duedate'=>$this->get_instance()->duedate, + 'maxattempts' => $this->get_instance()->maxattempts, 'attemptreopenmethod'=>$this->get_instance()->attemptreopenmethod, 'feedbackplugins'=>$this->get_feedback_plugins(), 'context'=>$this->get_context(), @@ -5003,6 +5000,7 @@ class assign { $batchformparams = array('cm'=>$this->get_course_module()->id, 'submissiondrafts'=>$this->get_instance()->submissiondrafts, 'duedate'=>$this->get_instance()->duedate, + 'maxattempts' => $this->get_instance()->maxattempts, 'attemptreopenmethod'=>$this->get_instance()->attemptreopenmethod, 'feedbackplugins'=>$this->get_feedback_plugins(), 'context'=>$this->get_context(), @@ -7972,9 +7970,8 @@ class assign { } // Do not show if we are editing a previous attempt. - if (($attemptnumber == -1 || - ($attemptnumber + 1) == count($this->get_all_submissions($userid))) && - $this->get_instance()->attemptreopenmethod != ASSIGN_ATTEMPT_REOPEN_METHOD_NONE) { + if (($attemptnumber == -1 || ($attemptnumber + 1) == count($this->get_all_submissions($userid))) && + ($this->get_instance()->maxattempts > 1 || $this->get_instance()->maxattempts == ASSIGN_UNLIMITED_ATTEMPTS)) { $mform->addElement('header', 'attemptsettings', get_string('attemptsettings', 'assign')); $attemptreopenmethod = get_string('attemptreopenmethod_' . $this->get_instance()->attemptreopenmethod, 'assign'); $mform->addElement('static', 'attemptreopenmethod', get_string('attemptreopenmethod', 'assign'), $attemptreopenmethod); @@ -8946,7 +8943,8 @@ class assign { protected function add_attempt($userid) { require_capability('mod/assign:grade', $this->context); - if ($this->get_instance()->attemptreopenmethod == ASSIGN_ATTEMPT_REOPEN_METHOD_NONE) { + // If additional attempts are disallowed. + if ($this->get_instance()->maxattempts == 1) { return false; } diff --git a/mod/assign/mod_form.php b/mod/assign/mod_form.php index 3a8c612e6a9..eafd8a5c1ac 100644 --- a/mod/assign/mod_form.php +++ b/mod/assign/mod_form.php @@ -138,19 +138,18 @@ class mod_assign_mod_form extends moodleform_mod { 'assign'); $mform->setType('requiresubmissionstatement', PARAM_BOOL); - $options = array( - ASSIGN_ATTEMPT_REOPEN_METHOD_NONE => get_string('attemptreopenmethod_none', 'mod_assign'), - ASSIGN_ATTEMPT_REOPEN_METHOD_MANUAL => get_string('attemptreopenmethod_manual', 'mod_assign'), - ASSIGN_ATTEMPT_REOPEN_METHOD_UNTILPASS => get_string('attemptreopenmethod_untilpass', 'mod_assign') - ); - $mform->addElement('select', 'attemptreopenmethod', get_string('attemptreopenmethod', 'mod_assign'), $options); - $mform->addHelpButton('attemptreopenmethod', 'attemptreopenmethod', 'mod_assign'); - - $options = array(ASSIGN_UNLIMITED_ATTEMPTS => get_string('unlimitedattempts', 'mod_assign')); + $options = [ASSIGN_UNLIMITED_ATTEMPTS => get_string('unlimitedattempts', 'mod_assign')]; $options += array_combine(range(1, 30), range(1, 30)); $mform->addElement('select', 'maxattempts', get_string('maxattempts', 'mod_assign'), $options); $mform->addHelpButton('maxattempts', 'maxattempts', 'assign'); - $mform->hideIf('maxattempts', 'attemptreopenmethod', 'eq', ASSIGN_ATTEMPT_REOPEN_METHOD_NONE); + + $options = [ + ASSIGN_ATTEMPT_REOPEN_METHOD_MANUAL => get_string('attemptreopenmethod_manual', 'mod_assign'), + ASSIGN_ATTEMPT_REOPEN_METHOD_UNTILPASS => get_string('attemptreopenmethod_untilpass', 'mod_assign') + ]; + $mform->addElement('select', 'attemptreopenmethod', get_string('attemptreopenmethod', 'mod_assign'), $options); + $mform->addHelpButton('attemptreopenmethod', 'attemptreopenmethod', 'mod_assign'); + $mform->hideIf('attemptreopenmethod', 'maxattempts', 'eq', 1); $mform->addElement('header', 'groupsubmissionsettings', get_string('groupsubmissionsettings', 'assign')); @@ -269,7 +268,9 @@ class mod_assign_mod_form extends moodleform_mod { $errors['gradingduedate'] = get_string('gradingdueduedatevalidation', 'assign'); } } - if ($data['blindmarking'] && $data['attemptreopenmethod'] == ASSIGN_ATTEMPT_REOPEN_METHOD_UNTILPASS) { + $multipleattemptsallowed = $data['maxattempts'] > 1 || $data['maxattempts'] == ASSIGN_UNLIMITED_ATTEMPTS; + if ($data['blindmarking'] && $multipleattemptsallowed && + $data['attemptreopenmethod'] == ASSIGN_ATTEMPT_REOPEN_METHOD_UNTILPASS) { $errors['attemptreopenmethod'] = get_string('reopenuntilpassincompatiblewithblindmarking', 'assign'); } diff --git a/mod/assign/settings.php b/mod/assign/settings.php index 234992a4135..b0386120b8e 100644 --- a/mod/assign/settings.php +++ b/mod/assign/settings.php @@ -31,6 +31,8 @@ $ADMIN->add('modsettings', new admin_category('modassignfolder', new lang_string $settings = new admin_settingpage($section, get_string('settings', 'mod_assign'), 'moodle/site:config', $module->is_enabled() === false); if ($ADMIN->fulltree) { + require_once($CFG->dirroot . '/mod/assign/locallib.php'); + $menu = array(); foreach (core_component::get_plugin_list('assignfeedback') as $type => $notused) { $visible = !get_config('assignfeedback_' . $type, 'disabled'); @@ -191,33 +193,22 @@ if ($ADMIN->fulltree) { $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false); $settings->add($setting); - // Constants from "locallib.php". - $options = array( - 'none' => get_string('attemptreopenmethod_none', 'mod_assign'), - 'manual' => get_string('attemptreopenmethod_manual', 'mod_assign'), - 'untilpass' => get_string('attemptreopenmethod_untilpass', 'mod_assign') - ); - $name = new lang_string('attemptreopenmethod', 'mod_assign'); - $description = new lang_string('attemptreopenmethod_help', 'mod_assign'); - $setting = new admin_setting_configselect('assign/attemptreopenmethod', - $name, - $description, - 'none', - $options); + $options = [ASSIGN_UNLIMITED_ATTEMPTS => new lang_string('unlimitedattempts', 'mod_assign')]; + $options += array_combine(range(1, 30), range(1, 30)); + $name = new lang_string('maxattempts', 'mod_assign'); + $description = new lang_string('maxattempts_help', 'mod_assign'); + $setting = new admin_setting_configselect('assign/maxattempts', $name, $description, 1, $options); $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, false); $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false); $settings->add($setting); - // Constants from "locallib.php". - $options = array(-1 => get_string('unlimitedattempts', 'mod_assign')); - $options += array_combine(range(1, 30), range(1, 30)); - $name = new lang_string('maxattempts', 'mod_assign'); - $description = new lang_string('maxattempts_help', 'mod_assign'); - $setting = new admin_setting_configselect('assign/maxattempts', - $name, - $description, - -1, - $options); + $options = [ + ASSIGN_ATTEMPT_REOPEN_METHOD_MANUAL => new lang_string('attemptreopenmethod_manual', 'mod_assign'), + ASSIGN_ATTEMPT_REOPEN_METHOD_UNTILPASS => new lang_string('attemptreopenmethod_untilpass', 'mod_assign'), + ]; + $name = new lang_string('attemptreopenmethod', 'mod_assign'); + $description = new lang_string('attemptreopenmethod_help', 'mod_assign'); + $setting = new admin_setting_configselect('assign/attemptreopenmethod', $name, $description, 'untilpass', $options); $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, false); $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false); $settings->add($setting); diff --git a/mod/assign/tests/behat/allow_another_attempt.feature b/mod/assign/tests/behat/allow_another_attempt.feature index 92c9fd80c6d..db6be7b01b7 100644 --- a/mod/assign/tests/behat/allow_another_attempt.feature +++ b/mod/assign/tests/behat/allow_another_attempt.feature @@ -16,6 +16,7 @@ Feature: In an assignment, students start a new attempt based on their previous | intro | Submit your online text | | assignsubmission_onlinetext_enabled | 1 | | assignsubmission_file_enabled | 0 | + | maxattempts | -1 | | attemptreopenmethod | manual | | hidegrader | 1 | | submissiondrafts | 0 | diff --git a/mod/assign/tests/behat/edit_previous_feedback.feature b/mod/assign/tests/behat/edit_previous_feedback.feature index 68d398ee264..3a2fe7c7d6e 100644 --- a/mod/assign/tests/behat/edit_previous_feedback.feature +++ b/mod/assign/tests/behat/edit_previous_feedback.feature @@ -29,6 +29,7 @@ Feature: In an assignment, teachers can edit feedback for a students previous su | assignsubmission_onlinetext_enabled | 1 | | assignfeedback_comments_enabled | 1 | | submissiondrafts | 0 | + | maxattempts | -1 | | attemptreopenmethod | manual | And the following "mod_assign > submissions" exist: | assign | user | onlinetext | diff --git a/mod/assign/tests/behat/group_submission.feature b/mod/assign/tests/behat/group_submission.feature index 2376fc0defc..f635e78db93 100644 --- a/mod/assign/tests/behat/group_submission.feature +++ b/mod/assign/tests/behat/group_submission.feature @@ -154,6 +154,7 @@ Feature: Group assignment submissions | assignsubmission_onlinetext_enabled | 1 | | assignsubmission_file_enabled | 0 | | teamsubmission | 1 | + | maxattempts | -1 | | attemptreopenmethod | manual | | requireallteammemberssubmit | 0 | And the following "mod_assign > submissions" exist: diff --git a/mod/assign/tests/behat/reopen_locked_submission.feature b/mod/assign/tests/behat/reopen_locked_submission.feature index f351203f317..3521832d28d 100644 --- a/mod/assign/tests/behat/reopen_locked_submission.feature +++ b/mod/assign/tests/behat/reopen_locked_submission.feature @@ -25,6 +25,7 @@ Feature: Submissions are unlocked when a new attempt is given | name | Test assignment name | | submissiondrafts | 0 | | assignsubmission_onlinetext_enabled | 1 | + | maxattempts | -1 | | attemptreopenmethod | untilpass | | gradepass | 50 | | submissiondrafts | 0 | @@ -53,6 +54,7 @@ Feature: Submissions are unlocked when a new attempt is given | name | Test assignment name | | submissiondrafts | 0 | | assignsubmission_onlinetext_enabled | 1 | + | maxattempts | -1 | | attemptreopenmethod | manual | And the following "mod_assign > submissions" exist: | assign | user | onlinetext | diff --git a/mod/assign/tests/externallib_advanced_testcase.php b/mod/assign/tests/externallib_advanced_testcase.php index e5876290caa..9c717b60070 100644 --- a/mod/assign/tests/externallib_advanced_testcase.php +++ b/mod/assign/tests/externallib_advanced_testcase.php @@ -58,6 +58,7 @@ abstract class externallib_advanced_testcase extends \externallib_advanced_testc 'submissiondrafts' => 1, 'assignfeedback_file_enabled' => 1, 'assignfeedback_comments_enabled' => 1, + 'maxattempts' => ASSIGN_UNLIMITED_ATTEMPTS, 'attemptreopenmethod' => ASSIGN_ATTEMPT_REOPEN_METHOD_MANUAL, 'sendnotifications' => 0 ], $params); diff --git a/mod/assign/tests/externallib_test.php b/mod/assign/tests/externallib_test.php index f5a37cf4a75..3d93e8aec87 100644 --- a/mod/assign/tests/externallib_test.php +++ b/mod/assign/tests/externallib_test.php @@ -614,6 +614,7 @@ class externallib_test extends \mod_assign\externallib_advanced_testcase { $result = $this->create_assign_with_student_and_teacher([ 'assignsubmission_onlinetext_enabled' => 1, + 'maxattempts' => ASSIGN_UNLIMITED_ATTEMPTS, 'attemptreopenmethod' => 'manual', 'teamsubmission' => 1, ]); diff --git a/mod/assign/tests/fixtures/testable_assign.php b/mod/assign/tests/fixtures/testable_assign.php index 573944aead3..bacb65a2fa6 100644 --- a/mod/assign/tests/fixtures/testable_assign.php +++ b/mod/assign/tests/fixtures/testable_assign.php @@ -145,6 +145,7 @@ class mod_assign_testable_assign extends assign { $formparams = array(); $formparams['submissiondrafts'] = 1; $formparams['duedate'] = 1; + $formparams['maxattempts'] = ASSIGN_UNLIMITED_ATTEMPTS; $formparams['attemptreopenmethod'] = ASSIGN_ATTEMPT_REOPEN_METHOD_MANUAL; $formparams['feedbackplugins'] = array(); $formparams['markingworkflow'] = 1; diff --git a/mod/assign/tests/generator/lib.php b/mod/assign/tests/generator/lib.php index f0a072f2bbc..027aa4e5e44 100644 --- a/mod/assign/tests/generator/lib.php +++ b/mod/assign/tests/generator/lib.php @@ -36,7 +36,7 @@ class mod_assign_generator extends testing_module_generator { public function create_instance($record = null, array $options = null) { $record = (object)(array)$record; - $defaultsettings = array( + $defaultsettings = [ 'alwaysshowdescription' => 1, 'submissiondrafts' => 1, 'requiresubmissionstatement' => 0, @@ -52,15 +52,15 @@ class mod_assign_generator extends testing_module_generator { 'requireallteammemberssubmit' => 0, 'teamsubmissiongroupingid' => 0, 'blindmarking' => 0, - 'attemptreopenmethod' => 'none', - 'maxattempts' => -1, + 'attemptreopenmethod' => 'untilpass', + 'maxattempts' => 1, 'markingworkflow' => 0, 'markingallocation' => 0, 'markinganonymous' => 0, 'activityformat' => 0, 'timelimit' => 0, 'submissionattachments' => 0, - ); + ]; if (property_exists($record, 'teamsubmissiongroupingid')) { $record->teamsubmissiongroupingid = $this->get_grouping_id($record->teamsubmissiongroupingid); diff --git a/mod/assign/tests/locallib_test.php b/mod/assign/tests/locallib_test.php index 144bc13d474..1808f48b74d 100644 --- a/mod/assign/tests/locallib_test.php +++ b/mod/assign/tests/locallib_test.php @@ -3746,6 +3746,7 @@ Anchor link 2:Link text $teacher->ignoresesskey = true; $this->setUser($teacher); $assign = $this->create_instance($course, [ + 'maxattempts' => ASSIGN_UNLIMITED_ATTEMPTS, 'attemptreopenmethod' => ASSIGN_ATTEMPT_REOPEN_METHOD_MANUAL, ]); diff --git a/mod/assign/tests/markerallocation_test.php b/mod/assign/tests/markerallocation_test.php index 8f044ff3ad7..3ced03b6644 100644 --- a/mod/assign/tests/markerallocation_test.php +++ b/mod/assign/tests/markerallocation_test.php @@ -49,7 +49,7 @@ class markerallocation_test extends \advanced_testcase { $record = new \stdClass(); $record->course = $this->course; - $modulesettings = array( + $modulesettings = [ 'alwaysshowdescription' => 1, 'submissiondrafts' => 1, 'requiresubmissionstatement' => 0, @@ -64,11 +64,11 @@ class markerallocation_test extends \advanced_testcase { 'requireallteammemberssubmit' => 0, 'teamsubmissiongroupingid' => 0, 'blindmarking' => 0, - 'attemptreopenmethod' => 'none', - 'maxattempts' => -1, + 'attemptreopenmethod' => 'untilpass', + 'maxattempts' => 1, 'markingworkflow' => 1, 'markingallocation' => 1, - ); + ]; $assignelement = $this->getDataGenerator()->create_module('assign', $record, $modulesettings); diff --git a/mod/assign/upgrade.txt b/mod/assign/upgrade.txt index 0d203b9e95f..0b264a23541 100644 --- a/mod/assign/upgrade.txt +++ b/mod/assign/upgrade.txt @@ -5,6 +5,13 @@ This file has been replaced by UPGRADING.md. See MDL-81125 for further informati === This files describes API changes in the assign code. +=== 4.4 === + +* The default option "Never" for "attemptreopenmethod" setting, which disallowed multiple attempts at the assignment, + has been removed. This option was unnecessary because limiting attempts to 1 through the "maxattempts" setting achieves + the same behavior. As a part of the removal process, the constant ASSIGN_ATTEMPT_REOPEN_METHOD_NONE has been deprecated, + and a new default value for "attemptreopenmethod" has been set to "Automatically until pass". + === 4.3 === * The following deprecated methods have been removed and should not be used any more: - `assign::add_to_log` diff --git a/mod/assign/version.php b/mod/assign/version.php index 4a453fd7f53..df7d76b383d 100644 --- a/mod/assign/version.php +++ b/mod/assign/version.php @@ -25,5 +25,5 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'mod_assign'; // Full name of the plugin (used for diagnostics). -$plugin->version = 2024042200; // The current module version (Date: YYYYMMDDXX). +$plugin->version = 2024042201; // The current module version (Date: YYYYMMDDXX). $plugin->requires = 2024041600; // Requires this Moodle version.