Merge branch 'MDL-70676-310' of git://github.com/ilyatregubov/moodle into MOODLE_310_STABLE

Fixed mod/workshop/db/upgrade.php: \xmldb_field::getNotNull()
does not verify if the column is nullable in the database.
This commit is contained in:
Víctor Déniz 2021-03-02 18:25:54 +00:00
commit 45a7f417ce
5 changed files with 26 additions and 9 deletions

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="mod/workshop/db" VERSION="20180626" COMMENT="XMLDB file for Moodle mod/workshop"
<XMLDB PATH="mod/workshop/db" VERSION="20210302" COMMENT="XMLDB file for Moodle mod/workshop"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
>
@ -109,7 +109,7 @@
<FIELD NAME="assessmentid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="Part of which assessment this grade is of"/>
<FIELD NAME="strategy" TYPE="char" LENGTH="30" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="dimensionid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="Foreign key. References dimension id in one of the grading strategy tables."/>
<FIELD NAME="grade" TYPE="number" LENGTH="10" NOTNULL="true" SEQUENCE="false" DECIMALS="5" COMMENT="Given grade in the referenced assessment dimension."/>
<FIELD NAME="grade" TYPE="number" LENGTH="10" NOTNULL="false" SEQUENCE="false" DECIMALS="5" COMMENT="Given grade in the referenced assessment dimension."/>
<FIELD NAME="peercomment" TYPE="text" NOTNULL="false" SEQUENCE="false" COMMENT="Reviewer's comment to the grade value."/>
<FIELD NAME="peercommentformat" TYPE="int" LENGTH="3" NOTNULL="false" DEFAULT="0" SEQUENCE="false" COMMENT="The format of peercomment field"/>
</FIELDS>

View file

@ -98,5 +98,18 @@ function xmldb_workshop_upgrade($oldversion) {
// Automatically generated Moodle v3.10.0 release upgrade line.
// Put any upgrade step following this.
if ($oldversion < 2020110901) {
// Changing nullability of field grade on table workshop_grades to null.
$table = new xmldb_table('workshop_grades');
$field = new xmldb_field('grade', XMLDB_TYPE_NUMBER, '10, 5', null, null, null, null, 'dimensionid');
// Launch change of nullability for field grade.
$dbman->change_field_notnull($table, $field);
// Main savepoint reached.
upgrade_mod_savepoint(true, 2020110901, 'workshop');
}
return true;
}

View file

@ -76,11 +76,13 @@ class workshop_accumulative_assessment_form extends workshop_assessment_form {
// grade for this aspect
$label = get_string('dimensiongradefor', 'workshopform_accumulative', $dimtitle);
$options = make_grades_menu($fields->{'grade__idx_' . $i});
$options = array('-1' => get_string('choosedots')) + $options;
$mform->addElement('select', 'grade__idx_' . $i, $label, $options);
$mform->addRule(array('grade__idx_' . $i, 'minusone') , get_string('mustchoosegrade', 'workshopform_accumulative'), 'compare', 'gt');
if ($fields->{'grade__idx_' . $i}) {
$options = make_grades_menu($fields->{'grade__idx_' . $i});
$options = array('-1' => get_string('choosedots')) + $options;
$mform->addElement('select', 'grade__idx_' . $i, $label, $options);
$mform->addRule(array('grade__idx_' . $i, 'minusone'),
get_string('mustchoosegrade', 'workshopform_accumulative'), 'compare', 'gt');
}
// comment
$label = get_string('dimensioncommentfor', 'workshopform_accumulative', $dimtitle);
//$mform->addElement('editor', 'peercomment__idx_' . $i, $label, null, array('maxfiles' => 0));

View file

@ -269,7 +269,9 @@ class workshop_accumulative_strategy implements workshop_strategy {
$grade->assessmentid = $assessment->id;
$grade->strategy = 'accumulative';
$grade->dimensionid = $data->{'dimensionid__idx_' . $i};
$grade->grade = $data->{'grade__idx_' . $i};
if (isset($data->{'grade__idx_' . $i})) {
$grade->grade = $data->{'grade__idx_' . $i};
}
$grade->peercomment = $data->{'peercomment__idx_' . $i};
$grade->peercommentformat = FORMAT_MOODLE;
if (empty($grade->id)) {

View file

@ -24,6 +24,6 @@
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2020110900; // The current module version (YYYYMMDDXX)
$plugin->version = 2020110901; // The current module version (YYYYMMDDXX).
$plugin->requires = 2020110300; // Requires this Moodle version.
$plugin->component = 'mod_workshop';