[LON-CAPA-cvs] cvs: loncom(GCI_3) /interface domainprefs.pm

raeburn raeburn@source.lon-capa.org
Sun, 12 Sep 2010 22:12:52 -0000


raeburn		Sun Sep 12 22:12:52 2010 EDT

  Modified files:              (Branch: GCI_3)
    /loncom/interface	domainprefs.pm 
  Log:
  - Backport 1.139.
  
  
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.123.2.1 loncom/interface/domainprefs.pm:1.123.2.2
--- loncom/interface/domainprefs.pm:1.123.2.1	Mon Dec  7 01:47:49 2009
+++ loncom/interface/domainprefs.pm	Sun Sep 12 22:12:52 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: domainprefs.pm,v 1.123.2.1 2009/12/07 01:47:49 raeburn Exp $
+# $Id: domainprefs.pm,v 1.123.2.2 2010/09/12 22:12:52 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -328,10 +328,10 @@
                              {col1 => 'Unauthenticated Help Settings',
                               col2 => ''}],
                  },
-        'coursedefaults' => 
+        'coursedefaults' =>
                  {text => 'Course/Community defaults',
                   help => 'Domain_Configuration_Course_Defaults',
-                  header => [{col1 => 'Setting',
+                  header => [{col1 => 'Defaults which can be overridden for each course by a DC',
                               col2 => 'Value',}],
                  },
         'privacy' => 
@@ -2092,14 +2092,27 @@
     my ($css_class,$datatable);
     my $itemcount = 1;
     my (%checkedon,%checkedoff,%choices,%defaultchecked,@toggles);
-    %choices =
+    $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
+    my %choices =
         &Apache::lonlocal::texthash (
-            canuse_pdfforms => 'Course/Community users can create/upload PDF forms',
+            anonsurvey_threshold => 'Responder count needed before showing submissions for anonymous surveys',
     );
-    %defaultchecked = ('canuse_pdfforms' => 'off');
-    @toggles = ('canuse_pdfforms',);
-    ($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked,
-                                                 \%choices,$itemcount);
+    my $currdefresponder;
+    if (ref($settings) eq 'HASH') {
+        $currdefresponder = $settings->{'anonsurvey_threshold'};
+    }
+    if (!$currdefresponder) {
+        $currdefresponder = 10;
+    } elsif ($currdefresponder < 1) {
+        $currdefresponder = 1;
+    }
+    $datatable .=
+           '<tr'.$css_class.'><td><span class="LC_nobreak">'.$choices{'anonsurvey_threshold'}.
+            '</span></td>'.
+            '<td class="LC_right_item"><span class="LC_nobreak">'.
+            '<input type="text" name="anonsurvey_threshold"'.
+            ' value="'.$currdefresponder.'" size="5" /></span>'.
+            '</td></tr>';
     $$rowtotal += $itemcount;
     return $datatable;
 }
@@ -6107,6 +6120,18 @@
             }
             $defaultshash{'coursedefaults'}{$item} = $env{'form.'.$item};
         }
+        my $currdefresponder = $domconfig{'coursedefaults'}{'anonsurvey_threshold'};
+        my $newdefresponder = $env{'form.anonsurvey_threshold'};
+        $newdefresponder =~ s/\D//g;
+        if ($newdefresponder eq '' || $newdefresponder < 1) {
+            $newdefresponder = 1;
+        }
+        $defaultshash{'coursedefaults'}{'anonsurvey_threshold'} = $newdefresponder;
+        if ($currdefresponder ne $newdefresponder) {
+            unless ($currdefresponder eq '' && $newdefresponder == 10) {
+                $changes{'anonsurvey_threshold'} = 1;
+            }
+        }
     }
     my $putresult = &Apache::lonnet::put_dom('configuration',\%defaultshash,
                                              $dom);
@@ -6126,7 +6151,10 @@
                     } else {
                         $resulttext .= '<li>'.&mt('Course/Community users can create/upload PDF forms set to "off"').'</li>';
                     }
+                } elsif ($item eq 'anonsurvey_threshold') {
+                        $resulttext .= '<li>'.&mt('Responder count required for display of anonymous survey submissions set to [_1].',$defaultshash{'coursedefaults'}{'anonsurvey_threshold'}).'</li>';
                 }
+
             }
             $resulttext .= '</ul>';
         } else {