mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
Rename column question_dataset_items->number to itemnumber, to avoid reserved word.
This commit is contained in:
parent
b22c03ce99
commit
717cfb0a7b
@ -1136,6 +1136,10 @@ function quiz_upgrade($oldversion) {
|
||||
$success = $success && table_column('question_sessions', 'comment', 'manualcomment', 'text', '', '', '');
|
||||
}
|
||||
|
||||
if ($success && $oldversion < 2006091900) {
|
||||
$success = $success && table_column('question_dataset_items', 'number', 'itemnumber', 'text', '', '', '');
|
||||
}
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
|
@ -187,7 +187,7 @@ CREATE TABLE prefix_question_dataset_definitions (
|
||||
CREATE TABLE prefix_question_dataset_items (
|
||||
id int(10) unsigned NOT NULL auto_increment,
|
||||
definition int(10) unsigned NOT NULL default '0',
|
||||
number int(10) unsigned NOT NULL default '0',
|
||||
itemnumber int(10) unsigned NOT NULL default '0',
|
||||
value varchar(255) NOT NULL default '',
|
||||
PRIMARY KEY (id),
|
||||
KEY definition (definition)
|
||||
|
@ -1458,6 +1458,10 @@ function quiz_upgrade($oldversion) {
|
||||
$success = $success && table_column('question_sessions', 'comment', 'manualcomment', 'text', '', '', '');
|
||||
}
|
||||
|
||||
if ($success && $oldversion < 2006091900) {
|
||||
$success = $success && table_column('question_dataset_items', 'number', 'itemnumber', 'text', '', '', '');
|
||||
}
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
|
@ -176,7 +176,7 @@ CREATE INDEX prefix_question_dataset_definitions_category_idx ON prefix_question
|
||||
CREATE TABLE prefix_question_dataset_items (
|
||||
id SERIAL8 PRIMARY KEY,
|
||||
definition INT8 NOT NULL default '0',
|
||||
number INT8 NOT NULL default '0',
|
||||
itemnumber INT8 NOT NULL default '0',
|
||||
value varchar(255) NOT NULL default ''
|
||||
);
|
||||
CREATE INDEX prefix_question_dataset_items_definition_idx ON prefix_question_dataset_items (definition);
|
||||
|
@ -1198,7 +1198,7 @@
|
||||
|
||||
//Now, build the question_dataset_ITEMS record structure
|
||||
$dataset_item->definition = $definitionid;
|
||||
$dataset_item->number = backup_todb($di_info['#']['NUMBER']['0']['#']);
|
||||
$dataset_item->itemnumber = backup_todb($di_info['#']['NUMBER']['0']['#']);
|
||||
$dataset_item->value = backup_todb($di_info['#']['VALUE']['0']['#']);
|
||||
|
||||
//The structure is equal to the db, so insert the question_dataset_items
|
||||
|
@ -5,7 +5,7 @@
|
||||
// This fragment is called by moodle_needs_upgrading() and /admin/index.php
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$module->version = 2006091201; // The (date) version of this module
|
||||
$module->version = 2006091900; // The (date) version of this module
|
||||
$module->requires = 2006080900; // Requires this Moodle version
|
||||
$module->cron = 0; // How often should cron check this module (seconds)?
|
||||
|
||||
|
@ -277,7 +277,7 @@
|
||||
foreach ($dataset_items as $dataset_item) {
|
||||
$status = $status &&fwrite ($bf,start_tag("DATASET_ITEM",$level+1,true));
|
||||
//Print question_dataset contents
|
||||
fwrite ($bf,full_tag("NUMBER",$level+2,false,$dataset_item->number));
|
||||
fwrite ($bf,full_tag("NUMBER",$level+2,false,$dataset_item->itemnumber));
|
||||
fwrite ($bf,full_tag("VALUE",$level+2,false,$dataset_item->value));
|
||||
//End dataset definition
|
||||
$status = $status &&fwrite ($bf,end_tag("DATASET_ITEM",$level+1,true));
|
||||
|
@ -108,13 +108,13 @@ class qformat_webct_modified_calculated_qtype extends question_calculated_qtype
|
||||
|
||||
// Set items and retrieve ->itemcout
|
||||
$item->definition = $datasetdef->id;
|
||||
for ($item->number=1 ; isset($datasetdata->items["$item->number"]) ; ++$item->number) {
|
||||
$item->value = $datasetdata->items["$item->number"];
|
||||
for ($item->itemnumber=1 ; isset($datasetdata->items["$item->itemnumber"]) ; ++$item->itemnumber) {
|
||||
$item->value = $datasetdata->items["$item->itemnumber"];
|
||||
if (!insert_record('question_dataset_items', $item)) {
|
||||
error("Unable to insert dataset item $item->number with $item->value for $datasetdef->name");
|
||||
error("Unable to insert dataset item $item->itemnumber with $item->value for $datasetdef->name");
|
||||
}
|
||||
}
|
||||
$datasetdef->itemcount = $item->number - 1;
|
||||
$datasetdef->itemcount = $item->itemnumber - 1;
|
||||
|
||||
// Retrieve ->options
|
||||
if (is_numeric($datasetdata->min) && is_numeric($datasetdata->max)
|
||||
|
@ -568,7 +568,7 @@
|
||||
//Now, build the question_dataset_ITEMS record structure
|
||||
$dataset_item = new stdClass;
|
||||
$dataset_item->definition = $definitionid;
|
||||
$dataset_item->number = backup_todb($di_info['#']['NUMBER']['0']['#']);
|
||||
$dataset_item->itemnumber = backup_todb($di_info['#']['NUMBER']['0']['#']);
|
||||
$dataset_item->value = backup_todb($di_info['#']['VALUE']['0']['#']);
|
||||
|
||||
//The structure is equal to the db, so insert the question_dataset_items
|
||||
|
@ -461,7 +461,7 @@ class question_dataset_dependent_questiontype extends default_questiontype {
|
||||
WHERE q.question = $question->id
|
||||
AND q.datasetdefinition = d.id
|
||||
AND d.id = i.definition
|
||||
AND i.number = $datasetitem")) {
|
||||
AND i.itemnumber = $datasetitem")) {
|
||||
error("Couldn't get the specified dataset for a dataset dependent " .
|
||||
"question! (question: {$question->id}, " .
|
||||
"datasetitem: {$datasetitem})");
|
||||
|
@ -50,7 +50,7 @@
|
||||
// Handle adding and removing of dataset items
|
||||
// This twisted condition should effectively stop resubmits caused by reloads
|
||||
if (isset($form->addbutton) && $maxnumber + 1 == $form->numbertoadd) {
|
||||
$addeditem->number = $form->numbertoadd;
|
||||
$addeditem->itemnumber = $form->numbertoadd;
|
||||
foreach ($form->definition as $key => $defid) {
|
||||
$addeditem->definition = $datasetdefs[$defid]->id;
|
||||
$addeditem->value = $form->value[$key];
|
||||
@ -76,7 +76,7 @@
|
||||
}
|
||||
}
|
||||
// else Success:
|
||||
$maxnumber = $addeditem->number;
|
||||
$maxnumber = $addeditem->itemnumber;
|
||||
|
||||
} else if (isset($form->deletebutton)
|
||||
&& $maxnumber == $form->numbertodelete) {
|
||||
@ -107,7 +107,7 @@
|
||||
foreach ($datasetdefs as $defid => $datasetdef) {
|
||||
if (isset($datasetdef->id)) {
|
||||
$datasetdefs[$defid]->items = get_records_sql( // Use number as key!!
|
||||
" SELECT number, definition, id, value
|
||||
" SELECT itemnumber, definition, id, value
|
||||
FROM {$CFG->prefix}question_dataset_items
|
||||
WHERE definition = $datasetdef->id ");
|
||||
}
|
||||
@ -123,7 +123,7 @@
|
||||
$datasetitem->id =
|
||||
isset($datasetdefs[$defid]->items[$maxnumber + 1]->id)
|
||||
? $datasetdefs[$defid]->items[$maxnumber + 1]->id : '';
|
||||
$datasetitem->number = $maxnumber + 1;
|
||||
$datasetitem->itemnumber = $maxnumber + 1;
|
||||
if ($this->supports_dataset_item_generation()) {
|
||||
if (!empty($form->addbutton) || // If we added an item
|
||||
!isset($form->value) || // If we don't have a value
|
||||
|
Loading…
x
Reference in New Issue
Block a user