Diff for /loncom/interface/lonwhatsnew.pm between versions 1.73 and 1.83

version 1.73, 2007/09/26 12:34:19 version 1.83, 2008/12/12 15:48:05
Line 36  use Apache::lonlocal; Line 36  use Apache::lonlocal;
 use Apache::loncoursedata();  use Apache::loncoursedata();
 use Apache::lonnavmaps();  use Apache::lonnavmaps();
 use Apache::lonuserstate;  use Apache::lonuserstate;
   use Apache::lonuserutils; 
 use Apache::Constants qw(:common :http);  use Apache::Constants qw(:common :http);
 use Time::Local;  use Time::Local;
 use GDBM_File;  use GDBM_File;
Line 68  sub handler { Line 69  sub handler {
     ['vgr','abovethreshold',1],      ['vgr','abovethreshold',1],
     ['opa','haserrors',1],      ['opa','haserrors',1],
     ['mdc','versionchanges',0],      ['mdc','versionchanges',0],
                               ['vcl','newroles',1],
                               ['vcl','oldroles',1],
     ) {      ) {
  my ($perm,$key,$check_section) = @{ $perm_check };   my ($perm,$key,$check_section) = @{ $perm_check };
  my $scope = $env{'request.course.id'};   my $scope = $env{'request.course.id'};
Line 125  sub handler { Line 128  sub handler {
         $r->print(&Apache::lonhtmlcommon::breadcrumbs          $r->print(&Apache::lonhtmlcommon::breadcrumbs
             ("What's New?",#'Course_Action_Items_Initialization'              ("What's New?",#'Course_Action_Items_Initialization'
      ));       ));
       } elsif ($command eq 'chgoldroleinterval' && $checkallowed{'oldroles'}) {
           &Apache::lonhtmlcommon::add_breadcrumb
               ({href=>'/adm/whatsnew?command=chgoldroleinterval&refpage='.$refpage,
                 text=>"Change interval"});
           $r->print(&Apache::lonhtmlcommon::breadcrumbs
               ("What's New?",#'Course_Action_Items_Intervals'
                ));
       } elsif ($command eq 'chgnewroleinterval' && $checkallowed{'newroles'}) {
           &Apache::lonhtmlcommon::add_breadcrumb
               ({href=>'/adm/whatsnew?command=chgnewroleinterval&refpage='.$refpage,
                 text=>"Change interval"});
           $r->print(&Apache::lonhtmlcommon::breadcrumbs
               ("What's New?",#'Course_Action_Items_Intervals'
                ));
     } else {      } else {
         $r->print(&Apache::lonhtmlcommon::breadcrumbs          $r->print(&Apache::lonhtmlcommon::breadcrumbs
             ("What's New?",#'Course_Action_Items_Display'              ("What's New?",#'Course_Action_Items_Display'
Line 152  sub display_main_box { Line 169  sub display_main_box {
                          degdiff => 'Degree of difficulty',                           degdiff => 'Degree of difficulty',
                          numstudents => 'Total number of students with submissions',                           numstudents => 'Total number of students with submissions',
     );      );
       my %versions = (
     my %interval_titles = &Apache::lonlocal::texthash (                         -1 => "version changes since start of $lctype",
                             -1 => "since start of $lctype",                    2592000 => 'version changes since last month',
                        2592000 => 'since last month',                     604800 => 'version changes since last week',
                         604800 => 'since last week',                      86400 => 'version changes since yesterday',
                          86400 => 'since yesterday',                     );
       my %newroles = (
                          -1 => "roles which have become active since start of $lctype",
                     2592000 => 'roles which have become active since last month',
                      604800 => 'roles which have become active since last week',
                       86400 => 'roles which have become active since yesterday',
                      );
       my %oldroles = (
                          -1 => "roles which expired since start of $lctype",
                     2592000 => 'roles which expired since last month',
                      604800 => 'roles which expired since last week',
                       86400 => 'roles which expired since yesterday',
                      );
       my %interval_titles = (
           versions => \%versions,
           newroles => \%newroles,
           oldroles => \%oldroles,
     );      );
   
     my %initpage = &Apache::lonlocal::texthash (      my %initpage = &Apache::lonlocal::texthash (
                      firstres => "first resource in the $lctype",                       firstres => "first resource in the $lctype",
                      whatsnew => "what's new? page",                       whatsnew => "what's new? page",
Line 175  sub display_main_box { Line 207  sub display_main_box {
                                                                    $cdom,$crs);                                                                     $cdom,$crs);
     } elsif (($command eq 'chginterval')       } elsif (($command eq 'chginterval') 
      && $checkallowed->{'versionchanges'}) {       && $checkallowed->{'versionchanges'}) {
         &display_interval_config($r,$refpage,\%interval_titles);          &display_interval_config($r,$refpage,\%interval_titles,'versions');
     } elsif (($command eq 'chgdisc')       } elsif (($command eq 'chgdisc') 
      && $checkallowed->{'coursediscussion'}) {       && $checkallowed->{'coursediscussion'}) {
         &display_discussion_config($r,$refpage);          &display_discussion_config($r,$refpage);
     } elsif ($command eq 'courseinit') {      } elsif ($command eq 'courseinit') {
         &courseinit_config($r,$refpage,\%initpage);          &courseinit_config($r,$refpage,\%initpage);
       } elsif (($command eq 'chgnewroleinterval')
                && $checkallowed->{'newroles'}) {
           &display_interval_config($r,$refpage,\%interval_titles,'newroles');
       } elsif (($command eq 'chgoldroleinterval')
                && $checkallowed->{'oldroles'}) {
           &display_interval_config($r,$refpage,\%interval_titles,'oldroles');
     } else {      } else {
         &display_actions_box($r,$command,$refpage,\%threshold_titles,          &display_actions_box($r,$command,$refpage,\%threshold_titles,
                         \%interval_titles,\%initpage,$cdom,$crs,$checkallowed);                          \%interval_titles,\%initpage,$cdom,$crs,$checkallowed);
Line 205  sub display_header { Line 243  sub display_header {
     my ($command,$checkallowed) = @_;      my ($command,$checkallowed) = @_;
           
     my $scripttag;      my $scripttag;
     unless ($command eq 'chgthreshold' || $command eq 'chginterval') {      unless ($command eq 'chgthreshold' || $command eq 'chginterval' || 
               $command eq 'chgoldroleinterval' || $command eq 'chgnewroleinterval') {
        $scripttag = <<"END";         $scripttag = <<"END";
 <script type="text/javascript">  <script type="text/javascript">
 function change_display(caller,change) {  function change_display(caller,change) {
     caller.value = change;      caller.value = change;
     document.visible.submit();       document.visible.submit();
 }  }
   
 function changeAll(change) {  function changeAll(change) {
Line 271  sub display_actions_box { Line 310  sub display_actions_box {
     my @warnings = ();      my @warnings = ();
     my $msgcount = 0;      my $msgcount = 0;
     my $critmsgcount = 0;      my $critmsgcount = 0;
       my $expirecount;
       my %expired;
       my $activecount;
       my %activated;
     my %res_title = ();      my %res_title = ();
     my %show = ();      my %show = ();
     my $needitems = 0;      my $needitems = 0;
Line 308  sub display_actions_box { Line 350  sub display_actions_box {
                   '</a></span><br />');                    '</a></span><br />');
         }          }
     }      }
     $r->print(&mt('Page set to be displayed after you have selected a role in this '.$lctype).      $r->print(&mt('Page set to be displayed after you have selected a role in this '.$lctype).'.'
               '. <span class="LC_nobreak">'.&mt('Currently: <i>[_1]</i>',$currinit).'.&nbsp;&nbsp;'.                .' <span class="LC_nobreak">'
               &mt('<b>Change</b> for just <a href="/adm/whatsnew?command=courseinit&amp;refpage=[_1]">this '.$lctype.'</a>',$refpage).' '.                .&mt('Currently: [_1].','<i>'.$currinit.'</i>')
               &mt('or for all <a href="/adm/preferences?action=changecourseinit&amp;refpage=[_1]">your courses</a>.',$refpage).'</span><br /><hr />');                .'&nbsp;&nbsp;'
                 .&mt('[_1]Change[_2] for just [_3]this course[_4] or for all [_5]your courses[_6].'
                     ,'<b>'
                     ,'</b>'
                     ,'<a href="/adm/whatsnew?command=courseinit&amp;refpage='.$refpage.'">'
                     ,'</a>'
                     ,'<a href="/adm/preferences?action=changecourseinit&amp;refpage='.$refpage.'">'
                     ,'</a>')
                 .' </span><br /><hr />');
   
     if ($command eq 'reset') {      if ($command eq 'reset') {
         $result = &process_reset($cdom,$crs);          $result = &process_reset($cdom,$crs);
Line 337  sub display_actions_box { Line 387  sub display_actions_box {
     }      }
     $r->rflush();      $r->rflush();
   
       my (%timediff,%interval);
     my %display_settings = &get_display_settings($uname,$udom,$cid);      my %display_settings = &get_display_settings($uname,$udom,$cid);
     my $timediff = $display_settings{$cid.':interval'};      $timediff{'versions'} = $display_settings{$cid.':interval'};
     unless (defined($timediff)) { $timediff = 604800; }       unless (defined($timediff{'versions'})) { $timediff{'versions'} = 604800; } 
     my $now = time;      $interval{'versions'} = $interval_titles->{'versions'}->{$timediff{'versions'}};
     my $interval = $$interval_titles{$timediff};  
     if ($timediff == -1) {  
         $timediff = time;  
     }   
     my $starttime = $now - $timediff;  
     my $countunread = $display_settings{$cid.':countunread'};  
     unless (defined($countunread)) {  
         $countunread = 'on';  
     }  
   
     my %headings = &Apache::lonlocal::texthash(      my %headings = &Apache::lonlocal::texthash(
                 coursediscussion =>  'Unread '.$lctype.' discussion posts',                  coursediscussion => 'Unread '.$lctype.' discussion posts',
                 handgrading =>  'Problems requiring handgrading',                  handgrading      => 'Problems requiring handgrading',
                 haserrors => 'Problems with errors',                  haserrors        => 'Problems with errors',
                 versionchanges => 'Resources in '.$lctype.' with version changes '.$interval,  
                 coursenormalmail => 'New '.$lctype.' messages',                  coursenormalmail => 'New '.$lctype.' messages',
                 coursecritmail => 'New critical messages in '.$lctype,                  coursecritmail   => 'New critical messages in '.$lctype,
     );      );
   
       if ($timediff{'versions'} == -1) {
           $headings{'versionchanges'} = &mt('Resources in '.$lctype.' with version changes since start of '.$lctype);
       } elsif ($timediff{'versions'} == 2592000) {
           $headings{'versionchanges'} = &mt('Resources in '.$lctype.' with version changes since last month');
       } elsif ($timediff{'versions'} == 604800) {
           $headings{'versionchanges'} = &mt('Resources in '.$lctype.' with version changes since last week');
       } elsif ($timediff{'versions'} == 86400) {
           $headings{'versionchanges'} = &mt('Resources in '.$lctype.' with version changes since yesterday');
       }
   
       $timediff{'oldroles'} = $display_settings{$cid.':oldroleinterval'};
       unless (defined($timediff{'oldroles'})) { $timediff{'oldroles'} = 604800; }
       $interval{'oldroles'} = $interval_titles->{'oldroles'}->{$timediff{'oldroles'}};
   
       if ($timediff{'oldroles'} == -1) {
           $headings{'oldroles'} = &mt('Roles for which access to '.$lctype.' has expired since start of '.$lctype);
       } elsif ($timediff{'oldroles'} == 2592000) {
           $headings{'oldroles'} = &mt('Roles for which access to '.$lctype.' has expired since last month');
       } elsif ($timediff{'oldroles'} == 604800) {
           $headings{'oldroles'} = &mt('Roles for which access to '.$lctype.' has expired since last week');
       } elsif ($timediff{'oldroles'} == 86400) {
           $headings{'oldroles'} = &mt('Roles for which access to '.$lctype.' has expired since yesterday');
       }
   
       $timediff{'newroles'} = $display_settings{$cid.':newroleinterval'};
       unless (defined($timediff{'newroles'})) { $timediff{'newroles'} = 604800; }
       $interval{'newroles'} = $interval_titles->{'newroles'}->{$timediff{'newroles'}};
   
       if ($timediff{'newroles'} == -1) {
           $headings{'newroles'} = &mt('Roles for which access to '.$lctype.' has become available since start of '.$lctype);
       } elsif ($timediff{'newroles'} == 2592000) {
           $headings{'newroles'} = &mt('Roles for which access to '.$lctype.' has become available since last month');
       } elsif ($timediff{'newroles'} == 604800) {
           $headings{'newroles'} = &mt('Roles for which access to '.$lctype.' has become available since last week');
       } elsif ($timediff{'newroles'} == 86400) {
           $headings{'newroles'} = &mt('Roles for which access to '.$lctype.' has become available since yesterday');
       }
   
       my $now = time;
       if ($timediff{'versions'} == -1) {
           $timediff{'versions'} = time;
       }
       my $starttime = $now - $timediff{'versions'};
   
       if ($timediff{'newroles'} == -1) {
           $timediff{'newroles'} = time;
       }
       my $activatedstart = $now - $timediff{'newroles'};
   
       if ($timediff{'oldroles'} == -1) {
           $timediff{'oldroles'} = time;
       }
       my $expiredstart = $now - $timediff{'oldroles'};
   
       my $countunread = $display_settings{$cid.':countunread'};
       unless (defined($countunread)) {
           $countunread = 'on';
       }
     if ($$checkallowed{'abovethreshold'}) {      if ($$checkallowed{'abovethreshold'}) {
         &get_curr_thresholds(\%threshold,$uname,$udom,$cid,$cdom,$crs);          &get_curr_thresholds(\%threshold,$uname,$udom,$cid,$cdom,$crs);
     }      }
   
     $headings{'abovethreshold'} =       $headings{'abovethreshold'} = 
  &mt('Problems with av. attempts &ge; [_1] or deg. difficulty &ge; [_2] <br /> and total number of '.$stulabel{$crstype}.' with submissions &ge; [_3]',   &mt('(Problems with av. attempts &ge; [_1] or deg. difficulty &ge; [_2]) [_3] and total number of '.$stulabel{$crstype}.' with submissions &ge; [_4]',
     $threshold{'av_attempts'},$threshold{'degdiff'},      $threshold{'av_attempts'},$threshold{'degdiff'},
     $threshold{'numstudents'});      '<br />',$threshold{'numstudents'});
   
     my @actionorder = ('handgrading','haserrors','abovethreshold','versionchanges','coursediscussion','coursenormalmail','coursecritmail');      my @actionorder = ('handgrading','haserrors','abovethreshold','versionchanges','coursediscussion','coursenormalmail','coursecritmail','newroles','oldroles');
   
     foreach my $key (keys(%{$checkallowed})) {      foreach my $key (keys(%{$checkallowed})) {
  if ($key =~ /_section$/) { next; }   if ($key =~ /_section$/) { next; }
Line 383  sub display_actions_box { Line 481  sub display_actions_box {
     }      }
   
     foreach my $item (@actionorder) {      foreach my $item (@actionorder) {
         unless ($item eq 'coursenormalmail' || $item eq 'coursecritmail') {          unless ($item eq 'coursenormalmail' || $item eq 'coursecritmail' ||
                   $item eq 'newroles' || $item eq 'oldroles') {
             if ($show{$item}) {              if ($show{$item}) {
                 $needitems = 1;                  $needitems = 1;
                 last;                  last;
Line 400  sub display_actions_box { Line 499  sub display_actions_box {
     if ($show{'coursecritmail'}) {      if ($show{'coursecritmail'}) {
         $critmsgcount = &getcritmail(\@critmsgs);          $critmsgcount = &getcritmail(\@critmsgs);
     }      }
       if ($show{'oldroles'}) {
           $expirecount = &getexpired(\%expired,$expiredstart,'previous');
       }
       if ($show{'newroles'}) {
           $activecount = &getactivated(\%activated,$activatedstart,'active');
       }
     $r->print(qq|<a href="javascript:changeAll('hide');">$lt{'hial'}</a>      $r->print(qq|<a href="javascript:changeAll('hide');">$lt{'hial'}</a>
      &nbsp;&nbsp;<a href="javascript:changeAll('show');">$lt{'shal'}</a>       &nbsp;&nbsp;<a href="javascript:changeAll('show');">$lt{'shal'}</a>
      <form method="post" name="visible" action="/adm/whatsnew">\n|);       <form method="post" name="visible" action="/adm/whatsnew">\n|);
Line 422  sub display_actions_box { Line 526  sub display_actions_box {
             $totalboxes ++;              $totalboxes ++;
         }          }
     }      }
     my $halfway = int($totalboxes/2) + $totalboxes%2;      my $halfway = 4;
   #    my $halfway = int($totalboxes/2) + $totalboxes%2;
     foreach my $actionitem (@actionorder) {      foreach my $actionitem (@actionorder) {
         if ($$checkallowed{$actionitem}) {          if ($$checkallowed{$actionitem}) {
             if ($displayed == $halfway) {              if ($displayed == $halfway) {
                 $r->print('</td><td>&nbsp;</td><td class="LC_right_col" >');                  $r->print('</td><td>&nbsp;</td><td class="LC_right_col" >');
             }              }
             &display_launcher($r,$actionitem,$refpage,$checkallowed,\%show,\%headings,\%res_title,\@tograde,\%ungraded,\@bombs,\%bombed,\%changed,\@warnings,\%triggered,\@newdiscussions,\%unread,$msgcount,\@newmsgs,$critmsgcount,\@critmsgs,$interval,$countunread);              &display_launcher($r,$actionitem,$refpage,$checkallowed,\%show,\%headings,\%res_title,\@tograde,\%ungraded,\@bombs,\%bombed,\%changed,\@warnings,\%triggered,\@newdiscussions,\%unread,$msgcount,\@newmsgs,$critmsgcount,\@critmsgs,\%interval,$countunread,\%expired,$expirecount,\%activated,$activecount,$crstype);
             $displayed ++;               $displayed ++; 
         }          }
     }      }
Line 488  sub display_threshold_config { Line 593  sub display_threshold_config {
                  &Apache::loncommon::end_data_table_row());                   &Apache::loncommon::end_data_table_row());
     }      }
     $r->print(&Apache::loncommon::end_data_table()."\n".      $r->print(&Apache::loncommon::end_data_table()."\n".
           '<br /><input type="submit" name="threshold" value="Make changes" />            '<br /><input type="submit" name="threshold" value="'.&mt('Make changes').'" />
                  <input type="hidden" name="command" value="update" />                   <input type="hidden" name="command" value="update" />
                  <input type="hidden" name="refpage" value="'.$refpage.'" />                   <input type="hidden" name="refpage" value="'.$refpage.'" />
                </form>');                 </form>');
Line 502  sub display_threshold_config { Line 607  sub display_threshold_config {
 #-------------------------------  #-------------------------------
                                                                                                                                                                         
 sub display_interval_config {  sub display_interval_config {
     my ($r,$refpage,$interval_titles) = @_;      my ($r,$refpage,$interval_titles,$context) = @_;
       my $setting = 'interval';
       if ($context eq 'oldroles') {
           $setting = 'oldroleinterval';
       } elsif ($context eq 'newroles') {
           $setting = 'newroleinterval'; 
       }
     my $lctype = lc(&Apache::loncommon::course_type());      my $lctype = lc(&Apache::loncommon::course_type());
     my $current = &get_current($env{'user.name'},$env{'user.domain'},      my $current = &get_current($env{'user.name'},$env{'user.domain'},
                                 $env{'request.course.id'},'interval');                                  $env{'request.course.id'},$setting);
     $r->print('<br />'.&mt('Choose the time window to use for display of version changes for resources in the '.$lctype.'.'));      if ($context eq 'oldroles') {
           $r->print('<br />'.&mt('Choose the time window to use to display roles for which access to the '.$lctype.' expired.').'<br />');
       } elsif ($context eq 'newroles') {
           $r->print('<br />'.&mt('Choose the time window to use to display roles for which access to the '.$lctype.' became available.').'<br />');
       } else {
           $r->print('<br />'.&mt('Choose the time window to use to display resources in the '.$lctype.' with version changes.').'<br />');
       }
     unless ($current eq '') {      unless ($current eq '') {
         $r->print(' '.&mt('Current value is [_1]','<b>'.          if (ref($interval_titles->{$context}) eq 'HASH') {
                   $$interval_titles{$current}.'</b>.'));              $r->print(' '.&mt('Current value is "[_1]".','<b>'.
                         $interval_titles->{$context}->{$current}.'</b>').'<br />');
           }
     }      }
     $r->print('<br /><br />      $r->print('<br />
 <form method="post" name="intervalswitch" action="/adm/whatsnew">  <form method="post" name="intervalswitch" action="/adm/whatsnew">
 <input type="hidden" name="command" value="newinterval" />  <input type="hidden" name="command" value="newinterval" />
 <input type="hidden" name="refpage" value="'.$refpage.'" />  <input type="hidden" name="intervaltype" value="'.$context.'" />
   <input type="hidden" name="refpage" value="'.$refpage.'" />'.
   &mt('Display:').' 
 <select name="interval">  <select name="interval">
   <option value="" selected="selected">'.&mt('Select').'</option>
 ');  ');
     foreach my $key (reverse sort ({$a cmp $b} (keys(%{$interval_titles})))) {      if (ref($interval_titles) eq 'HASH') {
         $r->print('<option value="'.$key.'">'.&mt('Version changes').' '.$$interval_titles{$key}.          if (ref($interval_titles->{$context}) eq 'HASH') {
                   '</option>'."\n");              foreach my $key (reverse sort ({$a cmp $b} (keys(%{$interval_titles->{$context}})))) {
                   $r->print('<option value="'.$key.'">'.&mt($interval_titles->{$context}->{$key}).
                             '</option>'."\n");
               }
           }
     }      }
     $r->print('</select>&nbsp;&nbsp;      $r->print('</select>&nbsp;&nbsp;
                <input type="submit" name="display" value="'.                 <input type="submit" name="display" value="'.
Line 553  function toggle_countunread(choice) { Line 679  function toggle_countunread(choice) {
     document.discussionswitch.submit();      document.discussionswitch.submit();
 }  }
 </script>');  </script>');
     $r->print('<br />'.&mt('Choose whether or not to display a count of the number of new posts for each resource or bulletin board which has unread posts.').'<br />'.&mt("This can increase the time taken to gather data for the '<i>What's New?</i>' page by a few seconds.").'&nbsp;&nbsp;'.&mt("Currently set to <b>$current</b>."));      $r->print('<br />'
                .&mt('Choose whether or not to display a count of the number of new posts for each resource or bulletin board which has unread posts.')
                .'<br />'
                .&mt("This can increase the time taken to gather data for the '<i>What's New?</i>' page by a few seconds.")
                .'&nbsp;&nbsp;'
                .&mt('Currently set to [_1].','<b>'.$current.'</b>.')
       );
     $r->print('<br /><br />      $r->print('<br /><br />
 <form method="post" name="discussionswitch" action="/adm/whatsnew">  <form method="post" name="discussionswitch" action="/adm/whatsnew">
 <input type="hidden" name="command" value="newdiscconf" />  <input type="hidden" name="command" value="newdiscconf" />
Line 562  function toggle_countunread(choice) { Line 694  function toggle_countunread(choice) {
 ');  ');
     $r->print('<br/>      $r->print('<br/>
                <input type="button" name="display" value="'.                 <input type="button" name="display" value="'.
                &mt('Change to [_1]',$opposite{$current}).'"                  &mt('Change to [_1]',&mt($opposite{$current})).'" 
                onclick="javascript:toggle_countunread('."'change'".')" />                 onclick="javascript:toggle_countunread('."'change'".')" />'.
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp;                 ('&nbsp;' x7).
                <input type="button" name="nochange" value="'.                 '<input type="button" name="nochange" value="'.
                &mt("No change").'"                  &mt("No change").'" 
                onclick="javascript:toggle_countunread('."'unchanged'".')" />                 onclick="javascript:toggle_countunread('."'unchanged'".')" />
                </form>');                 </form>');
Line 653  sub display_launcher { Line 785  sub display_launcher {
     my ($r,$action,$refpage,$checkallowed,$show,$headings,$res_title,      my ($r,$action,$refpage,$checkallowed,$show,$headings,$res_title,
         $tograde,$ungraded,$bombs,$bombed,$changed,$warnings,$triggered,          $tograde,$ungraded,$bombs,$bombed,$changed,$warnings,$triggered,
         $newdiscussions,$unread,$msgcount,$newmsgs,$critmsgcount,$critmsgs,          $newdiscussions,$unread,$msgcount,$newmsgs,$critmsgcount,$critmsgs,
         $interval,$countunread) = @_;          $interval,$countunread,$expired,$expirecount,$activated,$activecount,
           $crstype) = @_;
   
     if ($$checkallowed{$action}) {      if ($$checkallowed{$action}) {
         &start_box($r,$show,$headings,$action,$refpage,$action);          &start_box($r,$show,$headings,$action,$refpage,$action);
Line 663  sub display_launcher { Line 796  sub display_launcher {
             } elsif ($action eq 'haserrors') { # BOMBS              } elsif ($action eq 'haserrors') { # BOMBS
                 &display_haserrors($r,$bombs,$bombed,$res_title);                  &display_haserrors($r,$bombs,$bombed,$res_title);
             } elsif ($action eq 'versionchanges') { # VERSION CHANGES              } elsif ($action eq 'versionchanges') { # VERSION CHANGES
                 &display_versionchanges($r,$changed,$res_title,$interval);                  &display_versionchanges($r,$changed,$res_title,$interval->{'versions'});
             } elsif ($action eq 'abovethreshold') { # DEGDIFF/AV. TRIES TRIGGERS              } elsif ($action eq 'abovethreshold') { # DEGDIFF/AV. TRIES TRIGGERS
                 &display_abovethreshold($r,$refpage,$warnings,$triggered,                  &display_abovethreshold($r,$refpage,$warnings,$triggered,
  $res_title);   $res_title);
Line 674  sub display_launcher { Line 807  sub display_launcher {
                 &display_coursenormalmail($r,$msgcount,$newmsgs);                  &display_coursenormalmail($r,$msgcount,$newmsgs);
             } elsif ($action eq 'coursecritmail') { # CRITICAL MESSAGES              } elsif ($action eq 'coursecritmail') { # CRITICAL MESSAGES
                 &display_coursecritmail($r,$critmsgcount,$critmsgs);                  &display_coursecritmail($r,$critmsgcount,$critmsgs);
               } elsif ($action eq 'newroles') { # ACTIVATED ROLES
                   &display_rolechanges($r,$activecount,$activated,$interval->{'newroles'},
                                        $crstype);
               } elsif ($action eq 'oldroles') { # EXPIRED ROLES
                   &display_rolechanges($r,$expirecount,$expired,$interval->{'oldroles'},
                                        $crstype);
             }              }
         }          }
         &end_box($r);          &end_box($r);
Line 866  sub check_thresholds { Line 1005  sub check_thresholds {
                 my $resettitle = 'title_'.&escape($symb."\0".$part);                  my $resettitle = 'title_'.&escape($symb."\0".$part);
                 if (@parts > 1) {                  if (@parts > 1) {
                     $$triggered{$symb}{text}[$partcount] = '                      $$triggered{$symb}{text}[$partcount] = '
                      <td>part - '.$part.'</td>';                       <td>'.&mt('part - ').$part.'</td>';
                 } else {                  } else {
                     $$triggered{$symb}{text}[$partcount] = '                      $$triggered{$symb}{text}[$partcount] = '
                      <td>single part</td>';                       <td>'.&mt('single part').'</td>';
                 }                  }
                 $$triggered{$symb}{text}[$partcount] .= '                  $$triggered{$symb}{text}[$partcount] .= '
                      <td>'.$stats{$part}{users}.'</td>                       <td>'.$stats{$part}{users}.'</td>
Line 979  sub process_reset { Line 1118  sub process_reset {
   
 sub process_update {  sub process_update {
     my ($uname,$udom,$threshold_titles) = @_;      my ($uname,$udom,$threshold_titles) = @_;
     my $setoutput = '<b>Changes to threshold(s) for problem tracking:</b><br />';      my $setoutput = '<b>'.&mt('Changes to threshold(s) for problem tracking:').'</b><br />';
     foreach (keys %env) {      foreach (keys %env) {
         next if ($_!~/^form\.(.+)\_setparmval$/);          next if ($_!~/^form\.(.+)\_setparmval$/);
         my $name  = $1;          my $name  = $1;
Line 1066  sub getcritmail { Line 1205  sub getcritmail {
     return $critmsgcount;      return $critmsgcount;
 }  }
   
   sub getexpired {
       my ($rolechgs,$rolechgtime,$status) = @_;
       my $expirecount = &getrolechanges($rolechgs,$rolechgtime,$status);
       return $expirecount;
   }
   
   sub getactivated {
       my ($rolechgs,$rolechgtime,$status) = @_;
       my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
       my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
       my $now = time();
       my $context = 'course';
       my ($permission,$allowed) =
           &Apache::lonuserutils::get_permission($context);
       my $viewablesec = &Apache::lonuserutils::viewable_section($permission);
       my %changes=&Apache::lonnet::dump('nohist_rolelog',$cdom,$cnum);
       my (%stucounted,%advcounted);
       my $activatedcount = 0;
       if (keys(%changes) > 0) {
           foreach my $chg (sort { $b <=> $a } (keys(%changes))) {
               if (ref($changes{$chg}) eq 'HASH') {
                   my $timestamp = $changes{$chg}{'exe_time'};
                   if ($timestamp) {
                       if ($rolechgtime > 0) {
                           if ($timestamp < $rolechgtime) {
                               last;
                           }
                       }
                       if (ref($changes{$chg}{'logentry'}) eq 'HASH') {
                           next if ($changes{$chg}{'delflag'});
                           my $start = $changes{$chg}{'logentry'}{'start'};
                           my $end = $changes{$chg}{'logentry'}{'end'};
                           my $section = $changes{$chg}{'logentry'}{'section'};
                           my $role = $changes{$chg}{'logentry'}{'role'};
                           my $uname = $changes{$chg}{'uname'};
                           my $udom = $changes{$chg}{'udom'};
                           next if ($end && $end <= $now);
                           if (($viewablesec ne '') && ($section ne '')) {
                               next if ($viewablesec ne $section);
                           }
                           next if ($start >= $timestamp);
                           if ($role eq 'st') {
                               $stucounted{$uname.':'.$udom.':'.$section} = $start.':'.$end;
                           } else {
                               $advcounted{$uname.':'.$udom.':'.$role.':'.$section} = $start.':'.$end;
                           }
                           my %chginfo = (
                                          'section' => $section,
                                          'uname'   => $uname,
                                          'udom'    => $udom,
                                          'role'    => $role,
                                          'status'  => $status,
                           );
                           $activatedcount ++;
                           push (@{$rolechgs->{$timestamp}},\%chginfo);
                       }
                   }
               }
           }
       }
       $activatedcount += &getrolechanges($rolechgs,$rolechgtime,$status,\%stucounted,\%advcounted);
       return $activatedcount;
   }
   
   sub getrolechanges {
       my ($rolechgs,$rolechgtime,$status,$stucountref,$advcountref) = @_;
       my (%stucounted,%advcounted);
       if (ref($stucountref) eq 'HASH') {
           %stucounted = %{$stucountref};
       }
       if (ref($advcountref) eq 'HASH') {
           %advcounted = %{$advcountref};
       }
       my $withsec = 1;
       my $hidepriv = 1;
       my $context = 'course';
       my @statuses = ($status);
       my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
       my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
       my $now = time();
       my ($permission,$allowed) =
           &Apache::lonuserutils::get_permission($context);
       my $viewablesec = &Apache::lonuserutils::viewable_section($permission);
       my $classlist = &Apache::loncoursedata::get_classlist();
       my $secidx = &Apache::loncoursedata::CL_SECTION();
       my $startidx = &Apache::loncoursedata::CL_START();
       my $endidx = &Apache::loncoursedata::CL_END();
       my $rolechgcount = 0;
       foreach my $key (keys(%{$classlist})) {
           my ($userstatus,$eventtime);   
           my $student = $classlist->{$key};
           if (ref($student) eq 'ARRAY') {
               my $start = $student->[$startidx];
               my $end = $student->[$endidx];
               my $sec = $student->[$secidx]; 
               my ($stuname,$studom) = split(/:/,$key);
               if ($status eq 'active') {
                   if (exists($stucounted{$key.':'.$sec})) {
                       next;
                   }
               }
               if (($end == 0) || ($end > $start)) {
                   if ($start <= $now) {
                       if ($end && $end < $now) {
                           if ($rolechgtime > 0) {
                               if ($end > $rolechgtime) {
                                   $userstatus = 'previous';
                               }
                           } else {
                               $userstatus = 'previous';
                           }
                       } else {
                           if ($rolechgtime > 0) {
                               if ($start >= $rolechgtime) {
                                   $userstatus = 'active';
                               }
                           } else {
                               $userstatus = 'active';
                           }
                       }
                   }
               }
               next if ($userstatus ne $status);
               if ($status eq 'active') {
                   $eventtime = $start;
               } else {
                   $eventtime = $end;
               }
               if (($viewablesec ne '') && ($sec ne '')) {
                   next if ($viewablesec ne $sec);
               }
               my %chginfo = (
                               'section' => $sec,
                               'uname'   => $stuname,
                               'udom'    => $studom,
                               'role'    => 'st', 
                               'status'  => $userstatus,
                             );
               $rolechgcount ++;
               push (@{$rolechgs->{$eventtime}},\%chginfo);
           }
       }
       my %advrolehash = &Apache::lonnet::get_my_roles($cnum,$cdom,undef,
                                 \@statuses,undef,undef,$withsec,$hidepriv);
       foreach my $item (keys(%advrolehash)) {
           my ($userstatus,$eventtime);
           my ($uname,$udom,$role,$section) = split(/:/,$item,-1);
           my ($start,$end) = split(/:/,$advrolehash{$item});
           if ($start eq '-1' && $end eq '-1') {
               next;
           } else {
               if ($status eq 'active') {
                   if (exists($advcounted{$item})) {
                       next;
                   }
               }
               if (($end == 0) || ($end > $start)) {
                   if ($start <= $now) {
                       if ($end && $end < $now) {
                           if ($rolechgtime > 0) {
                               if ($end > $rolechgtime) {
                                   $userstatus = 'previous';
                               }
                           } else {
                               $userstatus = 'previous';
                           }
                       } else {
                           if ($rolechgtime > 0) {
                               if ($start >= $rolechgtime) {
                                   $userstatus = 'active';
                               }
                           } else {
                               $userstatus = 'active';
                           }
                       }
                   }
               }
               next if ($userstatus ne $status);
               if ($status eq 'active') {
                   $eventtime = $start;
               } else {
                   $eventtime = $end;
               }
           }
           if (($viewablesec ne '') && ($section ne '')) {
               next if ($viewablesec ne $section);
           }
           my %chginfo = ( 
                           'section' => $section,
                           'uname'   => $uname,
                           'udom'    => $udom,
                           'role'    => $role,
                           'status'  => $userstatus,    
                         );
           $rolechgcount ++; 
           push (@{$rolechgs->{$eventtime}},\%chginfo); 
       }
       return $rolechgcount;
   }
   
 sub checkversions {  sub checkversions {
     my ($cdom,$crs,$navmap,$changed,$starttime) = @_;      my ($cdom,$crs,$navmap,$changed,$starttime) = @_;
Line 1231  sub display_versionchanges { Line 1569  sub display_versionchanges {
         'revd' => 'Last revised',          'revd' => 'Last revised',
         'newv' => 'New version',          'newv' => 'New version',
         'veru' => 'Version used',          'veru' => 'Version used',
         'noup' => 'No updated versions',   
     );      );
     if (keys(%{$changed}) > 0) {      if (keys(%{$changed}) > 0) {
         $r->print('<tr class="LC_info_row"><td class="LC_left_item">'.          $r->print('<tr class="LC_info_row"><td class="LC_left_item">'.
Line 1254  sub display_versionchanges { Line 1591  sub display_versionchanges {
                       $$changed{$item}{'version'}.'</td></tr>');                        $$changed{$item}{'version'}.'</td></tr>');
         }          }
     } else {      } else {
         $r->print('<tr class="LC_empty_row"><td>'.$lt{'noup'}.          $r->print('<tr class="LC_empty_row"><td>'
                   ' '.$interval.'</td></tr>');                   .&mt('No '.$interval).'</td></tr>');
       }
       return;
   }
   
   sub display_rolechanges {
       my ($r,$chgcount,$changed,$interval,$crstype) = @_;
       my $now = time();
       my %lt = &Apache::lonlocal::texthash(
           'user'  => 'User',
           'tich'  => 'Time of change',
           'role'  => 'Role',
           'sec'   => 'Section',
           'status'  => 'Status',
       );
       if ($chgcount) {
           $r->print('<tr class="LC_info_row">'.
                     '<td class="LC_left_item">'.$lt{'tich'}.'</td>'.
                     '<td class="LC_left_item">'.$lt{'user'}.'</td>'.
                     '<td class="LC_left_item">'.$lt{'role'}.'</td>'.
                     '<td class="LC_left_item">'.$lt{'sec'}.'</td>'.
                     '<td class="LC_left_item">'.$lt{'status'}.'</td></tr>');
           if (ref($changed) eq 'HASH') {
               my @changes = sort { $b <=> $a } (keys(%{$changed}));
               my $changenum = 0;
               foreach my $item (@changes) {
                   if (ref($changed->{$item}) eq 'ARRAY') {
                       foreach my $chg (@{$changed->{$item}}) {
                           if (ref($chg) eq 'HASH') {
                               my $section;
                               my $role = 
                                   &Apache::lonnet::plaintext($chg->{'role'},$crstype);
                               my $status = &mt($chg->{'status'});
                               if ($chg->{'section'} eq '') {
                                   $section = &mt('none');
                               } else {
                                   $section = $chg->{'section'};
                               }
                               my $uname = $chg->{'uname'};
                               my $udom = $chg->{'udom'};
                               $changenum ++;
                               my $css_class = $changenum%2?' class="LC_odd_row"':'';
                               my $link = 
                                   &Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($uname,$udom),$uname,$udom);
                               $r->print('<tr'.$css_class.'>'.
                                         '<td>'.&Apache::lonlocal::locallocaltime($item).'</td>'.
                                         '<td>'.$link.'</td>'.
                                         '<td>'.$role.'</td>'.
                                         '<td>'.$section.'</td>'.
                                         '<td>'.$status.'</td></tr>');
                           }
                       }
                   }
               }
           }
       } else {
           $r->print('<tr class="LC_empty_row"><td>'
                    .&mt('There are no '.$interval).'</td></tr>');
     }      }
     return;      return;
 }  }
Line 1326  sub display_coursenormalmail { Line 1720  sub display_coursenormalmail {
         foreach my $msg (@{$newmsgs}) {          foreach my $msg (@{$newmsgs}) {
             $mailcount ++;              $mailcount ++;
             my $css_class = $mailcount%2?' class="LC_odd_row"':'';              my $css_class = $mailcount%2?' class="LC_odd_row"':'';
             $r->print('<tr'.$css_class.'><td>'.$mailcount.              $r->print('<tr'.$css_class.'><td>'.$mailcount
                       '. &nbsp;</td><td><a href="/adm/communicate">'.                        .'.&nbsp;</td><td><a href="/adm/email?display='
                       $msg->{'shortsub'}.'</a>&nbsp; &nbsp;</td><td>&nbsp;'.                        .$msg->{'msgid'}.'">'
                       $msg->{'from'}.':'.$msg->{'fromdom'}.'&nbsp;</td><td>'.                        .$msg->{'shortsub'}.'</a>&nbsp;&nbsp;</td><td>&nbsp;'
                       $msg->{'sendtime'}.'</td></tr>');                        .$msg->{'from'}.':'.$msg->{'fromdom'}.'&nbsp;</td><td>'
                         .$msg->{'sendtime'}.'</td></tr>');
         }          }
     } else {      } else {
         $r->print('<tr class="LC_empty_row"><td>'.          $r->print('<tr class="LC_empty_row"><td>'.
Line 1411  sub store_interval_setting { Line 1806  sub store_interval_setting {
     my ($uname,$udom,$cid,$interval_titles) = @_;      my ($uname,$udom,$cid,$interval_titles) = @_;
     my %interval_settings = ();      my %interval_settings = ();
     my $result;      my $result;
     if (defined($env{'form.interval'})) {      my $context = $env{'form.intervaltype'};
         $interval_settings{$cid.':interval'} = $env{'form.interval'};      if ($env{'form.interval'} ne '') {
           if ($context eq 'oldroles') {
               $interval_settings{$cid.':oldroleinterval'} = $env{'form.interval'};
           } elsif ($context eq 'newroles') {
               $interval_settings{$cid.':newroleinterval'} = $env{'form.interval'};
           } else {
               $interval_settings{$cid.':interval'} = $env{'form.interval'};
           }
         my $outcome = &Apache::lonnet::put('nohist_whatsnew',          my $outcome = &Apache::lonnet::put('nohist_whatsnew',
                                              \%interval_settings,$udom,$uname);                                               \%interval_settings,$udom,$uname);
         if ($outcome eq 'ok') {          if ($outcome eq 'ok') {
             $result = &mt('Interval set to version changes [_1]',              if (ref($interval_titles->{$context}) eq 'HASH') {
                   '<b>'.$$interval_titles{$env{'form.interval'}}.'</b><br />');                  $result = &mt('New filter setting: [_1].','<b>'. 
                                 $interval_titles->{$context}->{$env{'form.interval'}}.'</b>').'<br />';
               }
         } else {          } else {
     my $lctype = lc(&Apache::loncommon::course_type());      my $lctype = lc(&Apache::loncommon::course_type());
             &Apache::lonnet::logthis('Error saving whatsnew interval setting'.              &Apache::lonnet::logthis('Error saving whatsnew '.$context.' interval setting'.
                 ' '.$outcome.' for '.$uname.':'.$udom.' in '.$lctype.' '.$cid);                  ' '.$outcome.' for '.$uname.':'.$udom.' in '.$lctype.' '.$cid);
             $result = &mt('Unable to set interval to [_1] due to [_2].',              $result = &mt('Unable to set interval to [_1] due to [_2].',
                          '<b>'.$$interval_titles{$env{'form.interval'}}.'</b>',                           '<b>'.$interval_titles->{$context}->{$env{'form.interval'}}.'</b>',
                          '<tt>'.$outcome.'</tt>.<br />');                           '<tt>'.$outcome.'</tt>.<br />');
         }          }
     }      }
Line 1441  sub store_discussion_setting { Line 1844  sub store_discussion_setting {
                                              \%discussion_settings,$udom,$uname);                                               \%discussion_settings,$udom,$uname);
         if ($outcome eq 'ok') {          if ($outcome eq 'ok') {
             $result = &mt('Count unread posts in discussions display set to [_1]',              $result = &mt('Count unread posts in discussions display set to [_1]',
                   '<b>'.$env{'form.countunread'}.'</b><br />');                    '<b>'.&mt($env{'form.countunread'}).'</b>').'<br />';
                                                                                                                                                                       
         } else {          } else {
     my $lctype = lc(&Apache::loncommon::course_type());      my $lctype = lc(&Apache::loncommon::course_type());
Line 1449  sub store_discussion_setting { Line 1852  sub store_discussion_setting {
                 ' '.$outcome.' for '.$uname.':'.$udom.' in '.$lctype.' '.$cid);                  ' '.$outcome.' for '.$uname.':'.$udom.' in '.$lctype.' '.$cid);
             $result = &mt('Unable to set "number unread posts display" to [_1]'.              $result = &mt('Unable to set "number unread posts display" to [_1]'.
                           ' due to [_2].',                            ' due to [_2].',
                          '<b>'.$env{'form.countunread'}.'</b>',                           '<b>'.&mt($env{'form.countunread'}).'</b>',
                          '<tt>'.$outcome.'</tt>.<br />');                           '<tt>'.$outcome.'</tt>.<br />');
         }          }
     }      }
Line 1478  sub store_courseinit_setting { Line 1881  sub store_courseinit_setting {
                                            \%courseinit_settings,$udom,$uname);                                             \%courseinit_settings,$udom,$uname);
             if ($outcome eq 'ok') {              if ($outcome eq 'ok') {
                 if ($page_control eq 'global preferences') {                  if ($page_control eq 'global preferences') {
                     $result = &mt("Page displayed after role selection in $lctype now set by <b>user's global preferences</b>.");                      $result = &mt("Page displayed after role selection in $lctype now set by [_1]user's global preferences[_2].",'<b>','</b>');
                 } else {                  } else {
                     $result = &mt('Page displayed after role selection in this '.$lctype.' set to <b>[_2]</b>',$lctype,$$initpage{$env{'form.courseinit_page'}});                      $result = &mt('Page displayed after role selection in this '.$lctype.' set to [_1].'
                                    ,'<b>'.$$initpage{$env{'form.courseinit_page'}}.'</b>');
                 }                  }
             } else {              } else {
                 &Apache::lonnet::logthis('Error saving whatsnew courseinit '.                  &Apache::lonnet::logthis('Error saving whatsnew courseinit '.
Line 1492  sub store_courseinit_setting { Line 1896  sub store_courseinit_setting {
                          '<b>'.$page_control.'</b>',                           '<b>'.$page_control.'</b>',
                          '<tt>'.$outcome.'</tt>.<br />');                           '<tt>'.$outcome.'</tt>.<br />');
                 } else {                  } else {
                     $result = &mt('Unable to set page display, after role selection, for this '.$lctype.' to <b>[_2]</b> due to <tt>[_3]</tt>.<br />',                      $result = &mt('Unable to set page display, after role selection, for this '.$lctype.' to [_1] due to [_2].'
                          $$initpage{$env{'form.courseinit_page'}},$outcome);                                   ,'<b>'.$$initpage{$env{'form.courseinit_page'}}.'</b>'
                                    ,'<tt>'.$outcome.'</tt>')
                                .'<br />';
                 }                  }
             }              }
         }          }
Line 1547  sub start_box { Line 1953  sub start_box {
                 <td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chgdisc&refpage='.$refpage.'">'.$lt{'chop'}.'</a></td>                  <td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chgdisc&refpage='.$refpage.'">'.$lt{'chop'}.'</a></td>
               </tr>');                </tr>');
          }           }
        } elsif (($caller eq 'newroles') && ($$show{$caller})) {
            if ($$show{$caller}) {
                $r->print('
                 <tr>
                   <td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chgnewroleinterval&refpage='.$refpage.'">'.$lt{'chin'}.'</a></td>
                 </tr>');
            }
        } elsif (($caller eq 'oldroles') && ($$show{$caller})) {
            if ($$show{$caller}) {
                $r->print('
                 <tr>
                   <td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chgoldroleinterval&refpage='.$refpage.'">'.$lt{'chin'}.'</a></td>
                 </tr>');
            }
      }       }
     $r->print('      $r->print('
               <tr>                <tr>

Removed from v.1.73  
changed lines
  Added in v.1.83


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