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

raeburn raeburn at source.lon-capa.org
Sat Apr 30 20:57:24 EDT 2022


raeburn		Sun May  1 00:57:24 2022 EDT

  Modified files:              
    /loncom/interface	lonparmset.pm 
  Log:
  - Bug 6598
    - When using "Edit Resource Parameters - Overview Mode", any instances of
    the Time-Limit parameter for which nothing has previously been set now have
    blank selected in the Days, Hours, Minutes & Seconds select boxes, instead of 0.
  
  
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.610 loncom/interface/lonparmset.pm:1.611
--- loncom/interface/lonparmset.pm:1.610	Sat Apr 30 19:29:43 2022
+++ loncom/interface/lonparmset.pm	Sun May  1 00:57:24 2022
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set parameters for assessments
 #
-# $Id: lonparmset.pm,v 1.610 2022/04/30 19:29:43 raeburn Exp $
+# $Id: lonparmset.pm,v 1.611 2022/05/01 00:57:24 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1461,6 +1461,8 @@
 
 # Javascript function toggleSecret, for overview mode.
 sub done_proctor_js {
+    my $defaultdone = &mt('Done');
+    &js_escape(\$defaultdone);
     return <<"END";
 function toggleSecret(form,radio,key) {
     var radios = form[radio+key];
@@ -1477,6 +1479,15 @@
                         document.getElementById('done_'+key+'_proctorkey').value='';
                     }
                 }
+                if (document.getElementById('done_'+key+'_buttontext')) {
+                    if (radios[i].value == '') {
+                        document.getElementById('done_'+key+'_buttontext').value = '';
+                    } else {
+                        if (document.getElementById('done_'+key+'_buttontext').value == '') {
+                            document.getElementById('done_'+key+'_buttontext').value = '$defaultdone';
+                        }
+                    }
+                }
             }
         }
     }
@@ -5026,13 +5037,17 @@
 sub get_date_interval_from_form {
     my ($key) = @_;
     my $seconds = 0;
+    my $numnotnull = 0;
     foreach my $which (['days', 86400],
                ['hours', 3600],
                ['minutes', 60],
                ['seconds',  1]) {
         my ($name, $factor) = @{ $which };
         if (defined($env{'form.'.$name.'_'.$key})) {
-            $seconds += $env{'form.'.$name.'_'.$key} * $factor;
+            unless ($env{'form.'.$name.'_'.$key} eq '') {
+                $numnotnull ++;
+                $seconds += $env{'form.'.$name.'_'.$key} * $factor;
+            }
         }
     }
     if (($key =~ /\.interval$/) &&
@@ -5051,6 +5066,7 @@
             $seconds .= '_'.$env{'form.done_'.$key.'_proctorkey'};
         }
     }
+    return if (!$numnotnull);
     return $seconds;
 }
 
@@ -5711,6 +5727,11 @@
         $showval  %= $factor;
         my %select = ((map {$_ => $_} (0..$max)),
                 'select_form_order' => [0..$max]);
+        if ($currval eq '') {
+            unshift(@{$select{'select_form_order'}},'');
+            $select{''} = '';
+            $amount = '';
+        }
         $result .= &Apache::loncommon::select_form($amount,$name.'_'.$thiskey,
                             \%select,'',$readonly);
         $result .= ' '.&mt($name);
@@ -5718,29 +5739,29 @@
     if ($name eq 'interval') {
         unless ($skipval{'done'}) {
             my $checkedon = '';
+            my $checkedoff = '';
             my $checkedproc = '';
             my $currproctorkey = '';
             my $currprocdisplay = 'hidden';
             my $currdonetext = &mt('Done');
-            my $checkedoff = ' checked="checked"';
             if ($currval =~ /^(?:\d+)_done$/) {
                 $checkedon = ' checked="checked"';
-                $checkedoff = '';
             } elsif ($currval =~ /^(?:\d+)_done\:([^\:]+)\:$/) {
                 $currdonetext = $1;
                 $checkedon = ' checked="checked"';
-                $checkedoff = '';
             } elsif ($currval =~ /^(?:\d+)_done_proctor_(.+)$/) {
                 $currproctorkey = $1;
                 $checkedproc = ' checked="checked"';
-                $checkedoff = '';
                 $currprocdisplay = 'text';
             } elsif ($currval =~ /^(?:\d+)_done\:([^\:]+)\:_proctor_(.+)$/) {
                 $currdonetext = $1;
                 $currproctorkey = $2;
                 $checkedproc = ' checked="checked"';
-                $checkedoff = '';
                 $currprocdisplay = 'text';
+            } elsif ($currval ne '') {
+                $checkedoff = ' checked="checked"';
+            } else {
+                $currdonetext = '';
             }
             my $onclick = ' onclick="toggleSecret(this.form,'."'done_','$thiskey'".');"';
             my $disabled;
@@ -5757,7 +5778,8 @@
                        '<input type="'.$currprocdisplay.'" id="done_'.$thiskey.'_proctorkey" '.
                        'name="done_'.$thiskey.'_proctorkey" value="'.&HTML::Entities::encode($currproctorkey,'"<>&').'"'.$disabled.' /></span><br />'.
                        '<span class="LC_nobreak">'.&mt('Button text').': '.
-                       '<input type="text" name="done_'.$thiskey.'_buttontext" value="'.&HTML::Entities::encode($currdonetext,'"<>&').'"'.$disabled.' /></span>';
+                       '<input type="text" name="done_'.$thiskey.'_buttontext" id="done_'.$thiskey.'_buttontext" value="'.
+                       &HTML::Entities::encode($currdonetext,'"<>&').'"'.$disabled.' /></span>';
         }
     }
     unless ($readonly) {




More information about the LON-CAPA-cvs mailing list