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

raeburn raeburn at source.lon-capa.org
Wed Mar 11 13:15:41 EDT 2015


raeburn		Wed Mar 11 17:15:41 2015 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/interface	domainprefs.pm 
  Log:
  - For 2.11
    Backport 1.257 and remove canuse_pdfforms option (not supported in 2.11). 
  
  
-------------- next part --------------
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.160.6.56 loncom/interface/domainprefs.pm:1.160.6.57
--- loncom/interface/domainprefs.pm:1.160.6.56	Wed Mar 11 15:56:36 2015
+++ loncom/interface/domainprefs.pm	Wed Mar 11 17:15:40 2015
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: domainprefs.pm,v 1.160.6.56 2015/03/11 15:56:36 raeburn Exp $
+# $Id: domainprefs.pm,v 1.160.6.57 2015/03/11 17:15:40 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -414,7 +414,9 @@
         'coursedefaults' => 
                  {text => 'Course/Community defaults',
                   help => 'Domain_Configuration_Course_Defaults',
-                  header => [{col1 => 'Defaults which can be overridden for each course by a DC',
+                  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',},],
                   print => \&print_coursedefaults,
                   modify => \&modify_coursedefaults,
@@ -670,7 +672,7 @@
              </tr>';
         $rowtotal ++;
         if (($action eq 'autoupdate') || ($action eq 'usercreation') || ($action eq 'selfcreation') ||
-            ($action eq 'usermodification') || ($action eq 'defaults') ||
+            ($action eq 'usermodification') || ($action eq 'defaults') || ($action eq 'coursedefaults') ||
             ($action eq 'selfenrollment') || ($action eq 'usersessions')) {
             $output .= $item->{'print'}->('top',$dom,$settings,\$rowtotal);
         } elsif ($action eq 'coursecategories') {
@@ -725,7 +727,8 @@
                 $output .= $item->{'print'}->('bottom',$dom,$settings,\$rowtotal);
             }
             $rowtotal ++;
-        } elsif (($action eq 'usermodification') || ($action eq 'defaults')) {
+        } elsif (($action eq 'usermodification') || ($action eq 'coursedefaults') ||
+                  ($action eq 'defaults')) {
             $output .= $item->{'print'}->('bottom',$dom,$settings,\$rowtotal);
         } elsif ($action eq 'login') {
             if ($numheaders == 4) {
@@ -2825,7 +2828,7 @@
 
 sub radiobutton_prefs {
     my ($settings,$toggles,$defaultchecked,$choices,$itemcount,$onclick,
-        $additional) = @_;
+        $additional,$align) = @_;
     return unless ((ref($toggles) eq 'ARRAY') && (ref($defaultchecked) eq 'HASH') &&
                    (ref($choices) eq 'HASH'));
 
@@ -2859,8 +2862,14 @@
         $datatable .=
             '<tr'.$css_class.'><td valign="top">'.
             '<span class="LC_nobreak">'.$choices->{$item}.
-            '</span></td>'.
-            '<td class="LC_right_item"><span class="LC_nobreak">'.
+            '</span></td>';
+        if ($align eq 'left') {
+            $datatable .= '<td class="LC_left_item">';
+        } else {
+            $datatable .= '<td class="LC_right_item">';
+        }
+        $datatable .=
+            '<span class="LC_nobreak">'.
             '<label><input type="radio" name="'.
             $item.'" '.$checkedon{$item}.' value="1"'.$onclick.' />'.&mt('Yes').
             '</label> <label><input type="radio" name="'.$item.'" '.
@@ -2878,25 +2887,31 @@
     my ($css_class,$datatable,%checkedon,%checkedoff,%defaultchecked, at toggles);
     my $itemcount = 1;
     my %choices =  &Apache::lonlocal::texthash (
-        canuse_pdfforms      => 'Course/Community users can create/upload PDF forms',
         uploadquota          => 'Default quota for files uploaded directly to course/community using Course Editor (MB)',
         anonsurvey_threshold => 'Responder count needed before showing submissions for anonymous surveys',
         coursecredits        => 'Credits can be specified for courses',
+        uselcmath            => 'Math preview uses LON-CAPA previewer (javascript) in place of DragMath (Java)',
+        usejsme              => 'Molecule editor uses JSME (HTML5) in place of JME (Java)',
+        postsubmit           => 'Disable submit button/keypress following student submission',
     );
     my %staticdefaults = (
                            anonsurvey_threshold => 10,
                            uploadquota          => 500,
+                           postsubmit           => 60,
                          );
     if ($position eq 'top') {
-        %defaultchecked = ('canuse_pdfforms' => 'off');
-        @toggles = ('canuse_pdfforms');
+        %defaultchecked = (
+                            'uselcmath'       => 'on',
+                            'usejsme'         => 'on',
+                          );
+        @toggles = ('uselcmath','usejsme');
         ($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked,
-                                                 \%choices,$itemcount);
+                                                     \%choices,$itemcount);
     } else {
         $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
-        my ($currdefresponder,$def_official_credits,$def_unofficial_credits,$def_textbook_credits,
-            %curruploadquota);
+        my ($currdefresponder,%defcredits,%curruploadquota,%deftimeout);
         my $currusecredits = 0;
+        my $postsubmitclient = 1;
         my @types = ('official','unofficial','community','textbook');
         if (ref($settings) eq 'HASH') {
             $currdefresponder = $settings->{'anonsurvey_threshold'};
@@ -2906,12 +2921,36 @@
                 }
             }
             if (ref($settings->{'coursecredits'}) eq 'HASH') {
-                $def_official_credits = $settings->{'coursecredits'}->{'official'};
-                $def_unofficial_credits = $settings->{'coursecredits'}->{'unofficial'};
-                $def_textbook_credits = $settings->{'coursecredits'}->{'textbook'};
-                if (($def_official_credits ne '') || ($def_unofficial_credits ne '') ||
-                    ($def_textbook_credits ne '')) {
-                    $currusecredits = 1;
+                foreach my $type (@types) {
+                    next if ($type eq 'community');
+                    $defcredits{$type} = $settings->{'coursecredits'}->{$type};
+                    if ($defcredits{$type} ne '') {
+                        $currusecredits = 1;
+                    }
+                }
+            }
+            if (ref($settings->{'postsubmit'}) eq 'HASH') {
+                if ($settings->{'postsubmit'}->{'client'} eq 'off') {
+                    $postsubmitclient = 0;
+                    foreach my $type (@types) {
+                        $deftimeout{$type} = $staticdefaults{'postsubmit'};
+                    }
+                } else {
+                    foreach my $type (@types) {
+                        if (ref($settings->{'postsubmit'}->{'timeout'}) eq 'HASH') {
+                            if ($settings->{'postsubmit'}->{'timeout'}->{$type} =~ /^\d+$/) {
+                                $deftimeout{$type} = $settings->{'postsubmit'}->{'timeout'}->{$type};
+                            } else {
+                                $deftimeout{$type} = $staticdefaults{'postsubmit'};
+                            }
+                        } else {
+                            $deftimeout{$type} = $staticdefaults{'postsubmit'};
+                        }
+                    }
+                }
+            } else {
+                foreach my $type (@types) {
+                    $deftimeout{$type} = $staticdefaults{'postsubmit'};
                 }
             }
         }
@@ -2953,21 +2992,14 @@
             $display = 'block';
         }
         my $additional = '<div id="credits" style="display: '.$display.'">'.
-                         '<span class="LC_nobreak">'.
-                         &mt('Default credits for official courses [_1]',
-                         '<input type="text" name="official_credits" value="'.
-                         $def_official_credits.'" size="3" />').
-                         '</span><br />'.
-                         '<span class="LC_nobreak">'.
-                         &mt('Default credits for unofficial courses [_1]',
-                         '<input type="text" name="unofficial_credits" value="'.
-                         $def_unofficial_credits.'" size="3" />').
-                         '</span><br />'.
-                         '<span class="LC_nobreak">'.
-                         &mt('Default credits for textbook courses [_1]',
-                         '<input type="text" name="textbook_credits" value="'.
-                         $def_textbook_credits.'" size="3" />').
-                         '</span></div>'."\n";
+                         '<i>'.&mt('Default credits').'</i><br /><table><tr>';
+        foreach my $type (@types) {
+            next if ($type eq 'community');
+            $additional .= '<td align="center">'.&mt($type).'<br />'.
+                           '<input type="text" name="'.$type.'_credits"'.
+                           ' value="'.$defcredits{$type}.'" size="3" /></td>';
+        }
+        $additional .= '</tr></table></div>'."\n";
         %defaultchecked = ('coursecredits' => 'off');
         @toggles = ('coursecredits');
         my $current = {
@@ -2975,9 +3007,30 @@
                       };
         (my $table,$itemcount) =
             &radiobutton_prefs($current,\@toggles,\%defaultchecked,
-                               \%choices,$itemcount,$onclick,$additional);
+                               \%choices,$itemcount,$onclick,$additional,'left');
+        $datatable .= $table;
+        $onclick = "toggleDisplay(this.form,'studentsubmission');";
+        my $display = 'none';
+        if ($postsubmitclient) {
+            $display = 'block';
+        }
+        $additional = '<div id="studentsubmission" style="display: '.$display.'">'.
+                      '<i>'.&mt('Number of seconds submit is disabled').'</i><br /><table><tr>';
+        foreach my $type (@types) {
+            $additional .= '<td align="center">'.&mt($type).'<br />'.
+                           '<input type="text" name="'.$type.'_timeout" value="'.
+                           $deftimeout{$type}.'" size="5" /></td>';
+        }
+        $additional .= '</tr></table></div>'."\n";
+        %defaultchecked = ('postsubmit' => 'on');
+        @toggles = ('postsubmit');
+        my $current = {
+                        'postsubmit' => $postsubmitclient,
+                      };
+        ($table,$itemcount) =
+            &radiobutton_prefs($current,\@toggles,\%defaultchecked,
+                               \%choices,$itemcount,$onclick,$additional,'left');
         $datatable .= $table;
-        $itemcount ++;
     }
     $$rowtotal += $itemcount;
     return $datatable;
@@ -10156,14 +10209,18 @@
 sub modify_coursedefaults {
     my ($dom,$lastactref,%domconfig) = @_;
     my ($resulttext,$errors,%changes,%defaultshash);
-    my %defaultchecked = ('canuse_pdfforms' => 'off');
-    my @toggles = ('canuse_pdfforms');
+    my %defaultchecked = (
+                           'uselcmath'       => 'on',
+                           'usejsme'         => 'on'
+                         );
+    my @toggles = ('uselcmath','usejsme');
     my @numbers = ('anonsurvey_threshold','uploadquota_official','uploadquota_unofficial',
                    'uploadquota_community','uploadquota_textbook');
     my @types = ('official','unofficial','community','textbook');
     my %staticdefaults = (
                            anonsurvey_threshold => 10,
                            uploadquota          => 500,
+                           postsubmit           => 60,
                          );
 
     $defaultshash{'coursedefaults'} = {};
@@ -10225,26 +10282,81 @@
             }
         }
 
-        my $officialcreds = $env{'form.official_credits'};
-        $officialcreds =~ s/[^\d.]+//g;
-        my $unofficialcreds = $env{'form.unofficial_credits'};
-        $unofficialcreds =~ s/[^\d.]+//g;
-        my $textbookcreds = $env{'form.textbook_credits'};
-        $textbookcreds =~ s/[^\d.]+//g;
-        if (ref($domconfig{'coursedefaults'}{'coursecredits'} ne 'HASH') &&
-                ($env{'form.coursecredits'} eq '1')) {
-                $changes{'coursecredits'} = 1;
-        } else {
-            if (($domconfig{'coursedefaults'}{'coursecredits'}{'official'} ne $officialcreds)  ||
-                ($domconfig{'coursedefaults'}{'coursecredits'}{'unofficial'} ne $unofficialcreds) ||
-                ($domconfig{'coursedefaults'}{'coursecredits'}{'textbook'} ne $textbookcreds)) {
-                $changes{'coursecredits'} = 1;
-            }
-        }
-        $defaultshash{'coursedefaults'}{'coursecredits'} = {
-            official   => $officialcreds,
-            unofficial => $unofficialcreds,
-            textbook   => $textbookcreds,
+        my %credits;
+        foreach my $type (@types) {
+            unless ($type eq 'community') {
+                $credits{$type} = $env{'form.'.$type.'_credits'};
+                $credits{$type} =~ s/[^\d.]+//g;
+            }
+        }
+        if ((ref($domconfig{'coursedefaults'}{'coursecredits'}) ne 'HASH') &&
+            ($env{'form.coursecredits'} eq '1')) {
+            $changes{'coursecredits'} = 1;
+            foreach my $type (keys(%credits)) {
+                $defaultshash{'coursedefaults'}{'coursecredits'}{$type} = $credits{$type};
+            }
+        } else {
+            if ($env{'form.coursecredits'} eq '1') {
+                foreach my $type (@types) {
+                    unless ($type eq 'community') {
+                        if ($domconfig{'coursedefaults'}{'coursecredits'}{$type} ne $credits{$type}) {
+                            $changes{'coursecredits'} = 1;
+                        }
+                        $defaultshash{'coursedefaults'}{'coursecredits'}{$type} = $credits{$type};
+                    }
+                }
+            } elsif (ref($domconfig{'coursedefaults'}{'coursecredits'}) eq 'HASH') {
+                foreach my $type (@types) {
+                    unless ($type eq 'community') {
+                        if ($domconfig{'coursedefaults'}{'coursecredits'}{$type}) {
+                            $changes{'coursecredits'} = 1;
+                            last;
+                        }
+                    }
+                }
+            }
+        }
+        if ($env{'form.postsubmit'} eq '1') {
+            $defaultshash{'coursedefaults'}{'postsubmit'}{'client'} = 'on';
+            my %currtimeout;
+            if (ref($domconfig{'coursedefaults'}{'postsubmit'}) eq 'HASH') {
+                if ($domconfig{'coursedefaults'}{'postsubmit'}{'client'} eq 'off') {
+                    $changes{'postsubmit'} = 1;
+                }
+                if (ref($domconfig{'coursedefaults'}{'postsubmit'}{'timeout'}) eq 'HASH') {
+                    %currtimeout = %{$domconfig{'coursedefaults'}{'postsubmit'}{'timeout'}};
+                }
+            } else {
+                $changes{'postsubmit'} = 1;
+            }
+            foreach my $type (@types) {
+                my $timeout = $env{'form.'.$type.'_timeout'};
+                $timeout =~ s/\D//g;
+                if ($timeout == $staticdefaults{'postsubmit'}) {
+                    $timeout = '';
+                } elsif (($timeout eq '') || ($timeout =~ /^0+$/)) {
+                    $timeout = '0';
+                }
+                unless ($timeout eq '') {
+                    $defaultshash{'coursedefaults'}{'postsubmit'}{'timeout'}{$type} = $timeout;
+                }
+                if (exists($currtimeout{$type})) {
+                    if ($timeout ne $currtimeout{$type}) {
+                        $changes{'postsubmit'} = 1;
+                    }
+                } elsif ($timeout ne '') {
+                    $changes{'postsubmit'} = 1;
+                }
+            }
+        } else {
+            $defaultshash{'coursedefaults'}{'postsubmit'}{'client'} = 'off';
+            if (ref($domconfig{'coursedefaults'}{'postsubmit'}) eq 'HASH') {
+                if ($domconfig{'coursedefaults'}{'postsubmit'}{'client'} eq 'on') {
+                    $changes{'postsubmit'} = 1;
+                }
+            } else {
+                $changes{'postsubmit'} = 1;
+            }
         }
     }
     my $putresult = &Apache::lonnet::put_dom('configuration',\%defaultshash,
@@ -10252,19 +10364,30 @@
     if ($putresult eq 'ok') {
         if (keys(%changes) > 0) {
             my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1);
-            if (($changes{'canuse_pdfforms'}) || ($changes{'coursecredits'}) || 
-                ($changes{'uploadquota'})) { 
-                if ($changes{'canuse_pdfforms'}) {
-                    $domdefaults{'canuse_pdfforms'}=$defaultshash{'coursedefaults'}{'canuse_pdfforms'};
+            if (($changes{'uploadquota'}) || ($changes{'postsubmit'}) ||
+                ($changes{'coursecredits'}) || ($changes{'uselcmath'}) || ($changes{'usejsme'})) {
+                foreach my $item ('uselcmath','usejsme') {
+                    if ($changes{$item}) {
+                        $domdefaults{$item}=$defaultshash{'coursedefaults'}{$item};
+                    }
                 }
                 if ($changes{'coursecredits'}) {
                     if (ref($defaultshash{'coursedefaults'}{'coursecredits'}) eq 'HASH') {
-                        $domdefaults{'officialcredits'} =
-                            $defaultshash{'coursedefaults'}{'coursecredits'}{'official'};
-                        $domdefaults{'unofficialcredits'} =
-                            $defaultshash{'coursedefaults'}{'coursecredits'}{'unofficial'};
-                        $domdefaults{'textbookcredits'} =
-                            $domdefaults{'coursedefaults'}{'coursecredits'}{'textbook'};
+                        foreach my $type (keys(%{$defaultshash{'coursedefaults'}{'coursecredits'}})) {
+                            $domdefaults{$type.'credits'} =
+                                $defaultshash{'coursedefaults'}{'coursecredits'}{$type};
+                        }
+                    }
+                }
+                if ($changes{'postsubmit'}) {
+                    if (ref($defaultshash{'coursedefaults'}{'postsubmit'}) eq 'HASH') {
+                        $domdefaults{'postsubmit'} = $defaultshash{'coursedefaults'}{'postsubmit'}{'client'};
+                        if (ref($defaultshash{'coursedefaults'}{'postsubmit'}{'timeout'}) eq 'HASH') {
+                            foreach my $type (keys(%{$defaultshash{'coursedefaults'}{'postsubmit'}{'timeout'}})) {
+                                $domdefaults{$type.'postsubtimeout'} =
+                                    $defaultshash{'coursedefaults'}{'postsubmit'}{'timeout'}{$type};
+                            }
+                        }
                     }
                 }
                 if ($changes{'uploadquota'}) {
@@ -10282,11 +10405,17 @@
             }
             $resulttext = &mt('Changes made:').'<ul>';
             foreach my $item (sort(keys(%changes))) {
-                if ($item eq 'canuse_pdfforms') {
+                if ($item eq 'uselcmath') {
                     if ($env{'form.'.$item} eq '1') {
-                        $resulttext .= '<li>'.&mt("Course/Community users can create/upload PDF forms set to 'on'").'</li>';
+                        $resulttext .= '<li>'.&mt('Math preview uses LON-CAPA previewer (javascript), if supported by browser.').'</li>';
                     } else {
-                        $resulttext .= '<li>'.&mt('Course/Community users can create/upload PDF forms set to "off"').'</li>';
+                        $resulttext .= '<li>'.&mt('Math preview uses DragMath (Java), if supported by client OS.').'</li>';
+                    }
+                } elsif ($item eq 'usejsme') {
+                    if ($env{'form.'.$item} eq '1') {
+                        $resulttext .= '<li>'.&mt('Molecule editor uses JSME (HTML5), if supported by browser.').'</li>';
+                    } else {
+                        $resulttext .= '<li>'.&mt('Molecule editor uses JME (Java), if supported by client OS.').'</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>';
@@ -10303,6 +10432,42 @@
                     } else {
                         $resulttext .= '<li>'.&mt('Default quota for content uploaded via Course Editor remains default: [_1] MB',$staticdefaults{'uploadquota'}).'</li>';
                     }
+                } elsif ($item eq 'postsubmit') {
+                    if ($domdefaults{'postsubmit'} eq 'off') {
+                        $resulttext .= '<li>'.&mt('Submit button(s) remain enabled on page after student makes submission.');
+                    } else {
+                        $resulttext .= '<li>'.&mt('Submit button(s) disabled on page after student makes submission').'; ';
+                        if (ref($defaultshash{'coursedefaults'}{'postsubmit'}) eq 'HASH') {
+                            $resulttext .= &mt('durations:').'<ul>';
+                            foreach my $type (@types) {
+                                $resulttext .= '<li>';
+                                my $timeout;
+                                if (ref($defaultshash{'coursedefaults'}{'postsubmit'}{'timeout'}) eq 'HASH') {
+                                    $timeout = $defaultshash{'coursedefaults'}{'postsubmit'}{'timeout'}{$type};
+                                }
+                                my $display;
+                                if ($timeout eq '0') {
+                                    $display = &mt('unlimited');
+                                } elsif ($timeout eq '') {
+                                    $display = &mt('[quant,_1,second] (default)',$staticdefaults{'postsubmit'});
+                                } else {
+                                    $display = &mt('[quant,_1,second]',$timeout);
+                                }
+                                if ($type eq 'community') {
+                                    $resulttext .= &mt('Communities');
+                                } elsif ($type eq 'official') {
+                                    $resulttext .= &mt('Official courses');
+                                } elsif ($type eq 'unofficial') {
+                                    $resulttext .= &mt('Unofficial courses');
+                                } elsif ($type eq 'textbook') {
+                                    $resulttext .= &mt('Textbook courses');
+                                }
+                                $resulttext .= ' -- '.$display.'</li>';
+                            }
+                            $resulttext .= '</ul>';
+                        }
+                        $resulttext .= '</li>';
+                    }
                 } elsif ($item eq 'coursecredits') {
                     if (ref($defaultshash{'coursedefaults'}{'coursecredits'}) eq 'HASH') {
                         if (($domdefaults{'officialcredits'} eq '') &&
@@ -11779,6 +11944,9 @@
         if (caller == 'emailoptions') {
             optionsElement = domForm.cancreate_email; 
         }
+        if (caller == 'studentsubmission') {
+            optionsElement = domForm.postsubmit;
+        }
         if (optionsElement.length) {
             var currval;
             for (var i=0; i<optionsElement.length; i++) {


More information about the LON-CAPA-cvs mailing list