MDL-27408 Moved the question engine install/upgrade code into the proper place.
I have tested upgrade from the previous development version, and a clean install. Upgrade from 2.0 still needs more work.
This commit is contained in:
@@ -3762,6 +3762,35 @@ class admin_setting_special_calendar_weekend extends admin_setting {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Admin setting that allows a user to pick a behaviour.
|
||||
*
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class admin_setting_question_behaviour extends admin_setting_configselect {
|
||||
/**
|
||||
* @param string $name name of config variable
|
||||
* @param string $visiblename display name
|
||||
* @param string $description description
|
||||
* @param string $default default.
|
||||
*/
|
||||
public function __construct($name, $visiblename, $description, $default) {
|
||||
parent::__construct($name, $visiblename, $description, $default, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load list of behaviours as choices
|
||||
* @return bool true => success, false => error.
|
||||
*/
|
||||
public function load_choices() {
|
||||
global $CFG;
|
||||
require_once($CFG->dirroot . '/question/engine/lib.php');
|
||||
$this->choices = question_engine::get_archetypal_behaviours();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Admin setting that allows a user to pick appropriate roles for something.
|
||||
*
|
||||
|
||||
+84
-9
@@ -1279,9 +1279,9 @@
|
||||
<FIELD NAME="questiontext" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" PREVIOUS="name" NEXT="questiontextformat"/>
|
||||
<FIELD NAME="questiontextformat" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" PREVIOUS="questiontext" NEXT="generalfeedback"/>
|
||||
<FIELD NAME="generalfeedback" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" COMMENT="to store the question feedback" PREVIOUS="questiontextformat" NEXT="generalfeedbackformat"/>
|
||||
<FIELD NAME="generalfeedbackformat" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" PREVIOUS="generalfeedback" NEXT="defaultgrade"/>
|
||||
<FIELD NAME="defaultgrade" TYPE="number" LENGTH="12" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" DECIMALS="7" PREVIOUS="generalfeedbackformat" NEXT="penalty"/>
|
||||
<FIELD NAME="penalty" TYPE="number" LENGTH="12" NOTNULL="true" UNSIGNED="false" DEFAULT="0.1" SEQUENCE="false" DECIMALS="7" PREVIOUS="defaultgrade" NEXT="qtype"/>
|
||||
<FIELD NAME="generalfeedbackformat" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" PREVIOUS="generalfeedback" NEXT="defaultmark"/>
|
||||
<FIELD NAME="defaultmark" TYPE="number" LENGTH="12" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" DECIMALS="7" PREVIOUS="generalfeedbackformat" NEXT="penalty"/>
|
||||
<FIELD NAME="penalty" TYPE="number" LENGTH="12" NOTNULL="true" UNSIGNED="false" DEFAULT="0.1" SEQUENCE="false" DECIMALS="7" PREVIOUS="defaultmark" NEXT="qtype"/>
|
||||
<FIELD NAME="qtype" TYPE="char" LENGTH="20" NOTNULL="true" SEQUENCE="false" PREVIOUS="penalty" NEXT="length"/>
|
||||
<FIELD NAME="length" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" PREVIOUS="qtype" NEXT="stamp"/>
|
||||
<FIELD NAME="stamp" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="length" NEXT="version"/>
|
||||
@@ -1300,7 +1300,7 @@
|
||||
<KEY NAME="modifiedby" TYPE="foreign" FIELDS="modifiedby" REFTABLE="user" REFFIELDS="id" COMMENT="foreign (modifiedby) references user (id)" PREVIOUS="createdby"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
<TABLE NAME="question_answers" COMMENT="Answers, with a fractional grade (0-1) and feedback" PREVIOUS="question" NEXT="question_attempts">
|
||||
<TABLE NAME="question_answers" COMMENT="Answers, with a fractional grade (0-1) and feedback" PREVIOUS="question" NEXT="question_hints">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="question"/>
|
||||
<FIELD NAME="question" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="id" NEXT="answer"/>
|
||||
@@ -1315,16 +1315,91 @@
|
||||
<KEY NAME="question" TYPE="foreign" FIELDS="question" REFTABLE="question" REFFIELDS="id" PREVIOUS="primary"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
<TABLE NAME="question_attempts" COMMENT="Student attempts. This table gets extended by the modules" PREVIOUS="question_answers" NEXT="question_states">
|
||||
<TABLE NAME="question_hints" COMMENT="Stores the the part of the question definition that gives different feedback after each try in interactive and similar behaviours." PREVIOUS="question_answers" NEXT="question_usages">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="modulename"/>
|
||||
<FIELD NAME="modulename" TYPE="char" LENGTH="20" NOTNULL="true" DEFAULT="quiz" SEQUENCE="false" PREVIOUS="id"/>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="questionid"/>
|
||||
<FIELD NAME="questionid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" PREVIOUS="id" NEXT="hint"/>
|
||||
<FIELD NAME="hint" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" COMMENT="The text of the feedback to be given." PREVIOUS="questionid" NEXT="shownumcorrect"/>
|
||||
<FIELD NAME="shownumcorrect" TYPE="int" LENGTH="1" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" COMMENT="Whether the feedback should include a message about how many things the student got right. This is only applicable to certain question types (for example matching or multiple choice multiple-response)." PREVIOUS="hint" NEXT="clearwrong"/>
|
||||
<FIELD NAME="clearwrong" TYPE="int" LENGTH="1" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" COMMENT="Whether any wrong choices should be cleared before the next try. Whether this is applicable, and what it means, depends on the question type, as with the shownumright option." PREVIOUS="shownumcorrect" NEXT="options"/>
|
||||
<FIELD NAME="options" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="A space for any other question-type specific options." PREVIOUS="clearwrong"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="questionid"/>
|
||||
<KEY NAME="questionid" TYPE="foreign" FIELDS="questionid" REFTABLE="question" REFFIELDS="id" PREVIOUS="primary"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
<TABLE NAME="question_states" COMMENT="Stores user responses to an attempt, and percentage grades" PREVIOUS="question_attempts" NEXT="question_sessions">
|
||||
<TABLE NAME="question_usages" COMMENT="This table's main purpose it to assign a unique id to each attempt at a set of questions by some part of Moodle. A question usage is made up of a number of question_attempts." PREVIOUS="question_hints" NEXT="question_attempts">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="contextid"/>
|
||||
<FIELD NAME="contextid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="Every question usage must be associated with some context." PREVIOUS="id" NEXT="component"/>
|
||||
<FIELD NAME="component" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="The plugin this attempt belongs to, e.g. 'mod_quiz', 'block_questionoftheday', 'filter_embedquestion'." PREVIOUS="contextid" NEXT="preferredbehaviour"/>
|
||||
<FIELD NAME="preferredbehaviour" TYPE="char" LENGTH="32" NOTNULL="true" SEQUENCE="false" COMMENT="The archetypal behaviour that should be used for question attempts in this usage." PREVIOUS="component"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="contextid"/>
|
||||
<KEY NAME="contextid" TYPE="foreign" FIELDS="contextid" REFTABLE="context" REFFIELDS="id" PREVIOUS="primary"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
<TABLE NAME="question_attempts" COMMENT="Each row here corresponds to an attempt at one question, as part of a question_usage. A question_attempt will have some question_attempt_steps" PREVIOUS="question_usages" NEXT="question_attempt_steps">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="questionusageid"/>
|
||||
<FIELD NAME="questionusageid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="Foreign key, references question_usages.id" PREVIOUS="id" NEXT="slot"/>
|
||||
<FIELD NAME="slot" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="Used to number the questions in one attempt sequentially." PREVIOUS="questionusageid" NEXT="behaviour"/>
|
||||
<FIELD NAME="behaviour" TYPE="char" LENGTH="32" NOTNULL="true" SEQUENCE="false" COMMENT="The name of the question behaviour that is managing this question attempt." PREVIOUS="slot" NEXT="questionid"/>
|
||||
<FIELD NAME="questionid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="The id of the question being attempted. Foreign key references question.id." PREVIOUS="behaviour" NEXT="maxmark"/>
|
||||
<FIELD NAME="maxmark" TYPE="number" LENGTH="12" NOTNULL="true" UNSIGNED="false" SEQUENCE="false" DECIMALS="7" COMMENT="The grade this question is marked out of in this attempt." PREVIOUS="questionid" NEXT="minfraction"/>
|
||||
<FIELD NAME="minfraction" TYPE="number" LENGTH="12" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" DECIMALS="7" COMMENT="Some questions can award negative marks. This indicates the most negative mark that can be awarded, on the faction scale where the maximum positive mark is 1." PREVIOUS="maxmark" NEXT="flagged"/>
|
||||
<FIELD NAME="flagged" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Whether this question has been flagged within the attempt." PREVIOUS="minfraction" NEXT="questionsummary"/>
|
||||
<FIELD NAME="questionsummary" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" COMMENT="If this question uses randomisation, it should set this field to summarise what random version the student actually saw. This is a human-readable textual summary of the student's response which might, for example, be used in a report." PREVIOUS="flagged" NEXT="rightanswer"/>
|
||||
<FIELD NAME="rightanswer" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" COMMENT="This is a human-readable textual summary of the right answer to this question. Might be used, for example on the quiz preview, to help people who are testing the question. Or might be used in reports." PREVIOUS="questionsummary" NEXT="responsesummary"/>
|
||||
<FIELD NAME="responsesummary" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" COMMENT="This is a textual summary of the student's response (basically what you would expect to in the Quiz responses report)." PREVIOUS="rightanswer" NEXT="timemodified"/>
|
||||
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="The time this record was last changed." PREVIOUS="responsesummary"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="questionid"/>
|
||||
<KEY NAME="questionid" TYPE="foreign" FIELDS="questionid" REFTABLE="question" REFFIELDS="id" PREVIOUS="primary" NEXT="questionusageid"/>
|
||||
<KEY NAME="questionusageid" TYPE="foreign" FIELDS="questionusageid" REFTABLE="question_usages" REFFIELDS="id" PREVIOUS="questionid"/>
|
||||
</KEYS>
|
||||
<INDEXES>
|
||||
<INDEX NAME="questionusageid-slot" UNIQUE="true" FIELDS="questionusageid, slot"/>
|
||||
</INDEXES>
|
||||
</TABLE>
|
||||
<TABLE NAME="question_attempt_steps" COMMENT="Stores one step in in a question attempt. As well as the data here, the step will have some data in the question_attempt_step_data table." PREVIOUS="question_attempts" NEXT="question_attempt_step_data">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="questionattemptid"/>
|
||||
<FIELD NAME="questionattemptid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="Foreign key, references question_attempt.id" PREVIOUS="id" NEXT="sequencenumber"/>
|
||||
<FIELD NAME="sequencenumber" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="Numbers the steps in a question attempt sequentially." PREVIOUS="questionattemptid" NEXT="state"/>
|
||||
<FIELD NAME="state" TYPE="char" LENGTH="13" NOTNULL="true" SEQUENCE="false" COMMENT="One of the constants defined by the question_state class, giving the state of the question at the end of this step." PREVIOUS="sequencenumber" NEXT="fraction"/>
|
||||
<FIELD NAME="fraction" TYPE="number" LENGTH="12" NOTNULL="false" UNSIGNED="false" SEQUENCE="false" DECIMALS="7" COMMENT="The grade for this question, when graded out of 1. Needs to be multiplied by question_attempt.maxmark to get the actual mark for the question." PREVIOUS="state" NEXT="timecreated"/>
|
||||
<FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="Time-stamp of the action that lead to this state being created." PREVIOUS="fraction" NEXT="userid"/>
|
||||
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" COMMENT="The user whose action lead to this state being created." PREVIOUS="timecreated"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="questionattemptid"/>
|
||||
<KEY NAME="questionattemptid" TYPE="foreign" FIELDS="questionattemptid" REFTABLE="question_attempts" REFFIELDS="id" PREVIOUS="primary" NEXT="userid"/>
|
||||
<KEY NAME="userid" TYPE="foreign" FIELDS="userid" REFTABLE="user" REFFIELDS="id" PREVIOUS="questionattemptid"/>
|
||||
</KEYS>
|
||||
<INDEXES>
|
||||
<INDEX NAME="questionattemptid-sequencenumber" UNIQUE="true" FIELDS="questionattemptid, sequencenumber"/>
|
||||
</INDEXES>
|
||||
</TABLE>
|
||||
<TABLE NAME="question_attempt_step_data" COMMENT="Each question_attempt_step has an associative array of the data that was submitted by the user in the POST request. It can also contain extra data from the question type or behaviour to avoid re-computation. The convention is that names belonging to the behaviour start with -, and cached values added to the submitted data start with _, or _-" PREVIOUS="question_attempt_steps" NEXT="question_states">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="attemptstepid"/>
|
||||
<FIELD NAME="attemptstepid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="Foreign key, references question_attempt_steps.id" PREVIOUS="id" NEXT="name"/>
|
||||
<FIELD NAME="name" TYPE="char" LENGTH="32" NOTNULL="true" SEQUENCE="false" COMMENT="The name of this bit of data." PREVIOUS="attemptstepid" NEXT="value"/>
|
||||
<FIELD NAME="value" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" COMMENT="The corresponding value" PREVIOUS="name"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="attemptstepid"/>
|
||||
<KEY NAME="attemptstepid" TYPE="foreign" FIELDS="attemptstepid" REFTABLE="question_attempt_steps" REFFIELDS="id" PREVIOUS="primary"/>
|
||||
</KEYS>
|
||||
<INDEXES>
|
||||
<INDEX NAME="attemptstepid-name" UNIQUE="true" FIELDS="attemptstepid, name"/>
|
||||
</INDEXES>
|
||||
</TABLE>
|
||||
<TABLE NAME="question_states" COMMENT="Stores user responses to an attempt, and percentage grades" PREVIOUS="question_attempt_step_data" NEXT="question_sessions">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="attempt"/>
|
||||
<FIELD NAME="attempt" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="id" NEXT="question"/>
|
||||
|
||||
@@ -6062,6 +6062,358 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
|
||||
upgrade_main_savepoint(true, 2011022100.01);
|
||||
}
|
||||
|
||||
if ($oldversion < 2011051200) {
|
||||
|
||||
// Changing the default of field penalty on table question to 0.3333333
|
||||
$table = new xmldb_table('question');
|
||||
$field = new xmldb_field('penalty');
|
||||
$field->set_attributes(XMLDB_TYPE_FLOAT, null, null,
|
||||
XMLDB_NOTNULL, null, '0.3333333', 'defaultgrade');
|
||||
|
||||
// Launch change of default for field penalty
|
||||
$dbman->change_field_default($table, $field);
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_main_savepoint(true, 2011051200);
|
||||
}
|
||||
|
||||
if ($oldversion < 2011051201) {
|
||||
|
||||
// Rename field defaultgrade on table question to defaultmark
|
||||
$table = new xmldb_table('question');
|
||||
$field = new xmldb_field('defaultgrade');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
|
||||
XMLDB_NOTNULL, null, '1', 'generalfeedback');
|
||||
|
||||
// Launch rename field defaultmark
|
||||
if ($dbman->field_exists($table, $field)) {
|
||||
$dbman->rename_field($table, $field, 'defaultmark');
|
||||
}
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_main_savepoint(true, 2011051201);
|
||||
}
|
||||
|
||||
if ($oldversion < 2011051202) {
|
||||
|
||||
// Rename the question_attempts table to question_usages.
|
||||
$table = new xmldb_table('question_attempts');
|
||||
if (!$dbman->table_exists('question_usages')) {
|
||||
$dbman->rename_table($table, 'question_usages');
|
||||
}
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_main_savepoint(true, 2011051202);
|
||||
}
|
||||
|
||||
if ($oldversion < 2011051203) {
|
||||
|
||||
// Rename the modulename field to component ...
|
||||
$table = new xmldb_table('question_usages');
|
||||
$field = new xmldb_field('modulename');
|
||||
$field->set_attributes(XMLDB_TYPE_CHAR, '255', null,
|
||||
XMLDB_NOTNULL, null, null, 'contextid');
|
||||
|
||||
if ($dbman->field_exists($table, $field)) {
|
||||
$dbman->rename_field($table, $field, 'component');
|
||||
}
|
||||
|
||||
// ... and update its contents.
|
||||
$DB->set_field('question_usages', 'component', 'mod_quiz', array('component' => 'quiz'));
|
||||
|
||||
// Add the contextid field.
|
||||
$field = new xmldb_field('contextid');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
|
||||
null, null, null, 'id');
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
|
||||
// And populate it.
|
||||
$quizmoduleid = $DB->get_field('modules', 'id', array('name' => 'quiz'));
|
||||
$DB->execute("
|
||||
UPDATE {question_usages} SET contextid = (
|
||||
SELECT ctx.id
|
||||
FROM {context} ctx
|
||||
JOIN {course_modules} cm ON cm.id = ctx.instanceid AND cm.module = $quizmoduleid
|
||||
JOIN {quiz_attempts} quiza ON quiza.quiz = cm.instance
|
||||
WHERE ctx.contextlevel = " . CONTEXT_MODULE . "
|
||||
AND quiza.uniqueid = {question_usages}.id
|
||||
)
|
||||
");
|
||||
|
||||
// Then make it NOT NULL.
|
||||
$field = new xmldb_field('contextid');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
|
||||
XMLDB_NOTNULL, null, null, 'id');
|
||||
$dbman->change_field_notnull($table, $field);
|
||||
}
|
||||
|
||||
// Add the preferredbehaviour column. Populate it with a dummy value
|
||||
// for now. We will fill in the appropriate behaviour name when
|
||||
// updating all the rest of the attempt data.
|
||||
$field = new xmldb_field('preferredbehaviour');
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$field->set_attributes(XMLDB_TYPE_CHAR, '32', null,
|
||||
XMLDB_NOTNULL, null, 'to_be_set_later', 'component');
|
||||
$dbman->add_field($table, $field);
|
||||
|
||||
// Then remove the default value, now the column is populated.
|
||||
$field = new xmldb_field('preferredbehaviour');
|
||||
$field->set_attributes(XMLDB_TYPE_CHAR, '32', null,
|
||||
XMLDB_NOTNULL, null, null, 'component');
|
||||
$dbman->change_field_default($table, $field);
|
||||
}
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_main_savepoint(true, 2011051203);
|
||||
}
|
||||
|
||||
if ($oldversion < 2011051204) {
|
||||
|
||||
// Define key contextid (foreign) to be added to question_usages
|
||||
$table = new xmldb_table('question_usages');
|
||||
$key = new XMLDBKey('contextid');
|
||||
$key->set_attributes(XMLDB_KEY_FOREIGN, array('contextid'), 'context', array('id'));
|
||||
|
||||
// Launch add key contextid
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_main_savepoint(true, 2011051204);
|
||||
}
|
||||
|
||||
if ($oldversion < 2011051205) {
|
||||
|
||||
// Changing precision of field component on table question_usages to (255)
|
||||
// This was missed during the upgrade from old versions.
|
||||
$table = new xmldb_table('question_usages');
|
||||
$field = new xmldb_field('component');
|
||||
$field->set_attributes(XMLDB_TYPE_CHAR, '255', null,
|
||||
XMLDB_NOTNULL, null, null, 'contextid');
|
||||
|
||||
// Launch change of precision for field component
|
||||
$dbman->change_field_precision($table, $field);
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_main_savepoint(true, 2011051205);
|
||||
}
|
||||
|
||||
if ($oldversion < 2011051206) {
|
||||
|
||||
// Define table question_attempts to be created
|
||||
$table = new xmldb_table('question_attempts');
|
||||
if (!$dbman->table_exists($table)) {
|
||||
|
||||
// Adding fields to table question_attempts
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
|
||||
XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('questionusageid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
|
||||
XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('slot', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
|
||||
XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('behaviour', XMLDB_TYPE_CHAR, '32', null,
|
||||
XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('questionid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
|
||||
XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('maxmark', XMLDB_TYPE_NUMBER, '12, 7', null,
|
||||
XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('minfraction', XMLDB_TYPE_NUMBER, '12, 7', null,
|
||||
XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('flagged', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED,
|
||||
XMLDB_NOTNULL, null, '0');
|
||||
$table->add_field('questionsummary', XMLDB_TYPE_TEXT, 'small', null,
|
||||
null, null, null);
|
||||
$table->add_field('rightanswer', XMLDB_TYPE_TEXT, 'small', null,
|
||||
null, null, null);
|
||||
$table->add_field('responsesummary', XMLDB_TYPE_TEXT, 'small', null,
|
||||
null, null, null);
|
||||
$table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
|
||||
XMLDB_NOTNULL, null, null);
|
||||
|
||||
// Adding keys to table question_attempts
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
$table->add_key('questionid', XMLDB_KEY_FOREIGN, array('questionid'),
|
||||
'question', array('id'));
|
||||
$table->add_key('questionusageid', XMLDB_KEY_FOREIGN, array('questionusageid'),
|
||||
'question_usages', array('id'));
|
||||
|
||||
// Adding indexes to table question_attempts
|
||||
$table->add_index('questionusageid-slot', XMLDB_INDEX_UNIQUE,
|
||||
array('questionusageid', 'slot'));
|
||||
|
||||
// Launch create table for question_attempts
|
||||
$dbman->create_table($table);
|
||||
}
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_main_savepoint(true, 2011051206);
|
||||
}
|
||||
|
||||
if ($oldversion < 2011051207) {
|
||||
|
||||
// Define table question_attempt_steps to be created
|
||||
$table = new xmldb_table('question_attempt_steps');
|
||||
if (!$dbman->table_exists($table)) {
|
||||
|
||||
// Adding fields to table question_attempt_steps
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
|
||||
XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('questionattemptid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
|
||||
XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('sequencenumber', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
|
||||
XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('state', XMLDB_TYPE_CHAR, '13', null,
|
||||
XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('fraction', XMLDB_TYPE_NUMBER, '12, 7', null,
|
||||
null, null, null);
|
||||
$table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
|
||||
XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
|
||||
null, null, null);
|
||||
|
||||
// Adding keys to table question_attempt_steps
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
$table->add_key('questionattemptid', XMLDB_KEY_FOREIGN,
|
||||
array('questionattemptid'), 'question_attempts_new', array('id'));
|
||||
$table->add_key('userid', XMLDB_KEY_FOREIGN, array('userid'),
|
||||
'user', array('id'));
|
||||
|
||||
// Adding indexes to table question_attempt_steps
|
||||
$table->add_index('questionattemptid-sequencenumber', XMLDB_INDEX_UNIQUE,
|
||||
array('questionattemptid', 'sequencenumber'));
|
||||
|
||||
// Launch create table for question_attempt_steps
|
||||
$dbman->create_table($table);
|
||||
}
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_main_savepoint(true, 2011051207);
|
||||
}
|
||||
|
||||
if ($oldversion < 2011051208) {
|
||||
|
||||
// Define table question_attempt_step_data to be created
|
||||
$table = new xmldb_table('question_attempt_step_data');
|
||||
if (!$dbman->table_exists($table)) {
|
||||
|
||||
// Adding fields to table question_attempt_step_data
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
|
||||
XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('attemptstepid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
|
||||
XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('name', XMLDB_TYPE_CHAR, '32', null,
|
||||
XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('value', XMLDB_TYPE_TEXT, 'small', null,
|
||||
null, null, null);
|
||||
|
||||
// Adding keys to table question_attempt_step_data
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
$table->add_key('attemptstepid', XMLDB_KEY_FOREIGN, array('attemptstepid'),
|
||||
'question_attempt_steps', array('id'));
|
||||
|
||||
// Adding indexes to table question_attempt_step_data
|
||||
$table->add_index('attemptstepid-name', XMLDB_INDEX_UNIQUE,
|
||||
array('attemptstepid', 'name'));
|
||||
|
||||
// Launch create table for question_attempt_step_data
|
||||
$dbman->create_table($table);
|
||||
}
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_main_savepoint(true, 2011051208);
|
||||
}
|
||||
|
||||
if ($oldversion < 2011051209) {
|
||||
|
||||
// Define table question_hints to be created
|
||||
$table = new xmldb_table('question_hints');
|
||||
|
||||
// Adding fields to table question_hints
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
|
||||
XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('questionid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
|
||||
XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('hint', XMLDB_TYPE_TEXT, 'small', null,
|
||||
XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('hintformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED,
|
||||
XMLDB_NOTNULL, null, '0');
|
||||
$table->add_field('shownumcorrect', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED,
|
||||
null, null, null);
|
||||
$table->add_field('clearwrong', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED,
|
||||
null, null, null);
|
||||
$table->add_field('options', XMLDB_TYPE_CHAR, '255', null,
|
||||
null, null, null);
|
||||
|
||||
// Adding keys to table question_hints
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
$table->add_key('questionid', XMLDB_KEY_FOREIGN, array('questionid'),
|
||||
'question', array('id'));
|
||||
|
||||
// Conditionally launch create table for question_hints
|
||||
if (!$dbman->table_exists($table)) {
|
||||
$dbman->create_table($table);
|
||||
}
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_main_savepoint(true, 2011051209);
|
||||
}
|
||||
|
||||
if ($oldversion < 2011051210) {
|
||||
|
||||
// In the past, question_answer fractions were stored with rather
|
||||
// sloppy rounding. Now update them to the new standard of 7 d.p.
|
||||
$changes = array(
|
||||
'-0.66666' => '-0.6666667',
|
||||
'-0.33333' => '-0.3333333',
|
||||
'-0.16666' => '-0.1666667',
|
||||
'-0.142857' => '-0.1428571',
|
||||
'0.11111' => '0.1111111',
|
||||
'0.142857' => '0.1428571',
|
||||
'0.16666' => '0.1666667',
|
||||
'0.33333' => '0.3333333',
|
||||
'0.333333' => '0.3333333',
|
||||
'0.66666' => '0.6666667',
|
||||
);
|
||||
foreach ($changes as $from => $to) {
|
||||
$DB->set_field('question_answers',
|
||||
'fraction', $to, array('fraction' => $from));
|
||||
}
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_main_savepoint(true, 2011051210);
|
||||
}
|
||||
|
||||
if ($oldversion < 2011051211) {
|
||||
|
||||
// In the past, question penalties were stored with rather
|
||||
// sloppy rounding. Now update them to the new standard of 7 d.p.
|
||||
$DB->set_field('question',
|
||||
'penalty', 0.3333333, array('penalty' => 33.3));
|
||||
$DB->set_field_select('question',
|
||||
'penalty', 0.3333333, 'penalty >= 0.33 AND penalty <= 0.34');
|
||||
$DB->set_field_select('question',
|
||||
'penalty', 0.6666667, 'penalty >= 0.66 AND penalty <= 0.67');
|
||||
$DB->set_field_select('question',
|
||||
'penalty', 1, 'penalty > 1');
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_main_savepoint(true, 2011051211);
|
||||
}
|
||||
|
||||
if ($oldversion < 2011051212) {
|
||||
|
||||
// Define field hintformat to be added to question_hints table.
|
||||
$table = new xmldb_table('question_hints');
|
||||
$field = new xmldb_field('hintformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED,
|
||||
XMLDB_NOTNULL, null, '0');
|
||||
|
||||
// Conditionally launch add field partiallycorrectfeedbackformat
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
upgrade_main_savepoint(true, 2011051212);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,696 +0,0 @@
|
||||
<?php
|
||||
|
||||
function xmldb_local_qedatabase_install() {
|
||||
global $DB;
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
// Bit of a hack to prevent errors like "Cannot downgrade local_qedatabase from ... to ...".
|
||||
$oldversion = 2008000000;
|
||||
$DB->set_field('config_plugins', 'value', $oldversion,
|
||||
array('plugin' => 'local_qedatabase', 'name' => 'version'));
|
||||
|
||||
// Add new preferredbehaviour column to the quiz table.
|
||||
if ($oldversion < 2008000100) {
|
||||
$table = new xmldb_table('quiz');
|
||||
$field = new xmldb_field('preferredbehaviour');
|
||||
$field->set_attributes(XMLDB_TYPE_CHAR, '32', null, null, null, null, 'timeclose');
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008000100, 'local', 'qedatabase');
|
||||
}
|
||||
|
||||
// Populate preferredbehaviour column based on old optionflags column.
|
||||
if ($oldversion < 2008000101) {
|
||||
$DB->set_field_select('quiz', 'preferredbehaviour', 'deferredfeedback',
|
||||
'optionflags = 0');
|
||||
$DB->set_field_select('quiz', 'preferredbehaviour', 'adaptive',
|
||||
'optionflags <> 0 AND penaltyscheme <> 0');
|
||||
$DB->set_field_select('quiz', 'preferredbehaviour', 'adaptivenopenalty',
|
||||
'optionflags <> 0 AND penaltyscheme = 0');
|
||||
|
||||
set_config('preferredbehaviour', 'deferredfeedback', 'quiz');
|
||||
set_config('fix_preferredbehaviour', 0, 'quiz');
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008000101, 'local', 'qedatabase');
|
||||
}
|
||||
|
||||
// Add a not-NULL constraint to the preferredmodel field now that it is populated.
|
||||
if ($oldversion < 2008000102) {
|
||||
$table = new xmldb_table('quiz');
|
||||
$field = new xmldb_field('preferredbehaviour');
|
||||
$field->set_attributes(XMLDB_TYPE_CHAR, '32', null, XMLDB_NOTNULL, null, null, 'timeclose');
|
||||
|
||||
$dbman->change_field_notnull($table, $field);
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008000102, 'local', 'qedatabase');
|
||||
}
|
||||
|
||||
// Drop the old optionflags field.
|
||||
if ($oldversion < 2008000103) {
|
||||
$table = new xmldb_table('quiz');
|
||||
$field = new xmldb_field('optionflags');
|
||||
$dbman->drop_field($table, $field);
|
||||
|
||||
unset_config('optionflags', 'quiz');
|
||||
unset_config('fix_optionflags', 'quiz');
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008000103, 'local', 'qedatabase');
|
||||
}
|
||||
|
||||
// Drop the old penaltyscheme field.
|
||||
if ($oldversion < 2008000104) {
|
||||
$table = new xmldb_table('quiz');
|
||||
$field = new xmldb_field('penaltyscheme');
|
||||
$dbman->drop_field($table, $field);
|
||||
|
||||
unset_config('penaltyscheme', 'quiz');
|
||||
unset_config('fix_penaltyscheme', 'quiz');
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008000104, 'local', 'qedatabase');
|
||||
}
|
||||
|
||||
if ($oldversion < 2008000110) {
|
||||
|
||||
// Changing nullability of field sumgrades on table quiz_attempts to null
|
||||
$table = new xmldb_table('quiz_attempts');
|
||||
$field = new xmldb_field('sumgrades');
|
||||
$field->set_attributes(XMLDB_TYPE_NUMBER, '10, 5', null, null, null, null, 'attempt');
|
||||
|
||||
// Launch change of nullability for field sumgrades
|
||||
$dbman->change_field_notnull($table, $field);
|
||||
|
||||
// Launch change of default for field sumgrades
|
||||
$dbman->change_field_default($table, $field);
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008000110, 'local', 'qedatabase');
|
||||
}
|
||||
|
||||
if ($oldversion < 2008000111) {
|
||||
|
||||
// Changing the default of field penalty on table question to 0.3333333
|
||||
$table = new xmldb_table('question');
|
||||
$field = new xmldb_field('penalty');
|
||||
$field->set_attributes(XMLDB_TYPE_FLOAT, null, null, XMLDB_NOTNULL, null, '0.3333333', 'defaultgrade');
|
||||
|
||||
// Launch change of default for field penalty
|
||||
$dbman->change_field_default($table, $field);
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008000111, 'local', 'qedatabase');
|
||||
}
|
||||
|
||||
// Update the quiz from the old single review column to seven new columns.
|
||||
|
||||
if ($oldversion < 2008000200) {
|
||||
|
||||
// Define field reviewattempt to be added to quiz
|
||||
$table = new xmldb_table('quiz');
|
||||
$field = new xmldb_field('reviewattempt');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '6', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'review');
|
||||
|
||||
// Launch add field reviewattempt
|
||||
$dbman->add_field($table, $field);
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008000200, 'local', 'qedatabase');
|
||||
}
|
||||
|
||||
if ($oldversion < 2008000201) {
|
||||
|
||||
// Define field reviewattempt to be added to quiz
|
||||
$table = new xmldb_table('quiz');
|
||||
$field = new xmldb_field('reviewcorrectness');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '6', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'reviewattempt');
|
||||
|
||||
// Launch add field reviewattempt
|
||||
$dbman->add_field($table, $field);
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008000201, 'local', 'qedatabase');
|
||||
}
|
||||
|
||||
if ($oldversion < 2008000202) {
|
||||
|
||||
// Define field reviewattempt to be added to quiz
|
||||
$table = new xmldb_table('quiz');
|
||||
$field = new xmldb_field('reviewmarks');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '6', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'reviewcorrectness');
|
||||
|
||||
// Launch add field reviewattempt
|
||||
$dbman->add_field($table, $field);
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008000202, 'local', 'qedatabase');
|
||||
}
|
||||
|
||||
if ($oldversion < 2008000203) {
|
||||
|
||||
// Define field reviewattempt to be added to quiz
|
||||
$table = new xmldb_table('quiz');
|
||||
$field = new xmldb_field('reviewspecificfeedback');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '6', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'reviewmarks');
|
||||
|
||||
// Launch add field reviewattempt
|
||||
$dbman->add_field($table, $field);
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008000203, 'local', 'qedatabase');
|
||||
}
|
||||
|
||||
if ($oldversion < 2008000204) {
|
||||
|
||||
// Define field reviewattempt to be added to quiz
|
||||
$table = new xmldb_table('quiz');
|
||||
$field = new xmldb_field('reviewgeneralfeedback');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '6', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'reviewspecificfeedback');
|
||||
|
||||
// Launch add field reviewattempt
|
||||
$dbman->add_field($table, $field);
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008000204, 'local', 'qedatabase');
|
||||
}
|
||||
|
||||
if ($oldversion < 2008000205) {
|
||||
|
||||
// Define field reviewattempt to be added to quiz
|
||||
$table = new xmldb_table('quiz');
|
||||
$field = new xmldb_field('reviewrightanswer');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '6', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'reviewgeneralfeedback');
|
||||
|
||||
// Launch add field reviewattempt
|
||||
$dbman->add_field($table, $field);
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008000205, 'local', 'qedatabase');
|
||||
}
|
||||
|
||||
if ($oldversion < 2008000206) {
|
||||
|
||||
// Define field reviewattempt to be added to quiz
|
||||
$table = new xmldb_table('quiz');
|
||||
$field = new xmldb_field('reviewoverallfeedback');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '6', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'reviewrightanswer');
|
||||
|
||||
// Launch add field reviewattempt
|
||||
$dbman->add_field($table, $field);
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008000206, 'local', 'qedatabase');
|
||||
}
|
||||
|
||||
define('QUIZ_NEW_DURING', 0x10000);
|
||||
define('QUIZ_NEW_IMMEDIATELY_AFTER', 0x01000);
|
||||
define('QUIZ_NEW_LATER_WHILE_OPEN', 0x00100);
|
||||
define('QUIZ_NEW_AFTER_CLOSE', 0x00010);
|
||||
|
||||
define('QUIZ_OLD_IMMEDIATELY', 0x3c003f);
|
||||
define('QUIZ_OLD_OPEN', 0x3c00fc0);
|
||||
define('QUIZ_OLD_CLOSED', 0x3c03f000);
|
||||
|
||||
define('QUIZ_OLD_RESPONSES', 1*0x1041); // Show responses
|
||||
define('QUIZ_OLD_SCORES', 2*0x1041); // Show scores
|
||||
define('QUIZ_OLD_FEEDBACK', 4*0x1041); // Show question feedback
|
||||
define('QUIZ_OLD_ANSWERS', 8*0x1041); // Show correct answers
|
||||
define('QUIZ_OLD_SOLUTIONS', 16*0x1041); // Show solutions
|
||||
define('QUIZ_OLD_GENERALFEEDBACK',32*0x1041); // Show question general feedback
|
||||
define('QUIZ_OLD_OVERALLFEEDBACK', 1*0x4440000); // Show quiz overall feedback
|
||||
|
||||
// Copy the old review settings
|
||||
if ($oldversion < 2008000210) {
|
||||
$DB->execute("
|
||||
UPDATE {quiz}
|
||||
SET reviewattempt = " . $DB->sql_bitor($DB->sql_bitor(
|
||||
QUIZ_NEW_DURING,
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_RESPONSES) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_IMMEDIATELY_AFTER . ' ELSE 0 END'), $DB->sql_bitor(
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_OPEN & QUIZ_OLD_RESPONSES) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_LATER_WHILE_OPEN . ' ELSE 0 END',
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_CLOSED & QUIZ_OLD_RESPONSES) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_AFTER_CLOSE . ' ELSE 0 END')) . "
|
||||
");
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008000210, 'local', 'qedatabase');
|
||||
}
|
||||
|
||||
if ($oldversion < 2008000211) {
|
||||
$DB->execute("
|
||||
UPDATE {quiz}
|
||||
SET reviewcorrectness = " . $DB->sql_bitor($DB->sql_bitor(
|
||||
QUIZ_NEW_DURING,
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_SCORES) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_IMMEDIATELY_AFTER . ' ELSE 0 END'), $DB->sql_bitor(
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_OPEN & QUIZ_OLD_SCORES) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_LATER_WHILE_OPEN . ' ELSE 0 END',
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_CLOSED & QUIZ_OLD_SCORES) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_AFTER_CLOSE . ' ELSE 0 END')) . "
|
||||
");
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008000211, 'local', 'qedatabase');
|
||||
}
|
||||
|
||||
if ($oldversion < 2008000212) {
|
||||
$DB->execute("
|
||||
UPDATE {quiz}
|
||||
SET reviewmarks = " . $DB->sql_bitor($DB->sql_bitor(
|
||||
QUIZ_NEW_DURING,
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_SCORES) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_IMMEDIATELY_AFTER . ' ELSE 0 END'), $DB->sql_bitor(
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_OPEN & QUIZ_OLD_SCORES) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_LATER_WHILE_OPEN . ' ELSE 0 END',
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_CLOSED & QUIZ_OLD_SCORES) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_AFTER_CLOSE . ' ELSE 0 END')) . "
|
||||
");
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008000212, 'local', 'qedatabase');
|
||||
}
|
||||
|
||||
if ($oldversion < 2008000213) {
|
||||
$DB->execute("
|
||||
UPDATE {quiz}
|
||||
SET reviewspecificfeedback = " . $DB->sql_bitor($DB->sql_bitor(
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_FEEDBACK) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_DURING . ' ELSE 0 END',
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_FEEDBACK) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_IMMEDIATELY_AFTER . ' ELSE 0 END'), $DB->sql_bitor(
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_OPEN & QUIZ_OLD_FEEDBACK) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_LATER_WHILE_OPEN . ' ELSE 0 END',
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_CLOSED & QUIZ_OLD_FEEDBACK) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_AFTER_CLOSE . ' ELSE 0 END')) . "
|
||||
");
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008000213, 'local', 'qedatabase');
|
||||
}
|
||||
|
||||
if ($oldversion < 2008000214) {
|
||||
$DB->execute("
|
||||
UPDATE {quiz}
|
||||
SET reviewgeneralfeedback = " . $DB->sql_bitor($DB->sql_bitor(
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_GENERALFEEDBACK) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_DURING . ' ELSE 0 END',
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_GENERALFEEDBACK) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_IMMEDIATELY_AFTER . ' ELSE 0 END'), $DB->sql_bitor(
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_OPEN & QUIZ_OLD_GENERALFEEDBACK) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_LATER_WHILE_OPEN . ' ELSE 0 END',
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_CLOSED & QUIZ_OLD_GENERALFEEDBACK) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_AFTER_CLOSE . ' ELSE 0 END')) . "
|
||||
");
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008000214, 'local', 'qedatabase');
|
||||
}
|
||||
|
||||
if ($oldversion < 2008000215) {
|
||||
$DB->execute("
|
||||
UPDATE {quiz}
|
||||
SET reviewrightanswer = " . $DB->sql_bitor($DB->sql_bitor(
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_ANSWERS) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_DURING . ' ELSE 0 END',
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_ANSWERS) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_IMMEDIATELY_AFTER . ' ELSE 0 END'), $DB->sql_bitor(
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_OPEN & QUIZ_OLD_ANSWERS) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_LATER_WHILE_OPEN . ' ELSE 0 END',
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_CLOSED & QUIZ_OLD_ANSWERS) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_AFTER_CLOSE . ' ELSE 0 END')) . "
|
||||
");
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008000215, 'local', 'qedatabase');
|
||||
}
|
||||
|
||||
if ($oldversion < 2008000216) {
|
||||
$DB->execute("
|
||||
UPDATE {quiz}
|
||||
SET reviewoverallfeedback = " . $DB->sql_bitor($DB->sql_bitor(
|
||||
0,
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_OVERALLFEEDBACK) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_IMMEDIATELY_AFTER . ' ELSE 0 END'), $DB->sql_bitor(
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_OPEN & QUIZ_OLD_OVERALLFEEDBACK) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_LATER_WHILE_OPEN . ' ELSE 0 END',
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_CLOSED & QUIZ_OLD_OVERALLFEEDBACK) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_AFTER_CLOSE . ' ELSE 0 END')) . "
|
||||
");
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008000216, 'local', 'qedatabase');
|
||||
}
|
||||
|
||||
// And, do the same for the defaults
|
||||
if ($oldversion < 2008000217) {
|
||||
if (empty($CFG->quiz_review)) {
|
||||
$CFG->quiz_review = 0;
|
||||
}
|
||||
|
||||
set_config('reviewattempt',
|
||||
QUIZ_NEW_DURING |
|
||||
($CFG->quiz_review & QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_RESPONSES ? QUIZ_NEW_IMMEDIATELY_AFTER : 0) |
|
||||
($CFG->quiz_review & QUIZ_OLD_OPEN & QUIZ_OLD_RESPONSES ? QUIZ_NEW_LATER_WHILE_OPEN : 0) |
|
||||
($CFG->quiz_review & QUIZ_OLD_CLOSED & QUIZ_OLD_RESPONSES ? QUIZ_NEW_AFTER_CLOSE : 0),
|
||||
'quiz');
|
||||
|
||||
set_config('reviewcorrectness',
|
||||
QUIZ_NEW_DURING |
|
||||
($CFG->quiz_review & QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_SCORES ? QUIZ_NEW_IMMEDIATELY_AFTER : 0) |
|
||||
($CFG->quiz_review & QUIZ_OLD_OPEN & QUIZ_OLD_SCORES ? QUIZ_NEW_LATER_WHILE_OPEN : 0) |
|
||||
($CFG->quiz_review & QUIZ_OLD_CLOSED & QUIZ_OLD_SCORES ? QUIZ_NEW_AFTER_CLOSE : 0),
|
||||
'quiz');
|
||||
|
||||
set_config('reviewmarks',
|
||||
QUIZ_NEW_DURING |
|
||||
($CFG->quiz_review & QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_SCORES ? QUIZ_NEW_IMMEDIATELY_AFTER : 0) |
|
||||
($CFG->quiz_review & QUIZ_OLD_OPEN & QUIZ_OLD_SCORES ? QUIZ_NEW_LATER_WHILE_OPEN : 0) |
|
||||
($CFG->quiz_review & QUIZ_OLD_CLOSED & QUIZ_OLD_SCORES ? QUIZ_NEW_AFTER_CLOSE : 0),
|
||||
'quiz');
|
||||
|
||||
set_config('reviewspecificfeedback',
|
||||
($CFG->quiz_review & QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_FEEDBACK ? QUIZ_NEW_DURING : 0) |
|
||||
($CFG->quiz_review & QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_FEEDBACK ? QUIZ_NEW_IMMEDIATELY_AFTER : 0) |
|
||||
($CFG->quiz_review & QUIZ_OLD_OPEN & QUIZ_OLD_FEEDBACK ? QUIZ_NEW_LATER_WHILE_OPEN : 0) |
|
||||
($CFG->quiz_review & QUIZ_OLD_CLOSED & QUIZ_OLD_FEEDBACK ? QUIZ_NEW_AFTER_CLOSE : 0),
|
||||
'quiz');
|
||||
|
||||
set_config('reviewgeneralfeedback',
|
||||
($CFG->quiz_review & QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_GENERALFEEDBACK ? QUIZ_NEW_DURING : 0) |
|
||||
($CFG->quiz_review & QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_GENERALFEEDBACK ? QUIZ_NEW_IMMEDIATELY_AFTER : 0) |
|
||||
($CFG->quiz_review & QUIZ_OLD_OPEN & QUIZ_OLD_GENERALFEEDBACK ? QUIZ_NEW_LATER_WHILE_OPEN : 0) |
|
||||
($CFG->quiz_review & QUIZ_OLD_CLOSED & QUIZ_OLD_GENERALFEEDBACK ? QUIZ_NEW_AFTER_CLOSE : 0),
|
||||
'quiz');
|
||||
|
||||
set_config('reviewrightanswer',
|
||||
($CFG->quiz_review & QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_ANSWERS ? QUIZ_NEW_DURING : 0) |
|
||||
($CFG->quiz_review & QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_ANSWERS ? QUIZ_NEW_IMMEDIATELY_AFTER : 0) |
|
||||
($CFG->quiz_review & QUIZ_OLD_OPEN & QUIZ_OLD_ANSWERS ? QUIZ_NEW_LATER_WHILE_OPEN : 0) |
|
||||
($CFG->quiz_review & QUIZ_OLD_CLOSED & QUIZ_OLD_ANSWERS ? QUIZ_NEW_AFTER_CLOSE : 0),
|
||||
'quiz');
|
||||
|
||||
set_config('reviewoverallfeedback',
|
||||
0 |
|
||||
($CFG->quiz_review & QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_OVERALLFEEDBACK ? QUIZ_NEW_IMMEDIATELY_AFTER : 0) |
|
||||
($CFG->quiz_review & QUIZ_OLD_OPEN & QUIZ_OLD_OVERALLFEEDBACK ? QUIZ_NEW_LATER_WHILE_OPEN : 0) |
|
||||
($CFG->quiz_review & QUIZ_OLD_CLOSED & QUIZ_OLD_OVERALLFEEDBACK ? QUIZ_NEW_AFTER_CLOSE : 0),
|
||||
'quiz');
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008000217, 'local', 'qedatabase');
|
||||
}
|
||||
|
||||
// Finally drop the old column
|
||||
if ($oldversion < 2008000220) {
|
||||
// Define field review to be dropped from quiz
|
||||
$table = new xmldb_table('quiz');
|
||||
$field = new xmldb_field('review');
|
||||
|
||||
// Launch drop field review
|
||||
$dbman->drop_field($table, $field);
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008000220, 'local', 'qedatabase');
|
||||
}
|
||||
|
||||
if ($oldversion < 2008000221) {
|
||||
unset_config('review', 'quiz');
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008000221, 'local', 'qedatabase');
|
||||
}
|
||||
|
||||
if ($oldversion < 2008000501) {
|
||||
|
||||
// Rename field defaultgrade on table question to defaultmark
|
||||
$table = new xmldb_table('question');
|
||||
$field = new xmldb_field('defaultgrade');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '1', 'generalfeedback');
|
||||
|
||||
// Launch rename field defaultmark
|
||||
$dbman->rename_field($table, $field, 'defaultmark');
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008000501, 'local', 'qedatabase');
|
||||
}
|
||||
|
||||
if ($oldversion < 2008000505) {
|
||||
|
||||
// Rename the question_attempts table to question_usages.
|
||||
$table = new xmldb_table('question_attempts');
|
||||
if ($dbman->table_exists($table)) {
|
||||
$dbman->rename_table($table, 'question_usages');
|
||||
}
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008000505, 'local', 'qedatabase');
|
||||
}
|
||||
|
||||
if ($oldversion < 2008000507) {
|
||||
|
||||
// Rename the modulename field to component ...
|
||||
$table = new xmldb_table('question_usages');
|
||||
$field = new xmldb_field('modulename');
|
||||
$field->set_attributes(XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, 'contextid');
|
||||
$dbman->rename_field($table, $field, 'component');
|
||||
|
||||
// ... and update its contents.
|
||||
$DB->set_field('question_usages', 'component', 'mod_quiz', array('component' => 'quiz'));
|
||||
|
||||
// Add the contextid field.
|
||||
$field = new xmldb_field('contextid');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, 'id');
|
||||
$dbman->add_field($table, $field);
|
||||
|
||||
// And populate it.
|
||||
$quizmoduleid = $DB->get_field('modules', 'id', array('name' => 'quiz'));
|
||||
$DB->execute("
|
||||
UPDATE {question_usages} SET contextid = (
|
||||
SELECT ctx.id
|
||||
FROM {context} ctx
|
||||
JOIN {course_modules} cm ON cm.id = ctx.instanceid AND cm.module = $quizmoduleid
|
||||
JOIN {quiz_attempts} quiza ON quiza.quiz = cm.instance
|
||||
WHERE ctx.contextlevel = " . CONTEXT_MODULE . "
|
||||
AND quiza.uniqueid = {question_usages}.id
|
||||
)
|
||||
");
|
||||
|
||||
// Then make it NOT NULL.
|
||||
$field = new xmldb_field('contextid');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, 'id');
|
||||
$dbman->change_field_notnull($table, $field);
|
||||
|
||||
// Add the preferredbehaviour column. Populate it with a dummy value
|
||||
// for now. We will fill in the appropriate behaviour name when
|
||||
// updating all the rest of the attempt data.
|
||||
$field = new xmldb_field('preferredbehaviour');
|
||||
$field->set_attributes(XMLDB_TYPE_CHAR, '32', null, XMLDB_NOTNULL, null, 'to_be_set_later', 'component');
|
||||
$dbman->add_field($table, $field);
|
||||
|
||||
// Then remove the default value, now the column is populated.
|
||||
$field = new xmldb_field('preferredbehaviour');
|
||||
$field->set_attributes(XMLDB_TYPE_CHAR, '32', null, XMLDB_NOTNULL, null, null, 'component');
|
||||
$dbman->change_field_default($table, $field);
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008000507, 'local', 'qedatabase');
|
||||
}
|
||||
|
||||
if ($oldversion < 2008000513) {
|
||||
|
||||
// Define key contextid (foreign) to be added to question_usages
|
||||
$table = new xmldb_table('question_usages');
|
||||
$key = new XMLDBKey('contextid');
|
||||
$key->set_attributes(XMLDB_KEY_FOREIGN, array('contextid'), 'context', array('id'));
|
||||
|
||||
// Launch add key contextid
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008000513, 'local', 'qedatabase');
|
||||
}
|
||||
|
||||
if ($oldversion < 2008000514) {
|
||||
|
||||
// Changing precision of field component on table question_usages to (255)
|
||||
// This was missed during the upgrade from old versions.
|
||||
$table = new xmldb_table('question_usages');
|
||||
$field = new xmldb_field('component');
|
||||
$field->set_attributes(XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, 'contextid');
|
||||
|
||||
// Launch change of precision for field component
|
||||
$dbman->change_field_precision($table, $field);
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008000514, 'local', 'qedatabase');
|
||||
}
|
||||
|
||||
if ($oldversion < 2008000520) {
|
||||
|
||||
// Define table question_attempts to be created
|
||||
$table = new xmldb_table('question_attempts');
|
||||
if (!$dbman->table_exists($table)) {
|
||||
|
||||
// Adding fields to table question_attempts
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('questionusageid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('slot', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('behaviour', XMLDB_TYPE_CHAR, '32', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('questionid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('maxmark', XMLDB_TYPE_NUMBER, '12, 7', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('minfraction', XMLDB_TYPE_NUMBER, '12, 7', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('flagged', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
|
||||
$table->add_field('questionsummary', XMLDB_TYPE_TEXT, 'small', null, null, null, null);
|
||||
$table->add_field('rightanswer', XMLDB_TYPE_TEXT, 'small', null, null, null, null);
|
||||
$table->add_field('responsesummary', XMLDB_TYPE_TEXT, 'small', null, null, null, null);
|
||||
$table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
|
||||
// Adding keys to table question_attempts
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
$table->add_key('questionid', XMLDB_KEY_FOREIGN, array('questionid'), 'question', array('id'));
|
||||
$table->add_key('questionusageid', XMLDB_KEY_FOREIGN, array('questionusageid'), 'question_usages', array('id'));
|
||||
|
||||
// Adding indexes to table question_attempts
|
||||
$table->add_index('questionusageid-slot', XMLDB_INDEX_UNIQUE, array('questionusageid', 'slot'));
|
||||
|
||||
// Launch create table for question_attempts
|
||||
$dbman->create_table($table);
|
||||
}
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008000520, 'local', 'qedatabase');
|
||||
}
|
||||
|
||||
if ($oldversion < 2008000521) {
|
||||
|
||||
// Define table question_attempt_steps to be created
|
||||
$table = new xmldb_table('question_attempt_steps');
|
||||
if (!$dbman->table_exists($table)) {
|
||||
|
||||
// Adding fields to table question_attempt_steps
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('questionattemptid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('sequencenumber', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('state', XMLDB_TYPE_CHAR, '13', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('fraction', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null);
|
||||
$table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null);
|
||||
|
||||
// Adding keys to table question_attempt_steps
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
$table->add_key('questionattemptid', XMLDB_KEY_FOREIGN, array('questionattemptid'), 'question_attempts_new', array('id'));
|
||||
$table->add_key('userid', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
|
||||
|
||||
// Adding indexes to table question_attempt_steps
|
||||
$table->add_index('questionattemptid-sequencenumber', XMLDB_INDEX_UNIQUE, array('questionattemptid', 'sequencenumber'));
|
||||
|
||||
// Launch create table for question_attempt_steps
|
||||
$dbman->create_table($table);
|
||||
}
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008000521, 'local', 'qedatabase');
|
||||
}
|
||||
|
||||
if ($oldversion < 2008000522) {
|
||||
|
||||
// Define table question_attempt_step_data to be created
|
||||
$table = new xmldb_table('question_attempt_step_data');
|
||||
if (!$dbman->table_exists($table)) {
|
||||
|
||||
// Adding fields to table question_attempt_step_data
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('attemptstepid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('name', XMLDB_TYPE_CHAR, '32', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('value', XMLDB_TYPE_TEXT, 'small', null, null, null, null);
|
||||
|
||||
// Adding keys to table question_attempt_step_data
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
$table->add_key('attemptstepid', XMLDB_KEY_FOREIGN, array('attemptstepid'), 'question_attempt_steps', array('id'));
|
||||
|
||||
// Adding indexes to table question_attempt_step_data
|
||||
$table->add_index('attemptstepid-name', XMLDB_INDEX_UNIQUE, array('attemptstepid', 'name'));
|
||||
|
||||
// Launch create table for question_attempt_step_data
|
||||
$dbman->create_table($table);
|
||||
}
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008000522, 'local', 'qedatabase');
|
||||
}
|
||||
|
||||
if ($oldversion < 2008000600) {
|
||||
|
||||
// Define table question_hints to be created
|
||||
$table = new xmldb_table('question_hints');
|
||||
|
||||
// Adding fields to table question_hints
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('questionid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('hint', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('hintformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
|
||||
$table->add_field('shownumcorrect', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, null);
|
||||
$table->add_field('clearwrong', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, null);
|
||||
$table->add_field('options', XMLDB_TYPE_CHAR, '255', null, null, null, null);
|
||||
|
||||
// Adding keys to table question_hints
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
$table->add_key('questionid', XMLDB_KEY_FOREIGN, array('questionid'), 'question', array('id'));
|
||||
|
||||
// Conditionally launch create table for question_hints
|
||||
if (!$dbman->table_exists($table)) {
|
||||
$dbman->create_table($table);
|
||||
}
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008000600, 'local', 'qedatabase');
|
||||
}
|
||||
|
||||
if ($oldversion < 2008000601) {
|
||||
|
||||
// In the past, question_answer fractions were stored with rather
|
||||
// sloppy rounding. Now update them to the new standard of 7 d.p.
|
||||
$changes = array(
|
||||
'-0.66666' => '-0.6666667',
|
||||
'-0.33333' => '-0.3333333',
|
||||
'-0.16666' => '-0.1666667',
|
||||
'-0.142857' => '-0.1428571',
|
||||
'0.11111' => '0.1111111',
|
||||
'0.142857' => '0.1428571',
|
||||
'0.16666' => '0.1666667',
|
||||
'0.33333' => '0.3333333',
|
||||
'0.333333' => '0.3333333',
|
||||
'0.66666' => '0.6666667',
|
||||
);
|
||||
foreach ($changes as $from => $to) {
|
||||
$DB->set_field('question_answers',
|
||||
'fraction', $to, array('fraction' => $from));
|
||||
}
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008000601, 'local', 'qedatabase');
|
||||
}
|
||||
|
||||
if ($oldversion < 2008000602) {
|
||||
|
||||
// In the past, question penalties were stored with rather
|
||||
// sloppy rounding. Now update them to the new standard of 7 d.p.
|
||||
$DB->set_field('question',
|
||||
'penalty', 0.3333333, array('penalty' => 33.3));
|
||||
$DB->set_field_select('question',
|
||||
'penalty', 0.3333333, 'penalty >= 0.33 AND penalty <= 0.34');
|
||||
$DB->set_field_select('question',
|
||||
'penalty', 0.6666667, 'penalty >= 0.66 AND penalty <= 0.67');
|
||||
$DB->set_field_select('question',
|
||||
'penalty', 1, 'penalty > 1');
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008000602, 'local', 'qedatabase');
|
||||
}
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
<?php
|
||||
|
||||
function xmldb_local_qedatabase_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
if ($oldversion < 2008000700) {
|
||||
|
||||
// Define field hintformat to be added to question_hints table.
|
||||
$table = new xmldb_table('question_hints');
|
||||
$field = new xmldb_field('hintformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
|
||||
|
||||
// Conditionally launch add field partiallycorrectfeedbackformat
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
upgrade_plugin_savepoint(true, 2008000700, 'local', 'qedatabase');
|
||||
}
|
||||
|
||||
if ($oldversion < 2008000701) {
|
||||
// Define table quiz_report to be renamed to quiz_reports
|
||||
$table = new xmldb_table('quiz_report');
|
||||
|
||||
// Launch rename table for quiz_reports
|
||||
if ($dbman->table_exists($table)) {
|
||||
$dbman->rename_table($table, 'quiz_reports');
|
||||
}
|
||||
|
||||
upgrade_plugin_savepoint(true, 2008000701, 'local', 'qedatabase');
|
||||
}
|
||||
|
||||
if ($oldversion < 2008000702) {
|
||||
// Define index name (unique) to be added to quiz_reports
|
||||
$table = new xmldb_table('quiz_reports');
|
||||
$index = new xmldb_index('name', XMLDB_INDEX_UNIQUE, array('name'));
|
||||
|
||||
// Conditionally launch add index name
|
||||
if (!$dbman->index_exists($table, $index)) {
|
||||
$dbman->add_index($table, $index);
|
||||
}
|
||||
|
||||
upgrade_plugin_savepoint(true, 2008000702, 'local', 'qedatabase');
|
||||
}
|
||||
|
||||
if ($oldversion < 2008000703) {
|
||||
// Rename the quiz_report table to quiz_reports.
|
||||
$table = new xmldb_table('quiz_report');
|
||||
if ($dbman->table_exists($table)) {
|
||||
$dbman->rename_table($table, 'quiz_reports');
|
||||
}
|
||||
|
||||
upgrade_plugin_savepoint(true, 2008000703, 'local', 'qedatabase');
|
||||
}
|
||||
|
||||
if ($oldversion < 2008000704) {
|
||||
|
||||
// Changing nullability of field sumgrades on table quiz_attempts to null
|
||||
$table = new xmldb_table('quiz_attempts');
|
||||
$field = new xmldb_field('sumgrades', XMLDB_TYPE_NUMBER, '10, 5', null, null, null, null, 'attempt');
|
||||
|
||||
// Launch change of nullability for field sumgrades
|
||||
$dbman->change_field_notnull($table, $field);
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008000704, 'local', 'qedatabase');
|
||||
}
|
||||
|
||||
if ($oldversion < 2008000799) {
|
||||
// Define field needsupgradetonewqe to be added to quiz_attempts
|
||||
$table = new xmldb_table('quiz_attempts');
|
||||
$field = new xmldb_field('needsupgradetonewqe', XMLDB_TYPE_INTEGER, '3', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'preview');
|
||||
|
||||
// Launch add field needsupgradetonewqe
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
$DB->set_field('quiz_attempts', 'needsupgradetonewqe', 1);
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008000800, 'local', 'qedatabase');
|
||||
}
|
||||
|
||||
if ($oldversion < 2008000800) {
|
||||
$table = new xmldb_table('question_states');
|
||||
if ($dbman->table_exists($table)) {
|
||||
// First delete all data from preview attempts.
|
||||
$DB->delete_records_select('question_states',
|
||||
"attempt IN (SELECT uniqueid FROM {quiz_attempts} WHERE preview = 1)");
|
||||
$DB->delete_records_select('question_sessions',
|
||||
"attemptid IN (SELECT uniqueid FROM {quiz_attempts} WHERE preview = 1)");
|
||||
$DB->delete_records('quiz_attempts', array('preview' => 1));
|
||||
|
||||
// Now update all the old attempt data.
|
||||
$oldrcachesetting = $CFG->rcache;
|
||||
$CFG->rcache = false;
|
||||
|
||||
require_once($CFG->dirroot . '/question/engine/upgrade/upgradelib.php');
|
||||
$upgrader = new question_engine_attempt_upgrader();
|
||||
$upgrader->convert_all_quiz_attempts();
|
||||
|
||||
$CFG->rcache = $oldrcachesetting;
|
||||
}
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_plugin_savepoint(true, 2008000800, 'local', 'qedatabase');
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
This local plugin exists simply to create and update the database as required
|
||||
by the new Question Engine.
|
||||
@@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Question engine database upgrade version information
|
||||
*
|
||||
* @package moodlecore
|
||||
* @subpackage questionengine
|
||||
* @copyright 2010 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
$plugin->version = 2008000800;
|
||||
$plugin->requires = 2010080300;
|
||||
@@ -374,12 +374,6 @@ class quiz_attempt {
|
||||
protected static function create_helper($conditions) {
|
||||
global $DB;
|
||||
|
||||
// TODO deal with the issue that makes this necessary.
|
||||
// if (!$DB->record_exists('question_sessions', array('attemptid' => $attempt->uniqueid))) {
|
||||
// // this attempt has not yet been upgraded to the new model
|
||||
// quiz_upgrade_states($attempt);
|
||||
// }
|
||||
|
||||
$attempt = $DB->get_record('quiz_attempts', $conditions, '*', MUST_EXIST);
|
||||
$quiz = $DB->get_record('quiz', array('id' => $attempt->quiz), '*', MUST_EXIST);
|
||||
$course = $DB->get_record('course', array('id' => $quiz->course), '*', MUST_EXIST);
|
||||
|
||||
@@ -36,15 +36,15 @@ function xmldb_quiz_install() {
|
||||
$record = new stdClass();
|
||||
$record->name = 'overview';
|
||||
$record->displayorder = '10000';
|
||||
$DB->insert_record('quiz_report', $record);
|
||||
$DB->insert_record('quiz_reports', $record);
|
||||
|
||||
$record = new stdClass();
|
||||
$record->name = 'responses';
|
||||
$record->displayorder = '9000';
|
||||
$DB->insert_record('quiz_report', $record);
|
||||
$DB->insert_record('quiz_reports', $record);
|
||||
|
||||
$record = new stdClass();
|
||||
$record->name = 'grading';
|
||||
$record->displayorder = '6000';
|
||||
$DB->insert_record('quiz_report', $record);
|
||||
$DB->insert_record('quiz_reports', $record);
|
||||
}
|
||||
|
||||
+61
-56
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<XMLDB PATH="mod/quiz/db" VERSION="20100722" COMMENT="XMLDB file for Moodle mod/quiz"
|
||||
<XMLDB PATH="mod/quiz/db" VERSION="20110512" COMMENT="XMLDB file for Moodle mod/quiz"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
|
||||
>
|
||||
@@ -7,36 +7,40 @@
|
||||
<TABLE NAME="quiz" COMMENT="Main information about each quiz" NEXT="quiz_attempts">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="course"/>
|
||||
<FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Foreign key references course.id." PREVIOUS="id" NEXT="name"/>
|
||||
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="The name of this quiz." PREVIOUS="course" NEXT="intro"/>
|
||||
<FIELD NAME="intro" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" COMMENT="The introductory text desplayed on the view.php page." PREVIOUS="name" NEXT="introformat"/>
|
||||
<FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="id" NEXT="name"/>
|
||||
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="course" NEXT="intro"/>
|
||||
<FIELD NAME="intro" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" PREVIOUS="name" NEXT="introformat"/>
|
||||
<FIELD NAME="introformat" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="intro" NEXT="timeopen"/>
|
||||
<FIELD NAME="timeopen" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Time at which students may start attempting this quiz." PREVIOUS="introformat" NEXT="timeclose"/>
|
||||
<FIELD NAME="timeclose" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Time by which students must have completed their attempt." PREVIOUS="timeopen" NEXT="optionflags"/>
|
||||
<FIELD NAME="optionflags" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="This stores the adaptive mode setting for this quiz." PREVIOUS="timeclose" NEXT="penaltyscheme"/>
|
||||
<FIELD NAME="penaltyscheme" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Stores the apply penaties setting." PREVIOUS="optionflags" NEXT="attempts"/>
|
||||
<FIELD NAME="attempts" TYPE="int" LENGTH="6" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" COMMENT="The maximum number of attempts that a student is allowed at this quiz. 0 mean no limit." PREVIOUS="penaltyscheme" NEXT="attemptonlast"/>
|
||||
<FIELD NAME="attemptonlast" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" COMMENT="Whether each attempt builds on last mode is on." PREVIOUS="attempts" NEXT="grademethod"/>
|
||||
<FIELD NAME="grademethod" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="false" DEFAULT="1" SEQUENCE="false" COMMENT="How individual attempt grades are combined to get the overall grade. From the top of mod/quiz/lib.php: 1 = QUIZ_GRADEHIGHEST, 2 = QUIZ_GRADEAVERAGE, 3 = QUIZ_ATTEMPTFIRST, 4 = QUIZ_ATTEMPTLAST." PREVIOUS="attemptonlast" NEXT="decimalpoints"/>
|
||||
<FIELD NAME="decimalpoints" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="false" DEFAULT="2" SEQUENCE="false" COMMENT="Number of decimal points to display when printing scores belonging to this quiz." PREVIOUS="grademethod" NEXT="questiondecimalpoints"/>
|
||||
<FIELD NAME="questiondecimalpoints" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="false" DEFAULT="-2" SEQUENCE="false" COMMENT="The number of decimal digits to use when displaying question grades. -1 = use decimalpoints, otherwise a separate setting." PREVIOUS="decimalpoints" NEXT="review"/>
|
||||
<FIELD NAME="review" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="A bitfield encoding the Review options setting. Read the code of function quiz_get_reviewoptions from mod/quiz/locallib.php to see what each bit means." PREVIOUS="questiondecimalpoints" NEXT="questionsperpage"/>
|
||||
<FIELD NAME="questionsperpage" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" COMMENT="This does not do exactly what the name suggests, and the behaviour depends on the shufflequestions setting." PREVIOUS="review" NEXT="shufflequestions"/>
|
||||
<FIELD NAME="shufflequestions" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" COMMENT="Whether the list of questions in the quiz should be randomly shuffled at the start of each attempt." PREVIOUS="questionsperpage" NEXT="shuffleanswers"/>
|
||||
<FIELD NAME="shuffleanswers" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" COMMENT="Whether, in question types that support it, individual parts of a question should be shuffled." PREVIOUS="shufflequestions" NEXT="questions"/>
|
||||
<FIELD NAME="questions" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" COMMENT="Comma-separated list of questionids, with 0s for page breaks. The layout of questions in this quiz." PREVIOUS="shuffleanswers" NEXT="sumgrades"/>
|
||||
<FIELD NAME="sumgrades" TYPE="number" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" DECIMALS="5" COMMENT="Total of the maximum grades you can get from each question. This is redundant, it is SELECT SUM(grade) FROM {quiz_question_instances} WHERE quiz = ?." PREVIOUS="questions" NEXT="grade"/>
|
||||
<FIELD NAME="grade" TYPE="number" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" DECIMALS="5" COMMENT="Maximum grade that you can get from this quiz." PREVIOUS="sumgrades" NEXT="timecreated"/>
|
||||
<FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Timestamp when this quiz was created." PREVIOUS="grade" NEXT="timemodified"/>
|
||||
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Timestamp when this row was last updated." PREVIOUS="timecreated" NEXT="timelimit"/>
|
||||
<FIELD NAME="timelimit" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Time limit in seconds." PREVIOUS="timemodified" NEXT="password"/>
|
||||
<FIELD NAME="password" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="Students must enter this password before they can attempt the quiz." PREVIOUS="timelimit" NEXT="subnet"/>
|
||||
<FIELD NAME="subnet" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="If set, only allow attempts from certain IP addresses. The checking is performed by the address_in_subnet function from lib/moodlelib.php." PREVIOUS="password" NEXT="popup"/>
|
||||
<FIELD NAME="popup" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" COMMENT="Force the quiz to be attempted in a full-screen pop-up window with some evil JavaScript that attempts to prevent copying and pasting, etc." PREVIOUS="subnet" NEXT="delay1"/>
|
||||
<FIELD NAME="delay1" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" COMMENT="Enforced delay between the first and second attempts, in seconds." PREVIOUS="popup" NEXT="delay2"/>
|
||||
<FIELD NAME="delay2" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" COMMENT="Enforced delay between the second and subsequent attempts, in seconds." PREVIOUS="delay1" NEXT="showuserpicture"/>
|
||||
<FIELD NAME="showuserpicture" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" COMMENT="Option to show the user's picture during the attempt and on the review page." PREVIOUS="delay2" NEXT="showblocks"/>
|
||||
<FIELD NAME="showblocks" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" COMMENT="Whether blocks should be shown on the attempt.php and review.php pages." PREVIOUS="showuserpicture"/>
|
||||
<FIELD NAME="timeopen" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="introformat" NEXT="timeclose"/>
|
||||
<FIELD NAME="timeclose" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="timeopen" NEXT="preferredbehaviour"/>
|
||||
<FIELD NAME="preferredbehaviour" TYPE="char" LENGTH="32" NOTNULL="true" SEQUENCE="false" PREVIOUS="timeclose" NEXT="attemptonlast"/>
|
||||
<FIELD NAME="attemptonlast" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="preferredbehaviour" NEXT="attempts"/>
|
||||
<FIELD NAME="attempts" TYPE="int" LENGTH="6" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" PREVIOUS="attemptonlast" NEXT="grademethod"/>
|
||||
<FIELD NAME="grademethod" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="false" DEFAULT="1" SEQUENCE="false" PREVIOUS="attempts" NEXT="decimalpoints"/>
|
||||
<FIELD NAME="decimalpoints" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="false" DEFAULT="2" SEQUENCE="false" PREVIOUS="grademethod" NEXT="questiondecimalpoints"/>
|
||||
<FIELD NAME="questiondecimalpoints" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="false" DEFAULT="-1" SEQUENCE="false" PREVIOUS="decimalpoints" NEXT="reviewattempt"/>
|
||||
<FIELD NAME="reviewattempt" TYPE="int" LENGTH="6" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Whether users are allowed to review their quiz attempts at various times. This is a bit field, decoded by the mod_quiz_display_options class. It is formed by ORing together the constants defined there." PREVIOUS="questiondecimalpoints" NEXT="reviewcorrectness"/>
|
||||
<FIELD NAME="reviewcorrectness" TYPE="int" LENGTH="6" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Whether users are allowed to review their quiz attempts at various times. A bit field, like reviewattempt." PREVIOUS="reviewattempt" NEXT="reviewmarks"/>
|
||||
<FIELD NAME="reviewmarks" TYPE="int" LENGTH="6" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Whether users are allowed to review their quiz attempts at various times. A bit field, like reviewattempt." PREVIOUS="reviewcorrectness" NEXT="reviewspecificfeedback"/>
|
||||
<FIELD NAME="reviewspecificfeedback" TYPE="int" LENGTH="6" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Whether users are allowed to review their quiz attempts at various times. A bit field, like reviewattempt." PREVIOUS="reviewmarks" NEXT="reviewgeneralfeedback"/>
|
||||
<FIELD NAME="reviewgeneralfeedback" TYPE="int" LENGTH="6" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Whether users are allowed to review their quiz attempts at various times. A bit field, like reviewattempt." PREVIOUS="reviewspecificfeedback" NEXT="reviewrightanswer"/>
|
||||
<FIELD NAME="reviewrightanswer" TYPE="int" LENGTH="6" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Whether users are allowed to review their quiz attempts at various times. A bit field, like reviewattempt." PREVIOUS="reviewgeneralfeedback" NEXT="reviewoverallfeedback"/>
|
||||
<FIELD NAME="reviewoverallfeedback" TYPE="int" LENGTH="6" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Whether users are allowed to review their quiz attempts at various times. A bit field, like reviewattempt." PREVIOUS="reviewrightanswer" NEXT="questionsperpage"/>
|
||||
<FIELD NAME="questionsperpage" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" PREVIOUS="reviewoverallfeedback" NEXT="shufflequestions"/>
|
||||
<FIELD NAME="shufflequestions" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" PREVIOUS="questionsperpage" NEXT="shuffleanswers"/>
|
||||
<FIELD NAME="shuffleanswers" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" PREVIOUS="shufflequestions" NEXT="questions"/>
|
||||
<FIELD NAME="questions" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" PREVIOUS="shuffleanswers" NEXT="sumgrades"/>
|
||||
<FIELD NAME="sumgrades" TYPE="number" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" DECIMALS="5" PREVIOUS="questions" NEXT="grade"/>
|
||||
<FIELD NAME="grade" TYPE="number" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" DECIMALS="5" PREVIOUS="sumgrades" NEXT="timecreated"/>
|
||||
<FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="grade" NEXT="timemodified"/>
|
||||
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="timecreated" NEXT="timelimit"/>
|
||||
<FIELD NAME="timelimit" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="timemodified" NEXT="password"/>
|
||||
<FIELD NAME="password" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="timelimit" NEXT="subnet"/>
|
||||
<FIELD NAME="subnet" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="password" NEXT="popup"/>
|
||||
<FIELD NAME="popup" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" PREVIOUS="subnet" NEXT="delay1"/>
|
||||
<FIELD NAME="delay1" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" PREVIOUS="popup" NEXT="delay2"/>
|
||||
<FIELD NAME="delay2" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" PREVIOUS="delay1" NEXT="showuserpicture"/>
|
||||
<FIELD NAME="showuserpicture" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" COMMENT="Option to show the user's picture during the attempt and on the review page." PREVIOUS="delay2"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
@@ -48,16 +52,17 @@
|
||||
<TABLE NAME="quiz_attempts" COMMENT="Stores various attempts on a quiz" PREVIOUS="quiz" NEXT="quiz_grades">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="uniqueid"/>
|
||||
<FIELD NAME="uniqueid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Foreign key references question_attempts.id, and hence links into the attempt information for each question in the attempt." PREVIOUS="id" NEXT="quiz"/>
|
||||
<FIELD NAME="quiz" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Foreign key references quiz.id." PREVIOUS="uniqueid" NEXT="userid"/>
|
||||
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Foreign key references user.id." PREVIOUS="quiz" NEXT="attempt"/>
|
||||
<FIELD NAME="attempt" TYPE="int" LENGTH="6" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" COMMENT="The attempt number for this user on this quiz. It counts up from one. (quiz, userid, attempt) could be an alternate primary key for this table." PREVIOUS="userid" NEXT="sumgrades"/>
|
||||
<FIELD NAME="sumgrades" TYPE="number" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" DECIMALS="5" COMMENT="The sum of the user's grades for all questions in this attempt." PREVIOUS="attempt" NEXT="timestart"/>
|
||||
<FIELD NAME="timestart" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="The time this attempt started." PREVIOUS="sumgrades" NEXT="timefinish"/>
|
||||
<FIELD NAME="timefinish" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="The time this attempt finished. If 0, this attempt is still open." PREVIOUS="timestart" NEXT="timemodified"/>
|
||||
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="The time this attemtp was last modified. I think this is not changed by a regrade, and I don't know about what happens if a teacher manually grades a question. If you really need to know, look at the code, then update this comment. Thanks." PREVIOUS="timefinish" NEXT="layout"/>
|
||||
<FIELD NAME="layout" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" COMMENT="A comma-separated list of question ids, with 0s for page breaks. If quiz.shuffequestions = 0, this will be the same as quiz.layout." PREVIOUS="timemodified" NEXT="preview"/>
|
||||
<FIELD NAME="preview" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Used to distinguish preview attempts. Previews do not show up in reports; are deleted automatically when quiz settings are changed; and do not prevent the quiz from being edited." PREVIOUS="layout"/>
|
||||
<FIELD NAME="uniqueid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="id" NEXT="quiz"/>
|
||||
<FIELD NAME="quiz" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="uniqueid" NEXT="userid"/>
|
||||
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="quiz" NEXT="attempt"/>
|
||||
<FIELD NAME="attempt" TYPE="int" LENGTH="6" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" PREVIOUS="userid" NEXT="sumgrades"/>
|
||||
<FIELD NAME="sumgrades" TYPE="number" LENGTH="10" NOTNULL="false" UNSIGNED="false" SEQUENCE="false" DECIMALS="5" PREVIOUS="attempt" NEXT="timestart"/>
|
||||
<FIELD NAME="timestart" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="sumgrades" NEXT="timefinish"/>
|
||||
<FIELD NAME="timefinish" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="timestart" NEXT="timemodified"/>
|
||||
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="timefinish" NEXT="layout"/>
|
||||
<FIELD NAME="layout" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" PREVIOUS="timemodified" NEXT="preview"/>
|
||||
<FIELD NAME="preview" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="layout" NEXT="needsupgradetonewqe"/>
|
||||
<FIELD NAME="needsupgradetonewqe" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="preview"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="uniqueid"/>
|
||||
@@ -97,7 +102,7 @@
|
||||
<KEY NAME="question" TYPE="foreign" FIELDS="question" REFTABLE="question" REFFIELDS="id" PREVIOUS="quiz"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
<TABLE NAME="quiz_feedback" COMMENT="Feedback given to students based on which grade band their overall score lies." PREVIOUS="quiz_question_instances" NEXT="quiz_report">
|
||||
<TABLE NAME="quiz_feedback" COMMENT="Feedback given to students based on which grade band their overall score lies." PREVIOUS="quiz_question_instances" NEXT="quiz_overrides">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="quizid"/>
|
||||
<FIELD NAME="quizid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Foreign key references quiz.id." PREVIOUS="id" NEXT="feedbacktext"/>
|
||||
@@ -111,20 +116,7 @@
|
||||
<KEY NAME="quizid" TYPE="foreign" FIELDS="quizid" REFTABLE="quiz" REFFIELDS="id" PREVIOUS="primary"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
<TABLE NAME="quiz_report" COMMENT="Lists all the installed quiz reports and their display order and so on. No need to worry about deleting old records. Only records with an equivalent directory are displayed." PREVIOUS="quiz_feedback" NEXT="quiz_overrides">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="name"/>
|
||||
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="name of the report, same as the directory name" PREVIOUS="id" NEXT="displayorder"/>
|
||||
<FIELD NAME="displayorder" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="display order for report tabs" PREVIOUS="name" NEXT="lastcron"/>
|
||||
<FIELD NAME="lastcron" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="timestamp when cron was last run for this report." PREVIOUS="displayorder" NEXT="cron"/>
|
||||
<FIELD NAME="cron" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="0 if there is no cron for this report (default) or the time between crons otherwise." PREVIOUS="lastcron" NEXT="capability"/>
|
||||
<FIELD NAME="capability" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="Capability required to see this report. May be blank which means use the default of mod/quiz:viewreport. This is used when deciding which tabs to render." PREVIOUS="cron"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
<TABLE NAME="quiz_overrides" COMMENT="The overrides to quiz settings on a per-user and per-group basis." PREVIOUS="quiz_report">
|
||||
<TABLE NAME="quiz_overrides" COMMENT="The overrides to quiz settings on a per-user and per-group basis." PREVIOUS="quiz_feedback" NEXT="quiz_reports">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="quiz"/>
|
||||
<FIELD NAME="quiz" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Foreign key references quiz.id" PREVIOUS="id" NEXT="groupid"/>
|
||||
@@ -143,5 +135,18 @@
|
||||
<KEY NAME="userid" TYPE="foreign" FIELDS="userid" REFTABLE="user" REFFIELDS="id" PREVIOUS="groupid"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
<TABLE NAME="quiz_reports" COMMENT="Lists all the installed quiz reports and their display order and so on. No need to worry about deleting old records. Only records with an equivalent directory are displayed." PREVIOUS="quiz_overrides">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="name"/>
|
||||
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="name of the report, same as the directory name" PREVIOUS="id" NEXT="displayorder"/>
|
||||
<FIELD NAME="displayorder" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="display order for report tabs" PREVIOUS="name" NEXT="lastcron"/>
|
||||
<FIELD NAME="lastcron" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="timestamp when cron was last run for this report." PREVIOUS="displayorder" NEXT="cron"/>
|
||||
<FIELD NAME="cron" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="0 if there is no cron for this report (default) or the time between crons otherwise." PREVIOUS="lastcron" NEXT="capability"/>
|
||||
<FIELD NAME="capability" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="Capability required to see this report. May be blank which means use the default of mod/quiz:viewreport. This is used when deciding which tabs to render." PREVIOUS="cron"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
</TABLES>
|
||||
</XMLDB>
|
||||
</XMLDB>
|
||||
|
||||
@@ -541,6 +541,610 @@ function xmldb_quiz_upgrade($oldversion) {
|
||||
upgrade_mod_savepoint(true, 2010122304, 'quiz');
|
||||
}
|
||||
|
||||
// Complete any old upgrade from 1.5 that was never finished.
|
||||
if ($oldversion < 2011051199) {
|
||||
$table = new xmldb_table('question_states');
|
||||
if ($dbman->table_exists($table)) {
|
||||
$transaction = $DB->start_delegated_transaction();
|
||||
|
||||
$oldattempts = $DB->get_records_sql('
|
||||
SELECT quiza
|
||||
FROM {quiz_attempts} quiza
|
||||
WHERE uniqueid IN (
|
||||
SELECT DISTINCT qst.attempt
|
||||
FROM {question_states} qst
|
||||
LEFT JOIN {question_sessions} qsess ON
|
||||
qst.question = qsess.questionid AND qst.attempt = qsess.attemptid
|
||||
WHERE qsess.id IS NULL
|
||||
)
|
||||
');
|
||||
|
||||
if ($oldattempts) {
|
||||
$pbar = new progress_bar('q15upgrade');
|
||||
$a = new stdClass();
|
||||
$a->todo = count($oldattempts);
|
||||
$a->done = 0;
|
||||
$pbar->update($a->done, $a->todo,
|
||||
get_string('upgradingveryoldquizattempts', 'quiz', $a));
|
||||
|
||||
foreach ($oldattempts as $oldattempt) {
|
||||
quiz_upgrade_very_old_question_sessions($oldattempt);
|
||||
|
||||
$a->done += 1;
|
||||
$pbar->update($a->done, $a->todo,
|
||||
get_string('upgradingveryoldquizattempts', 'quiz', $a));
|
||||
}
|
||||
}
|
||||
|
||||
$transaction->allow_commit();
|
||||
}
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_mod_savepoint(true, 2011051199, 'quiz');
|
||||
}
|
||||
|
||||
// Add new preferredbehaviour column to the quiz table.
|
||||
if ($oldversion < 2011051200) {
|
||||
$table = new xmldb_table('quiz');
|
||||
$field = new xmldb_field('preferredbehaviour');
|
||||
$field->set_attributes(XMLDB_TYPE_CHAR, '32', null,
|
||||
null, null, null, 'timeclose');
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_mod_savepoint(true, 2011051200, 'quiz');
|
||||
}
|
||||
|
||||
// Populate preferredbehaviour column based on old optionflags column.
|
||||
if ($oldversion < 2011051201) {
|
||||
if ($dbman->field_exists('quiz', 'optionflags')) {
|
||||
$DB->set_field_select('quiz', 'preferredbehaviour', 'deferredfeedback',
|
||||
'optionflags = 0');
|
||||
$DB->set_field_select('quiz', 'preferredbehaviour', 'adaptive',
|
||||
'optionflags <> 0 AND penaltyscheme <> 0');
|
||||
$DB->set_field_select('quiz', 'preferredbehaviour', 'adaptivenopenalty',
|
||||
'optionflags <> 0 AND penaltyscheme = 0');
|
||||
|
||||
set_config('preferredbehaviour', 'deferredfeedback', 'quiz');
|
||||
set_config('fix_preferredbehaviour', 0, 'quiz');
|
||||
}
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_mod_savepoint(true, 2011051201, 'quiz');
|
||||
}
|
||||
|
||||
// Add a not-NULL constraint to the preferredmodel field now that it is populated.
|
||||
if ($oldversion < 2011051202) {
|
||||
$table = new xmldb_table('quiz');
|
||||
$field = new xmldb_field('preferredbehaviour');
|
||||
$field->set_attributes(XMLDB_TYPE_CHAR, '32', null,
|
||||
XMLDB_NOTNULL, null, null, 'timeclose');
|
||||
|
||||
$dbman->change_field_notnull($table, $field);
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_mod_savepoint(true, 2011051202, 'quiz');
|
||||
}
|
||||
|
||||
// Drop the old optionflags field.
|
||||
if ($oldversion < 2011051203) {
|
||||
$table = new xmldb_table('quiz');
|
||||
$field = new xmldb_field('optionflags');
|
||||
|
||||
if ($dbman->field_exists($table, $field)) {
|
||||
$dbman->drop_field($table, $field);
|
||||
}
|
||||
|
||||
unset_config('optionflags', 'quiz');
|
||||
unset_config('fix_optionflags', 'quiz');
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_mod_savepoint(true, 2011051203, 'quiz');
|
||||
}
|
||||
|
||||
// Drop the old penaltyscheme field.
|
||||
if ($oldversion < 2011051204) {
|
||||
$table = new xmldb_table('quiz');
|
||||
$field = new xmldb_field('penaltyscheme');
|
||||
|
||||
if ($dbman->field_exists($table, $field)) {
|
||||
$dbman->drop_field($table, $field);
|
||||
}
|
||||
|
||||
unset_config('penaltyscheme', 'quiz');
|
||||
unset_config('fix_penaltyscheme', 'quiz');
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_mod_savepoint(true, 2011051204, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2011051205) {
|
||||
|
||||
// Changing nullability of field sumgrades on table quiz_attempts to null
|
||||
$table = new xmldb_table('quiz_attempts');
|
||||
$field = new xmldb_field('sumgrades');
|
||||
$field->set_attributes(XMLDB_TYPE_NUMBER, '10, 5', null,
|
||||
null, null, null, 'attempt');
|
||||
|
||||
// Launch change of nullability for field sumgrades
|
||||
$dbman->change_field_notnull($table, $field);
|
||||
|
||||
// Launch change of default for field sumgrades
|
||||
$dbman->change_field_default($table, $field);
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_mod_savepoint(true, 2011051205, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2011051206) {
|
||||
|
||||
// Changing the default of field penalty on table question to 0.3333333
|
||||
$table = new xmldb_table('question');
|
||||
$field = new xmldb_field('penalty');
|
||||
$field->set_attributes(XMLDB_TYPE_FLOAT, null, null,
|
||||
XMLDB_NOTNULL, null, '0.3333333', 'defaultgrade');
|
||||
|
||||
// Launch change of default for field penalty
|
||||
$dbman->change_field_default($table, $field);
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_mod_savepoint(true, 2011051206, 'quiz');
|
||||
}
|
||||
|
||||
// Update the quiz from the old single review column to seven new columns.
|
||||
|
||||
if ($oldversion < 2011051207) {
|
||||
|
||||
// Define field reviewattempt to be added to quiz
|
||||
$table = new xmldb_table('quiz');
|
||||
$field = new xmldb_field('reviewattempt');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '6', XMLDB_UNSIGNED,
|
||||
XMLDB_NOTNULL, null, '0', 'review');
|
||||
|
||||
// Launch add field reviewattempt
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_mod_savepoint(true, 2011051207, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2011051208) {
|
||||
|
||||
// Define field reviewattempt to be added to quiz
|
||||
$table = new xmldb_table('quiz');
|
||||
$field = new xmldb_field('reviewcorrectness');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '6', XMLDB_UNSIGNED,
|
||||
XMLDB_NOTNULL, null, '0', 'reviewattempt');
|
||||
|
||||
// Launch add field reviewattempt
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_mod_savepoint(true, 2011051208, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2011051209) {
|
||||
|
||||
// Define field reviewattempt to be added to quiz
|
||||
$table = new xmldb_table('quiz');
|
||||
$field = new xmldb_field('reviewmarks');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '6', XMLDB_UNSIGNED,
|
||||
XMLDB_NOTNULL, null, '0', 'reviewcorrectness');
|
||||
|
||||
// Launch add field reviewattempt
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_mod_savepoint(true, 2011051209, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2011051210) {
|
||||
|
||||
// Define field reviewattempt to be added to quiz
|
||||
$table = new xmldb_table('quiz');
|
||||
$field = new xmldb_field('reviewspecificfeedback');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '6', XMLDB_UNSIGNED,
|
||||
XMLDB_NOTNULL, null, '0', 'reviewmarks');
|
||||
|
||||
// Launch add field reviewattempt
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_mod_savepoint(true, 2011051210, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2011051211) {
|
||||
|
||||
// Define field reviewattempt to be added to quiz
|
||||
$table = new xmldb_table('quiz');
|
||||
$field = new xmldb_field('reviewgeneralfeedback');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '6', XMLDB_UNSIGNED,
|
||||
XMLDB_NOTNULL, null, '0', 'reviewspecificfeedback');
|
||||
|
||||
// Launch add field reviewattempt
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_mod_savepoint(true, 2011051211, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2011051212) {
|
||||
|
||||
// Define field reviewattempt to be added to quiz
|
||||
$table = new xmldb_table('quiz');
|
||||
$field = new xmldb_field('reviewrightanswer');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '6', XMLDB_UNSIGNED,
|
||||
XMLDB_NOTNULL, null, '0', 'reviewgeneralfeedback');
|
||||
|
||||
// Launch add field reviewattempt
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_mod_savepoint(true, 2011051212, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2011051213) {
|
||||
|
||||
// Define field reviewattempt to be added to quiz
|
||||
$table = new xmldb_table('quiz');
|
||||
$field = new xmldb_field('reviewoverallfeedback');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '6', XMLDB_UNSIGNED,
|
||||
XMLDB_NOTNULL, null, '0', 'reviewrightanswer');
|
||||
|
||||
// Launch add field reviewattempt
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_mod_savepoint(true, 2011051213, 'quiz');
|
||||
}
|
||||
|
||||
define('QUIZ_NEW_DURING', 0x10000);
|
||||
define('QUIZ_NEW_IMMEDIATELY_AFTER', 0x01000);
|
||||
define('QUIZ_NEW_LATER_WHILE_OPEN', 0x00100);
|
||||
define('QUIZ_NEW_AFTER_CLOSE', 0x00010);
|
||||
|
||||
define('QUIZ_OLD_IMMEDIATELY', 0x3c003f);
|
||||
define('QUIZ_OLD_OPEN', 0x3c00fc0);
|
||||
define('QUIZ_OLD_CLOSED', 0x3c03f000);
|
||||
|
||||
define('QUIZ_OLD_RESPONSES', 1*0x1041); // Show responses
|
||||
define('QUIZ_OLD_SCORES', 2*0x1041); // Show scores
|
||||
define('QUIZ_OLD_FEEDBACK', 4*0x1041); // Show question feedback
|
||||
define('QUIZ_OLD_ANSWERS', 8*0x1041); // Show correct answers
|
||||
define('QUIZ_OLD_SOLUTIONS', 16*0x1041); // Show solutions
|
||||
define('QUIZ_OLD_GENERALFEEDBACK',32*0x1041); // Show question general feedback
|
||||
define('QUIZ_OLD_OVERALLFEEDBACK', 1*0x4440000); // Show quiz overall feedback
|
||||
|
||||
// Copy the old review settings
|
||||
if ($oldversion < 2011051214) {
|
||||
if ($dbman->field_exists('quiz', 'review')) {
|
||||
$DB->execute("
|
||||
UPDATE {quiz}
|
||||
SET reviewattempt = " . $DB->sql_bitor($DB->sql_bitor(
|
||||
QUIZ_NEW_DURING,
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_RESPONSES) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_IMMEDIATELY_AFTER . ' ELSE 0 END'), $DB->sql_bitor(
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_OPEN & QUIZ_OLD_RESPONSES) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_LATER_WHILE_OPEN . ' ELSE 0 END',
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_CLOSED & QUIZ_OLD_RESPONSES) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_AFTER_CLOSE . ' ELSE 0 END')) . "
|
||||
");
|
||||
}
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_mod_savepoint(true, 2011051214, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2011051215) {
|
||||
if ($dbman->field_exists('quiz', 'review')) {
|
||||
$DB->execute("
|
||||
UPDATE {quiz}
|
||||
SET reviewcorrectness = " . $DB->sql_bitor($DB->sql_bitor(
|
||||
QUIZ_NEW_DURING,
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_SCORES) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_IMMEDIATELY_AFTER . ' ELSE 0 END'), $DB->sql_bitor(
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_OPEN & QUIZ_OLD_SCORES) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_LATER_WHILE_OPEN . ' ELSE 0 END',
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_CLOSED & QUIZ_OLD_SCORES) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_AFTER_CLOSE . ' ELSE 0 END')) . "
|
||||
");
|
||||
}
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_mod_savepoint(true, 2011051215, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2011051216) {
|
||||
if ($dbman->field_exists('quiz', 'review')) {
|
||||
$DB->execute("
|
||||
UPDATE {quiz}
|
||||
SET reviewmarks = " . $DB->sql_bitor($DB->sql_bitor(
|
||||
QUIZ_NEW_DURING,
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_SCORES) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_IMMEDIATELY_AFTER . ' ELSE 0 END'), $DB->sql_bitor(
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_OPEN & QUIZ_OLD_SCORES) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_LATER_WHILE_OPEN . ' ELSE 0 END',
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_CLOSED & QUIZ_OLD_SCORES) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_AFTER_CLOSE . ' ELSE 0 END')) . "
|
||||
");
|
||||
}
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_mod_savepoint(true, 2011051216, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2011051217) {
|
||||
if ($dbman->field_exists('quiz', 'review')) {
|
||||
$DB->execute("
|
||||
UPDATE {quiz}
|
||||
SET reviewspecificfeedback = " . $DB->sql_bitor($DB->sql_bitor(
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_FEEDBACK) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_DURING . ' ELSE 0 END',
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_FEEDBACK) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_IMMEDIATELY_AFTER . ' ELSE 0 END'), $DB->sql_bitor(
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_OPEN & QUIZ_OLD_FEEDBACK) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_LATER_WHILE_OPEN . ' ELSE 0 END',
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_CLOSED & QUIZ_OLD_FEEDBACK) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_AFTER_CLOSE . ' ELSE 0 END')) . "
|
||||
");
|
||||
}
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_mod_savepoint(true, 2011051217, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2011051218) {
|
||||
if ($dbman->field_exists('quiz', 'review')) {
|
||||
$DB->execute("
|
||||
UPDATE {quiz}
|
||||
SET reviewgeneralfeedback = " . $DB->sql_bitor($DB->sql_bitor(
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_GENERALFEEDBACK) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_DURING . ' ELSE 0 END',
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_GENERALFEEDBACK) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_IMMEDIATELY_AFTER . ' ELSE 0 END'), $DB->sql_bitor(
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_OPEN & QUIZ_OLD_GENERALFEEDBACK) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_LATER_WHILE_OPEN . ' ELSE 0 END',
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_CLOSED & QUIZ_OLD_GENERALFEEDBACK) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_AFTER_CLOSE . ' ELSE 0 END')) . "
|
||||
");
|
||||
}
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_mod_savepoint(true, 2011051218, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2011051219) {
|
||||
if ($dbman->field_exists('quiz', 'review')) {
|
||||
$DB->execute("
|
||||
UPDATE {quiz}
|
||||
SET reviewrightanswer = " . $DB->sql_bitor($DB->sql_bitor(
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_ANSWERS) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_DURING . ' ELSE 0 END',
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_ANSWERS) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_IMMEDIATELY_AFTER . ' ELSE 0 END'), $DB->sql_bitor(
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_OPEN & QUIZ_OLD_ANSWERS) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_LATER_WHILE_OPEN . ' ELSE 0 END',
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_CLOSED & QUIZ_OLD_ANSWERS) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_AFTER_CLOSE . ' ELSE 0 END')) . "
|
||||
");
|
||||
}
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_mod_savepoint(true, 2011051219, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2011051220) {
|
||||
if ($dbman->field_exists('quiz', 'review')) {
|
||||
$DB->execute("
|
||||
UPDATE {quiz}
|
||||
SET reviewoverallfeedback = " . $DB->sql_bitor($DB->sql_bitor(
|
||||
0,
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_OVERALLFEEDBACK) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_IMMEDIATELY_AFTER . ' ELSE 0 END'), $DB->sql_bitor(
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_OPEN & QUIZ_OLD_OVERALLFEEDBACK) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_LATER_WHILE_OPEN . ' ELSE 0 END',
|
||||
'CASE WHEN ' . $DB->sql_bitand('review', QUIZ_OLD_CLOSED & QUIZ_OLD_OVERALLFEEDBACK) .
|
||||
' <> 0 THEN ' . QUIZ_NEW_AFTER_CLOSE . ' ELSE 0 END')) . "
|
||||
");
|
||||
}
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_mod_savepoint(true, 2011051220, 'quiz');
|
||||
}
|
||||
|
||||
// And, do the same for the defaults
|
||||
if ($oldversion < 2011051221) {
|
||||
$quizrevew = get_config('quiz', 'review');
|
||||
if (!empty($quizrevew)) {
|
||||
|
||||
set_config('reviewattempt',
|
||||
QUIZ_NEW_DURING |
|
||||
($quizrevew & QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_RESPONSES ? QUIZ_NEW_IMMEDIATELY_AFTER : 0) |
|
||||
($quizrevew & QUIZ_OLD_OPEN & QUIZ_OLD_RESPONSES ? QUIZ_NEW_LATER_WHILE_OPEN : 0) |
|
||||
($quizrevew & QUIZ_OLD_CLOSED & QUIZ_OLD_RESPONSES ? QUIZ_NEW_AFTER_CLOSE : 0),
|
||||
'quiz');
|
||||
|
||||
set_config('reviewcorrectness',
|
||||
QUIZ_NEW_DURING |
|
||||
($quizrevew & QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_SCORES ? QUIZ_NEW_IMMEDIATELY_AFTER : 0) |
|
||||
($quizrevew & QUIZ_OLD_OPEN & QUIZ_OLD_SCORES ? QUIZ_NEW_LATER_WHILE_OPEN : 0) |
|
||||
($quizrevew & QUIZ_OLD_CLOSED & QUIZ_OLD_SCORES ? QUIZ_NEW_AFTER_CLOSE : 0),
|
||||
'quiz');
|
||||
|
||||
set_config('reviewmarks',
|
||||
QUIZ_NEW_DURING |
|
||||
($quizrevew & QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_SCORES ? QUIZ_NEW_IMMEDIATELY_AFTER : 0) |
|
||||
($quizrevew & QUIZ_OLD_OPEN & QUIZ_OLD_SCORES ? QUIZ_NEW_LATER_WHILE_OPEN : 0) |
|
||||
($quizrevew & QUIZ_OLD_CLOSED & QUIZ_OLD_SCORES ? QUIZ_NEW_AFTER_CLOSE : 0),
|
||||
'quiz');
|
||||
|
||||
set_config('reviewspecificfeedback',
|
||||
($quizrevew & QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_FEEDBACK ? QUIZ_NEW_DURING : 0) |
|
||||
($quizrevew & QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_FEEDBACK ? QUIZ_NEW_IMMEDIATELY_AFTER : 0) |
|
||||
($quizrevew & QUIZ_OLD_OPEN & QUIZ_OLD_FEEDBACK ? QUIZ_NEW_LATER_WHILE_OPEN : 0) |
|
||||
($quizrevew & QUIZ_OLD_CLOSED & QUIZ_OLD_FEEDBACK ? QUIZ_NEW_AFTER_CLOSE : 0),
|
||||
'quiz');
|
||||
|
||||
set_config('reviewgeneralfeedback',
|
||||
($quizrevew & QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_GENERALFEEDBACK ? QUIZ_NEW_DURING : 0) |
|
||||
($quizrevew & QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_GENERALFEEDBACK ? QUIZ_NEW_IMMEDIATELY_AFTER : 0) |
|
||||
($quizrevew & QUIZ_OLD_OPEN & QUIZ_OLD_GENERALFEEDBACK ? QUIZ_NEW_LATER_WHILE_OPEN : 0) |
|
||||
($quizrevew & QUIZ_OLD_CLOSED & QUIZ_OLD_GENERALFEEDBACK ? QUIZ_NEW_AFTER_CLOSE : 0),
|
||||
'quiz');
|
||||
|
||||
set_config('reviewrightanswer',
|
||||
($quizrevew & QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_ANSWERS ? QUIZ_NEW_DURING : 0) |
|
||||
($quizrevew & QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_ANSWERS ? QUIZ_NEW_IMMEDIATELY_AFTER : 0) |
|
||||
($quizrevew & QUIZ_OLD_OPEN & QUIZ_OLD_ANSWERS ? QUIZ_NEW_LATER_WHILE_OPEN : 0) |
|
||||
($quizrevew & QUIZ_OLD_CLOSED & QUIZ_OLD_ANSWERS ? QUIZ_NEW_AFTER_CLOSE : 0),
|
||||
'quiz');
|
||||
|
||||
set_config('reviewoverallfeedback',
|
||||
0 |
|
||||
($quizrevew & QUIZ_OLD_IMMEDIATELY & QUIZ_OLD_OVERALLFEEDBACK ? QUIZ_NEW_IMMEDIATELY_AFTER : 0) |
|
||||
($quizrevew & QUIZ_OLD_OPEN & QUIZ_OLD_OVERALLFEEDBACK ? QUIZ_NEW_LATER_WHILE_OPEN : 0) |
|
||||
($quizrevew & QUIZ_OLD_CLOSED & QUIZ_OLD_OVERALLFEEDBACK ? QUIZ_NEW_AFTER_CLOSE : 0),
|
||||
'quiz');
|
||||
}
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_mod_savepoint(true, 2011051221, 'quiz');
|
||||
}
|
||||
|
||||
// Finally drop the old column
|
||||
if ($oldversion < 2011051222) {
|
||||
// Define field review to be dropped from quiz
|
||||
$table = new xmldb_table('quiz');
|
||||
$field = new xmldb_field('review');
|
||||
|
||||
// Launch drop field review
|
||||
if ($dbman->field_exists($table, $field)) {
|
||||
$dbman->drop_field($table, $field);
|
||||
}
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_mod_savepoint(true, 2011051222, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2011051223) {
|
||||
unset_config('review', 'quiz');
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_mod_savepoint(true, 2011051223, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2011051224) {
|
||||
|
||||
// Define field hintformat to be added to question_hints table.
|
||||
$table = new xmldb_table('question_hints');
|
||||
$field = new xmldb_field('hintformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED,
|
||||
XMLDB_NOTNULL, null, '0');
|
||||
|
||||
// Conditionally launch add field partiallycorrectfeedbackformat
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
upgrade_mod_savepoint(true, 2011051224, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2011051225) {
|
||||
// Define table quiz_report to be renamed to quiz_reports
|
||||
$table = new xmldb_table('quiz_report');
|
||||
|
||||
// Launch rename table for quiz_reports
|
||||
if ($dbman->table_exists($table)) {
|
||||
$dbman->rename_table($table, 'quiz_reports');
|
||||
}
|
||||
|
||||
upgrade_mod_savepoint(true, 2011051225, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2011051226) {
|
||||
// Define index name (unique) to be added to quiz_reports
|
||||
$table = new xmldb_table('quiz_reports');
|
||||
$index = new xmldb_index('name', XMLDB_INDEX_UNIQUE, array('name'));
|
||||
|
||||
// Conditionally launch add index name
|
||||
if (!$dbman->index_exists($table, $index)) {
|
||||
$dbman->add_index($table, $index);
|
||||
}
|
||||
|
||||
upgrade_mod_savepoint(true, 2011051226, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2011051227) {
|
||||
|
||||
// Changing nullability of field sumgrades on table quiz_attempts to null
|
||||
$table = new xmldb_table('quiz_attempts');
|
||||
$field = new xmldb_field('sumgrades', XMLDB_TYPE_NUMBER, '10, 5', null,
|
||||
null, null, null, 'attempt');
|
||||
|
||||
// Launch change of nullability for field sumgrades
|
||||
$dbman->change_field_notnull($table, $field);
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_mod_savepoint(true, 2011051227, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2011051228) {
|
||||
// Define field needsupgradetonewqe to be added to quiz_attempts
|
||||
$table = new xmldb_table('quiz_attempts');
|
||||
$field = new xmldb_field('needsupgradetonewqe', XMLDB_TYPE_INTEGER, '3', XMLDB_UNSIGNED,
|
||||
XMLDB_NOTNULL, null, '0', 'preview');
|
||||
|
||||
// Launch add field needsupgradetonewqe
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
$DB->set_field('quiz_attempts', 'needsupgradetonewqe', 1);
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_mod_savepoint(true, 2011051228, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2011051229) {
|
||||
$table = new xmldb_table('question_states');
|
||||
if ($dbman->table_exists($table)) {
|
||||
// First delete all data from preview attempts.
|
||||
$DB->delete_records_select('question_states',
|
||||
"attempt IN (SELECT uniqueid FROM {quiz_attempts} WHERE preview = 1)");
|
||||
$DB->delete_records_select('question_sessions',
|
||||
"attemptid IN (SELECT uniqueid FROM {quiz_attempts} WHERE preview = 1)");
|
||||
$DB->delete_records('quiz_attempts', array('preview' => 1));
|
||||
|
||||
// Now update all the old attempt data.
|
||||
$oldrcachesetting = $CFG->rcache;
|
||||
$CFG->rcache = false;
|
||||
|
||||
require_once($CFG->dirroot . '/question/engine/upgrade/upgradelib.php');
|
||||
$upgrader = new question_engine_attempt_upgrader();
|
||||
$upgrader->convert_all_quiz_attempts();
|
||||
|
||||
$CFG->rcache = $oldrcachesetting;
|
||||
}
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_mod_savepoint(true, 2011051229, 'quiz');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Upgrade helper code for the quiz module.
|
||||
*
|
||||
* @package mod
|
||||
* @subpackage quiz
|
||||
* @copyright 2006 Eloy Lafuente (stronk7)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
|
||||
/**
|
||||
* Upgrade states for an attempt to Moodle 1.5 model
|
||||
*
|
||||
* Any state that does not yet have its timestamp set to nonzero has not yet been
|
||||
* upgraded from Moodle 1.4. The reason these are still around is that for large
|
||||
* sites it would have taken too long to upgrade all states at once. This function
|
||||
* sets the timestamp field and creates an entry in the question_sessions table.
|
||||
* @param object $attempt The attempt whose states need upgrading
|
||||
*/
|
||||
function quiz_upgrade_very_old_question_sessions($attempt) {
|
||||
global $DB;
|
||||
// The old quiz model only allowed a single response per quiz attempt so that there will be
|
||||
// only one state record per question for this attempt.
|
||||
|
||||
// We set the timestamp of all states to the timemodified field of the attempt.
|
||||
$DB->execute("UPDATE {question_states} SET timestamp = ? WHERE attempt = ?",
|
||||
array($attempt->timemodified, $attempt->uniqueid));
|
||||
|
||||
// For each state we create an entry in the question_sessions table, with both newest and
|
||||
// newgraded pointing to this state.
|
||||
// Actually we only do this for states whose question is actually listed in $attempt->layout.
|
||||
// We do not do it for states associated to wrapped questions like for example the questions
|
||||
// used by a RANDOM question
|
||||
$session = new stdClass();
|
||||
$session->attemptid = $attempt->uniqueid;
|
||||
$session->sumpenalty = 0;
|
||||
$session->manualcomment = '';
|
||||
$session->manualcommentformat = FORMAT_HTML;
|
||||
$session->flagged = 0;
|
||||
|
||||
$questionlist = str_replace(',0', '', quiz_clean_layout($layout, true));
|
||||
if (!$questionlist) {
|
||||
return;
|
||||
}
|
||||
list($usql, $question_params) = $DB->get_in_or_equal(explode(',', $questionlist));
|
||||
$params = array_merge(array($attempt->uniqueid), $question_params);
|
||||
|
||||
if ($states = $DB->get_records_select('question_states',
|
||||
"attempt = ? AND question $usql", $params)) {
|
||||
foreach ($states as $state) {
|
||||
$session->newgraded = $state->id;
|
||||
$session->newest = $state->id;
|
||||
$session->questionid = $state->question;
|
||||
$DB->insert_record('question_sessions', $session, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -347,6 +347,7 @@ $string['guestsno'] = 'Sorry, guests cannot see or attempt quizzes';
|
||||
$string['hidebreaks'] = 'Hide page breaks';
|
||||
$string['hidereordertool'] = 'Hide the reordering tool';
|
||||
$string['history'] = 'History of responses:';
|
||||
$string['howquestionsbehave_desc'] = 'Default setting for how questions behave in a quiz.';
|
||||
$string['imagedisplay'] = 'Image to display';
|
||||
$string['import'] = 'Import';
|
||||
$string['import_help'] = 'This function allows you to import questions from external text files.
|
||||
@@ -768,6 +769,8 @@ $string['updatingatttemptgrades'] = 'Updating attempt grades.';
|
||||
$string['updatingfinalgrades'] = 'Updating final grades.';
|
||||
$string['updatingthegradebook'] = 'Updating the gradebook.';
|
||||
$string['upgradesure'] = '<div>In particular the quiz module will perform an extensive change of the quiz tables and this upgrade has not yet been sufficiently tested. You are very strongly urged to backup your database tables before proceeding.</div>';
|
||||
$string['upgradingquizattempts'] = 'Upgrading quiz attempts: quiz {$a->done}/{$a->outof} (Quiz id {$a->info})';
|
||||
$string['upgradingveryoldquizattempts'] = 'Upgrading very old quiz attempts: {$a->done}/{$a->outof}';
|
||||
$string['url'] = 'URL';
|
||||
$string['usedcategorymoved'] = 'This category has been preserved and moved to the site level because it is a published category still in use by other courses.';
|
||||
$string['useroverrides'] = 'User overrides';
|
||||
|
||||
@@ -820,47 +820,6 @@ function quiz_get_grading_option_name($option) {
|
||||
|
||||
/// Other quiz functions ////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Upgrade states for an attempt to Moodle 1.5 model
|
||||
*
|
||||
* Any state that does not yet have its timestamp set to nonzero has not yet been
|
||||
* upgraded from Moodle 1.4. The reason these are still around is that for large
|
||||
* sites it would have taken too long to upgrade all states at once. This function
|
||||
* sets the timestamp field and creates an entry in the question_sessions table.
|
||||
* @param object $attempt The attempt whose states need upgrading
|
||||
*/
|
||||
function quiz_upgrade_states($attempt) {
|
||||
global $DB;
|
||||
// The old quiz model only allowed a single response per quiz attempt so that there will be
|
||||
// only one state record per question for this attempt.
|
||||
|
||||
// We set the timestamp of all states to the timemodified field of the attempt.
|
||||
$DB->execute("UPDATE {question_states} SET timestamp = ? WHERE attempt = ?",
|
||||
array($attempt->timemodified, $attempt->uniqueid));
|
||||
|
||||
// For each state we create an entry in the question_sessions table, with both newest and
|
||||
// newgraded pointing to this state.
|
||||
// Actually we only do this for states whose question is actually listed in $attempt->layout.
|
||||
// We do not do it for states associated to wrapped questions like for example the questions
|
||||
// used by a RANDOM question
|
||||
$session = new stdClass();
|
||||
$session->attemptid = $attempt->uniqueid;
|
||||
$questionlist = quiz_questions_in_quiz($attempt->layout);
|
||||
$params = array($attempt->uniqueid);
|
||||
list($usql, $question_params) = $DB->get_in_or_equal(explode(',', $questionlist));
|
||||
$params = array_merge($params, $question_params);
|
||||
|
||||
if ($questionlist and $states = $DB->get_records_select('question_states',
|
||||
"attempt = ? AND question $usql", $params)) {
|
||||
foreach ($states as $state) {
|
||||
$session->newgraded = $state->id;
|
||||
$session->newest = $state->id;
|
||||
$session->questionid = $state->question;
|
||||
$DB->insert_record('question_sessions', $session, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $quiz the quiz.
|
||||
* @param int $cmid the course_module object for this quiz.
|
||||
|
||||
@@ -154,8 +154,7 @@ class mod_quiz_mod_form extends moodleform_mod {
|
||||
$behaviours = question_engine::get_behaviour_options($currentbehaviour);
|
||||
$mform->addElement('select', 'preferredbehaviour', get_string('howquestionsbehave', 'question'), $behaviours);
|
||||
$mform->addHelpButton('preferredbehaviour', 'howquestionsbehave', 'question');
|
||||
$mform->setAdvanced('preferredbehaviour', $CFG->quiz_fix_preferredbehaviour);
|
||||
$mform->setDefault('preferredbehaviour', $CFG->quiz_preferredbehaviour);
|
||||
$mform->setDefault('preferredbehaviour', $quizconfig->preferredbehaviour);
|
||||
|
||||
/// Each attempt builds on last.
|
||||
$mform->addElement('selectyesno', 'attemptonlast', get_string('eachattemptbuildsonthelast', 'quiz'));
|
||||
|
||||
@@ -103,15 +103,10 @@ $quizsettings->add(new admin_setting_configcheckbox_with_advanced('quiz/shufflea
|
||||
get_string('shufflewithin', 'quiz'), get_string('configshufflewithin', 'quiz'),
|
||||
array('value' => 1, 'adv' => false)));
|
||||
|
||||
// Adaptive mode.
|
||||
$quizsettings->add(new admin_setting_configcheckbox_with_advanced('quiz/optionflags',
|
||||
get_string('adaptive', 'quiz'), get_string('configadaptive', 'quiz'),
|
||||
array('value' => 1, 'adv' => false)));
|
||||
|
||||
// Apply penalties.
|
||||
$quizsettings->add(new admin_setting_configcheckbox_with_advanced('quiz/penaltyscheme',
|
||||
get_string('penaltyscheme', 'quiz'), get_string('configpenaltyscheme', 'quiz'),
|
||||
array('value' => 1, 'adv' => true)));
|
||||
// Preferred behaviour.
|
||||
$quizsettings->add(new admin_setting_question_behaviour('quiz/preferredbehaviour',
|
||||
get_string('howquestionsbehave', 'question'), get_string('howquestionsbehave_desc', 'quiz'),
|
||||
'deferredfeedback'));
|
||||
|
||||
// Each attempt builds on last.
|
||||
$quizsettings->add(new admin_setting_configcheckbox_with_advanced('quiz/attemptonlast',
|
||||
|
||||
@@ -25,6 +25,6 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$module->version = 2010122304; // The (date) version of this module
|
||||
$module->requires = 2010080300; // Requires this Moodle version
|
||||
$module->version = 2011051250; // The (date) version of this module
|
||||
$module->requires = 2011051212; // Requires this Moodle version
|
||||
$module->cron = 0; // How often should cron check this module (seconds)?
|
||||
|
||||
@@ -46,6 +46,8 @@ class question_engine_attempt_upgrader {
|
||||
protected $logger;
|
||||
/** @var int used by {@link prevent_timeout()}. */
|
||||
protected $dotcounter = 0;
|
||||
/** @var progress_bar */
|
||||
protected $progressbar = null;
|
||||
|
||||
/**
|
||||
* Called before starting to upgrade all the attempts at a particular quiz.
|
||||
@@ -54,8 +56,16 @@ class question_engine_attempt_upgrader {
|
||||
* @param int $quizid the id of the quiz that is about to be processed.
|
||||
*/
|
||||
protected function print_progress($done, $outof, $quizid) {
|
||||
if (is_null($this->progressbar)) {
|
||||
$this->progressbar = new progress_bar('qe2upgrade');
|
||||
}
|
||||
|
||||
gc_collect_cycles(); // This was really helpful in PHP 5.2. Perhaps remove.
|
||||
print_progress($done, $outof);
|
||||
$a = new stdClass();
|
||||
$a->done = $done;
|
||||
$a->todo = $outof;
|
||||
$a->info = $quizid;
|
||||
$this->progressbar->update($done, $outof, get_string('upgradingquizattempts', 'quiz', $a));
|
||||
}
|
||||
|
||||
protected function prevent_timeout() {
|
||||
@@ -71,7 +81,7 @@ class question_engine_attempt_upgrader {
|
||||
global $DB;
|
||||
// TODO, if local/qeupgradehelper/ is installed, and defines the right
|
||||
// function, use that to get the lest of quizzes instead.
|
||||
return $DB->get_records_menu('quiz', '', '', 'id', 'id,1');
|
||||
return $DB->get_records_menu('quiz', array(), '', 'id', 'id, 1');
|
||||
}
|
||||
|
||||
public function convert_all_quiz_attempts() {
|
||||
@@ -273,7 +283,7 @@ class question_engine_attempt_upgrader {
|
||||
|
||||
public function get_next_question_session($attempt, moodle_recordset $questionsessionsrs) {
|
||||
$qsession = $questionsessionsrs->current();
|
||||
|
||||
print_object($qsession); // DONOTCOMMIT
|
||||
if (!$qsession || $qsession->attemptid != $attempt->uniqueid) {
|
||||
// No more question sessions belonging to this attempt.
|
||||
return false;
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
|
||||
$version = 2011051100.00; // YYYYMMDD = weekly release date of this DEV branch
|
||||
$version = 2011051212.00; // YYYYMMDD = weekly release date of this DEV branch
|
||||
// RR = release increments - 00 in DEV branches
|
||||
// .XX = incremental changes
|
||||
|
||||
|
||||
Reference in New Issue
Block a user