turnitin/moodle-plagiarism_turnitin

Upgrade path issues for version 2020113001

jgg9026 opened this issue · 3 comments

Hi guys,

I was taking a look at your upgrade file and saw something weird with the last upgrade block.

if ($oldversion < 2020091401) {

        // Set itemid to default to null
        $table = new xmldb_table('plagiarism_turnitin_files');
        $field = new xmldb_field('itemid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, false, false, null, 'externalid');
        if ($dbman->field_exists($table, $field)) {
            $dbman->change_field_default($table, $field);
        }

        // Set student_read to default to null
        $field = new xmldb_field('student_read', XMLDB_TYPE_INTEGER, '10', false, false, false, null, 'errormsg');
        if ($dbman->field_exists($table, $field)) {
            $dbman->change_field_default($table, $field);
        }

        // Set turnitin_uid to allow null
        $field = new xmldb_field('turnitin_uid', XMLDB_TYPE_INTEGER, '10', null, false, false, null, 'userid');
        if ($dbman->field_exists($table, $field)) {
            $dbman->change_field_notnull($table, $field);
        }

        // Set turnitin_utp to allow null
        $field = new xmldb_field('turnitin_utp', XMLDB_TYPE_INTEGER, '10', null, false, false, 0, 'turnitin_uid');
        if ($dbman->field_exists($table, $field)) {
            $dbman->change_field_notnull($table, $field);
        }

        // Set ownerid to allow null
        $field = new xmldb_field('ownerid', XMLDB_TYPE_INTEGER, '10', null, false, false, null, 'courseid');
        if ($dbman->field_exists($table, $field)) {
            $dbman->change_field_notnull($table, $field);
        }

        // Set turnitin_ctl to allow null
        $field = new xmldb_field('turnitin_ctl', XMLDB_TYPE_TEXT, null, null, false, null, null, 'ownerid');
        if ($dbman->field_exists($table, $field)) {
            $dbman->change_field_notnull($table, $field);
        }

        // Set turnitin_cid to allow null
        $field = new xmldb_field('turnitin_cid', XMLDB_TYPE_INTEGER, '10', null, false, null, null, 'turnitin_ctl');
        if ($dbman->field_exists($table, $field)) {
            $dbman->change_field_notnull($table, $field);
        }

        upgrade_plugin_savepoint(true, 2020091401, 'plagiarism', 'turnitin');
    }

Please note that $table is not changing its value and there is no field turnitin_utp on the table plagiarism_turnitin_files since it belongs to plagiarism_turnitin_users. With that in mind it looks like only itemid and student_read are getting updated.

It looks like an easy fix BTW.

turnitin_uid and turnitin_utp belong to plagiarism_turnitin_users

Also ownerid, turnitin_ctl and turnitin_cid belong to plagiarism_turnitin_courses

Adding $table = new xmldb_table('plagiarism_turnitin_users'); at line 464, and $table = new xmldb_table('plagiarism_turnitin_courses'); at line 477 should be enough

Fixed as part of #576

Thank you for reporting this. Because the latest version of the plagiarism plugin is supported for versions of Moodle 4.1 and higher, I am closing this ticket. However, if you find this issue is occurring with the latest version of the plugin in any of the supported Moodle versions, please create a new ticket and we will address it.