Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 28... Línea 28...
28
 * @return bool
28
 * @return bool
29
 */
29
 */
30
function xmldb_assign_upgrade($oldversion) {
30
function xmldb_assign_upgrade($oldversion) {
31
    global $DB;
31
    global $DB;
Línea 32... Línea -...
32
 
-
 
33
    // Automatically generated Moodle v4.1.0 release upgrade line.
-
 
34
    // Put any upgrade step following this.
-
 
35
 
32
 
36
    // Automatically generated Moodle v4.2.0 release upgrade line.
33
    // Automatically generated Moodle v4.2.0 release upgrade line.
Línea 37... Línea 34...
37
    // Put any upgrade step following this.
34
    // Put any upgrade step following this.
38
 
35
 
Línea 64... Línea 61...
64
    }
61
    }
Línea 65... Línea 62...
65
 
62
 
66
    // Automatically generated Moodle v4.4.0 release upgrade line.
63
    // Automatically generated Moodle v4.4.0 release upgrade line.
Línea -... Línea 64...
-
 
64
    // Put any upgrade step following this.
-
 
65
 
-
 
66
    if ($oldversion < 2024042201) {
-
 
67
        // The 'Never' ('none') option for the additional attempts (attemptreopenmethod) setting is no longer supported
-
 
68
        // and needs to be updated in all relevant instances.
-
 
69
 
-
 
70
        // The default value for the 'attemptreopenmethod' field in the 'assign' database table is currently set to 'none',
-
 
71
        // This needs to be updated to 'untilpass' to ensure the system functions correctly. Additionally, the default
-
 
72
        // value for the 'maxattempts' field needs to be changed to '1' to prevent multiple attempts and maintain the
-
 
73
        // original behavior.
-
 
74
        $table = new xmldb_table('assign');
-
 
75
        $attemptreopenmethodfield = new xmldb_field('attemptreopenmethod', XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL,
-
 
76
            null, 'untilpass');
-
 
77
        $maxattemptsfield = new xmldb_field('maxattempts', XMLDB_TYPE_INTEGER, '6', null, XMLDB_NOTNULL,
-
 
78
            null, '1');
-
 
79
        $dbman->change_field_default($table, $attemptreopenmethodfield);
-
 
80
        $dbman->change_field_default($table, $maxattemptsfield);
-
 
81
 
-
 
82
        // If the current value for the 'attemptreopenmethod' global configuration in the assignment is set to 'none'.
-
 
83
        if (get_config('assign', 'attemptreopenmethod') == 'none') {
-
 
84
            // Reset the value to 'untilpass'.
-
 
85
            set_config('attemptreopenmethod', 'untilpass', 'assign');
-
 
86
            // Also, setting the value for the 'maxattempts' global config in the assignment to '1' ensures that the
-
 
87
            // original behaviour is preserved by disallowing any additional attempts by default.
-
 
88
            set_config('maxattempts', 1, 'assign');
-
 
89
        }
-
 
90
 
-
 
91
        // Update all the current assignment instances that have their 'attemptreopenmethod' set to 'none'.
-
 
92
        // By setting 'maxattempts' to 1, additional attempts are disallowed, preserving the original behavior.
-
 
93
        $DB->execute(
-
 
94
            'UPDATE {assign}
-
 
95
                    SET attemptreopenmethod = :newattemptreopenmethod,
-
 
96
                        maxattempts = :maxattempts
-
 
97
                  WHERE attemptreopenmethod = :oldattemptreopenmethod',
-
 
98
            [
-
 
99
                'newattemptreopenmethod' => 'untilpass',
-
 
100
                'maxattempts' => 1,
-
 
101
                'oldattemptreopenmethod' => 'none',
-
 
102
            ]
-
 
103
        );
-
 
104
 
-
 
105
        // Assign savepoint reached.
-
 
106
        upgrade_mod_savepoint(true, 2024042201, 'assign');
-
 
107
    }
-
 
108
 
-
 
109
    // Automatically generated Moodle v4.5.0 release upgrade line.
-
 
110
    // Put any upgrade step following this.
-
 
111
 
-
 
112
    if ($oldversion < 2024121801) {
-
 
113
 
-
 
114
        // Define field gradepenalty to be added to assign.
-
 
115
        $table = new xmldb_table('assign');
-
 
116
        $field = new xmldb_field('gradepenalty', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', 'submissionattachments');
-
 
117
 
-
 
118
        // Conditionally launch add field gradepenalty.
-
 
119
        if (!$dbman->field_exists($table, $field)) {
-
 
120
            $dbman->add_field($table, $field);
-
 
121
        }
-
 
122
 
-
 
123
        // Define index gradepenalty (not unique) to be added to assign.
-
 
124
        $index = new xmldb_index('gradepenalty', XMLDB_INDEX_NOTUNIQUE, ['gradepenalty']);
-
 
125
 
-
 
126
        // Conditionally launch add index gradepenalty.
-
 
127
        if (!$dbman->index_exists($table, $index)) {
-
 
128
            $dbman->add_index($table, $index);
-
 
129
        }
-
 
130
 
-
 
131
        // Define field penalty to be added to assign_grades.
-
 
132
        $table = new xmldb_table('assign_grades');
-
 
133
        $field = new xmldb_field('penalty', XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, '0', 'grade');
-
 
134
 
-
 
135
        // Conditionally launch add field penalty.
-
 
136
        if (!$dbman->field_exists($table, $field)) {
-
 
137
            $dbman->add_field($table, $field);
-
 
138
        }
-
 
139
 
-
 
140
        // Assign savepoint reached.
-
 
141
        upgrade_mod_savepoint(true, 2024121801, 'assign');
-
 
142
    }
-
 
143
 
-
 
144
    // Automatically generated Moodle v5.0.0 release upgrade line.
67
    // Put any upgrade step following this.
145
    // Put any upgrade step following this.
68
 
146