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

raeburn raeburn@source.lon-capa.org
Tue, 24 Aug 2010 13:37:50 -0000


raeburn		Tue Aug 24 13:37:50 2010 EDT

  Modified files:              
    /loncom/interface	domainprefs.pm 
  Log:
  - Domain Configuration: Number of responders to anonymous survey items required
    before displaying anonymized submission data can be set as domain default. 
  
  
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.138 loncom/interface/domainprefs.pm:1.139
--- loncom/interface/domainprefs.pm:1.138	Tue Jul 20 02:42:40 2010
+++ loncom/interface/domainprefs.pm	Tue Aug 24 13:37:50 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: domainprefs.pm,v 1.138 2010/07/20 02:42:40 raeburn Exp $
+# $Id: domainprefs.pm,v 1.139 2010/08/24 13:37:50 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -340,8 +340,10 @@
         'coursedefaults' => 
                  {text => 'Course/Community defaults',
                   help => 'Domain_Configuration_Course_Defaults',
-                  header => [{col1 => 'Setting',
-                              col2 => 'Value',}],
+                  header => [{col1 => 'Defaults which can be overridden in each course by a CC',
+                              col2 => 'Value',},
+                             {col1 => 'Defaults which can be overridden for each course by a DC',
+                              col2 => 'Value',},],
                  },
         'privacy' => 
                  {text   => 'User Privacy',
@@ -517,6 +519,8 @@
             $output .= &print_usersessions('top',$dom,$settings,\$rowtotal); 
         } elsif ($action eq 'rolecolors') {
             $output .= &print_rolecolors($phase,'student',$dom,$confname,$settings,\$rowtotal);
+        } elsif ($action eq 'coursedefaults') {
+            $output .= &print_coursedefaults('top',$dom,$settings,\$rowtotal);
         }
         $output .= '
            </table>
@@ -580,6 +584,8 @@
             $output .= &print_helpsettings('bottom',$dom,$confname,$settings,\$rowtotal);
         } elsif ($action eq 'usersessions') {
             $output .= &print_usersessions('bottom',$dom,$settings,\$rowtotal);
+        } elsif ($action eq 'coursedefaults') {
+            $output .= &print_coursedefaults('bottom',$dom,$settings,\$rowtotal);
         } elsif ($action eq 'rolecolors') {
             $output .= &print_rolecolors($phase,'coordinator',$dom,$confname,$settings,\$rowtotal).'
            </table>
@@ -668,8 +674,6 @@
             $output .= &print_serverstatuses($dom,$settings,\$rowtotal);
         } elsif ($action eq 'helpsettings') {
             $output .= &print_helpsettings('top',$dom,$confname,$settings,\$rowtotal);
-    	} elsif ($action eq 'coursedefaults') {
-            $output .= &print_coursedefaults($dom,$settings,\$rowtotal);
         }
     }
     $output .= '
@@ -2240,19 +2244,43 @@
 }
 
 sub print_coursedefaults {
-    my ($dom,$settings,$rowtotal) = @_;
+    my ($position,$dom,$settings,$rowtotal) = @_;
     my ($css_class,$datatable);
     my $itemcount = 1;
-    my (%checkedon,%checkedoff,%choices,%defaultchecked,@toggles);
-    %choices =
-        &Apache::lonlocal::texthash (
-            canuse_pdfforms => 'Course/Community users can create/upload PDF forms',
-    );
-    %defaultchecked = ('canuse_pdfforms' => 'off');
-    @toggles = ('canuse_pdfforms',);
-    ($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked,
+    if ($position eq 'top') {
+        my (%checkedon,%checkedoff,%choices,%defaultchecked,@toggles);
+        %choices =
+            &Apache::lonlocal::texthash (
+                canuse_pdfforms => 'Course/Community users can create/upload PDF forms',
+        );
+        %defaultchecked = ('canuse_pdfforms' => 'off');
+        @toggles = ('canuse_pdfforms',);
+        ($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked,
                                                  \%choices,$itemcount);
-    $$rowtotal += $itemcount;
+        $$rowtotal += $itemcount;
+    } else {
+        $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
+        my %choices =
+            &Apache::lonlocal::texthash (
+                anonsurvey_threshold => 'Responder count needed before showing submissions for anonymous surveys',
+        );
+        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>';
+    }
     return $datatable;
 }
 
@@ -6664,6 +6692,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);
@@ -6683,7 +6723,9 @@
                     } 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 {