Diff for /loncom/interface/lonblockingmenu.pm between versions 1.14.2.3.4.4 and 1.15

version 1.14.2.3.4.4, 2021/01/04 17:24:13 version 1.15, 2015/09/13 21:48:05
Line 105  block (including deletion), or when a ne Line 105  block (including deletion), or when a ne
   
 =over  =over
   
 =item &get_permission()  
   
 Returns information about permission user has to set/modify exam  
 blocking events.  
   
 Inputs: None  
   
 Outputs: 2  
     $readonly - true if modification of blocking events is prohibited.  
   
     $allowed  - true if blocking events information can be shown.  
   
   
 =item &get_timed_items()  =item &get_timed_items()
   
 Provides perl data structure with information about timed interval  Provides perl data structure with information about timed interval
Line 235  Side Effects: &update_released_required( Line 222  Side Effects: &update_released_required(
 Generates web form elements used to display, cancel, or modify   Generates web form elements used to display, cancel, or modify 
 existing blocking events.   existing blocking events. 
   
 Inputs: 8   Inputs: 7 
       - $r - Apache request object        - $r - Apache request object
   
       - $records - Reference to hash of current blocks        - $records - Reference to hash of current blocks
Line 251  Inputs: 8 Line 238  Inputs: 8
   
       - $blockcount - number of existing blocking events in course        - $blockcount - number of existing blocking events in course
   
       - $readonly - if true, modification not allowed.  
   
   
 Output: None  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. 
Line 318  Creates web form elements used to select Line 302  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: 8 (four required, last four optional)  Inputs: 7 (three 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 342  Inputs: 8 (four required, last four opti Line 323  Inputs: 8 (four required, last four opti
 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()  
   
 Creates name/scope of current interval and expandable/collapsible  
 showing which interval parameters apply to the current folder/resource  
   
 Inputs: 6  
   
     - $item - course, map url, or resource symb  
   
     - $type - course, map, or resource  
   
     - $url  - url of item (null if item is course).  
   
     - $navmap - navmaps object  
   
     - $intervals - Reference to hash of parameters for timed intervals  
   
     - $parmcount - unique ID for current element.  
   
   
 Outputs: 2  
   
    - $itemname - name/scope of interval (timer) parameter  
   
    - $iteminfo - Expandable/collapsible block showing which interval  
                  (timer) parameters affect the current folder or resource.  
   
   
 =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 379  Inputs: 1 - $parmcount - numericID of ex Line 332  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 424  Output: 1 - Javascript (with <script></s Line 376  Output: 1 - Javascript (with <script></s
   
 =item *  for action to take -- add or modify block  =item *  for action to take -- add or modify block
   
 =back  =item *  for display of detailed information about intervals 
   
   
 =item &details_javascript()  
   
 Create Javascript to toggle visibility of unordered list item  =back
 containing details about item with timed interval parameter.  
   
 Inputs: none  
   
 Output: 1 Javascript (with <script></script> tags) for functions used to:  =back  
           toggle visibility of unordered list for display of detailed  
           information about intervals.  
   
 =back  
   
 =cut  =cut
   
Line 479  sub handler { Line 422  sub handler {
   
 # ----------------------------------------------------------- Permissions check  # ----------------------------------------------------------- Permissions check
   
     my ($readonly,$allowed) = &get_permission();      unless ((&Apache::lonnet::allowed('dcm',$env{'request.course.id'})) ||
     unless ($allowed) {              (&Apache::lonnet::allowed('dcm',$env{'request.course.id'}.
                                         '/'.$env{'request.course.sec'}))) {
         $env{'user.error.msg'}=          $env{'user.error.msg'}=
      "/adm/setblock:dcm:0:0:Cannot view/set blocking of communications in a course";       "/adm/setblock:dcm:0:0:Cannot set blocking of communications in a course";
         return HTTP_NOT_ACCEPTABLE;          return HTTP_NOT_ACCEPTABLE;
     }      }
   
Line 527  sub handler { Line 471  sub handler {
             $r->print(&Apache::loncourserespicker::create_picker($navmap,              $r->print(&Apache::loncourserespicker::create_picker($navmap,
                                      'examblock','resourceblocks',$crstype,                                       'examblock','resourceblocks',$crstype,
                                      \%blockedmaps,\%blockedresources,                                       \%blockedmaps,\%blockedresources,
                                      $env{'form.block'},'','',undef,undef,$readonly));                                       $env{'form.block'}));
         } else {          } else {
             $r->print($errormsg);              $r->print($errormsg);
         }          }
Line 536  sub handler { Line 480  sub handler {
   
 # -------------------------- Store changes and retrieve latest block information  # -------------------------- Store changes and retrieve latest block information
     my $storeresult;      my $storeresult;
     unless ($readonly) {      if ($env{'form.action'} eq 'store') {
         if ($env{'form.action'} eq 'store') {          (my $numchanges,$storeresult) = &blockstore($r,$crstype,$blockcount,\%records);
             (my $numchanges,$storeresult) = &blockstore($r,$crstype,$blockcount,\%records);          if ($numchanges > 0) {
             if ($numchanges > 0) {              $blockcount = &get_blockdates(\%records);
                 $blockcount = &get_blockdates(\%records);  
             }  
         }          }
     }      }
   
Line 561  sub handler { Line 503  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 578  sub handler { Line 519  sub handler {
     my %lt=&Apache::lonlocal::texthash (      my %lt=&Apache::lonlocal::texthash (
             '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:",
             'flow' => "For the duration of an exam, or a timed quiz, event-driven interruptions to a student's workflow can be suppressed:",  
             '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 assignments 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:",
Line 618  sub handler { Line 558  sub handler {
             '<ul>'."\n".              '<ul>'."\n".
             '<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, blogs, or user information pages').'</li>'."\n".              '<li>'.&mt('accessing content in LON-CAPA portfolios or blogs').'</li>'."\n".
             '<li>'.&mt("generating printouts of $lctype content").'</li>'.              '<li>'.&mt("generating printouts of $lctype content").'</li>'.
             '<li>'.&mt("displaying the LON-CAPA gradebook in the $lctype").'</li>'.  
             '<li>'.&mt("searching $lctype content by keyword").'</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>'.  
             $lt{'flow'}.  
             '<ul>'."\n".  
             '<li>'.&mt("re-initialization of cached course structure, when a change has been made to $lctype content by a Coordinator").'</li>'.  
             '<li>'.&mt('display of Critical Messages when navigation arrows used to move to the adjacent resource').'</li>'.  
             '</ul>'.              '</ul>'.
             '<p class="LC_warning">'.$lt{'blca'}.'<br />'.$lt{'pobl'}.'</p>'              '<p class="LC_warning">'.$lt{'blca'}.'<br />'.$lt{'pobl'}.'</p>'
         );          );
Line 636  sub handler { Line 568  sub handler {
   
 # ------------------------ Choose between modifying existing block or adding new  # ------------------------ Choose between modifying existing block or adding new
     $r->print('<form name="blockform" method="post" action="/adm/setblock?action=store">');      $r->print('<form name="blockform" method="post" action="/adm/setblock?action=store">');
       if ($blockcount > 0) {
     unless ($readonly) {           $r->print(<<"END");
         if ($blockcount > 0) {  
             $r->print(<<"END");  
 <div class="LC_left_float">  <div class="LC_left_float">
 <fieldset><legend>$lt{'actt'}</legend>  <fieldset><legend>$lt{'actt'}</legend>
 <span class="LC_nobreak">  <span class="LC_nobreak">
Line 656  onclick="toggleAddModify();" />$lt{'addn Line 586  onclick="toggleAddModify();" />$lt{'addn
 <br clear="all" />  <br clear="all" />
 <div id="showadd" style="display:none">  <div id="showadd" style="display:none">
 END  END
         } else {      } else {
             $r->print($lt{'ncbc'}.'<br /><br />'.          $r->print($lt{'ncbc'}.'<br /><br />'.
                       '<h4>'.$lt{'addn'}.'</h4>'.                    '<h4>'.$lt{'addn'}.'</h4>'.
                       '<input type="hidden" name="blockaction" value="add" />');                    '<input type="hidden" name="blockaction" value="add" />');
         }  
     }      }
     my ($navmap,$errormsg) =      my ($navmap,$errormsg) =
         &Apache::loncourserespicker::get_navmap_object($crstype,'examblock');          &Apache::loncourserespicker::get_navmap_object($crstype,'examblock');
   
 # --------------------------------------------- Interface for adding a new block  # --------------------------------------------- Interface for adding a new block
     unless ($readonly) {      &display_addblocker_table($r,$blockcount,\%ltext,\%intervals,
         &display_addblocker_table($r,$blockcount,\%ltext,\%intervals,                                $navmap,$errormsg);
                                   $navmap,$errormsg);  
         if ($blockcount > 0) {  # ------------------------------------------------- Interface for existig blocks
             $r->print('</div>');      if ($blockcount > 0) {
         }          $r->print('</div>');
     }  
 # ------------------------------------------------ Interface for existing blocks  
     if (!$blockcount) {  
         if ($readonly) {  
             $r->print($lt{'ncbc'}.'<br />');  
         }  
     } else {  
         &display_blocker_status($r,\%records,\%ltext,\%intervals,          &display_blocker_status($r,\%records,\%ltext,\%intervals,
                                 $navmap,$errormsg,$blockcount,$readonly);                                  $navmap,$errormsg,$blockcount);
     }      }
     unless ($readonly) {      $r->print(<<"END");
         $r->print(<<"END");  
 <br />  <br />
 <input type ="submit" value="$lt{'stor'}" />  <input type ="submit" value="$lt{'stor'}" />
   </form>
 END  END
     }      $r->print(&Apache::loncommon::end_page());
     $r->print('</form>'.  
               &Apache::loncommon::end_page());  
     return OK;      return OK;
 }  }
   
 sub get_permission {  
     my %permission;  
     my $allowed = 0;  
     my $readonly = 0;  
     return ($readonly,$allowed) unless ($env{'request.course.id'});  
     if ((&Apache::lonnet::allowed('dcm',$env{'request.course.id'})) ||  
         (&Apache::lonnet::allowed('dcm',$env{'request.course.id'}.'/'.  
                   $env{'request.course.sec'}))) {  
         $allowed = 1;  
     } elsif ((&Apache::lonnet::allowed('vcb',$env{'request.course.id'})) ||  
              (&Apache::lonnet::allowed('vcb',$env{'request.course.id'}.'/'.  
                   $env{'request.course.sec'}))) {  
         $readonly = 1;  
         $allowed = 1;  
     }  
     return ($readonly,$allowed);  
 }  
   
 sub get_timed_items {  sub get_timed_items {
     my ($cdom,$cnum) = @_;      my ($cdom,$cnum) = @_;
     my ($cid,%intervals);      my ($cid,%intervals);
Line 727  sub get_timed_items { Line 629  sub get_timed_items {
     my $resourcedata=&Apache::lonparmset::readdata($cnum,$cdom);      my $resourcedata=&Apache::lonparmset::readdata($cnum,$cdom);
     if (ref($resourcedata) eq 'HASH') {      if (ref($resourcedata) eq 'HASH') {
         foreach my $key (keys(%{$resourcedata})) {          foreach my $key (keys(%{$resourcedata})) {
             if ($key =~ /^\Q$cid\E(.*)\.0\.interval$/) {              if ($key =~ /^\Q$cid\E(.+)\.0\.interval$/) {
                 my $middle = $1;                  my $middle = $1;
                 if ($middle eq '') {                  if ($middle eq '') {
                     $intervals{'course'}{'all'} = $resourcedata->{$key};                      $intervals{'course'}{'all'} = $resourcedata->{$key};
Line 885  sub blockstore { Line 787  sub blockstore {
                                            &escape($env{'form.title_'.$key})).'<br />';                                             &escape($env{'form.title_'.$key})).'<br />';
                         }                          }
                     }                      }
                     if ($blocktypes->{'alert'} eq 'on') {  
                         ($status,$needsrelease) = &check_release_required('alert',$chomemajor,$chomeminor);  
                         if ($status eq 'fail') {  
                             $blocktypes->{'alert'} = 'off';  
                             $output .= '<p class="LC_warning">'.  
                                        &mt('Message Alert blocking not allowed for [_1]',  
                                            &escape($env{'form.title_'.$key})).'<br />';  
                         }  
                     }  
                     if ($blocktypes->{'reinit'} eq 'on') {  
                         ($status,$needsrelease) = &check_release_required('reinit',$chomemajor,$chomeminor);  
                         if ($status eq 'fail') {  
                             $blocktypes->{'reinit'} = 'off';  
                             $output .= '<p class="LC_warning">'.  
                                        &mt('Course Re-initialization blocking not allowed for [_1]',  
                                            &escape($env{'form.title_'.$key})).'<br />';  
                         }  
                     }  
                 }                  }
                 if ($blockdocs) {                  if ($blockdocs) {
                     ($status,$needsrelease) = &check_release_required('docs',$chomemajor,$chomeminor);                      ($status,$needsrelease) = &check_release_required('docs',$chomemajor,$chomeminor);
Line 1066  sub get_block_choices { Line 950  sub get_block_choices {
   
 sub check_release_required {  sub check_release_required {
     my ($value,$chomemajor,$chomeminor) = @_;       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 ($needsmajor,$needsminor) = split(/\./,$needsrelease);          my ($needsmajor,$needsminor) = split(/\./,$needsrelease);
         if (($chomemajor < $needsmajor) ||           if (($chomemajor < $needsmajor) || 
Line 1090  sub check_release_required { Line 974  sub check_release_required {
 }  }
   
 sub display_blocker_status {  sub display_blocker_status {
     my ($r,$records,$ltext,$intervals,$navmap,$errormsg,$blockcount,$readonly) = @_;      my ($r,$records,$ltext,$intervals,$navmap,$errormsg,$blockcount) = @_;
     my $parmcount = 0;      my $parmcount = 0;
     my (%map_url,%resource_symb,%titles,%lookups,$disabled);      my (%map_url,%resource_symb,%titles,%lookups);
     &Apache::loncourserespicker::enumerate_course_contents($navmap,\%map_url,\%resource_symb,\%titles,'examblock');      &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);
Line 1102  sub display_blocker_status { Line 986  sub display_blocker_status {
         'noch' => 'No change',          'noch' => 'No change',
     );      );
     $r->print('<div id="showmodify" style="display:block">'.      $r->print('<div id="showmodify" style="display:block">'.
               &Apache::loncommon::start_data_table().'<tr>');                &Apache::loncommon::start_data_table());
     if ($readonly) {  
         $disabled = ' disabled="disabled"';  
     } else {  
         $r->print('<th></th>');  
     }  
     $r->print(<<"END");      $r->print(<<"END");
     <tr>
       <th></th>
     <th>$ltext->{'type'}</th>      <th>$ltext->{'type'}</th>
     <th>$ltext->{'even'}</th>      <th>$ltext->{'even'}</th>
     <th>$ltext->{'blck'}</th>      <th>$ltext->{'blck'}</th>
Line 1127  END Line 1008  END
            &Apache::loncommon::aboutmewrapper(             &Apache::loncommon::aboutmewrapper(
                            &Apache::loncommon::plainname($setuname,$setudom),                             &Apache::loncommon::plainname($setuname,$setudom),
                            $setuname,$setudom);                             $setuname,$setudom);
         my $state = '';  
         $r->print(&Apache::loncommon::start_data_table_row());          $r->print(&Apache::loncommon::start_data_table_row());
         if ($readonly) {          $r->print(<<"ACT");
             $state = 'disabled';  
         } else {  
             $r->print(<<"ACT");  
   
         <td valign="middle"><span class="LC_nobreak"><label>          <td valign="middle"><span class="LC_nobreak"><label>
         <input type="radio" name="action_$parmcount" value="modify" />$lt{'modi'}          <input type="radio" name="action_$parmcount" value="modify" />$lt{'modi'}
Line 1146  END Line 1023  END
         </label></span>          </label></span>
         </td>          </td>
 ACT  ACT
         }  
         my ($start,$end,$startform,$endform);           my ($start,$end,$startform,$endform); 
         if ($record =~ /^(\d+)____(\d+)$/) {          if ($record =~ /^(\d+)____(\d+)$/) {
             ($start,$end) = split(/____/,$record);              ($start,$end) = split(/____/,$record);
             $startform = &Apache::lonhtmlcommon::date_setter('blockform','startdate_'.              $startform = &Apache::lonhtmlcommon::date_setter('blockform','startdate_'.
                                                              $parmcount,$start,$onchange,                                                               $parmcount,$start,$onchange);
                                                              undef,$state);  
             $endform = &Apache::lonhtmlcommon::date_setter('blockform','enddate_'.              $endform = &Apache::lonhtmlcommon::date_setter('blockform','enddate_'.
                                                            $parmcount,$end,$onchange,                                                             $parmcount,$end,$onchange);
                                                            undef,$state);  
             $r->print('<td><fieldset><legend>'.$ltext->{'defs'}.'</legend>'.              $r->print('<td><fieldset><legend>'.$ltext->{'defs'}.'</legend>'.
                       $ltext->{'star'}.':&nbsp;'.$startform.'<br />'.                        $ltext->{'star'}.':&nbsp;'.$startform.'<br />'.
                       $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 1172  ACT Line 1047  ACT
                 $url = $item;                  $url = $item;
             }              }
             $r->print('<td><fieldset><legend>'.$ltext->{'trig'}.'</legend>');              $r->print('<td><fieldset><legend>'.$ltext->{'trig'}.'</legend>');
             my ($itemname,$iteminfo) = &interval_details($item,$type,$url,$navmap,$intervals,$parmcount);              if ($type eq 'course') {
             $r->print(&create_interval_form($intervals,$parmcount,$navmap,'blocking',$item,$jschg,                  $itemname = &mt('Timer for all items in course.');
                                             $itemname,$iteminfo,$disabled).'</fieldset></td>');              } 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).'</fieldset></td>');
         }          }
         $r->print(<<"END");          $r->print(<<"END");
         <td>          <td>
          <input type="text" name="title_$parmcount" size="15" value="$title" onfocus="$jschg" $disabled />           <input type="text" name="title_$parmcount" size="15" value="$title" onfocus="$jschg" />
          <input type="hidden" name="key_$parmcount" value="$blockid" />           <input type="hidden" name="key_$parmcount" value="$blockid" />
          <br />           <br />
          <br />           <br />
          $ltext->{'setb'}: $settername           $ltext->{'setb'}: $settername
         </td>          </td>
 END  END
         $r->print('<td>'.&blocker_checkboxes($parmcount,$blocks,$jschg,\%lookups,$disabled).'</td>'.          $r->print('<td>'.&blocker_checkboxes($parmcount,$blocks,$jschg,\%lookups).'</td>'.
                   &Apache::loncommon::end_data_table_row());                    &Apache::loncommon::end_data_table_row());
         $parmcount++;          $parmcount++;
     }      }
Line 1237  sub display_addblocker_table { Line 1222  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,'blocking');      my $intervalform = &create_interval_form($intervals,$parmcount,$navmap);
     if ($intervalform ne '') {      if ($intervalform ne '') {
         $intervalform = '<fieldset>'.          $intervalform = '<fieldset>'.
                         '<legend>'.$ltext->{'chtr'}.'</legend>'.                          '<legend>'.$ltext->{'chtr'}.'</legend>'.
Line 1275  END Line 1260  END
 }  }
   
 sub blocker_checkboxes {  sub blocker_checkboxes {
     my ($parmcount,$blocks,$jschg,$lookups,$disabled) = @_;      my ($parmcount,$blocks,$jschg,$lookups) = @_;
     my ($typeorder,$types) = &blocktype_text();      my ($typeorder,$types) = &blocktype_text();
     my $numinrow = 2;      my $numinrow = 2;
     my %currdocs;      my %currdocs;
Line 1342  sub blocker_checkboxes { Line 1327  sub blocker_checkboxes {
         }           } 
         $output .= '<span class="LC_nobreak"><label>'."\n".          $output .= '<span class="LC_nobreak"><label>'."\n".
                    '<input type="checkbox" id="'.$item.'" name="'.$item.'"'.                     '<input type="checkbox" id="'.$item.'" name="'.$item.'"'.
                    $blockstatus.$clickaction.' value="1"'.$disabled.' />'.                     $blockstatus.$clickaction.' value="1" />'.
                    $types->{$block}.'</label></span>'."\n";                     $types->{$block}.'</label></span>'."\n";
         if ($block eq 'docs') {          if ($block eq 'docs') {
             if ($blockstatus ne '') {              if ($blockstatus ne '') {
Line 1361  sub blocker_checkboxes { Line 1346  sub blocker_checkboxes {
 }  }
   
 sub create_interval_form {  sub create_interval_form {
     my ($intervals,$parmcount,$navmap,$context,$currkey,$jschg,$itemname,$iteminfo,$disabled) = @_;      my ($intervals,$parmcount,$navmap,$currkey,$jschg,$itemname,$iteminfo) = @_;
     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 1375  sub create_interval_form { Line 1359  sub create_interval_form {
                     $clickaction = ' onclick="'.$jschg.'"';                      $clickaction = ' onclick="'.$jschg.'"';
                 }                  }
                 $intervalform .= '<label><input type="radio" name="firstaccess_'.$parmcount.                  $intervalform .= '<label><input type="radio" name="firstaccess_'.$parmcount.
                                  '" value="course"'.$checked.$clickaction.$disabled.' />';                                   '" value="course"'.$checked.$clickaction.' />';
                 if ($currkey eq 'course') {                  if ($currkey eq 'course') {
                     $intervalform .= $itemname;                      $intervalform .= $itemname;
                 } else {                  } else {
Line 1384  sub create_interval_form { Line 1368  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 1406  sub create_interval_form { Line 1384  sub create_interval_form {
                             }                              }
                             $intervalform .= '<label><input type="radio" name="firstaccess_'.$parmcount.                              $intervalform .= '<label><input type="radio" name="firstaccess_'.$parmcount.
                                              '" value="'.&HTML::Entities::encode($map,'"<>&').'"'.                                               '" value="'.&HTML::Entities::encode($map,'"<>&').'"'.
                                              $checked.$clickaction.$disabled.' />';                                               $checked.$clickaction.' />';
                             if ($currkey eq $map) {                              if ($currkey eq $map) {
                                 $intervalform .= $itemname.'</label>'.$iteminfo;                                  $intervalform .= $itemname.'</label>'.$iteminfo;
                             } else {                              } else {
Line 1426  sub create_interval_form { Line 1404  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 1454  sub create_interval_form { Line 1425  sub create_interval_form {
                             }                              }
                             $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.$disabled.' />';                                               $checked.$clickaction.' />';
                             if ($currkey eq $resource) {                              if ($currkey eq $resource) {
                                 $intervalform .= $itemname.'</label>'.$iteminfo;                                  $intervalform .= $itemname.'</label>'.$iteminfo;
                             } else {                              } else {
                                 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 1474  sub create_interval_form { Line 1444  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 1496  sub create_interval_form { Line 1455  sub create_interval_form {
         if ($currkey ne '') {          if ($currkey ne '') {
             $intervalform = '<input type="radio" name="firstaccess_'.$parmcount.              $intervalform = '<input type="radio" name="firstaccess_'.$parmcount.
                             '" checked="checked" value="'.                              '" checked="checked" value="'.
                             &HTML::Entities::encode($currkey,'"<>&').'"'.$disabled.' />'.                              &HTML::Entities::encode($currkey,'"<>&').' />'.
                             $itemname.'<br />';                              $itemname.'<br />';
         } else {          } else {
             $intervalform = &mt('No timed items defined.').' '.              $intervalform = &mt('No timed items defined.').' '.
Line 1514  sub trigger_details_toggle { Line 1473  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 1655  sub blocktype_text { Line 1499  sub blocktype_text {
         'port' => 'Portfolio',          'port' => 'Portfolio',
         'groups' => 'Groups',          'groups' => 'Groups',
         'blogs' => 'Blogs',          'blogs' => 'Blogs',
         'about' => 'User Information',  
         'docs' => 'Content',          'docs' => 'Content',
         'printout' => 'Printouts',          'printout' => 'Printouts',
         'passwd' => 'Change Password',  
         'grades' => 'Gradebook',  
         'search' => 'Content Search',  
         'alert'  => 'Critical Alert',  
         'reinit' => 'Course Re-init',  
     );      );
     my $typeorder = ['com','chat','boards','port','groups','blogs','about','printout','docs','grades','search','alert','reinit','passwd'];      my $typeorder = ['com','chat','boards','port','groups','blogs','printout','docs'];
     return ($typeorder,\%types);      return ($typeorder,\%types);
 }  }
   
 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 1725  function toggleAddModify() { Line 1567  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.14.2.3.4.4  
changed lines
  Added in v.1.15


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