Diff for /loncom/interface/lonblockingmenu.pm between versions 1.5 and 1.17

version 1.5, 2012/04/04 21:04:56 version 1.17, 2016/01/27 03:04:49
Line 57  into this category. Line 57  into this category.
 (b) those which a student could use to access materials prepared by the  (b) those which a student could use to access materials prepared by the
 student in advance of an exam, (e.g., for use during an online exam, to  student in advance of an exam, (e.g., for use during an online exam, to
 gain an unfair advantage). Blogs and portfolio fall into this category.  gain an unfair advantage). Blogs and portfolio fall into this category.
   (c) those which a student could use to display or save content within
   the course itself (outside the exam folder). Printouts and resources
   fall into this category.
   
 For communication blocking to be truly effective in preventing unwanted  For communication blocking to be truly effective in preventing unwanted
 communication, or access to online materials, online testing needs to  communication, or access to online materials, online testing needs to
Line 64  take place in a lab setting where use of Line 67  take place in a lab setting where use of
 of web sites beyond LON-CAPA are unavailable.  of web sites beyond LON-CAPA are unavailable.
   
 Access to specified folder(s) and/or resources in the course contents   Access to specified folder(s) and/or resources in the course contents 
 can also be restricted for the duration of an exam.  can be restricted for the duration of an exam.
   
 Exam blocks are of two types:  Exam blocks are of two types:
 (a) Blocks with a defined start and end date.  (a) Blocks with a defined start and end date.
Line 87  it is important to use reasonable time w Line 90  it is important to use reasonable time w
 the case of blocks triggered by clicking a button to start a timed quiz,   the case of blocks triggered by clicking a button to start a timed quiz, 
 quiz durations that are of limited duration. This is especially important  quiz durations that are of limited duration. This is especially important
 when blocking prtfolio access, as other courses may require students to use  when blocking prtfolio access, as other courses may require students to use
 the portfolio as a mechanism for submitting assigments.  the portfolio as a mechanism for submitting assignments.
   
 Information about blocks in a course will be cached for 10 minutes, so,  Information about blocks in a course will be cached for 10 minutes, so,
 as with parameters set for resources, it can take up to 10 minutes for  as with parameters set for resources, it can take up to 10 minutes for
Line 124  Output: 1 Hash Line 127  Output: 1 Hash
 Stores changes to exam blocks in comm_block.db file for course.  Stores changes to exam blocks in comm_block.db file for course.
 Processes deletions, modifications and additions.  Processes deletions, modifications and additions.
   
 Inputs: 2  Inputs: 4
         $r = request object
   
       $crstype - Container type: Course or Community.        $crstype - Container type: Course or Community.
   
       $blockcount - Total number of blocking events in course.        $blockcount - Total number of blocking events in course.
   
         $currblockrecs - Ref to hash of current blocks in course.
   
 Outputs: 2  Outputs: 2
       $changestotal - Total number of changes made.        $changestotal - Total number of changes made.
   
       $output - Information about changes made.        $output - Information about changes made.
   
   
 =item &enumerate_course_contents()  
   
 Create hashes of maps (for folders/pages) and symbs (for resources) in  
 a course, where keys are numbers (starting with 1) and values are  
 map url, or symb, for an iteration through the course, as seen by  
 a Course Coordinator. Used to generate numerical IDs to facilitate  
 storage of lists of maps or resources to be blocked during an exam.     
   
 Inputs: 3  
       $navmap - navmaps object  
   
       $map_url - reference to hash to contain URLs of maps in course  
   
       $resource_symb - reference to hash to contain symbs for  
                        resources in course  
   
 Outputs: None  
   
 Side Effects: $map_url and $resource_symb hashrefs are populated.  
   
   
 =item &get_dates_from_form()  =item &get_dates_from_form()
   
 Extract start and end dates from web form input for blocks with  Extract start and end dates from web form input for blocks with
Line 181  Side Effects: populates records hashref. Line 167  Side Effects: populates records hashref.
 =item &get_block_choices()  =item &get_block_choices()
   
 Extract information from web form about which communication/  Extract information from web form about which communication/
 collaboration features are to be blocked, for a partilcuar event,  collaboration features are to be blocked, for a particular event,
 and also which content areas will have access blocked for the  and also which content areas will have access blocked for the
 duration of the block.  duration of the block.
   
Line 205  Update LON-CAPA version requirements for Line 191  Update LON-CAPA version requirements for
 (content) or blocking type (triggered by student starting timer)  (content) or blocking type (triggered by student starting timer)
 require specific LON-CAPA version (i.e., 2.11).  require specific LON-CAPA version (i.e., 2.11).
   
 Inputs: 1 - type of constraint (currently: 'docs' or 'timer').   Inputs: 3 - $value - type of constraint (currently: 'docs', 'printout' or 'timer'),
               $chomemajor - course's home server LON-CAPA major version number.
               $chomeminor - course's home server LON-CAPA minor version number.
   
 Outputs: None  Outputs: 2 - status ('ok' or 'fail') and LON-CAPA version needed.
   
   =over
   
                A status of 'fail' will be returned if the 
                LON-CAPA version installed on the course's 
                home server is older than the version 
                requirement for the blocking type.
                For a trigger type event, the requested
                blocking event will not be added if 
                the course's home server version is old to
                support that type of block.
   
   =back
   
 Side Effects: &update_released_required() called in lonnet, if  Side Effects: &update_released_required() called in lonnet, if
               needed to update version requirements for course.                   course's home server version is requied version or 
                 newer; will update version requirements for course to
                 a more recent version requirement than currently in
                 effect.
   
   
 =item &display_blocker_status()  =item &display_blocker_status()
Line 238  Output: None Line 242  Output: None
   
 Side Effects: prints web form elements (in a table) for current blocks.   Side Effects: prints web form elements (in a table) for current blocks. 
   
 =item &path_to_trigger()  
   
 Provides hierarchy of names of folders/sub-folders containing the current  
 item identified as an item with an interval timer set, to be used as a   
 trigger.   
   
 Inputs: 3   
      - $navmap - navmaps object  
   
      - $map - url for map (either the trigger itself, or map containing  
                            the resource, which is the trigger).   
   
      - $type - type of trigger: map or resource.  
   
 Outputs: 1 @pathitems - array of folder/subfolder names.    
   
   
 =item &convlim()  =item &convlim()
   
 Convert a time interval used for a timed quiz (in seconds) to  Convert a time interval used for a timed quiz (in seconds) to
Line 375  Output: 2 Line 362  Output: 2
 Create Javascript used to launch pop-up used for content selection, and to  Create Javascript used to launch pop-up used for content selection, and to
 toggle visibility of a number of expandable/collapsible divs.  toggle visibility of a number of expandable/collapsible divs.
   
 Inputs: 1 - $blockcount -   Inputs: 1 - $blockcount - Total number of blocks in course's comm_block.db
                             database file. 
   
 Output: 1 - Javascript (with <script></script> tags) for functions used to:  Output: 1 - Javascript (with <script></script> tags) for functions used to:
             (a) launch pop-up window for selection of course content to which              (a) launch pop-up window for selection of course content to which
Line 405  use Apache::Constants qw(:common :http); Line 393  use Apache::Constants qw(:common :http);
 use Apache::loncommon();  use Apache::loncommon();
 use Apache::lonhtmlcommon();  use Apache::lonhtmlcommon();
 use Apache::lonparmset();  use Apache::lonparmset();
   use Apache::loncourserespicker();
 use HTML::Entities();  use HTML::Entities();
 use Apache::lonlocal;  use Apache::lonlocal;
 use lib '/home/httpd/lib/perl/';  use lib '/home/httpd/lib/perl/';
 use LONCAPA qw(:DEFAULT :match);  use LONCAPA qw(:DEFAULT :match);
   
   my $registered_cleanup;
   my $modified_courses;
   
 sub handler {  sub handler {
     my $r=shift;      my $r=shift;
   
Line 440  sub handler { Line 432  sub handler {
   
 # -----------------------------Get action and calling context from query string  # -----------------------------Get action and calling context from query string
   
       $registered_cleanup=0;
       @{$modified_courses}=();
   
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
                                             ['action','caller','block']);                                              ['action','caller','block']);
   
Line 486  sub handler { Line 481  sub handler {
 # -------------------------- Store changes and retrieve latest block information  # -------------------------- Store changes and retrieve latest block information
     my $storeresult;      my $storeresult;
     if ($env{'form.action'} eq 'store') {      if ($env{'form.action'} eq 'store') {
         (my $numchanges,$storeresult) = &blockstore($crstype,$blockcount);          (my $numchanges,$storeresult) = &blockstore($r,$crstype,$blockcount,\%records);
         if ($numchanges > 0) {          if ($numchanges > 0) {
             $blockcount = &get_blockdates(\%records);              $blockcount = &get_blockdates(\%records);
         }          }
Line 506  sub handler { Line 501  sub handler {
     }      }
     &Apache::lonhtmlcommon::add_breadcrumb      &Apache::lonhtmlcommon::add_breadcrumb
         ({href=>'/adm/setblock',          ({href=>'/adm/setblock',
           text=>'Blocking communication/resource access'});            text=>'Blocking communication/content access'});
   
     my $js = &blockingmenu_javascript($blockcount);      my $js = &blockingmenu_javascript($blockcount);
   
Line 515  sub handler { Line 510  sub handler {
         &Apache::lonhtmlcommon::breadcrumbs('Blocking communication/content access'));          &Apache::lonhtmlcommon::breadcrumbs('Blocking communication/content access'));
   
     my $usertype;      my $usertype;
     my $crstype = &Apache::loncommon::course_type();  
     if ($crstype eq 'Community') {      if ($crstype eq 'Community') {
         $usertype = 'members';          $usertype = 'members';
     } else {      } else {
Line 526  sub handler { Line 520  sub handler {
             'cbds' => 'Blocking communication and/or content access during exams',              'cbds' => 'Blocking communication and/or content access during exams',
             'prev' => "For the duration of an exam, or a timed quiz, students in this course can be prevented from:",              'prev' => "For the duration of an exam, or a timed quiz, students in this course can be prevented from:",
             'blca' => "Blocks can potentially interrupt legitimate communication between $usertype who are also both enrolled in a different LON-CAPA $lctype.",              'blca' => "Blocks can potentially interrupt legitimate communication between $usertype who are also both enrolled in a different LON-CAPA $lctype.",
             'pobl' => "Portfolio blocking can impact a student's ability to complete assigments in courses besides your own. Please use this feature wisely.",              'pobl' => "Portfolio blocking can impact a student's ability to complete assignments in courses besides your own. Please use this feature wisely.",
             'actt' => "Action to take:",              'actt' => "Action to take:",
             'addn' => 'Add new blocking event',              'addn' => 'Add new blocking event',
             'mexb' => 'Modify existing blocking event(s)',               'mexb' => 'Modify existing blocking event(s)', 
Line 565  sub handler { Line 559  sub handler {
             '<li>'.&mt("displaying LON-CAPA messages sent by other $usertype in the $lctype").'</li>'."\n".              '<li>'.&mt("displaying LON-CAPA messages sent by other $usertype in the $lctype").'</li>'."\n".
             '<li>'.&mt("displaying or posting to LON-CAPA discussion boards or live chat in the $lctype").'</li>'."\n".              '<li>'.&mt("displaying or posting to LON-CAPA discussion boards or live chat in the $lctype").'</li>'."\n".
             '<li>'.&mt('accessing content in LON-CAPA portfolios or blogs').'</li>'."\n".              '<li>'.&mt('accessing content in LON-CAPA portfolios or blogs').'</li>'."\n".
               '<li>'.&mt("generating printouts of $lctype content").'</li>'.
             '<li>'.&mt("accessing $lctype content in specified folders or resources").'</li>'.              '<li>'.&mt("accessing $lctype content in specified folders or resources").'</li>'.
               '<li>'.&mt("changing user's own password").'</li>'.
             '</ul>'.              '</ul>'.
             '<p class="LC_warning">'.$lt{'blca'}.'<br />'.$lt{'pobl'}.'</p>'              '<p class="LC_warning">'.$lt{'blca'}.'<br />'.$lt{'pobl'}.'</p>'
         );          );
Line 666  sub get_timed_items { Line 662  sub get_timed_items {
 }  }
   
 sub blockstore {  sub blockstore {
     my ($crstype,$blockcount) = @_;      my ($r,$crstype,$blockcount,$currblockrecs) = @_;
     my %lt=&Apache::lonlocal::texthash(      my %lt=&Apache::lonlocal::texthash(
             'tfcm' => 'The following changes were made',              'tfcm' => 'The following changes were made',
             'ncwm' => 'No changes were made.',              'ncwm' => 'No changes were made.',
Line 681  sub blockstore { Line 677  sub blockstore {
     my $changestotal = 0;      my $changestotal = 0;
     my $addtimer = 0;      my $addtimer = 0;
     my %blocking = ();      my %blocking = ();
     my (%map_url,%resource_symb,$output);      my (%map_url,%resource_symb,%titles,$output);
     $output = '<h3>'.$lt{'head'}.'</h3>';      $output = '<h3>'.$lt{'head'}.'</h3>';
     if ($env{'form.blockaction'} eq 'modify') {      if ($env{'form.blockaction'} eq 'modify') {
         foreach my $envkey (keys(%env)) {          foreach my $envkey (keys(%env)) {
Line 707  sub blockstore { Line 703  sub blockstore {
         $output = $lt{'unna'}.' '.$lt{'ncwm'}.'</br>';          $output = $lt{'unna'}.' '.$lt{'ncwm'}.'</br>';
         return ($changestotal,$output);          return ($changestotal,$output);
     }      }
     &enumerate_course_contents($navmap,\%map_url,\%resource_symb);      &Apache::loncourserespicker::enumerate_course_contents($navmap,\%map_url,\%resource_symb,\%titles,'examblock');
       my $do_releasereq_update;
       my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
       my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
       my $chome = $env{'course.'.$env{'request.course.id'}.'.home'};
       my $chostname = &Apache::lonnet::hostname($chome);
       my ($chomemajor,$chomeminor) =
           split(/\./,&Apache::lonnet::get_server_loncaparev($cdom,$chome));
   
   
     foreach my $key (keys(%removals)) {      foreach my $key (keys(%removals)) {
         my $hashkey = $env{'form.key_'.$key};          my $hashkey = $env{'form.key_'.$key};
         &Apache::lonnet::del('comm_block',["$hashkey"],          if ($hashkey =~ /firstaccess____/) {
                          $env{'course.'.$env{'request.course.id'}.'.domain'},             $do_releasereq_update = 1;
                          $env{'course.'.$env{'request.course.id'}.'.num'}          }
                          );          if (ref($currblockrecs->{$hashkey}) eq 'HASH') {
               if (ref($currblockrecs->{$hashkey}->{'blocks'}) eq 'HASH') {
                   foreach my $type ('docs','printout') {
                       if (exists($currblockrecs->{$hashkey}->{'blocks'}->{$type})) {
                           $do_releasereq_update = 1;
                       }
                   }
               }
           }
           &Apache::lonnet::del('comm_block',["$hashkey"],$cdom,$cnum);
       }
       if ($do_releasereq_update) {
           push(@{$modified_courses},[$cdom,$cnum,$chome,$crstype]);
           unless ($registered_cleanup) {
               my $handlers = $r->get_handlers('PerlCleanupHandler');
               $r->set_handlers('PerlCleanupHandler' => [\&update_releasereq,@{$handlers}]);
               $registered_cleanup=1;
           }
     }      }
     foreach my $key (keys(%adds)) {      foreach my $key (keys(%adds)) {
         unless ( defined($cancels{$key}) ) {          unless ( defined($cancels{$key}) ) {
             my $newkey;              my ($newkey,$status,$needsrelease);;
             if ($env{'form.firstaccess_'.$key}) {              if ($env{'form.firstaccess_'.$key}) {
                 my $interval =                   my $interval = 
                     &HTML::Entities::decode($env{'form.firstaccess_'.$key});                      &HTML::Entities::decode($env{'form.firstaccess_'.$key});
Line 735  sub blockstore { Line 757  sub blockstore {
                     }                      }
                     if ($newkey ne '') {                      if ($newkey ne '') {
                         unless (defined($removals{$key})) {                          unless (defined($removals{$key})) {
                             $addtimer ++;                              ($status,$needsrelease) = &check_release_required('timer',$chomemajor,$chomeminor);
                               if ($status eq 'fail') {
                                   $newkey = '';
                                   $output .= '<p class="LC_warning">'.
                                              &mt('Triggering of blocking events not allowed for [_1]',
                                                  &escape($env{'form.title_'.$key})).'<br />';
                               }
                         }                          }
                     }                      }
                 }                  }
Line 743  sub blockstore { Line 771  sub blockstore {
                 my ($newstart,$newend) = &get_dates_from_form($key);                  my ($newstart,$newend) = &get_dates_from_form($key);
                 $newkey = $newstart.'____'.$newend;                  $newkey = $newstart.'____'.$newend;
             }              }
               if ($status eq 'fail') {
                   $output .=  &mt('LON-CAPA version ([_1]) installed on home server ([_2]) does not meet version requirements ([_3] or newer).',
                                   $chomemajor.'.'.$chomeminor,$chostname,$needsrelease).'</p>';
               }
             if ($newkey ne '') {              if ($newkey ne '') {
                 my ($blocktypes,$blockdocs) =                   my ($blocktypes,$blockdocs) = 
                     &get_block_choices($key,\%map_url,\%resource_symb);                      &get_block_choices($key,\%map_url,\%resource_symb);
                   if (ref($blocktypes) eq 'HASH') {
                       if ($blocktypes->{'printout'} eq 'on') {
                           ($status,$needsrelease) = &check_release_required('printout',$chomemajor,$chomeminor);
                           if ($status eq 'fail') {
                               $blocktypes->{'printout'} = 'off';
                               $output .= '<p class="LC_warning">'.
                                          &mt('Printout blocking not allowed for [_1]',
                                              &escape($env{'form.title_'.$key})).'<br />';
                           }
                       }
                   }
                   if ($blockdocs) {
                       ($status,$needsrelease) = &check_release_required('docs',$chomemajor,$chomeminor);
                       if ($status eq 'fail') {
                           delete($blocktypes->{'docs'});
                           $output .= '<p class="LC_warning">'.
                                      &mt('Content blocking not allowed for [_1]',
                                          &escape($env{'form.title_'.$key})).'<br />';
                       }
                   }
                 $blocking{$newkey} = {                  $blocking{$newkey} = {
                           setter => $env{'user.name'}.':'.$env{'user.domain'},                            setter => $env{'user.name'}.':'.$env{'user.domain'},
                           event  => &escape($env{'form.title_'.$key}),                            event  => &escape($env{'form.title_'.$key}),
                           blocks => $blocktypes,                            blocks => $blocktypes,
                         };                          };
                 if ($blockdocs) {  
                     &check_release_required('docs');  
                 }  
                 if (ref($blocktypes) eq 'HASH') {  
                     if ($blocktypes->{'printout'} eq 'on') {  
                         &check_release_required('printout');  
                     }  
                 }  
                 if (exists($removals{$key})) {                  if (exists($removals{$key})) {
                     $modtotal ++;                      $modtotal ++;
                 } else {                  } else {
Line 766  sub blockstore { Line 810  sub blockstore {
                 }                  }
             } else {              } else {
                 if ($env{'form.toggle_'.$key} eq 'timer') {                  if ($env{'form.toggle_'.$key} eq 'timer') {
                     $output .= '<p class="LC_warning">'.                      unless ($status eq 'fail') {
                                &mt('Invalid trigger for new blocking event').                          $output .= '<p class="LC_warning">'.
                                '</p>';                                     &mt('Invalid trigger for new blocking event').
                                      '</p>';
                       }
                 } else {                  } else {
                     $output .= '<p class="LC_warning">'.                      $output .= '<p class="LC_warning">'.
                                &mt('No date range found for new blocking event').                                 &mt('No date range found for new blocking event').
Line 782  sub blockstore { Line 828  sub blockstore {
                      $env{'course.'.$env{'request.course.id'}.'.domain'},                       $env{'course.'.$env{'request.course.id'}.'.domain'},
                      $env{'course.'.$env{'request.course.id'}.'.num'}                       $env{'course.'.$env{'request.course.id'}.'.num'}
                      );                       );
         if ($addtimer) {  
             &check_release_required('timer');  
         }  
     }      }
     $changestotal = $canceltotal + $modtotal + $addtotal;      $changestotal = $canceltotal + $modtotal + $addtotal;
     if ($changestotal > 0) {      if ($changestotal > 0) {
Line 817  sub blockstore { Line 860  sub blockstore {
     return ($changestotal,$output);      return ($changestotal,$output);
 }  }
   
 sub enumerate_course_contents {  sub update_releasereq {
     my ($navmap,$map_url,$resource_symb) = @_;      my $readmap = 1;
     if ((ref($navmap)) && (ref($map_url) eq 'HASH') &&       my $getrelreq = 1;
         (ref($resource_symb) eq 'HASH')) {      if (ref($modified_courses) eq 'ARRAY') {
         my $it = $navmap->getIterator(undef,undef,undef,1,undef,undef);          foreach my $item (@{$modified_courses}) {
         my $count = 0;              if (ref($item) eq 'ARRAY') {
         while (my $curRes = $it->next()) {                  my ($cdom,$cnum,$chome,$crstype) = @{$item};
             if (ref($curRes)) {                  &Apache::lonrelrequtils::modify_course_relreq(undef,undef,$cnum,$cdom,
                 $count ++;                                                                $chome,$crstype,$cdom.'_'.$cnum,
                 my $symb = $curRes->symb();                                                                $readmap,$getrelreq);
                 my $ressymb = $symb;  
                 if ($ressymb =~ m|adm/($match_domain)/($match_username)/(\d+)/bulletinboard$|) {  
                     unless ($ressymb =~ m|adm/wrapper/adm|) {  
                         $ressymb = 'bulletin___'.$3.'___adm/wrapper/adm/'.$1.'/'.$2.'/'.$3.  
                                    '/bulletinboard';  
                     }  
                 }  
                 if (($curRes->is_sequence()) || ($curRes->is_page())) {  
                     $map_url->{$count} = (&Apache::lonnet::decode_symb($symb))[2];  
                 } else {  
                     $resource_symb->{$count} = $ressymb;  
                 }  
             }              }
         }          }
           $modified_courses = [];
     }      }
       undef($registered_cleanup);
     return;      return;
 }  }
   
Line 881  sub get_block_choices { Line 914  sub get_block_choices {
                     if (ref($symb_ref) eq 'HASH') {                      if (ref($symb_ref) eq 'HASH') {
                         my %resources = map { $symb_ref->{$_} => 1; }                           my %resources = map { $symb_ref->{$_} => 1; } 
                                             (split(/,/,$env{'form.docs_resources_'.$item}));                                              (split(/,/,$env{'form.docs_resources_'.$item}));
                           if (exists($resources{''})) {
                               delete($resources{''});
                           }
                         $blocklist->{$type}->{resources} = \%resources;                          $blocklist->{$type}->{resources} = \%resources;
                         if (keys(%resources) > 0) {                          if (keys(%resources) > 0) {
                             $blockdocs = 1;                              $blockdocs = 1;
Line 892  sub get_block_choices { Line 928  sub get_block_choices {
                     if (ref($map_ref) eq 'HASH') {                      if (ref($map_ref) eq 'HASH') {
                         my %maps = map { $map_ref->{$_} => 1; }                                                       my %maps = map { $map_ref->{$_} => 1; }                             
                                        (split(/,/,$env{'form.docs_maps_'.$item}));                                         (split(/,/,$env{'form.docs_maps_'.$item}));
                           if (exists($maps{''})) {
                               delete($maps{''});
                           }
                         $blocklist->{$type}->{maps} = \%maps;                          $blocklist->{$type}->{maps} = \%maps;
                         if (keys(%maps) > 0) {                          if (keys(%maps) > 0) {
                             $blockdocs = 1;                              $blockdocs = 1;
Line 911  sub get_block_choices { Line 950  sub get_block_choices {
 }  }
   
 sub check_release_required {  sub check_release_required {
     my ($value) = @_;       my ($value,$chomemajor,$chomeminor) = @_; 
     my $needsrelease = $Apache::lonnet::needsrelease{'course:commblock:'.$value};      my $needsrelease = $Apache::lonnet::needsrelease{'course:commblock:'.$value.':'};
     if ($needsrelease) {      if ($needsrelease) {
         my $curr_required =           my ($needsmajor,$needsminor) = split(/\./,$needsrelease);
           if (($chomemajor < $needsmajor) || 
               (($chomemajor == $needsmajor) && ($chomeminor < $needsminor))) {
               return ('fail',$needsrelease);
           }
           my $curr_required =
             $env{'course.'.$env{'request.course.id'}.'.internal.releaserequired'};              $env{'course.'.$env{'request.course.id'}.'.internal.releaserequired'};
         if ($curr_required eq '') {          if ($curr_required eq '') {
             &Apache::lonnet::update_released_required($needsrelease);              &Apache::lonnet::update_released_required($needsrelease);
Line 927  sub check_release_required { Line 971  sub check_release_required {
             }              }
         }          }
     }      }
     return;      return ('ok',$needsrelease);
 }  }
   
 sub display_blocker_status {  sub display_blocker_status {
     my ($r,$records,$ltext,$intervals,$navmap,$errormsg,$blockcount) = @_;      my ($r,$records,$ltext,$intervals,$navmap,$errormsg,$blockcount) = @_;
     my $parmcount = 0;      my $parmcount = 0;
     my (%map_url,%resource_symb,%lookups);      my (%map_url,%resource_symb,%titles,%lookups);
     &enumerate_course_contents($navmap,\%map_url,\%resource_symb);      &Apache::loncourserespicker::enumerate_course_contents($navmap,\%map_url,\%resource_symb,\%titles,'examblock');
     %{$lookups{'maps'}} = reverse(%map_url);      %{$lookups{'maps'}} = reverse(%map_url);
     %{$lookups{'resources'}} = reverse(%resource_symb);      %{$lookups{'resources'}} = reverse(%resource_symb);
     my %lt = &Apache::lonlocal::texthash(      my %lt = &Apache::lonlocal::texthash(
Line 1010  ACT Line 1054  ACT
                 if (&Apache::lonnet::is_on_map($url)) {                   if (&Apache::lonnet::is_on_map($url)) { 
                     if ($type eq 'map') {                      if ($type eq 'map') {
                         if (ref($navmap)) {                          if (ref($navmap)) {
                             my $res = $navmap->getResourceByUrl($item);                              my $title;
                             my $title = $res->compTitle();                              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]',                              $itemname = &mt('Timer for all items in folder: [_1]',
                                             '<span style="font-style:italic">'.                                              '<span style="font-style:italic">'.
                                             $title.'</span>');                                              $title.'</span>');
                         }                          }
                     } else {                      } else {
                         if (ref($navmap)) {                          if (ref($navmap)) {
                             my $res = $navmap->getBySymb($item);                              my $title;
                             my $title = $res->compTitle();                              my $resobj = $navmap->getBySymb($item);
                               if (ref($resobj)) {
                                   $title = $resobj->compTitle();
                               } else {
                                   $title = &Apache::lonnet::gettitle($item);
                               }
                             $itemname = &mt('Timer for resource: [_1]',                              $itemname = &mt('Timer for resource: [_1]',
                                              '<span style="font-style:italic">'.                                               '<span style="font-style:italic">'.
                                              $title.'</span>');                                               $title.'</span>');
Line 1128  END Line 1182  END
     return;      return;
 }  }
   
 sub path_to_trigger {  
     my ($navmap,$map,$type) = @_;  
     my @pathitems;  
     if (ref($navmap)) {  
         my $mapres = $navmap->getResourceByUrl($map);  
         if (ref($mapres)) {  
             my $pcslist = $mapres->map_hierarchy();  
             if ($pcslist ne '') {  
                 my @pcs = split(/,/,$pcslist);  
                 foreach my $pc (@pcs) {      
                     if ($pc == 1) {  
                         push(@pathitems,&mt('Main Course Documents'));  
                     } else {  
                         my $res = $navmap->getByMapPc($pc);  
                         if (ref($res)) {  
                             my $title = $res->compTitle();  
                             $title =~ s/\W+/_/g;  
                             if ($title ne '') {  
                                 push(@pathitems,$title);  
                             }  
                         }  
                     }  
                 }  
             }  
         }  
         if ($type eq 'resource') {  
             if ($mapres->{ID} eq '0.0') {  
                 push(@pathitems,&mt('Main Course Documents'));  
             } else {  
                 my $maptitle = $mapres->compTitle();  
                 $maptitle =~ s/\W+/_/g;  
                 if ($maptitle ne '') {  
                     push(@pathitems,$maptitle);  
                 }  
             }  
         }  
     }  
     return @pathitems;  
 }  
   
 sub convlim {  sub convlim {
     my ($timelimit) = @_;      my ($timelimit) = @_;
     my $output;  
     my @order = ('days','hours','minutes','seconds');      my @order = ('days','hours','minutes','seconds');
     my %catlimits = (       my %catlimits = ( 
                       days    => 86400,                        days    => 86400,
Line 1180  sub convlim { Line 1193  sub convlim {
     my @toshow;      my @toshow;
     foreach my $cat (@order) {      foreach my $cat (@order) {
         if ($cat eq 'seconds') {          if ($cat eq 'seconds') {
             last if ($timelimit <= 0);              if ($timelimit > 0) {
                   push(@toshow,&mt("[_1] $cat",$timelimit));
               }
         } elsif ($timelimit >= $catlimits{$cat}) {          } elsif ($timelimit >= $catlimits{$cat}) {
             my $val = int($timelimit/$catlimits{$cat});              my $val = int($timelimit/$catlimits{$cat});
             if ($val > 0) {              if ($val > 0) {
                 push(@toshow,&mt("[_1] $cat",$val));                  push(@toshow,&mt("[_1] $cat",$val));
             }              }
             $timelimit =- $val*$catlimits{$cat};              $timelimit -= $val*$catlimits{$cat};
         }          }
     }      }
     my $output = join(', ',@toshow);      my $output = join(', ',@toshow);
Line 1360  sub create_interval_form { Line 1375  sub create_interval_form {
                 if (ref($intervals->{$type}) eq 'HASH') {                  if (ref($intervals->{$type}) eq 'HASH') {
                     if (ref($navmap)) {                      if (ref($navmap)) {
                         foreach my $map (sort(keys(%{$intervals->{$type}}))) {                          foreach my $map (sort(keys(%{$intervals->{$type}}))) {
                               next if ((!&Apache::lonnet::is_on_map($map)) &&
                                        ($currkey ne $map));
                             my ($checked,$clickaction);                              my ($checked,$clickaction);
                             if ($currkey eq $map) {                              if ($currkey eq $map) {
                                 $checked = ' checked="checked"';                                  $checked = ' checked="checked"';
Line 1370  sub create_interval_form { Line 1387  sub create_interval_form {
                                              '" value="'.&HTML::Entities::encode($map,'"<>&').'"'.                                               '" value="'.&HTML::Entities::encode($map,'"<>&').'"'.
                                              $checked.$clickaction.' />';                                               $checked.$clickaction.' />';
                             if ($currkey eq $map) {                              if ($currkey eq $map) {
                                 $intervalform .= $itemname.'</label>';                                  $intervalform .= $itemname.'</label>'.$iteminfo;
                             } else {                              } else {
                                 my $res = $navmap->getResourceByUrl($map);                                  my ($resobj,$title,$path,$hierarchy);
                                 my $title = $res->compTitle();                                  $resobj = $navmap->getResourceByUrl($map);
                                 my $path;                                  if (ref($resobj)) {
                                 my $hierarchy = &show_timer_path($type,$map,$navmap);                                      $title = $resobj->compTitle();
                                   } else {
                                       $title = &Apache::lonnet::gettitle($map);
                                   }
                                   $hierarchy = &show_timer_path($type,$map,$navmap);
                                 if ($hierarchy) {                                  if ($hierarchy) {
                                     $path = ' <span style="font-size:90%;">'.                                      $path = ' <span style="font-size:90%;">'.
                                             &mt('(in: [_1])',$hierarchy).                                              &mt('(in: [_1])',$hierarchy).
Line 1385  sub create_interval_form { Line 1406  sub create_interval_form {
                                                      '<i>'.$title.'</i>').                                                       '<i>'.$title.'</i>').
                                                  '</label>'.$path;                                                   '</label>'.$path;
                             }                              }
                             if ($currkey eq $map) {  
                                 $intervalform .= $iteminfo;  
                             }  
                             $intervalform .= '<br />';                              $intervalform .= '<br />';
                         }                          }
                     }                      }
Line 1396  sub create_interval_form { Line 1414  sub create_interval_form {
                 if (ref($intervals->{$type}) eq 'HASH') {                  if (ref($intervals->{$type}) eq 'HASH') {
                     if (ref($navmap)) {                      if (ref($navmap)) {
                         foreach my $resource (sort(keys(%{$intervals->{$type}}))) {                          foreach my $resource (sort(keys(%{$intervals->{$type}}))) {
                             my ($checked,$clickaction);                              my ($checked,$clickaction,$resobj);
                             if ($currkey eq $resource) {                              if ($currkey eq $resource) {
                                 $checked = ' checked="checked"';                                  $checked = ' checked="checked"';
                             } elsif ($jschg) {                              } else {
                                 $clickaction = ' onclick="'.$jschg.'"';                                  $resobj = $navmap->getBySymb($resource);
                                   next unless(ref($resobj));
                                   if ($jschg) {
                                       $clickaction = ' onclick="'.$jschg.'"';
                                   }
                             }                              }
                             $intervalform .= '<label><input type="radio" name="firstaccess_'.$parmcount.                              $intervalform .= '<label><input type="radio" name="firstaccess_'.$parmcount.
                                              '" value="'.&HTML::Entities::encode($resource,'"<>&').'"'.                                               '" value="'.&HTML::Entities::encode($resource,'"<>&').'"'.
                                              $checked.$clickaction.' />';                                               $checked.$clickaction.' />';
                             if ($currkey eq $resource) {                              if ($currkey eq $resource) {
                                 $intervalform .= $itemname.'</label>';                                  $intervalform .= $itemname.'</label>'.$iteminfo;
                             } else {                              } else {
                                 my $res = $navmap->getBySymb($resource);                                  my ($title,$path,$hierarchy);
                                 my $title = $res->compTitle();                                  if (ref($resobj)) {
                                 my $path;                                      $title = $resobj->compTitle();
                                 my $hierarchy = &show_timer_path($type,$resource,$navmap);                                  } else {
                                       $title = &Apache::lonnet::gettitle($resource);
                                   }
                                   $hierarchy = &show_timer_path($type,$resource,$navmap);
                                 if ($hierarchy) {                                  if ($hierarchy) {
                                     $path = ' <span style="font-size:90%;">'.                                      $path = ' <span style="font-size:90%;">'.
                                             &mt('(in: [_1])',$hierarchy).                                              &mt('(in: [_1])',$hierarchy).
Line 1421  sub create_interval_form { Line 1446  sub create_interval_form {
                                                  '</label>'.                                                   '</label>'.
                                                  $path;                                                   $path;
                             }                              }
                             if ($currkey eq $resource) {  
                                 $intervalform .= $iteminfo;  
                             }  
                             $intervalform .= '<br />';                              $intervalform .= '<br />';
                         }                          }
                     }                      }
Line 1457  sub show_timer_path { Line 1479  sub show_timer_path {
     return unless(ref($navmap));      return unless(ref($navmap));
     my @pathitems;      my @pathitems;
     if ($type eq 'map') {      if ($type eq 'map') {
         @pathitems = &path_to_trigger($navmap,$item,$type);          @pathitems = 
               &Apache::loncommon::get_folder_hierarchy($navmap,$item);
     } elsif ($type eq 'resource') {      } elsif ($type eq 'resource') {
         my ($map,$id,$resource) = &Apache::lonnet::decode_symb($item);          my ($map,$id,$resource) = &Apache::lonnet::decode_symb($item);
         @pathitems = &path_to_trigger($navmap,$map,$type);          @pathitems = 
               &Apache::loncommon::get_folder_hierarchy($navmap,$map,1);
     }      }
     if (@pathitems) {      if (@pathitems) {
         return join(' &raquo; ',@pathitems);          return join(' &raquo; ',@pathitems);
Line 1478  sub blocktype_text { Line 1502  sub blocktype_text {
         'blogs' => 'Blogs',          'blogs' => 'Blogs',
         'docs' => 'Content',          'docs' => 'Content',
         'printout' => 'Printouts',          'printout' => 'Printouts',
           'passwd' => 'Change Password',
     );      );
     my $typeorder = ['com','chat','boards','port','groups','blogs','printout','docs'];      my $typeorder = ['com','chat','boards','port','groups','blogs','printout','docs','passwd'];
     return ($typeorder,\%types);      return ($typeorder,\%types);
 }  }
   

Removed from v.1.5  
changed lines
  Added in v.1.17


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