mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 12:40:01 +01:00
Bug 3768 - Release is now a reserved word in MySql 5
This commit is contained in:
parent
7988d9e75a
commit
c100a341a6
@ -63,7 +63,7 @@
|
||||
fwrite ($bf,full_tag("TEXT",4,false,$choice->text));
|
||||
fwrite ($bf,full_tag("FORMAT",4,false,$choice->format));
|
||||
fwrite ($bf,full_tag("PUBLISH",4,false,$choice->publish));
|
||||
fwrite ($bf,full_tag("RELEASE",4,false,$choice->release));
|
||||
fwrite ($bf,full_tag("SHOWRESULTS",4,false,$choice->showresults));
|
||||
fwrite ($bf,full_tag("DISPLAY",4,false,$choice->display));
|
||||
fwrite ($bf,full_tag("ALLOWUPDATE",4,false,$choice->allowupdate));
|
||||
fwrite ($bf,full_tag("SHOWUNANSWERED",4,false,$choice->showunanswered));
|
||||
|
@ -119,7 +119,9 @@ function choice_upgrade($oldversion) {
|
||||
table_column('choice', '', 'limitanswers', 'TINYINT', '2', 'unsigned', 0, 'not null', 'showunanswered');
|
||||
table_column('choice_options', '', 'maxanswers', 'INTEGER', '10', 'unsigned', 0, 'null', 'text');
|
||||
}
|
||||
|
||||
if ($oldversion < 2006020900) { //rename release column to showanswers - Release is now reserved word in mySql
|
||||
table_column('choice', 'release', 'showresults', 'TINYINT', '2', 'unsigned', 0, 'not null');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1,85 +1,85 @@
|
||||
# phpMyAdmin MySQL-Dump
|
||||
# version 2.2.1
|
||||
# http://phpwizard.net/phpMyAdmin/
|
||||
# http://phpmyadmin.sourceforge.net/ (download page)
|
||||
#
|
||||
# Host: localhost
|
||||
# Generation Time: Nov 14, 2001 at 04:44 PM
|
||||
# Server version: 3.23.36
|
||||
# PHP Version: 4.0.6
|
||||
# Database : `moodle`
|
||||
# --------------------------------------------------------
|
||||
|
||||
#
|
||||
# Table structure for table `choice`
|
||||
#
|
||||
|
||||
CREATE TABLE prefix_choice (
|
||||
id int(10) unsigned NOT NULL auto_increment,
|
||||
course int(10) unsigned NOT NULL default '0',
|
||||
name varchar(255) NOT NULL default '',
|
||||
text text NOT NULL default '',
|
||||
format tinyint(2) unsigned NOT NULL default '0',
|
||||
publish tinyint(2) unsigned NOT NULL default '0',
|
||||
`release` tinyint(2) unsigned NOT NULL default '0',
|
||||
display tinyint(4) unsigned NOT NULL default '0',
|
||||
allowupdate tinyint(2) unsigned NOT NULL default '0',
|
||||
showunanswered tinyint(2) unsigned NOT NULL default '0',
|
||||
limitanswers tinyint(2) unsigned NOT NULL default '0',
|
||||
timeopen int(10) unsigned NOT NULL default '0',
|
||||
timeclose int(10) unsigned NOT NULL default '0',
|
||||
timemodified int(10) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE KEY id (id),
|
||||
KEY course (course)
|
||||
) TYPE=MyISAM COMMENT='Available choices are stored here.';
|
||||
|
||||
|
||||
# --------------------------------------------------------
|
||||
|
||||
#
|
||||
# Table structure for table `choice_answers`
|
||||
#
|
||||
|
||||
CREATE TABLE prefix_choice_answers (
|
||||
id int(10) unsigned NOT NULL auto_increment,
|
||||
choiceid int(10) unsigned NOT NULL default '0',
|
||||
userid int(10) unsigned NOT NULL default '0',
|
||||
optionid int(10) NOT NULL default '0',
|
||||
timemodified int(10) NOT NULL default '0',
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE KEY id (id),
|
||||
KEY userid (userid),
|
||||
KEY choiceid (choiceid)
|
||||
) TYPE=MyISAM;
|
||||
|
||||
|
||||
# --------------------------------------------------------
|
||||
|
||||
#
|
||||
# Table structure for table `choice_options`
|
||||
#
|
||||
|
||||
CREATE TABLE prefix_choice_options (
|
||||
id int(10) unsigned NOT NULL auto_increment,
|
||||
choiceid int(10) unsigned NOT NULL default '0',
|
||||
`text` text default '',
|
||||
maxanswers int(10) unsigned NULL default '0',
|
||||
timemodified int(10) NOT NULL default '0',
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE KEY id (id),
|
||||
KEY choiceid (choiceid)
|
||||
) TYPE=MyISAM;
|
||||
|
||||
#
|
||||
# Dumping data for table `log_display`
|
||||
#
|
||||
|
||||
INSERT INTO prefix_log_display VALUES ('choice', 'view', 'choice', 'name');
|
||||
INSERT INTO prefix_log_display VALUES ('choice', 'update', 'choice', 'name');
|
||||
INSERT INTO prefix_log_display VALUES ('choice', 'add', 'choice', 'name');
|
||||
INSERT INTO prefix_log_display VALUES ('choice', 'report', 'choice', 'name');
|
||||
INSERT INTO prefix_log_display VALUES ('choice', 'choose', 'choice', 'name');
|
||||
INSERT INTO prefix_log_display VALUES ('choice', 'choose again', 'choice', 'name');
|
||||
|
||||
|
||||
# phpMyAdmin MySQL-Dump
|
||||
# version 2.2.1
|
||||
# http://phpwizard.net/phpMyAdmin/
|
||||
# http://phpmyadmin.sourceforge.net/ (download page)
|
||||
#
|
||||
# Host: localhost
|
||||
# Generation Time: Nov 14, 2001 at 04:44 PM
|
||||
# Server version: 3.23.36
|
||||
# PHP Version: 4.0.6
|
||||
# Database : `moodle`
|
||||
# --------------------------------------------------------
|
||||
|
||||
#
|
||||
# Table structure for table `choice`
|
||||
#
|
||||
|
||||
CREATE TABLE prefix_choice (
|
||||
id int(10) unsigned NOT NULL auto_increment,
|
||||
course int(10) unsigned NOT NULL default '0',
|
||||
name varchar(255) NOT NULL default '',
|
||||
text text NOT NULL default '',
|
||||
format tinyint(2) unsigned NOT NULL default '0',
|
||||
publish tinyint(2) unsigned NOT NULL default '0',
|
||||
showresults tinyint(2) unsigned NOT NULL default '0',
|
||||
display tinyint(4) unsigned NOT NULL default '0',
|
||||
allowupdate tinyint(2) unsigned NOT NULL default '0',
|
||||
showunanswered tinyint(2) unsigned NOT NULL default '0',
|
||||
limitanswers tinyint(2) unsigned NOT NULL default '0',
|
||||
timeopen int(10) unsigned NOT NULL default '0',
|
||||
timeclose int(10) unsigned NOT NULL default '0',
|
||||
timemodified int(10) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE KEY id (id),
|
||||
KEY course (course)
|
||||
) TYPE=MyISAM COMMENT='Available choices are stored here.';
|
||||
|
||||
|
||||
# --------------------------------------------------------
|
||||
|
||||
#
|
||||
# Table structure for table `choice_answers`
|
||||
#
|
||||
|
||||
CREATE TABLE prefix_choice_answers (
|
||||
id int(10) unsigned NOT NULL auto_increment,
|
||||
choiceid int(10) unsigned NOT NULL default '0',
|
||||
userid int(10) unsigned NOT NULL default '0',
|
||||
optionid int(10) NOT NULL default '0',
|
||||
timemodified int(10) NOT NULL default '0',
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE KEY id (id),
|
||||
KEY userid (userid),
|
||||
KEY choiceid (choiceid)
|
||||
) TYPE=MyISAM;
|
||||
|
||||
|
||||
# --------------------------------------------------------
|
||||
|
||||
#
|
||||
# Table structure for table `choice_options`
|
||||
#
|
||||
|
||||
CREATE TABLE prefix_choice_options (
|
||||
id int(10) unsigned NOT NULL auto_increment,
|
||||
choiceid int(10) unsigned NOT NULL default '0',
|
||||
`text` text default '',
|
||||
maxanswers int(10) unsigned NULL default '0',
|
||||
timemodified int(10) NOT NULL default '0',
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE KEY id (id),
|
||||
KEY choiceid (choiceid)
|
||||
) TYPE=MyISAM;
|
||||
|
||||
#
|
||||
# Dumping data for table `log_display`
|
||||
#
|
||||
|
||||
INSERT INTO prefix_log_display VALUES ('choice', 'view', 'choice', 'name');
|
||||
INSERT INTO prefix_log_display VALUES ('choice', 'update', 'choice', 'name');
|
||||
INSERT INTO prefix_log_display VALUES ('choice', 'add', 'choice', 'name');
|
||||
INSERT INTO prefix_log_display VALUES ('choice', 'report', 'choice', 'name');
|
||||
INSERT INTO prefix_log_display VALUES ('choice', 'choose', 'choice', 'name');
|
||||
INSERT INTO prefix_log_display VALUES ('choice', 'choose again', 'choice', 'name');
|
||||
|
||||
|
||||
|
@ -98,7 +98,9 @@ function choice_upgrade($oldversion) {
|
||||
modify_database('','ALTER TABLE prefix_choice_answers ALTER choiceid SET NOT NULL');
|
||||
modify_database('','ALTER TABLE prefix_choice_answers ALTER optionid SET NOT NULL');
|
||||
}
|
||||
|
||||
if ($oldversion < 2006020900) { //rename release column to showanswers - Release is now reserved word in mySql
|
||||
table_column('choice', 'release', 'showresults', 'TINYINT', '2', 'unsigned', 0, 'not null');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ CREATE TABLE prefix_choice (
|
||||
showunanswered integer NOT NULL default '0',
|
||||
limitanswers integer NOT NULL default '0',
|
||||
publish integer NOT NULL default '0',
|
||||
release integer NOT NULL default '0',
|
||||
showresults integer NOT NULL default '0',
|
||||
display integer NOT NULL default '0',
|
||||
allowupdate integer NOT NULL default '0',
|
||||
timeopen integer NOT NULL default '0',
|
||||
|
@ -5,10 +5,10 @@ $COLUMN_HEIGHT = 300;
|
||||
define('CHOICE_PUBLISH_ANONYMOUS', '0');
|
||||
define('CHOICE_PUBLISH_NAMES', '1');
|
||||
|
||||
define('CHOICE_RELEASE_NOT', '0');
|
||||
define('CHOICE_RELEASE_AFTER_ANSWER', '1');
|
||||
define('CHOICE_RELEASE_AFTER_CLOSE', '2');
|
||||
define('CHOICE_RELEASE_ALWAYS', '3');
|
||||
define('CHOICE_SHOWRESULTS_NOT', '0');
|
||||
define('CHOICE_SHOWRESULTS_AFTER_ANSWER', '1');
|
||||
define('CHOICE_SHOWRESULTS_AFTER_CLOSE', '2');
|
||||
define('CHOICE_SHOWRESULTS_ALWAYS', '3');
|
||||
|
||||
define('CHOICE_DISPLAY_HORIZONTAL', '0');
|
||||
define('CHOICE_DISPLAY_VERTICAL', '1');
|
||||
@ -16,10 +16,10 @@ define('CHOICE_DISPLAY_VERTICAL', '1');
|
||||
$CHOICE_PUBLISH = array (CHOICE_PUBLISH_ANONYMOUS => get_string('publishanonymous', 'choice'),
|
||||
CHOICE_PUBLISH_NAMES => get_string('publishnames', 'choice'));
|
||||
|
||||
$CHOICE_RELEASE = array (CHOICE_RELEASE_NOT => get_string('publishnot', 'choice'),
|
||||
CHOICE_RELEASE_AFTER_ANSWER => get_string('publishafteranswer', 'choice'),
|
||||
CHOICE_RELEASE_AFTER_CLOSE => get_string('publishafterclose', 'choice'),
|
||||
CHOICE_RELEASE_ALWAYS => get_string('publishalways', 'choice'));
|
||||
$CHOICE_SHOWRESULTS = array (CHOICE_SHOWRESULTS_NOT => get_string('publishnot', 'choice'),
|
||||
CHOICE_SHOWRESULTS_AFTER_ANSWER => get_string('publishafteranswer', 'choice'),
|
||||
CHOICE_SHOWRESULTS_AFTER_CLOSE => get_string('publishafterclose', 'choice'),
|
||||
CHOICE_SHOWRESULTS_ALWAYS => get_string('publishalways', 'choice'));
|
||||
|
||||
$CHOICE_DISPLAY = array (CHOICE_DISPLAY_HORIZONTAL => get_string('displayhorizontal', 'choice'),
|
||||
CHOICE_DISPLAY_VERTICAL => get_string('displayvertical','choice'));
|
||||
|
@ -23,8 +23,8 @@
|
||||
if (empty($form->publish)) {
|
||||
$form->publish = 0;
|
||||
}
|
||||
if (empty($form->release)) {
|
||||
$form->release = 0;
|
||||
if (empty($form->showresults)) {
|
||||
$form->showresults = 0;
|
||||
}
|
||||
if (empty($form->allowupdate)) {
|
||||
$form->allowupdate = 0;
|
||||
@ -256,7 +256,7 @@ $limitfieldlist = trim($limitfieldlist, ",");
|
||||
<td colspan="2">
|
||||
<?php
|
||||
require_once("$CFG->dirroot/mod/choice/lib.php");
|
||||
choose_from_menu($CHOICE_RELEASE, "release", "$form->release", "", "return lockselects('form','release.options[0]',['publish'])");
|
||||
choose_from_menu($CHOICE_SHOWRESULTS, "showresults", "$form->showresults", "", "return lockselects('form','showresults.options[0]',['publish'])");
|
||||
?>
|
||||
<br />
|
||||
</td>
|
||||
@ -274,7 +274,7 @@ $limitfieldlist = trim($limitfieldlist, ",");
|
||||
</td>
|
||||
</tr>
|
||||
<script type="text/javascript">
|
||||
lockselects('form','release.options[0]',['publish']);
|
||||
lockselects('form','showresults.options[0]',['publish']);
|
||||
</script>
|
||||
|
||||
<tr valign="top">
|
||||
|
@ -49,7 +49,7 @@
|
||||
$choice->text = backup_todb($info['MOD']['#']['TEXT']['0']['#']);
|
||||
$choice->format = backup_todb($info['MOD']['#']['FORMAT']['0']['#']);
|
||||
$choice->publish = backup_todb($info['MOD']['#']['PUBLISH']['0']['#']);
|
||||
$choice->release = backup_todb($info['MOD']['#']['RELEASE']['0']['#']);
|
||||
$choice->showresults = backup_todb($info['MOD']['#']['SHOWRESULTS']['0']['#']);
|
||||
$choice->display = backup_todb($info['MOD']['#']['DISPLAY']['0']['#']);
|
||||
$choice->allowupdate = backup_todb($info['MOD']['#']['ALLOWUPDATE']['0']['#']);
|
||||
$choice->showunanswered = backup_todb($info['MOD']['#']['SHOWUNANSWERED']['0']['#']);
|
||||
@ -60,21 +60,25 @@
|
||||
|
||||
//To mantain compatibilty, in 1.4 the publish setting meaning has changed. We
|
||||
//have to modify some things it if the release field isn't present in the backup file.
|
||||
if (! isset($info['MOD']['#']['RELEASE']['0']['#'])) { //It's a pre-14 backup filea
|
||||
//Set the allowupdate field
|
||||
if ($choice->publish == 0) {
|
||||
$choice->allowupdate = 1;
|
||||
}
|
||||
//Set the release field as defined by the old publish field
|
||||
if ($choice->publish > 0) {
|
||||
$choice->release = 1;
|
||||
}
|
||||
//Recode the publish field to its 1.4 meaning
|
||||
if ($choice->publish > 0) {
|
||||
$choice->publish--;
|
||||
if (! isset($info['MOD']['#']['SHOWANSWERS']['0']['#'])) { //check for previous versions
|
||||
if (! isset($info['MOD']['#']['RELEASE']['0']['#'])) { //It's a pre-14 backup filea
|
||||
//Set the allowupdate field
|
||||
if ($choice->publish == 0) {
|
||||
$choice->allowupdate = 1;
|
||||
}
|
||||
//Set the showresults field as defined by the old publish field
|
||||
if ($choice->publish > 0) {
|
||||
$choice->showresults = 1;
|
||||
}
|
||||
//Recode the publish field to its 1.4 meaning
|
||||
if ($choice->publish > 0) {
|
||||
$choice->publish--;
|
||||
}
|
||||
} else { //it's post 1.4 pre 1.6
|
||||
//convert old release values into new showanswer column.
|
||||
$choice->showresults = backup_todb($info['MOD']['#']['RELEASE']['0']['#']);
|
||||
}
|
||||
}
|
||||
|
||||
//The structure is equal to the db, so insert the choice
|
||||
$newid = insert_record ("choice",$choice);
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
// This fragment is called by /admin/index.php
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$module->version = 2005041500;
|
||||
$module->version = 2006020900;
|
||||
$module->requires = 2005021600; // Requires this Moodle version
|
||||
$module->cron = 0;
|
||||
|
||||
|
@ -192,7 +192,7 @@
|
||||
}
|
||||
echo format_text($text. ' ', FORMAT_MOODLE, $displayoptions);
|
||||
|
||||
if ($choice->limitanswers && ($choice->release==CHOICE_RELEASE_ALWAYS) ){
|
||||
if ($choice->limitanswers && ($choice->showresults==CHOICE_SHOWRESULTS_ALWAYS) ){
|
||||
echo "</td><td>";
|
||||
|
||||
if ($maxans-$countanswers==0) {
|
||||
@ -234,9 +234,9 @@
|
||||
|
||||
// print the results at the bottom of the screen
|
||||
|
||||
if ( $choice->release == CHOICE_RELEASE_ALWAYS or
|
||||
( $choice->release == CHOICE_RELEASE_AFTER_ANSWER and $current ) or
|
||||
( $choice->release == CHOICE_RELEASE_AFTER_CLOSE and $choice->timeclose <= time() ) ) {
|
||||
if ( $choice->showresults == CHOICE_SHOWRESULTS_ALWAYS or
|
||||
( $choice->showresults == CHOICE_SHOWRESULTS_AFTER_ANSWER and $current ) or
|
||||
( $choice->showresults == CHOICE_SHOWRESULTS_AFTER_CLOSE and $choice->timeclose <= time() ) ) {
|
||||
|
||||
print_heading(get_string("responses", "choice"));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user