Skip to content
Snippets Groups Projects
Commit 16224edd authored by Tim Hunt's avatar Tim Hunt
Browse files

Store last modified date of question tests #360

parent 23b7d3a1
Branches
No related tags found
No related merge requests found
...@@ -74,7 +74,7 @@ class backup_qtype_stack_plugin extends backup_qtype_plugin { ...@@ -74,7 +74,7 @@ class backup_qtype_stack_plugin extends backup_qtype_plugin {
'falseanswernote', 'falsefeedback', 'falsefeedbackformat')); 'falseanswernote', 'falsefeedback', 'falsefeedbackformat'));
$stackqtests = new backup_nested_element('stackqtests'); $stackqtests = new backup_nested_element('stackqtests');
$stackqtest = new backup_nested_element('stackqtest', array('id'), array('testcase')); $stackqtest = new backup_nested_element('stackqtest', array('id'), array('testcase', 'timemodified'));
$stackqtestinputs = new backup_nested_element('stackqtestinputs'); $stackqtestinputs = new backup_nested_element('stackqtestinputs');
$stackqtestinput = new backup_nested_element('stackqtestinput', array('id'), $stackqtestinput = new backup_nested_element('stackqtestinput', array('id'),
......
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="question/type/stack/db" VERSION="20150630" COMMENT="XMLDB file for Moodle question/type/stack" <XMLDB PATH="question/type/stack/db" VERSION="20180319" COMMENT="XMLDB file for Moodle question/type/stack"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../lib/xmldb/xmldb.xsd" xsi:noNamespaceSchemaLocation="../../../../lib/xmldb/xmldb.xsd"
> >
...@@ -131,6 +131,7 @@ ...@@ -131,6 +131,7 @@
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/> <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
<FIELD NAME="questionid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="Foreign key link to question.id"/> <FIELD NAME="questionid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="Foreign key link to question.id"/>
<FIELD NAME="testcase" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="Sequential number for this testcase within this question."/> <FIELD NAME="testcase" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="Sequential number for this testcase within this question."/>
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false"/>
</FIELDS> </FIELDS>
<KEYS> <KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/> <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
......
...@@ -729,6 +729,21 @@ function xmldb_qtype_stack_upgrade($oldversion) { ...@@ -729,6 +729,21 @@ function xmldb_qtype_stack_upgrade($oldversion) {
upgrade_plugin_savepoint(true, 2017082400, 'qtype', 'stack'); upgrade_plugin_savepoint(true, 2017082400, 'qtype', 'stack');
} }
if ($oldversion < 2018021900) {
// Define field timemodified to be added to qtype_stack_qtests.
$table = new xmldb_table('qtype_stack_qtests');
$field = new xmldb_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'testcase');
// Conditionally launch add field timemodified.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Stack savepoint reached.
upgrade_plugin_savepoint(true, 2018021900, 'qtype', 'stack');
}
// Add new upgrade blocks just above here. // Add new upgrade blocks just above here.
// Check the version of the Maxima library code that comes with this version // Check the version of the Maxima library code that comes with this version
......
...@@ -588,7 +588,11 @@ class qtype_stack extends question_type { ...@@ -588,7 +588,11 @@ class qtype_stack extends question_type {
$testcasedata = new stdClass(); $testcasedata = new stdClass();
$testcasedata->questionid = $questionid; $testcasedata->questionid = $questionid;
$testcasedata->testcase = $testcase; $testcasedata->testcase = $testcase;
$testcasedata->timemodified = time();
$DB->insert_record('qtype_stack_qtests', $testcasedata); $DB->insert_record('qtype_stack_qtests', $testcasedata);
} else {
$DB->set_field('qtype_stack_qtests', 'timemodified', time(),
array('questionid' => $questionid, 'testcase' => $testcase));
} }
// Save the input data. // Save the input data.
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
$plugin->version = 2017121800; $plugin->version = 2018021900;
$plugin->requires = 2014051200; $plugin->requires = 2014051200;
$plugin->cron = 0; $plugin->cron = 0;
$plugin->component = 'qtype_stack'; $plugin->component = 'qtype_stack';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment