diff --git a/mod/choice/backuplib.php b/mod/choice/backuplib.php index 038f8ea8356..bbbb63ae9ff 100644 --- a/mod/choice/backuplib.php +++ b/mod/choice/backuplib.php @@ -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)); diff --git a/mod/choice/db/mysql.php b/mod/choice/db/mysql.php index 78a93984d54..73bd835352d 100644 --- a/mod/choice/db/mysql.php +++ b/mod/choice/db/mysql.php @@ -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; } diff --git a/mod/choice/db/mysql.sql b/mod/choice/db/mysql.sql index 88559949141..380b9ea7fb9 100755 --- a/mod/choice/db/mysql.sql +++ b/mod/choice/db/mysql.sql @@ -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'); + + diff --git a/mod/choice/db/postgres7.php b/mod/choice/db/postgres7.php index 275c00e9de7..57220443357 100644 --- a/mod/choice/db/postgres7.php +++ b/mod/choice/db/postgres7.php @@ -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; } diff --git a/mod/choice/db/postgres7.sql b/mod/choice/db/postgres7.sql index 6edac4fcc36..49b940ecc62 100755 --- a/mod/choice/db/postgres7.sql +++ b/mod/choice/db/postgres7.sql @@ -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', diff --git a/mod/choice/lib.php b/mod/choice/lib.php index c34ac6a83ee..3660a1f9c33 100644 --- a/mod/choice/lib.php +++ b/mod/choice/lib.php @@ -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')); diff --git a/mod/choice/mod.html b/mod/choice/mod.html index e76741f0bb9..c4ebcb1b299 100644 --- a/mod/choice/mod.html +++ b/mod/choice/mod.html @@ -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, ","); 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'])"); ?>
@@ -274,7 +274,7 @@ $limitfieldlist = trim($limitfieldlist, ","); diff --git a/mod/choice/restorelib.php b/mod/choice/restorelib.php index e0d4bc9d5f5..774cbe658d4 100644 --- a/mod/choice/restorelib.php +++ b/mod/choice/restorelib.php @@ -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); diff --git a/mod/choice/version.php b/mod/choice/version.php index 7298d916fdf..29e3b075923 100644 --- a/mod/choice/version.php +++ b/mod/choice/version.php @@ -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; diff --git a/mod/choice/view.php b/mod/choice/view.php index 4e7b6457a47..d88352edd3d 100644 --- a/mod/choice/view.php +++ b/mod/choice/view.php @@ -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 ""; 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"));