]> git.mjollnir.org Git - moodle.git/commitdiff
New setting makes it optional to show column of people who didn't answer
authormoodler <moodler>
Thu, 1 Jan 2004 06:35:22 +0000 (06:35 +0000)
committermoodler <moodler>
Thu, 1 Jan 2004 06:35:22 +0000 (06:35 +0000)
mod/choice/backuplib.php
mod/choice/db/mysql.php
mod/choice/db/mysql.sql
mod/choice/db/postgres7.php
mod/choice/db/postgres7.sql
mod/choice/mod.html
mod/choice/restorelib.php
mod/choice/version.php
mod/choice/view.php

index b9abb98d23b922c0d190d662fbec61d6363c81a0..7dfcdfb2e73e77998f1b37072db46577ff197a68 100644 (file)
@@ -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
index d8a021fc56089b771ae6f1fc33243e1e42c1b0a9..abf13bf7e5d1646c750f5720edfbb1f410574c01 100644 (file)
@@ -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;
 }
 
index 74de9de72b2f5dfa58d5d61098f173d7aaa9d9d9..c513fcbf15843c8a5ed71290903ae323e01a4d4a 100755 (executable)
@@ -27,6 +27,7 @@ CREATE TABLE prefix_choice (
   answer5 varchar(255) default NULL,\r
   answer6 varchar(255) default NULL,\r
   publish tinyint(2) unsigned NOT NULL default '0',\r
+  showunanswered tinyint(2) unsigned NOT NULL default '0',\r
   timemodified int(10) unsigned NOT NULL default '0',\r
   PRIMARY KEY  (id),\r
   UNIQUE KEY id (id)\r
index ea4ef82dc13a57bae4c61eb1a74c3e3a484737d2..66f37a7e9fc0c2ed86341ab32b333abc96b61abf 100644 (file)
@@ -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;
 }
index f7ba955adca6c402a42b87d8ba90d0ea561477c1..3fcc386d96633b1db877476043afc8706eb3e0c8 100755 (executable)
@@ -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'
 );
index 2db776ee34365ca1355cef095d2cb72e5dd1451e..0dce24aad3baded2b7c5fd380403b1d088cb9ebc 100644 (file)
@@ -6,7 +6,7 @@
         $form->text = "";
     }
     if (empty($form->format)) {
-        $form->format = "";
+        $form->format = 0;
     }
     if (empty($form->answer1)) {
         $form->answer1 = get_string("yes");
         $form->answer6 = "";
     }
     if (empty($form->publish)) {
-        $form->publish = "";
+        $form->publish = 0;
+    }
+    if (empty($form->showunanswered)) {
+        $form->showunanswered = 0;
     }
 
     if ($usehtmleditor = can_use_richtext_editor()) {
         <br \>
     </td>
 </tr>
+<tr valign=top>
+    <td align=right><P><B><?php print_string("showunanswered","choice") ?>:</b></p></td>
+    <td>
+        <?php
+        $options[0] = get_string("no");
+        $options[1] = get_string("yes");
+        choose_from_menu($options, "showunanswered", "$form->showunanswered", "");
+        ?>
+        <br \>
+    </td>
+</tr>
 
 </table>
 
index d342d6f39a37751655e7168e1a578d0bcebb00d5..4be35a645e87e975eed41cd2e519441c1ca51aba 100644 (file)
@@ -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']['#']);
 
index 53e00064b070f0dcd619440fde56bd25eaae87ce..6b36976977b0d566f4a51ca3a2b4684fb1447d39 100644 (file)
@@ -5,7 +5,7 @@
 //  This fragment is called by /admin/index.php
 ////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2003010100;
+$module->version  = 2004010100;
 $module->cron     = 0;
 
 ?>
index 976f9c59bfe5db4a6cca8dfbcb01597f3179d662..4309fc0079628d4c6ca7117aaaadf32945e2b61f 100644 (file)
                 $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) {  
             foreach ($useranswer as $key => $answer) {
                 if ($key) {
                     echo "<th width=\"$tablewidth%\">";
+                } else if ($choice->showunanswered) {
+                    echo "<th bgcolor=\"$THEME->body\" width=\"$tablewidth%\">";
                 } else {
-                    echo "<th bgcolor=\"$theme->body\" width=\"$tablewidth%\">";
+                    continue;
                 }
                 echo choice_get_answer($choice, $key);
                 echo "</th>";
             foreach ($useranswer as $key => $answer) {
                 if ($key) {
                     echo "<td width=\"$tablewidth%\" valign=top nowrap bgcolor=\"$theme->cellcontent\">";
-                } else {
+                } else if ($choice->showunanswered) {
                     echo "<td width=\"$tablewidth%\" valign=top nowrap bgcolor=\"$theme->body\">";
+                } else {
+                    continue;
                 }
     
                 echo "<table width=100%>";
             foreach ($useranswer as $key => $answer) {
                 if ($key) {
                     echo "<th width=\"$tablewidth%\">";
-                } else {
+                } else if ($choice->showunanswered) {
                     echo "<th bgcolor=\"$THEME->body\" width=\"$tablewidth%\">";
+                } else {
+                    continue;
                 }
                 echo choice_get_answer($choice, $key);
                 echo "</th>";
 
             $maxcolumn = 0;
             foreach ($useranswer as $key => $answer) {
+                if (!$key and !$choice->showunanswered) {
+                    continue;
+                }
                 $column[$key] = count($answer);
                 if ($column[$key] > $maxcolumn) {
                     $maxcolumn = $column[$key];
 
             echo "<tr>";
             foreach ($useranswer as $key => $answer) {
+                if (!$key and !$choice->showunanswered) {
+                    continue;
+                }
                 $height = $COLUMN_HEIGHT * ((float)$column[$key] / (float)$maxcolumn);
                 echo "<td valign=\"bottom\" align=\"center\">";
-                echo "<img src=\"column.png\" height=\"$height\" width=\"49\"></td>";
+                echo "<img src=\"column.png\" height=\"$height\" width=\"49\">";
+                echo "</td>";
             }
             echo "</tr>";
 
             echo "<tr>";
             foreach ($useranswer as $key => $answer) {
+                if (!$key and !$choice->showunanswered) {
+                    continue;
+                }
                 echo "<td align=\"center\">".$column[$key]."</td>";
             }
             echo "</tr></table>";