From: moodler Date: Thu, 1 Jan 2004 06:35:22 +0000 (+0000) Subject: New setting makes it optional to show column of people who didn't answer X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=263a47359378f9d0ebbb35da636c6f07e044adf5;p=moodle.git New setting makes it optional to show column of people who didn't answer --- diff --git a/mod/choice/backuplib.php b/mod/choice/backuplib.php index b9abb98d23..7dfcdfb2e7 100644 --- a/mod/choice/backuplib.php +++ b/mod/choice/backuplib.php @@ -45,6 +45,7 @@ fwrite ($bf,full_tag("ANSWER4",4,false,$choice->answer4)); fwrite ($bf,full_tag("ANSWER5",4,false,$choice->answer5)); fwrite ($bf,full_tag("ANSWER6",4,false,$choice->answer6)); + fwrite ($bf,full_tag("SHOWUNANSWERED",4,false,$choice->showunanswered)); fwrite ($bf,full_tag("PUBLISH",4,false,$choice->publish)); fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$choice->timemodified)); //if we've selected to backup users info, then execute backup_choice_answers diff --git a/mod/choice/db/mysql.php b/mod/choice/db/mysql.php index d8a021fc56..abf13bf7e5 100644 --- a/mod/choice/db/mysql.php +++ b/mod/choice/db/mysql.php @@ -21,6 +21,11 @@ function choice_upgrade($oldversion) { execute_sql(" ALTER TABLE `choice` ADD `format` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL AFTER `text` "); execute_sql(" ALTER TABLE `choice` ADD `publish` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL AFTER `answer6` "); } + + if ($oldversion < 2004010100) { + table_column("choice", "", "showunanswered", "integer", "4", "unsigned", "0", "", "publish"); + } + return true; } diff --git a/mod/choice/db/mysql.sql b/mod/choice/db/mysql.sql index 74de9de72b..c513fcbf15 100755 --- a/mod/choice/db/mysql.sql +++ b/mod/choice/db/mysql.sql @@ -27,6 +27,7 @@ CREATE TABLE prefix_choice ( answer5 varchar(255) default NULL, answer6 varchar(255) default NULL, publish tinyint(2) unsigned NOT NULL default '0', + showunanswered tinyint(2) unsigned NOT NULL default '0', timemodified int(10) unsigned NOT NULL default '0', PRIMARY KEY (id), UNIQUE KEY id (id) diff --git a/mod/choice/db/postgres7.php b/mod/choice/db/postgres7.php index ea4ef82dc1..66f37a7e9f 100644 --- a/mod/choice/db/postgres7.php +++ b/mod/choice/db/postgres7.php @@ -8,6 +8,9 @@ function choice_upgrade($oldversion) { execute_sql(" ALTER TABLE `choice` ADD `format` INTEGER DEFAULT '0' NOT NULL AFTER `text` "); execute_sql(" ALTER TABLE `choice` ADD `publish` INTEGER DEFAULT '0' NOT NULL AFTER `answer6` "); } + if ($oldversion < 2004010100) { + table_column("choice", "", "showunanswered", "integer", "4", "unsigned", "0", "", "publish"); + } return true; } diff --git a/mod/choice/db/postgres7.sql b/mod/choice/db/postgres7.sql index f7ba955adc..3fcc386d96 100755 --- a/mod/choice/db/postgres7.sql +++ b/mod/choice/db/postgres7.sql @@ -26,6 +26,7 @@ CREATE TABLE prefix_choice ( answer4 varchar(255) default NULL, answer5 varchar(255) default NULL, answer6 varchar(255) default NULL, + showunanswered integer NOT NULL default '0', publish integer NOT NULL default '0', timemodified integer NOT NULL default '0' ); diff --git a/mod/choice/mod.html b/mod/choice/mod.html index 2db776ee34..0dce24aad3 100644 --- a/mod/choice/mod.html +++ b/mod/choice/mod.html @@ -6,7 +6,7 @@ $form->text = ""; } if (empty($form->format)) { - $form->format = ""; + $form->format = 0; } if (empty($form->answer1)) { $form->answer1 = get_string("yes"); @@ -27,7 +27,10 @@ $form->answer6 = ""; } if (empty($form->publish)) { - $form->publish = ""; + $form->publish = 0; + } + if (empty($form->showunanswered)) { + $form->showunanswered = 0; } if ($usehtmleditor = can_use_richtext_editor()) { @@ -138,6 +141,17 @@
+ +

:

+ + showunanswered", ""); + ?> +
+ + diff --git a/mod/choice/restorelib.php b/mod/choice/restorelib.php index d342d6f39a..4be35a645e 100644 --- a/mod/choice/restorelib.php +++ b/mod/choice/restorelib.php @@ -49,6 +49,7 @@ $choice->answer4 = backup_todb($info['MOD']['#']['ANSWER4']['0']['#']); $choice->answer5 = backup_todb($info['MOD']['#']['ANSWER5']['0']['#']); $choice->answer6 = backup_todb($info['MOD']['#']['ANSWER6']['0']['#']); + $choice->showunanswered = backup_todb($info['MOD']['#']['SHOWUNANSWERED']['0']['#']); $choice->publish = backup_todb($info['MOD']['#']['PUBLISH']['0']['#']); $choice->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']); diff --git a/mod/choice/version.php b/mod/choice/version.php index 53e00064b0..6b36976977 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 = 2003010100; +$module->version = 2004010100; $module->cron = 0; ?> diff --git a/mod/choice/view.php b/mod/choice/view.php index 976f9c59bf..4309fc0079 100644 --- a/mod/choice/view.php +++ b/mod/choice/view.php @@ -123,8 +123,7 @@ $answer = $answers[$user->id]; $useranswer[(int)$answer->answer][] = $user; } else { - $answer = ""; - $useranswer[(int)$answer->answer][] = $user; + $useranswer[0][] = $user; } } foreach ($choice->answer as $key => $answer) { @@ -146,8 +145,10 @@ foreach ($useranswer as $key => $answer) { if ($key) { echo ""; + } else if ($choice->showunanswered) { + echo "body\" width=\"$tablewidth%\">"; } else { - echo "body\" width=\"$tablewidth%\">"; + continue; } echo choice_get_answer($choice, $key); echo ""; @@ -157,8 +158,10 @@ foreach ($useranswer as $key => $answer) { if ($key) { echo "cellcontent\">"; - } else { + } else if ($choice->showunanswered) { echo "body\">"; + } else { + continue; } echo ""; @@ -185,8 +188,10 @@ foreach ($useranswer as $key => $answer) { if ($key) { echo ""; @@ -195,6 +200,9 @@ $maxcolumn = 0; foreach ($useranswer as $key => $answer) { + if (!$key and !$choice->showunanswered) { + continue; + } $column[$key] = count($answer); if ($column[$key] > $maxcolumn) { $maxcolumn = $column[$key]; @@ -203,14 +211,21 @@ echo ""; foreach ($useranswer as $key => $answer) { + if (!$key and !$choice->showunanswered) { + continue; + } $height = $COLUMN_HEIGHT * ((float)$column[$key] / (float)$maxcolumn); echo ""; + echo ""; + echo ""; } echo ""; echo ""; foreach ($useranswer as $key => $answer) { + if (!$key and !$choice->showunanswered) { + continue; + } echo ""; } echo "
"; - } else { + } else if ($choice->showunanswered) { echo "body\" width=\"$tablewidth%\">"; + } else { + continue; } echo choice_get_answer($choice, $key); echo "
"; - echo "
".$column[$key]."
";