How to add new attribute in quiz table and new records in config_plugins table

How to add new attribute in quiz table and new records in config_plugins table

by Amrata Ramchandani -
Number of replies: 2

Hi,

I am trying to do few changes in quiz module for which I have to add new attribute in quiz table and new records in config_plugin table.

I was able to do directly from MySQL client ,but I am looking for the files in moodle code which does the same,So that later on I can include changes in the patch file itself.


Regards,

Amrata

Average of ratings: -
In reply to Amrata Ramchandani

Re: How to add new attribute in quiz table and new records in config_plugins table

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
If you look in mod/quiz/db/upgrade.php and find some code like


 if ($oldversion < 2015032302) {
        // Define field shufflequestions to be dropped from quiz.
        $table = new xmldb_table('quiz');
        $field = new xmldb_field('shufflequestions');
        // Conditionally launch drop field shufflequestions.
        if ($dbman->field_exists($table, $field)) {
            $dbman->drop_field($table, $field);
        }


Base yours on that (so change shuffledquestions to whatever the field is you want to add). You will need to increment the version number in version.php and match it in your upgrade code.




In reply to Marcus Green

Re: How to add new attribute in quiz table and new records in config_plugins table

by Amrata Ramchandani -

Thanks Marcus,I will look into this