Diff for /loncom/interface/lonparmset.pm between versions 1.618 and 1.622

version 1.618, 2023/04/03 15:39:10 version 1.622, 2025/06/28 14:34:46
Line 992  sub valout { Line 992  sub valout {
             $result=' ';              $result=' ';
         }          }
     } else {      } else {
         if ($type eq 'date_interval') {          if (($type eq 'date_interval') || ($type eq 'string_grace')) {
             my ($totalsecs,$donesuffix) = split(/_/,$value,2);              if ($type eq 'string_grace') {
             my ($usesdone,$donebuttontext,$proctor,$secretkey);                  my @items;
             if ($donesuffix =~ /^done\:([^\:]+)\:(.*)$/) {                  if ($value =~ /,/) {
                 $donebuttontext = $1;                      @items = split(/,/,$value);
                 (undef,$proctor,$secretkey) = split(/_/,$2);  
                 $usesdone = 'done';  
             } elsif ($donesuffix =~ /^done(|_.+)$/) {  
                 $donebuttontext = &mt('Done');  
                 ($usesdone,$proctor,$secretkey) = split(/_/,$donesuffix);  
             }  
             my ($sec,$min,$hour,$mday,$mon,$year)=gmtime($totalsecs);  
             my @timer;  
             $year=$year-70;  
             $mday--;  
             if ($year) {  
 #               $result.=&mt('[quant,_1,yr]',$year).' ';  
                 push(@timer,&mt('[quant,_1,yr]',$year));  
             }  
             if ($mon) {  
 #               $result.=&mt('[quant,_1,mth]',$mon).' ';  
                 push(@timer,&mt('[quant,_1,mth]',$mon));  
             }  
             if ($mday) {  
 #               $result.=&mt('[quant,_1,day]',$mday).' ';  
                 push(@timer,&mt('[quant,_1,day]',$mday));  
             }  
             if ($hour) {  
 #               $result.=&mt('[quant,_1,hr]',$hour).' ';  
                 push(@timer,&mt('[quant,_1,hr]',$hour));  
             }  
             if ($min) {  
 #               $result.=&mt('[quant,_1,min]',$min).' ';  
                 push(@timer,&mt('[quant,_1,min]',$min));  
             }  
             if ($sec) {  
 #               $result.=&mt('[quant,_1,sec]',$sec).' ';  
                 push(@timer,&mt('[quant,_1,sec]',$sec));  
             }  
 #           $result=~s/\s+$//;  
             if (!@timer) { # Special case: all entries 0 -> display "0 secs" intead of empty field to keep this field editable  
                 push(@timer,&mt('[quant,_1,sec]',0));  
             }  
             $result.=join(", ",@timer);  
             if ($usesdone eq 'done') {  
                 if ($secretkey) {  
                     $result .= ' '.&mt('+ "[_1]" with proctor key: [_2]',$donebuttontext,$secretkey);    
                 } else {                  } else {
                     $result .= ' + "'.$donebuttontext.'"';                      @items = ($value);
                   }
                   foreach my $item (@items) {
                       if ($item =~ /^\d+:(0|1)\.?\d*:(0|1)$/) {
                           my ($totalsecs,$fraction,$grad) = split(/:/,$item);
                           $result .= &interval_to_humanstr($totalsecs);
                           if (($fraction >=0) && ($fraction <=1)) {
                               $result .= '&nbsp;|&nbsp;'.$fraction.'&nbsp;'.&mt('pts');
                               if ($grad == 1) {
                                   $result .= '&nbsp;('.&mt('gradual').')';
                               }
                           }
                           $result .= ', ';
                       }
                   }
                   $result =~ s/, $//;
               } else {
                   my ($totalsecs,$donesuffix) = split(/_/,$value,2);
                   $result = &interval_to_humanstr($totalsecs);
                   my ($usesdone,$donebuttontext,$proctor,$secretkey);
                   if ($donesuffix =~ /^done\:([^\:]+)\:(.*)$/) {
                       $donebuttontext = $1;
                       (undef,$proctor,$secretkey) = split(/_/,$2);
                       $usesdone = 'done';
                   } elsif ($donesuffix =~ /^done(|_.+)$/) {
                       $donebuttontext = &mt('Done');
                       ($usesdone,$proctor,$secretkey) = split(/_/,$donesuffix);
                   }
                   if ($usesdone eq 'done') {
                       if ($secretkey) {
                           $result .= ' '.&mt('+ "[_1]" with proctor key: [_2]',$donebuttontext,$secretkey);
                       } else {
                           $result .= ' + "'.$donebuttontext.'"';
                       }
                 }                  }
             }              }
         } elsif (&isdateparm($type)) {          } elsif (&isdateparm($type)) {
Line 1055  sub valout { Line 1046  sub valout {
     return $result;      return $result;
 }  }
   
   sub interval_to_humanstr {
       my ($totalsecs) = @_;
       my ($sec,$min,$hour,$mday,$mon,$year)=gmtime($totalsecs);
       my @timer;
       $year=$year-70;
       $mday--;
       if ($year) {
           push(@timer,&mt('[quant,_1,yr]',$year));
       }
       if ($mon) {
           push(@timer,&mt('[quant,_1,mth]',$mon));
       }
       if ($mday) {
           push(@timer,&mt('[quant,_1,day]',$mday));
       }
       if ($hour) {
           push(@timer,&mt('[quant,_1,hr]',$hour));
       }
       if ($min) {
           push(@timer,&mt('[quant,_1,min]',$min));
       }
       if ($sec) {
           push(@timer,&mt('[quant,_1,sec]',$sec));
       }
       if (!@timer) { # Special case: all entries 0 -> display "0 secs" intead of empty field to keep this field editable
           push(@timer,&mt('[quant,_1,sec]',0));
       }
       return '<span style="white-space:nowrap">'.join('</span>, <span style="white-space:nowrap">',@timer).'</span>';
   }
   
 # Returns HTML containing a link on a parameter value, for table mode.  # Returns HTML containing a link on a parameter value, for table mode.
 # The link uses the javascript function 'pjump'.  # The link uses the javascript function 'pjump'.
Line 1245  function validateParms() { Line 1265  function validateParms() {
     var ipRegExp = /^setip/;      var ipRegExp = /^setip/;
     var ipallowRegExp = /^setipallow_/;      var ipallowRegExp = /^setipallow_/;
     var ipdenyRegExp = /^setipdeny_/;       var ipdenyRegExp = /^setipdeny_/; 
       var graceRegExp = /^setgrace_/;
     var deeplinkRegExp = /^deeplink_/;      var deeplinkRegExp = /^deeplink_/;
     var dlListScopeRegExp = /^deeplink_(state|others|listing|scope)_/;       var dlListScopeRegExp = /^deeplink_(state|others|listing|scope)_/; 
     var dlLinkProtectRegExp = /^deeplink_protect_/;      var dlLinkProtectRegExp = /^deeplink_protect_/;
Line 1461  function validateParms() { Line 1482  function validateParms() {
                             }                              }
                         }                          }
                     }                      }
                   } else if (graceRegExp.test(name)) {
                       var identifier = name.replace(graceRegExp,'');
                       var divElem = document.parmform.elements[i].closest('div'); 
                       var timeSels = divElem.getElementsByTagName("select");
                       var total = 0;
                       if (timeSels.length) {
                            for (var j=0; j<timeSels.length; j++) {
                               var sname = timeSels[j].getAttribute('name');
                               var poss = parseInt(timeSels[j].options[timeSels[j].selectedIndex].value);
                               if (sname == 'days_'+identifier) {
                                   if ((poss > 0) && (poss <= 31)) {
                                       total += (poss * 86400); 
                                   }
                               } else if (sname == 'hours_'+identifier) {
                                   if ((poss > 0) && (poss < 24)) {
                                       total += (poss * 3600);
                                   }
                               } else if (sname == 'minutes_'+identifier) {
                                   if ((poss > 0) && (poss < 60)) {
                                       total += (poss * 60);
                                   }
                               } else if (sname == 'seconds_'+identifier) {
                                   if ((poss > 0) && (poss < 60)) {
                                       total += poss;
                                   }
                               }
                           }
                       }
                       var inputElems = divElem.getElementsByTagName("input");
                       var frac = '';
                       var grad = '';
                       if (inputElems.length) {
                           for (var j=0; j<inputElems.length; j++) {
                               var iname = inputElems[j].getAttribute('name');
                               if (iname == 'frac_'+identifier) {
                                   var ival = inputElems[j].value;
                                   ival.trim();
                                   var poss = parseFloat(ival);
                                   if ((typeof poss === 'number') && (!isNaN(poss))) {
                                       if ((poss => 0) && (poss <= 1)) {
                                           frac = poss;
                                       }
                                   }
                               } else if (iname == 'grad_'+identifier) {
                                   if (inputElems[j].checked) {
                                       grad = 1;
                                   } else {
                                       grad = 0;
                                   }
                               }
                           }
                       }
                       document.parmform.elements[i].value = total+':'+frac+':'+grad;
                       if (document.parmform.elements['set_'+identifier].value) {
                           document.parmform.elements['set_'+identifier].value += ',';
                       }
                       document.parmform.elements['set_'+identifier].value += document.parmform.elements[i].value;
                 }                  }
             }              }
         }          }
Line 1513  sub ipacc_boxes_js  { Line 1591  sub ipacc_boxes_js  {
 END  END
 }  }
   
   sub grace_js {
       my %lt = &grace_titles();
       &js_escape(\%lt);
       my $overdue = '<fieldset class="LC_grace"><legend>'.$lt{'sinc'}.'</legend>';
       foreach my $which (['days', 86400, 31],
                          ['hours', 3600, 23],
                          ['minutes', 60, 59],
                          ['seconds',  1, 59]) {
           my ($name, $factor, $max) = @{ $which };
           my %select = ((map {$_ => $_} (0..$max)),
                         'select_form_order' => [0..$max]);
           my $selector = &Apache::loncommon::select_form('',$name."_'+identifier+'",
                                                          \%select);
           $selector =~ s/([\r\n\f]+)//g;
           $overdue .= $selector.'&nbsp;'.$lt{$name}.('&nbsp;'x2).' ';
       }
       $overdue .= '</fieldset>';
       return <<"END";
   \$(document).ready(function() {
       var wrapper         = \$(".LC_string_grace_wrap");
       var add_button      = \$(".LC_add_grace_button");
       var graceRegExp     = /^LC_string_grace_/;
   
       \$(add_button).click(function(e){
           e.preventDefault();
           var identifier = \$(this).closest("div").attr("id");
           identifier = identifier.replace(graceRegExp,'');
           \$(this).closest('div').find('.LC_string_grace_inner').append('<div><input type="hidden" name="setgrace_'+identifier+'" value="" />$overdue<fieldset class="LC_grace"><legend>$lt{scor}</legend><input type="text" size="3" name="frac_'+identifier+'" value="" />&nbsp;&nbsp;<label><input type="checkbox" value="1" name="grad_'+identifier+'" />$lt{grad}</label></fieldset><a href="#" class="LC_remove_grace">$lt{remo}</a></div>');
       });
   
       \$(wrapper).delegate(".LC_remove_grace","click", function(e){
           e.preventDefault(); \$(this).closest("div").remove();
       })
   });
   
   
   END
   }
   
 # Javascript function toggleSecret, for overview mode.  # Javascript function toggleSecret, for overview mode.
 sub done_proctor_js {  sub done_proctor_js {
     my $defaultdone = &mt('Done');      my $defaultdone = &mt('Done');
Line 1750  sub print_row { Line 1867  sub print_row {
     if ($automatic) {      if ($automatic) {
         $parm.='<span class="LC_warning"><br />'.&mt('Automatically sets').' '.join(', ',split(/\:/,$automatic)).'</span>';          $parm.='<span class="LC_warning"><br />'.&mt('Automatically sets').' '.join(', ',split(/\:/,$automatic)).'</span>';
     }      }
       my $advice;
       if ((ref($name) eq 'HASH') && ($name->{$which} eq 'mapalias') &&
           (ref($symbp) eq 'HASH') && ($parmlev eq 'full')) {
           if ($symbp->{$rid} =~ m{^uploaded/}) {
               if ($result == 14) {
                   $advice = &mt('Use Course Editor to modify this.');
               } else {
                   $advice = &mt('Use Course Editor to set this.');
               }
           } else {
               if ($result == 14) {
                   $advice = &mt('Use Resource Assembly Tool to modify this.');
               } else {
                   $advice = &mt('Use Resource Assembly Tool to set this.');
               }
           }
           $parm .= '<br /><span class="LC_fontsize_small LC_cusr_emph">'.$advice.'</span>';
       }
     $r->print('<td>'.$parm.'</td>');      $r->print('<td>'.$parm.'</td>');
   
     my $thismarker=$which;      my $thismarker=$which;
Line 1831  sub print_row { Line 1966  sub print_row {
                 $extra = 'ltid_'.$domltistr;                  $extra = 'ltid_'.$domltistr;
             }              }
         }          }
         my %courselti = &Apache::lonnet::get_course_lti($cnum,$cdom);          my %courselti = &Apache::lonnet::get_course_lti($cnum,$cdom,'provider');
         if (keys(%courselti)) {          if (keys(%courselti)) {
             foreach my $item (sort { $a <=> $b } keys(%courselti)) {              foreach my $item (sort { $a <=> $b } keys(%courselti)) {
                 if (($item =~ /^\d+$/) && (ref($courselti{$item}) eq 'HASH')) {                  if (($item =~ /^\d+$/) && (ref($courselti{$item}) eq 'HASH')) {
Line 2423  sub lookUpTableParameter { Line 2558  sub lookUpTableParameter {
         'opendate' => 'time_settings',          'opendate' => 'time_settings',
         'duedate' => 'time_settings',          'duedate' => 'time_settings',
         'answerdate' => 'time_settings',          'answerdate' => 'time_settings',
           'grace' => 'time_settings',
         'interval' => 'time_settings',          'interval' => 'time_settings',
         'contentopen' => 'time_settings',          'contentopen' => 'time_settings',
         'contentclose' => 'time_settings',          'contentclose' => 'time_settings',
Line 2464  sub lookUpTableParameter { Line 2600  sub lookUpTableParameter {
         'lenient' => 'grading',          'lenient' => 'grading',
         'retrypartial' => 'tries',          'retrypartial' => 'tries',
         'discussvote'  => 'misc',          'discussvote'  => 'misc',
           'texdisplay' => 'misc',
         'examcode' => 'high_level_randomization',          'examcode' => 'high_level_randomization',
     );      );
 }  }
Line 3161  sub standardkeyorder { Line 3298  sub standardkeyorder {
     return ('parameter_0_opendate' => 1,      return ('parameter_0_opendate' => 1,
         'parameter_0_duedate' => 2,          'parameter_0_duedate' => 2,
         'parameter_0_answerdate' => 3,          'parameter_0_answerdate' => 3,
         'parameter_0_interval' => 4,          'parameter_0_grace' => 4,
         'parameter_0_weight' => 5,          'parameter_0_interval' => 5,
         'parameter_0_maxtries' => 6,          'parameter_0_weight' => 6,
         'parameter_0_hinttries' => 7,          'parameter_0_maxtries' => 7,
         'parameter_0_contentopen' => 8,          'parameter_0_hinttries' => 8,
         'parameter_0_contentclose' => 9,          'parameter_0_contentopen' => 9,
         'parameter_0_type' => 10,          'parameter_0_contentclose' => 10,
         'parameter_0_problemstatus' => 11,          'parameter_0_type' => 11,
         'parameter_0_hiddenresource' => 12,          'parameter_0_problemstatus' => 12,
         'parameter_0_hiddenparts' => 13,          'parameter_0_hiddenresource' => 13,
         'parameter_0_display' => 14,          'parameter_0_hiddenparts' => 14,
         'parameter_0_ordered' => 15,          'parameter_0_display' => 15,
         'parameter_0_tol' => 16,          'parameter_0_ordered' => 16,
         'parameter_0_sig' => 17,          'parameter_0_tol' => 17,
         'parameter_0_turnoffunit' => 18,          'parameter_0_sig' => 18,
         'parameter_0_discussend' => 19,          'parameter_0_turnoffunit' => 19,
         'parameter_0_discusshide' => 20,          'parameter_0_discussend' => 20,
         'parameter_0_discussvote' => 21,          'parameter_0_discusshide' => 21,
         'parameter_0_printstartdate'  =>  22,          'parameter_0_discussvote' => 22,
         'parameter_0_printenddate' =>  23);          'parameter_0_printstartdate' => 23,
           'parameter_0_printenddate' => 24);
 }  }
   
   
Line 3693  sub assessparms { Line 3831  sub assessparms {
             'date_interval','int','float','string','string_lenient',              'date_interval','int','float','string','string_lenient',
             'string_examcode','string_deeplink','string_discussvote',              'string_examcode','string_deeplink','string_discussvote',
             'string_useslots','string_problemstatus','string_ip',              'string_useslots','string_problemstatus','string_ip',
             'string_questiontype') {              'string_questiontype','string_tex','string_grace') {
         $r->print('<input type="hidden" value="'.          $r->print('<input type="hidden" value="'.
             &HTML::Entities::encode($env{'form.recent_'.$item},'"&<>').              &HTML::Entities::encode($env{'form.recent_'.$item},'"&<>').
             '" name="recent_'.$item.'" />');              '" name="recent_'.$item.'" />');
Line 4362  sub readdata { Line 4500  sub readdata {
 # Stores parameter data, using form parameters directly.  # Stores parameter data, using form parameters directly.
 #  #
 # Uses the following form parameters. The variable part in the names is a resourcedata key (except for a modification for user data).  # Uses the following form parameters. The variable part in the names is a resourcedata key (except for a modification for user data).
 # set_* (except settext, setipallow, setipdeny, setdeeplink) - set a parameter value  # set_* (except settext, setipallow, setipdeny, setdeeplink, setgrace) - set a parameter value
 # del_* - remove a parameter  # del_* - remove a parameter
 # datepointer_* - set a date parameter (value is key_* refering to a set of other form parameters)  # datepointer_* - set a date parameter (value is key_* refering to a set of other form parameters)
 # dateinterval_* - set a date interval parameter (value refers to more form parameters)  # dateinterval_* - set a date interval parameter (value refers to more form parameters)
Line 4395  sub storedata { Line 4533  sub storedata {
             my $cmd=$1;              my $cmd=$1;
             my $thiskey=$2;              my $thiskey=$2;
             my ($altkey,$recursive,$tkey,$tkeyrec,$tkeynonrec);              my ($altkey,$recursive,$tkey,$tkeyrec,$tkeynonrec);
             next if ($cmd eq 'rec' || $cmd eq 'settext' || $cmd eq 'setipallow' || $cmd eq 'setipdeny' || $cmd eq 'setdeeplink');              next if ($cmd eq 'rec' || $cmd eq 'settext' || $cmd eq 'setipallow' || $cmd eq 'setipdeny' || $cmd eq 'setdeeplink' || $cmd eq 'setgrace');
             if ((($cmd eq 'set') || ($cmd eq 'datepointer') || ($cmd eq 'dateinterval') || ($cmd eq 'del')) &&               if ((($cmd eq 'set') || ($cmd eq 'datepointer') || ($cmd eq 'dateinterval') || ($cmd eq 'del')) && 
                  ($thiskey =~ /(?:sequence|page)\Q___(all)\E/)) {                   ($thiskey =~ /(?:sequence|page)\Q___(all)\E/)) {
                 unless ($thiskey =~ /(encrypturl|hiddenresource)$/) {                  unless ($thiskey =~ /(encrypturl|hiddenresource)$/) {
Line 4454  sub storedata { Line 4592  sub storedata {
                         if ($thiskey =~ /\.retrypartial$/) {                          if ($thiskey =~ /\.retrypartial$/) {
                             $name = 'retrypartial';                              $name = 'retrypartial';
                         }                          }
                       } elsif ($typeof eq 'string_tex') {
                           $name = 'texdisplay';
                     }                      }
                 } elsif ($cmd eq 'datepointer') {                  } elsif ($cmd eq 'datepointer') {
                     $data=&Apache::lonhtmlcommon::get_date_from_form($env{$key});                      $data=&Apache::lonhtmlcommon::get_date_from_form($env{$key});
Line 5028  sub listdata { Line 5168  sub listdata {
     # Ready to print      # Ready to print
     #      #
             my $parmitem = &standard_parameter_names($name);              my $parmitem = &standard_parameter_names($name);
               my $advice;
               if (($name eq 'mapalias') && ($middle) && (!$is_map)) {
                   if ($middle =~ m{^uploaded/}) {
                       $advice = &mt('Use Course Editor to set this.');
                   } else {
                       $advice = &mt('Use Resource Assembly Tool to set this.');
                   }
                   $advice = '<br /><span class="LC_fontsize_small LC_cusr_emph">'.$advice.'</span>';
               }
             $r->print(&tablestart($readonly,$is_map).              $r->print(&tablestart($readonly,$is_map).
                 &Apache::loncommon::start_data_table_row().                  &Apache::loncommon::start_data_table_row().
                 '<td><b>'.&mt($parmitem).                  '<td><b>'.&mt($parmitem).
                 '</b></td>');                  '</b>'.$advice.'</td>');
             unless ($readonly) {              unless ($readonly) {
                 my $disabled;                  my $disabled;
                 if (($name eq 'availablestudent') &&                  if (($name eq 'availablestudent') &&
                     (($showval eq '') || ($userscope))) {                      (($showval eq '') || ($userscope))) {
                     $disabled = ' disabled="disabled"';                      $disabled = ' disabled="disabled"';
                   } elsif (($name eq 'mapalias') && ($showval eq '')) {
                       $disabled = ' disabled="disabled"';
                 }                  }
                 $r->print('<td><input type="checkbox" name="del_'.                  $r->print('<td><input type="checkbox" name="del_'.
                         $thiskey.'"'.$disabled.' /></td>');                          $thiskey.'"'.$disabled.' /></td>');
Line 5069  sub listdata { Line 5220  sub listdata {
             } elsif ($thistype =~ m/^string/) {              } elsif ($thistype =~ m/^string/) {
                 if ($name eq 'availablestudent') {                  if ($name eq 'availablestudent') {
                     $readonly = 1;                      $readonly = 1;
                   } elsif (($name eq 'mapalias') && ($showval eq '')) {
                       $readonly = 1;
                 }                  }
                 $r->print(&string_selector($thistype,$thiskey,                  $r->print(&string_selector($thistype,$thiskey,
                           $showval,$name,$readonly));                            $showval,$name,$readonly));
Line 5314  sub string_deeplink_selector { Line 5467  sub string_deeplink_selector {
     }      }
     my %courselti =      my %courselti =
         &Apache::lonnet::get_course_lti($env{'course.'.$env{'request.course.id'}.'.num'},          &Apache::lonnet::get_course_lti($env{'course.'.$env{'request.course.id'}.'.num'},
                                         $env{'course.'.$env{'request.course.id'}.'.domain'});                                          $env{'course.'.$env{'request.course.id'}.'.domain'},
                                           'provider');
     foreach my $item (keys(%courselti)) {      foreach my $item (keys(%courselti)) {
         if (ref($courselti{$item}) eq 'HASH') {          if (ref($courselti{$item}) eq 'HASH') {
             $crslti{$item} = $courselti{$item}{'name'};              $crslti{$item} = $courselti{$item}{'name'};
Line 5478  sub string_deeplink_selector { Line 5632  sub string_deeplink_selector {
     return $output;      return $output;
 }  }
   
   sub string_grace_selector {
       my ($thiskey, $showval, $readonly) = @_;
       my $addmore;
       unless ($readonly) {
           $addmore = "\n".'<button class="LC_add_grace_button">'.&mt('Add more').'</button>';
       }
       my $output = '<input type="hidden" name="set_'.$thiskey.'" value="" />'.
                    '<div class="LC_string_grace_wrap" id="LC_string_grace_'.$thiskey.'">'."\n".
                    '<div class="LC_string_grace_inner">'."\n";
       if ($showval ne '') {
           my @current;
           if ($showval =~ /,/) {
               @current = split(/,/,$showval);
           } else {
               @current = ($showval);
           }
           my $num = scalar(@current);
           foreach my $item (@current) {
               my ($delta,$fraction,$gradational) = split(/:/,$item);
               if (($delta =~ /^\d+$/) && ($fraction =~ /^(0|1)\.?\d*$/) && 
                   (($gradational eq 1) || ($gradational eq '0'))) {
                   my $gradchk = '';
                   if ($gradational) {
                       $gradchk = ' checked="checked"';
                   }
                   $output .= &grace_form($thiskey,$delta,$fraction,$gradchk,
                                          $readonly);
               }
           }
       } elsif (!$readonly) {
           $output .= &grace_form($thiskey,'','','',$readonly);
       }
       $output .= '</div>'.$addmore.'</div>';
       return $output;
   }
   
   sub grace_form {
       my ($thiskey,$delta,$fraction,$gradchkon,$readonly) = @_;
       my $disabled;
       if ($readonly) {
           $disabled = ' disabled="disabled"';
       }
       my %lt = &grace_titles();
       my $output = '<div><input type="hidden" name="setgrace_'.$thiskey.'" value="" />'.
                    '<fieldset class="LC_grace"><legend>'.$lt{'sinc'}.'</legend>';
       foreach my $which (['days', 86400, 31],
                          ['hours', 3600, 23],
                          ['minutes', 60, 59],
                          ['seconds',  1, 59]) {
           my ($name, $factor, $max) = @{ $which };
           my $amount;
           if ($delta ne '') {
               $amount = int($delta/$factor);
               $delta %= $factor;
           }
           my %select = ((map {$_ => $_} (0..$max)),
                         'select_form_order' => [0..$max]);
           $output .= &Apache::loncommon::select_form($amount,$name.'_'.$thiskey,
                                                      \%select,'',$readonly);
           $output .= '&nbsp;'.$lt{$name}.'&nbsp;&nbsp; ';
       }
       $output .= '</fieldset>'.
                  '<fieldset class="LC_grace"><legend>'.$lt{'pcr'}.'</legend>'.
                  '<input type="text" size="3" name="frac_'.$thiskey.'" value="'.$fraction.'"'.$disabled.' />'.
                  '&nbsp;&nbsp;<label><input type="checkbox" value="1" name="grad_'.$thiskey.'"'.$gradchkon.$disabled.' />'.
                  $lt{'grad'}.'</label></fieldset>';
       unless ($readonly) {
           $output .= '<a href="#" class="LC_remove_grace">'.$lt{'remo'}.'</a>';
       }
       $output .= '</div>'."\n";
       return $output;
   }
   
   sub grace_titles {
       return &Apache::lonlocal::texthash (
                                            sinc => 'Time past due',
                                            remo => 'Remove',
                                            pcr => 'Partial credit',
                                            grad => 'gradual',
                                            days => 'days',
                                            hours => 'hours',
                                            minutes => 'minutes',
                                            seconds => 'seconds',
       );
   }
   
 { # block using some constants related to parameter types (overview mode)  { # block using some constants related to parameter types (overview mode)
   
Line 5514  my %strings = Line 5753  my %strings =
                  ['_denyfrom_','Hostname(s) or IP(s) from which access is disallowed']],                    ['_denyfrom_','Hostname(s) or IP(s) from which access is disallowed']], 
      'string_deeplink'       'string_deeplink'
              => [['on','Set choices for link protection, resource listing, access scope, shown menu items, embedding, and exit link']],               => [['on','Set choices for link protection, resource listing, access scope, shown menu items, embedding, and exit link']],
        'string_tex'
                => [['tth', 'tth (TeX to HTML)'],
                    ['mathjax', 'MathJax']],
        'string_grace'
                => [['on','Set grading scale and grace period for submissions after due date']],
     );      );
         
   
Line 5525  my %stringmatches = ( Line 5769  my %stringmatches = (
                   ['_denyfrom_','\!']],                    ['_denyfrom_','\!']],
          'string_deeplink'           'string_deeplink'
               => [['on','^(only|off|both)\,(hide|unhide)\,(full|absent|grades|details|datestatus)\,(res|map|rec)\,(none|key\:\w+|ltic\:\d+|ltid\:\d+)\,(\d+|)\,_(self|top),(yes|url|no)(|:[^:;\'",]+)$']],                => [['on','^(only|off|both)\,(hide|unhide)\,(full|absent|grades|details|datestatus)\,(res|map|rec)\,(none|key\:\w+|ltic\:\d+|ltid\:\d+)\,(\d+|)\,_(self|top),(yes|url|no)(|:[^:;\'",]+)$']],
            'string_grace'
                 => [['on','^\d+,(0|1)\.?\d*,(0|1)']],
     );      );
   
 my %stringtypes = (  my %stringtypes = (
Line 5535  my %stringtypes = ( Line 5781  my %stringtypes = (
                     examcode     => 'string_examcode',                      examcode     => 'string_examcode',
                     acc          => 'string_ip',                      acc          => 'string_ip',
                     deeplink     => 'string_deeplink',                      deeplink     => 'string_deeplink',
                       grace        => 'string_grace',
                       texdisplay   => 'string_tex',
                   );                    );
   
 # Returns the possible values and titles for a given string type, or undef if there are none.  # Returns the possible values and titles for a given string type, or undef if there are none.
Line 5595  sub string_selector { Line 5843  sub string_selector {
             ($thistype eq 'string_discussvote') ||              ($thistype eq 'string_discussvote') ||
             ($thistype eq 'string_ip') ||              ($thistype eq 'string_ip') ||
             ($thistype eq 'string_deeplink') ||              ($thistype eq 'string_deeplink') ||
               ($thistype eq 'string_tex') ||
               ($thistype eq 'string_grace') ||
             ($name eq 'retrypartial')) {              ($name eq 'retrypartial')) {
         my ($got_chostname,$chostname,$cmajor,$cminor);           my ($got_chostname,$chostname,$cmajor,$cminor); 
         foreach my $possibilities (@{ $strings{$thistype} }) {          foreach my $possibilities (@{ $strings{$thistype} }) {
Line 5632  sub string_selector { Line 5882  sub string_selector {
     }      }
   
     if ($thistype eq 'string_ip') {      if ($thistype eq 'string_ip') {
         return &string_ip_selector($thiskey,$showval,$readonly);           return &string_ip_selector($thiskey,$showval,$readonly);
       } elsif ($thistype eq 'string_grace') {
           return &string_grace_selector($thiskey,$showval,$readonly);
     } elsif ($thistype eq 'string_deeplink') {      } elsif ($thistype eq 'string_deeplink') {
         return &string_deeplink_selector($thiskey,$showval,$readonly);          return &string_deeplink_selector($thiskey,$showval,$readonly);
     }      }
Line 6071  sub newoverview { Line 6323  sub newoverview {
             &toggleparmtextbox_js()."\n".              &toggleparmtextbox_js()."\n".
             &validateparms_js()."\n".              &validateparms_js()."\n".
             &ipacc_boxes_js()."\n".              &ipacc_boxes_js()."\n".
               &grace_js()."\n".
             &done_proctor_js()."\n".              &done_proctor_js()."\n".
             &deeplink_js()."\n".              &deeplink_js()."\n".
 '// ]]>  '// ]]>
Line 6299  sub overview { Line 6552  sub overview {
              &toggleparmtextbox_js()."\n".               &toggleparmtextbox_js()."\n".
              &validateparms_js()."\n".               &validateparms_js()."\n".
              &ipacc_boxes_js()."\n".               &ipacc_boxes_js()."\n".
                &grace_js()."\n".
              &done_proctor_js()."\n".               &done_proctor_js()."\n".
              &deeplink_js()."\n".               &deeplink_js()."\n".
              '// ]]>'."\n".               '// ]]>'."\n".
Line 7588  sub parm_change_log { Line 7842  sub parm_change_log {
                     } else {                      } else {
                         if (&isdateparm($istype{$parmname})) {                          if (&isdateparm($istype{$parmname})) {
                             $showvalue = &Apache::lonlocal::locallocaltime($value);                              $showvalue = &Apache::lonlocal::locallocaltime($value);
                           } elsif (($istype{$parmname} eq 'string_grace') ||
                                    ($istype{$parmname} eq 'string_ip')) {
                               $showvalue =~ s/,/, /g;
                         }                          }
                     }                      }
                     $output .= $showvalue;                      $output .= $showvalue;

Removed from v.1.618  
changed lines
  Added in v.1.622


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>