Diff for /loncom/interface/lonblockingmenu.pm between versions 1.20 and 1.21

version 1.20, 2016/10/22 01:49:10 version 1.21, 2016/10/22 02:03:31
Line 318  Creates web form elements used to select Line 318  Creates web form elements used to select
 items in the course for use in an exam block of type: "Triggered by   items in the course for use in an exam block of type: "Triggered by 
 Activating Timer".  Activating Timer".
   
 Inputs: 7 (three required, last four optional)  Inputs: 8 (four required, last four optional)
    - $intervals - Reference to hash of parameters for timed intervals     - $intervals - Reference to hash of parameters for timed intervals
   
    - $parmcount - numeric ID of current block     - $parmcount - numeric ID of current block
   
    - $navmap - navmaps object     - $navmap - navmaps object
   
      - $context - this will be "accesstimes" if called by lonaccesstimes.pm,
                   or "blocking" if called internally by lonblockingmenu.pm
   
    - $currkey - current interval (where this is a block already using     - $currkey - current interval (where this is a block already using
                 an interval-based trigger).                    an interval-based trigger).  
   
Line 339  Inputs: 7 (three required, last four opt Line 342  Inputs: 7 (three required, last four opt
 Outputs: 1 - $intervalform - web form elements used to select a time interval  Outputs: 1 - $intervalform - web form elements used to select a time interval
   
   
   =item &interval_details()
   
   
 =item &trigger_details_toggle()  =item &trigger_details_toggle()
     
 Creates link used to expand item showing information about timer for current  Creates link used to expand item showing information about timer for current
Line 348  Inputs: 1 - $parmcount - numericID of ex Line 354  Inputs: 1 - $parmcount - numericID of ex
   
 Outputs: 1 - returns HTML for link to display contents of information item   Outputs: 1 - returns HTML for link to display contents of information item 
   
   
 =item &show_timer_path()  =item &show_timer_path()
   
 Display hierarchy of names of folders/sub-folders containing the current  Display hierarchy of names of folders/sub-folders containing the current
Line 392  Output: 1 - Javascript (with <script></s Line 399  Output: 1 - Javascript (with <script></s
   
 =item *  for action to take -- add or modify block  =item *  for action to take -- add or modify block
   
 =item *  for display of detailed information about intervals   
   
 =back  =back
   
   
   =item &details_javascript()
   
   Create Javascript to toggle visibility of unordered list item
   containing details about item with timed interval parameter.
   
   Inputs: none
   
   Output: 1 Javascript (with <script></script> tags) for functions used to:
             toggle visibility of unordered list for display of detailed 
             information about intervals.
    
 =back    =back  
   
 =cut  =cut
Line 520  sub handler { Line 536  sub handler {
         ({href=>'/adm/setblock',          ({href=>'/adm/setblock',
           text=>'Blocking communication/content access'});            text=>'Blocking communication/content access'});
   
     my $js = &blockingmenu_javascript($blockcount);      my $js = &blockingmenu_javascript($blockcount).
                &details_javascript();
   
     $r->print(      $r->print(
         &Apache::loncommon::start_page('Blocking communication/content access',$js).          &Apache::loncommon::start_page('Blocking communication/content access',$js).
Line 1094  ACT Line 1111  ACT
                       $ltext->{'endd'}.':&nbsp;&nbsp;'.$endform.'</fieldset></td>');                        $ltext->{'endd'}.':&nbsp;&nbsp;'.$endform.'</fieldset></td>');
         } elsif ($record =~ /^firstaccess____(.+)$/) {          } elsif ($record =~ /^firstaccess____(.+)$/) {
             my $item = $1;              my $item = $1;
             my ($itemname,$iteminfo,$skipdetails);  
             my $type = 'map';              my $type = 'map';
             my $url;              my $url;
             if ($item eq 'course') {              if ($item eq 'course') {
Line 1106  ACT Line 1122  ACT
                 $url = $item;                  $url = $item;
             }              }
             $r->print('<td><fieldset><legend>'.$ltext->{'trig'}.'</legend>');              $r->print('<td><fieldset><legend>'.$ltext->{'trig'}.'</legend>');
             if ($type eq 'course') {              my ($itemname,$iteminfo) = &interval_details($item,$type,$url,$navmap,$intervals,$parmcount);
                 $itemname = &mt('Timer for all items in course.');              $r->print(&create_interval_form($intervals,$parmcount,$navmap,'blocking',$item,$jschg,
             } else {  
                 if (&Apache::lonnet::is_on_map($url)) {   
                     if ($type eq 'map') {  
                         if (ref($navmap)) {  
                             my $title;  
                             my $resobj = $navmap->getResourceByUrl($item);  
                             if (ref($resobj)) {   
                                 $title = $resobj->compTitle();  
                             } else {  
                                 $title = &Apache::lonnet::gettitle($item);  
                             }  
                             $itemname = &mt('Timer for all items in folder: [_1]',  
                                             '<span style="font-style:italic">'.  
                                             $title.'</span>');  
                         }  
                     } else {  
                         if (ref($navmap)) {  
                             my $title;  
                             my $resobj = $navmap->getBySymb($item);  
                             if (ref($resobj)) {  
                                 $title = $resobj->compTitle();  
                             } else {  
                                 $title = &Apache::lonnet::gettitle($item);  
                             }  
                             $itemname = &mt('Timer for resource: [_1]',  
                                              '<span style="font-style:italic">'.  
                                              $title.'</span>');  
                         }  
                     }  
                     if (ref($navmap)) {  
                         my $path = &show_timer_path($type,$item);  
                         if ($path) {  
                             $iteminfo  = ' <span style="font-size:90%;">'.  
                                          &mt('(in: [_1])',$path).  
                                          '</span>';  
                         }  
                     }  
                 } else {  
                     $skipdetails = 1;  
                     $itemname = '<span style="LC_warning">'.  
                                 &mt('Timer folder/resource not in course').  
                                 '</span>';    
                 }  
             }  
             if ((!$skipdetails) && (ref($intervals) eq 'HASH')) {  
                 if (ref($intervals->{$type}) eq 'HASH') {  
                     $iteminfo .= &trigger_details_toggle($parmcount).  
                                 '<ul id="trigdetails_'.$parmcount.'" style="display:none">';  
                     if ($type eq 'course') {  
                         foreach my $scope (keys(%{$intervals->{$type}})) {  
                             if ($scope eq 'all') {  
                                 $iteminfo .= '<li>'.&mt('All users -- time limit: [_1]',  
                                          &convlim($intervals->{$type}->{$scope})).'</li>';  
                             } elsif ($scope eq 'secgrp') {  
                                 if (ref($intervals->{$type}->{$scope}) eq 'HASH') {  
                                     $iteminfo .= '<li>'.&mt('Sections/groups').'<ul>';  
                                     foreach my $item (sort(keys(%{$intervals->{$type}->{$scope}}))) {  
                                         $iteminfo .= '<li>'.&mt('[_1] -- time limit: [_2]',$item,  
                                                      &convlim($intervals->{$type}->{$scope}->{$item})).  
                                                      '</li>';  
                                     }  
                                     $iteminfo .= '</ul></li>';  
                                 }  
                             } elsif ($scope eq 'users') {  
                                 if (ref($intervals->{$type}->{$scope}) eq 'HASH') {  
                                     $iteminfo .= '<li>'.&mt('Users').'<ul>';   
                                     foreach my $item (sort(keys(%{$intervals->{$type}->{$scope}}))) {  
                                         $iteminfo .= '<li>'.&mt('[_1] -- time limit: [_2]',  
                                                      &convlim($item,$intervals->{$type}->{$scope}->{$item})).  
                                                      '</li>';  
                                     }  
                                     $iteminfo .= '</ul></li>';  
                                 }  
                             }  
                         }  
                     } elsif (($type eq 'map') || ($type eq 'resource')) {  
                         if (ref($intervals->{$type}->{$item}) eq 'HASH') {   
                             foreach my $scope (keys(%{$intervals->{$type}->{$item}})) {  
                                 if ($scope eq 'all') {  
                                     $iteminfo .= '<li>'.&mt('All users -- time limit: [_1]',  
                                                   &convlim($intervals->{$type}->{$item}->{$scope})).  
                                                   '</li>';  
                                 } elsif ($scope eq 'secgrp') {  
                                     if (ref($intervals->{$type}->{$item}->{$scope}) eq 'HASH') {  
                                         $iteminfo .= '<li>'.&mt('Sections/groups').'<ul>';  
                                         foreach my $sec (sort(keys(%{$intervals->{$type}->{$item}->{$scope}}))) {  
                                             $iteminfo .= '<li>'.&mt('[_1] -- time limit: [_2]',$sec,  
                                                          &convlim($intervals->{$type}->{$item}->{$scope}->{$sec})).  
                                                          '</li>';  
                                         }  
                                         $iteminfo .= '</ul></li>';   
                                     }  
                                 } elsif ($scope eq 'users') {  
                                     if (ref($intervals->{$type}->{$item}->{$scope}) eq 'HASH') {  
                                         $iteminfo .= '<li>'.&mt('Users').'<ul>';  
                                         foreach my $user (sort(keys(%{$intervals->{$type}->{$item}->{$scope}}))) {  
                                             $iteminfo .= '<li>'.&mt('[_1] -- time limit: [_2]',$user,  
                                                          &convlim($intervals->{$type}->{$item}->{$scope}->{$user})).  
                                                          '</li>';  
                                         }  
                                         $iteminfo .= '</ul></li>';  
                                     }  
                                 }  
                             }  
                         }  
                     }  
                     $iteminfo .= '</ul>';  
                 }  
             }  
             $r->print(&create_interval_form($intervals,$parmcount,$navmap,$item,$jschg,  
                                             $itemname,$iteminfo,$disabled).'</fieldset></td>');                                              $itemname,$iteminfo,$disabled).'</fieldset></td>');
         }          }
         $r->print(<<"END");          $r->print(<<"END");
Line 1281  sub display_addblocker_table { Line 1187  sub display_addblocker_table {
     my %lt = &Apache::lonlocal::texthash(      my %lt = &Apache::lonlocal::texthash(
         'exam' => 'e.g., Exam 1',          'exam' => 'e.g., Exam 1',
     );      );
     my $intervalform = &create_interval_form($intervals,$parmcount,$navmap);      my $intervalform = &create_interval_form($intervals,$parmcount,$navmap,'blocking');
     if ($intervalform ne '') {      if ($intervalform ne '') {
         $intervalform = '<fieldset>'.          $intervalform = '<fieldset>'.
                         '<legend>'.$ltext->{'chtr'}.'</legend>'.                          '<legend>'.$ltext->{'chtr'}.'</legend>'.
Line 1405  sub blocker_checkboxes { Line 1311  sub blocker_checkboxes {
 }  }
   
 sub create_interval_form {  sub create_interval_form {
     my ($intervals,$parmcount,$navmap,$currkey,$jschg,$itemname,$iteminfo,$disabled) = @_;      my ($intervals,$parmcount,$navmap,$context,$currkey,$jschg,$itemname,$iteminfo,$disabled) = @_;
     return unless ((ref($intervals) eq 'HASH') && (ref($navmap)));      return unless ((ref($intervals) eq 'HASH') && (ref($navmap)));
     my $intervalform;      my $intervalform;
       my $counter = 0;
     if (keys(%{$intervals}) > 0) {      if (keys(%{$intervals}) > 0) {
         foreach my $type (sort(keys(%{$intervals}))) {          foreach my $type (sort(keys(%{$intervals}))) {
             if ($type eq 'course') {              if ($type eq 'course') {
Line 1427  sub create_interval_form { Line 1334  sub create_interval_form {
                 $intervalform .= '</label>';                  $intervalform .= '</label>';
                 if ($currkey eq 'course') {                  if ($currkey eq 'course') {
                     $intervalform .= $iteminfo;                      $intervalform .= $iteminfo;
                   } elsif ($context eq 'accesstimes') {
                       (undef,$iteminfo) = &interval_details('course',$type,'',$navmap,$intervals,$counter);
                       if ($iteminfo) {
                           $intervalform .= ' '.$iteminfo;
                       }
                 }                  }
                 $intervalform .= '<br />';                  $intervalform .= '<br />';
                   $counter ++;
             } elsif ($type eq 'map') {              } elsif ($type eq 'map') {
                 if (ref($intervals->{$type}) eq 'HASH') {                  if (ref($intervals->{$type}) eq 'HASH') {
                     if (ref($navmap)) {                      if (ref($navmap)) {
Line 1463  sub create_interval_form { Line 1376  sub create_interval_form {
                                 $intervalform .= &mt('Timer for all items in folder: [_1]',                                  $intervalform .= &mt('Timer for all items in folder: [_1]',
                                                      '<i>'.$title.'</i>').                                                       '<i>'.$title.'</i>').
                                                  '</label>'.$path;                                                   '</label>'.$path;
                                   if ($context eq 'accesstimes') {
                                       (undef,$iteminfo) = &interval_details($map,$type,$map,$navmap,$intervals,$counter);
                                       if ($iteminfo) {
                                           $intervalform .= ' '.$iteminfo;
                                       }
                                   }
                             }                              }
                             $intervalform .= '<br />';                              $intervalform .= '<br />';
                               $counter ++;
                         }                          }
                     }                      }
                 }                  }
Line 1491  sub create_interval_form { Line 1411  sub create_interval_form {
                                 my ($title,$path,$hierarchy);                                  my ($title,$path,$hierarchy);
                                 if (ref($resobj)) {                                  if (ref($resobj)) {
                                     $title = $resobj->compTitle();                                      $title = $resobj->compTitle();
                                 } else {                                  }
                                   if ($title eq '') {                      
                                     $title = &Apache::lonnet::gettitle($resource);                                      $title = &Apache::lonnet::gettitle($resource);
                                 }                                  }
                                 $hierarchy = &show_timer_path($type,$resource,$navmap);                                  $hierarchy = &show_timer_path($type,$resource,$navmap);
Line 1503  sub create_interval_form { Line 1424  sub create_interval_form {
                                 $intervalform .= &mt('Timer for resource: [_1]','<i>'.$title.'</i>').                                  $intervalform .= &mt('Timer for resource: [_1]','<i>'.$title.'</i>').
                                                  '</label>'.                                                   '</label>'.
                                                  $path;                                                   $path;
                                   if ($context eq 'accesstimes') {
                                       if (ref($resobj)) {
                                           my $url = $resobj->src();
                                           if ($url eq '') {
                                               (my $map, my $resid, $url) = &Apache::lonnet::decode_symb($resource);
                                           }
                                           ($itemname,$iteminfo) = &interval_details($resource,$type,$url,$navmap,$intervals,$counter);
                                           $intervalform .= ' '.$iteminfo;
                                       }
                                   }
                             }                              }
                             $intervalform .= '<br />';                              $intervalform .= '<br />';
                               $counter ++;
                         }                          }
                     }                      }
                 }                  }
Line 1532  sub trigger_details_toggle { Line 1464  sub trigger_details_toggle {
            'style="text-decoration: none;"><b>'.&mt('(More ...)').'</b></a></span>';             'style="text-decoration: none;"><b>'.&mt('(More ...)').'</b></a></span>';
 }  }
   
   sub interval_details {
       my ($item,$type,$url,$navmap,$intervals,$parmcount) = @_;
       my ($itemname,$iteminfo,$skipdetails);
       if ($type eq 'course') {
           $itemname = &mt('Timer for all items in course.');
       } else {
           if (&Apache::lonnet::is_on_map($url)) {
               if ($type eq 'map') {
                   if (ref($navmap)) {
                       my $title;
                       my $resobj = $navmap->getResourceByUrl($item);
                       if (ref($resobj)) {
                           $title = $resobj->compTitle();
                       } else {
                           $title = &Apache::lonnet::gettitle($item);
                       }
                       $itemname = &mt('Timer for all items in folder: [_1]',
                                       '<span style="font-style:italic">'.
                                       $title.'</span>');
                   }
               } else {
                   if (ref($navmap)) {
                       my $title;
                       my $resobj = $navmap->getBySymb($item);
                       if (ref($resobj)) {
                           $title = $resobj->compTitle();
                       } else {
                           $title = &Apache::lonnet::gettitle($item);
                       }
                       $itemname = &mt('Timer for resource: [_1]',
                                       '<span style="font-style:italic">'.
                                       $title.'</span>');
                   }
               }
               if (ref($navmap)) {
                   my $path = &show_timer_path($type,$item);
                   if ($path) {
                      $iteminfo  = ' <span style="font-size:90%;">'.
                                     &mt('(in: [_1])',$path).
                                     '</span>';
                   }
               }
           } else {
               $skipdetails = 1;
               $itemname = '<span style="LC_warning">'.
                           &mt('Timer folder/resource not in course').
                           '</span>';
           }
       }
       if ((!$skipdetails) && (ref($intervals) eq 'HASH') && (ref($intervals->{$type}) eq 'HASH')) {
           $iteminfo = &trigger_details_toggle($parmcount).
                       '<ul id="trigdetails_'.$parmcount.'" style="display:none">';
           if ($type eq 'course') {
               foreach my $scope (keys(%{$intervals->{$type}})) {
                   if ($scope eq 'all') {
                       $iteminfo .= '<li>'.&mt('All users -- time limit: [_1]',
                                    &convlim($intervals->{$type}->{$scope})).'</li>';
                   } elsif ($scope eq 'secgrp') {
                       if (ref($intervals->{$type}->{$scope}) eq 'HASH') {
                           $iteminfo .= '<li>'.&mt('Sections/groups').'<ul>';
                           foreach my $item (sort(keys(%{$intervals->{$type}->{$scope}}))) {
                               $iteminfo .= '<li>'.&mt('[_1] -- time limit: [_2]',$item,
                                            &convlim($intervals->{$type}->{$scope}->{$item})).
                                            '</li>';
                           }
                           $iteminfo .= '</ul></li>';
                       }
                   } elsif ($scope eq 'users') {
                       if (ref($intervals->{$type}->{$scope}) eq 'HASH') {
                           $iteminfo .= '<li>'.&mt('Users').'<ul>';
                           foreach my $item (sort(keys(%{$intervals->{$type}->{$scope}}))) {
                               $iteminfo .= '<li>'.&mt('[_1] -- time limit: [_2]',
                                            &convlim($item,$intervals->{$type}->{$scope}->{$item})).
                                            '</li>';
                           }
                           $iteminfo .= '</ul></li>';
                       }
                   }
               }
           } elsif (($type eq 'map') || ($type eq 'resource')) {
               if (ref($intervals->{$type}->{$item}) eq 'HASH') {
                   foreach my $scope (keys(%{$intervals->{$type}->{$item}})) {
                       if ($scope eq 'all') {
                           $iteminfo .= '<li>'.&mt('All users -- time limit: [_1]',
                                        &convlim($intervals->{$type}->{$item}->{$scope})).
                                        '</li>';
                       } elsif ($scope eq 'secgrp') {
                           if (ref($intervals->{$type}->{$item}->{$scope}) eq 'HASH') {
                               $iteminfo .= '<li>'.&mt('Sections/groups').'<ul>';
                               foreach my $sec (sort(keys(%{$intervals->{$type}->{$item}->{$scope}}))) {
                                   $iteminfo .= '<li>'.&mt('[_1] -- time limit: [_2]',$sec,
                                                &convlim($intervals->{$type}->{$item}->{$scope}->{$sec})).
                                               '</li>';
                               }
                               $iteminfo .= '</ul></li>';
                           }
                       } elsif ($scope eq 'users') {
                           if (ref($intervals->{$type}->{$item}->{$scope}) eq 'HASH') {
                               $iteminfo .= '<li>'.&mt('Users').'<ul>';
                               foreach my $user (sort(keys(%{$intervals->{$type}->{$item}->{$scope}}))) {
                                   $iteminfo .= '<li>'.&mt('[_1] -- time limit: [_2]',$user,
                                                &convlim($intervals->{$type}->{$item}->{$scope}->{$user})).
                                                '</li>';
                               }
                               $iteminfo .= '</ul></li>';
                           }
                       }
                   }
               }
           }
           $iteminfo .= '</ul>';
       }
       return ($itemname,$iteminfo);
   }
   
 sub show_timer_path {  sub show_timer_path {
     my ($type,$item,$navmap) = @_;      my ($type,$item,$navmap) = @_;
     return unless(ref($navmap));      return unless(ref($navmap));
Line 1568  sub blocktype_text { Line 1615  sub blocktype_text {
   
 sub blockingmenu_javascript {  sub blockingmenu_javascript {
     my ($blockcount) = @_;      my ($blockcount) = @_;
     my %lt = &Apache::lonlocal::texthash (  
                                            more => 'More ...',  
                                            less => 'Less ...',  
                                          );  
     return <<ENDSCRIPT;      return <<ENDSCRIPT;
 <script type="text/javascript">  <script type="text/javascript">
 // <![CDATA[  // <![CDATA[
Line 1627  function toggleAddModify() { Line 1670  function toggleAddModify() {
     return;      return;
 }  }
   
   // ]]>
   </script>
   ENDSCRIPT
   
   }
   
   sub details_javascript {
       my %lt = &Apache::lonlocal::texthash (
                                              more => 'More ...',
                                              less => 'Less ...',
                                            );
       return <<ENDSCRIPT;
   
   <script type="text/javascript">
   // <![CDATA[
   
 function showTriggerDetails(item) {  function showTriggerDetails(item) {
     document.getElementById('trigdetails_'+item).style.display='block';      document.getElementById('trigdetails_'+item).style.display='block';
     document.getElementById('trigdetails_'+item).style.textAlign='left';      document.getElementById('trigdetails_'+item).style.textAlign='left';

Removed from v.1.20  
changed lines
  Added in v.1.21


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