Diff for /loncom/interface/lonwhatsnew.pm between versions 1.35 and 1.36

version 1.35, 2005/12/05 19:27:53 version 1.36, 2005/12/06 16:37:28
Line 54  sub handler { Line 54  sub handler {
     }      }
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['command']);      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['command']);
   
     my $command;      my $command = $env{'form.command'};
     if ($env{'form.action'} eq 'reset') {  
         $command = 'reset';  
     } elsif ($env{'form.action'} eq 'update') {  
         $command = 'update';  
     } else {  
         $command = $env{'form.command'};  
     }  
   
     &Apache::loncommon::content_type($r,'text/html');      &Apache::loncommon::content_type($r,'text/html');
     $r->send_http_header;      $r->send_http_header;
     $r->print(&display_header($command));  
     if (! (($env{'request.course.fn'}) && (&Apache::lonnet::allowed('bre',$env{'request.course.id'})))) {      if (! (($env{'request.course.fn'}) && (&Apache::lonnet::allowed('bre',$env{'request.course.id'})))) {
         # Not in a course, or not allowed to view action items          # Not in a course, or not allowed to view action items
         $env{'user.error.msg'}="/adm/whatsnew:bre:0:0:Cannot display what's new screen";          $env{'user.error.msg'}="/adm/whatsnew:bre:0:0:Cannot display what's new screen";
         return HTTP_NOT_ACCEPTABLE;          return HTTP_NOT_ACCEPTABLE;
     }      }
   
       my %checkallowed = (
                coursediscussion => &Apache::lonnet::allowed('pch',$env{'request.course.id'}),
                handgrading => &Apache::lonnet::allowed('mgr',$env{'request.course.id'}),
                abovethreshold => &Apache::lonnet::allowed('vgr',$env{'request.course.id'}),
                haserrors => &Apache::lonnet::allowed('opa',$env{'request.course.id'}),
                versionchanges => &Apache::lonnet::allowed('opa',$env{'request.course.id'}),
                coursenormalmail => 1,
                coursecritmail => 1,
       );
   
       $r->print(&display_header($command,\%checkallowed));
   
     &Apache::lonhtmlcommon::clear_breadcrumbs();      &Apache::lonhtmlcommon::clear_breadcrumbs();
       &Apache::lonhtmlcommon::add_breadcrumb
               ({href=>'/adm/whatsnew',
                 text=>"Display Action Items"});
     if (($command eq 'chgthreshold') && (&Apache::lonnet::allowed('vgr',$env{'request.course.id'}))) {      if (($command eq 'chgthreshold') && (&Apache::lonnet::allowed('vgr',$env{'request.course.id'}))) {
         &Apache::lonhtmlcommon::add_breadcrumb          &Apache::lonhtmlcommon::add_breadcrumb
             ({href=>'/adm/whatsnew?command=threshold',              ({href=>'/adm/whatsnew?command=chgthreshold',
               text=>"Change thresholds"});                text=>"Change thresholds"});
         $r->print(&Apache::lonhtmlcommon::breadcrumbs          $r->print(&Apache::lonhtmlcommon::breadcrumbs
             (undef,'Course Action Items','Course_Action_Items_Thresholds'));              (undef,'Course Action Items','Course_Action_Items_Thresholds'));
     } else {      } elsif (($command eq 'chginterval') && (&Apache::lonnet::allowed('vgr',$env{'request.course.id'}))) {
         &Apache::lonhtmlcommon::add_breadcrumb          &Apache::lonhtmlcommon::add_breadcrumb
             ({href=>'/adm/whatsnew',              ({href=>'/adm/whatsnew?command=chginterval',
               text=>"Display Action Items"});                text=>"Change interval"});
           $r->print(&Apache::lonhtmlcommon::breadcrumbs
               (undef,'Course Action Items','Course_Action_Items_Intervals'));
       } else {
         $r->print(&Apache::lonhtmlcommon::breadcrumbs          $r->print(&Apache::lonhtmlcommon::breadcrumbs
             (undef,'Course Action Items','Course_Action_Items_Display'));              (undef,'Course Action Items','Course_Action_Items_Display'));
     }      }
     &display_main_box($r,$command);      &display_main_box($r,$command,\%checkallowed);
     return OK;      return OK;
 }  }
   
Line 97  sub handler { Line 107  sub handler {
 #------------------------------  #------------------------------
                                                                                                                                                                   
 sub display_main_box {  sub display_main_box {
     my ($r,$command) = @_;      my ($r,$command,$checkallowed) = @_;
     my $domain=&Apache::loncommon::determinedomain();      my $domain=&Apache::loncommon::determinedomain();
     my $tabbg=&Apache::loncommon::designparm('coordinator.tabbg',$domain);      my $tabbg=&Apache::loncommon::designparm('coordinator.tabbg',$domain);
     $r->print('<table width="100%" border="0" cellpadding="5" cellspacing="0"><tr><td width="100%">');      $r->print('<table width="100%" border="0" cellpadding="5" cellspacing="0"><tr><td width="100%">');
Line 107  sub display_main_box { Line 117  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 %interval_titles = (
                               -1 => 'since start of course',
                          2592000 => 'since last month',
                           604800 => 'since last week',
                            86400 => 'since yesterday',
       );
   
     my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};      my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
     my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};      my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
   
     if (($command eq 'chgthreshold') && (&Apache::lonnet::allowed('vgr',$env{'request.course.id'}))) {      if (($command eq 'chgthreshold') && 
         &display_config_box($r,$command,$tabbg,\%threshold_titles,$cdom,$crs);                 (&Apache::lonnet::allowed('vgr',$env{'request.course.id'}))) {
           &display_threshold_config($r,$command,$tabbg,\%threshold_titles,
                                                                      $cdom,$crs);
       } elsif (($command eq 'chginterval') && 
                  (&Apache::lonnet::allowed('opa',$env{'request.course.id'}))) {
           &display_interval_config($r,\%interval_titles);
     } else {      } else {
         &display_actions_box($r,$command,\%threshold_titles,$cdom,$crs);          &display_actions_box($r,$command,\%threshold_titles,\%interval_titles,
                                                        $cdom,$crs,$checkallowed);
     }      }
     $r->print(<<END_OF_BLOCK);      $r->print(<<END_OF_BLOCK);
   </td>    </td>
Line 132  END_OF_BLOCK Line 156  END_OF_BLOCK
 #-------------------------------  #-------------------------------
   
 sub display_header{  sub display_header{
       my ($command,$checkallowed) = @_;
     my $html=&Apache::lonxml::xmlbegin();      my $html=&Apache::lonxml::xmlbegin();
     my $bodytag=&Apache::loncommon::bodytag('Course Action Items');      my $bodytag=&Apache::loncommon::bodytag('Course Action Items');
       my $scripttag;
       unless ($command eq 'chgthreshold' || $command eq 'chginterval') {
          $scripttag = <<"END";
   <script type="text/javascript">
   function change_display(caller,change) {
       caller.value = change;
       document.visible.submit(); 
   }
   
   function changeAll(change) {
   END
           foreach my $item (keys(%{$checkallowed})) {
               $scripttag.='document.visible.display_'.$item.'.value=change'."\n";
           }
           $scripttag.='document.visible.submit();
   }
   </script>
   ';
       }
     return(<<ENDHEAD);      return(<<ENDHEAD);
 $html  $html
 <head>  <head>
 <title>Course Action Items</title>  <title>Course Action Items</title>
   $scripttag
 </head>  </head>
 $bodytag  $bodytag
 ENDHEAD  ENDHEAD
Line 151  ENDHEAD Line 196  ENDHEAD
 #-------------------------------  #-------------------------------
                                                                                                                                                                   
 sub display_actions_box() {  sub display_actions_box() {
     my ($r,$command,$threshold_titles,$cdom,$crs) = @_;      my ($r,$command,$threshold_titles,$interval_titles,$cdom,$crs,
                                                              $checkallowed) = @_;
     my $rowColor1 = "#ffffff";      my $rowColor1 = "#ffffff";
     my $rowColor2 = "#eeeeee";      my $rowColor2 = "#eeeeee";
   
       my $udom = $env{'user.domain'};
       my $uname = $env{'user.name'};
       my $cid = $env{'request.course.id'};
   
       my %lt = &Apache::lonlocal::texthash(
                    'yacc' => 'You are accessing an invalid course.',
                    'gtfr' => 'Go to first resource',
                    'chyp' => 'Change your preferences',
                    'tsup' => 'to suppress display of this screen when accessing'.
                              ' this course in the future.',
                    'hial' => 'Hide all',
                    'shal' => 'Show all',
       );
   
     my %unread = ();      my %unread = ();
     my %ungraded = ();      my %ungraded = ();
     my %bombed = ();      my %bombed = ();
Line 193  sub display_actions_box() { Line 252  sub display_actions_box() {
     my $pgbg=&Apache::loncommon::designparm($function.'.pgbg',$domain);      my $pgbg=&Apache::loncommon::designparm($function.'.pgbg',$domain);
     my $tabbg=&Apache::loncommon::designparm($function.'.tabbg',$domain);      my $tabbg=&Apache::loncommon::designparm($function.'.tabbg',$domain);
   
     unless ($env{'request.course.id'}) {      unless ($cid) {
         $r->print('<br /><b><center>You are accessing an invalid course.</center></b><br /><br />');          $r->print('<br /><b><center>'.$lt{'yacc'}.'</center></b><br /><br />');
         return;          return;
     }      }
   
     my %checkallowed = (      if (tie(my %bighash,'GDBM_File',$env{'request.course.fn'}.'.db',
              coursediscussion => &Apache::lonnet::allowed('pch',$env{'request.course.id'}),              &GDBM_READER(),0640)) {
              handgrading => &Apache::lonnet::allowed('mgr',$env{'request.course.id'}),          my $furl=$bighash{'first_url'};
              abovethreshold => &Apache::lonnet::allowed('vgr',$env{'request.course.id'}),          $r->print('<font size="+1"><a href="'.$furl.'">'.$lt{'gtfr'}.
              haserrors => &Apache::lonnet::allowed('opa',$env{'request.course.id'}),                    '</a></font><a href="/adm/preferences?action=changecourseinit">'.
              versionchanges => &Apache::lonnet::allowed('opa',$env{'request.course.id'}),                    '</font><br />'.$lt{'chyp'}.'</a> '.$lt{'tsup'}.'<br /><hr />');
              coursenormalmail => 1,          untie(%bighash);
              coursecritmail => 1,      }
     );                                                                                          
       my $result;
                                                                                           
       if ($command eq 'reset') {
           $result = &process_reset($cdom,$crs);
       } elsif ($command eq 'update') {
           $result = &process_update($cdom,$crs,$threshold_titles);
       } elsif ($command eq 'newinterval') {
           $result = &store_interval_setting($uname,$udom,$cid,$interval_titles);
       }
   
       my $store_result=&store_display_settings($uname,$udom,$cid,$checkallowed);
   
     my $timediff = 604800;      unless ($store_result eq 'ok') { 
     my %display_settings = &get_display_settings();          &Apache::lonnet::logthis('Error storing whatsnew settings: '.
               $store_result.' for '.'user '.$uname.':'.$udom.' in course '.$cid);
           $result .= &mt('Unable to store visibility settings due to [_1]',
                          $store_result); 
       }
   
       if ($result) {
           $r->print($result.'<hr width="100%" />');
       }
       $r->rflush();
   
   
       my %display_settings = &get_display_settings($uname,$udom,$cid);
       my $timediff = $display_settings{$cid.':interval'};
       unless (defined($timediff)) { $timediff = 604800; } 
     my $now = time;      my $now = time;
     my %intervals = (      my $interval = $$interval_titles{$timediff};
                    -1 => 'since start of course',  
               2592000 => 'since last month',  
                604800 => 'since last week',  
                 86400 => 'since yesterday',  
     );  
     my $interval = $intervals{$timediff};  
     if ($timediff == -1) {      if ($timediff == -1) {
         $timediff = time;          $timediff = time;
     }       } 
Line 232  sub display_actions_box() { Line 310  sub display_actions_box() {
                 coursecritmail => 'New critical messages in course',                  coursecritmail => 'New critical messages in course',
     );      );
   
     if ($checkallowed{'abovethreshold'}) {      if ($$checkallowed{'abovethreshold'}) {
         &get_curr_thresholds(\%threshold,$cdom,$crs);          &get_curr_thresholds(\%threshold,$cdom,$crs);
     }      }
   
Line 240  sub display_actions_box() { Line 318  sub display_actions_box() {
   
     my @actionorder = ('handgrading','haserrors','abovethreshold','versionchanges','coursediscussion','coursenormalmail','coursecritmail');      my @actionorder = ('handgrading','haserrors','abovethreshold','versionchanges','coursediscussion','coursenormalmail','coursecritmail');
   
     foreach my $key (keys(%checkallowed)) {      foreach my $key (keys(%{$checkallowed})) {
         $show{$key} = 0;          $show{$key} = 0;
         if ($checkallowed{$key}) {          if ($$checkallowed{$key}) {
             unless ($display_settings{$key} eq 'off') {              unless ($display_settings{$cid.':'.$key} eq 'hide') {
                 $show{$key} = 1;                  $show{$key} = 1;
             }              }
         }          }
Line 258  sub display_actions_box() { Line 336  sub display_actions_box() {
         }          }
     }      }
   
   
     if (tie(my %bighash,'GDBM_File',$env{'request.course.fn'}.'.db',  
     &GDBM_READER(),0640)) {  
  my $furl=$bighash{'first_url'};  
  $r->print('<font size="+1"><a href="'.$furl.'">Go to first resource</a></font><a href="/adm/preferences?action=changecourseinit"></font><br />Change your preferences</a> to suppress display of this screen when accessing courses as Course Coordinator in the future.<br /><hr />');  
  untie(%bighash);  
     }  
   
     my $result;  
   
     if ($command eq 'reset') {  
         $result = &process_reset($cdom,$crs);  
     } elsif ($command eq 'update') {  
         $result = &process_update($cdom,$crs,$threshold_titles);  
     }  
     if ($result) {  
         $r->print($result.'<hr width="100%" />');  
     }  
     $r->rflush();  
   
     if ($needitems) {      if ($needitems) {
         &getitems(\%unread,\%ungraded,\%bombed,\%triggered,\%changed,\@newdiscussions,\@tograde,\@bombs,\@warnings,$rowColor1,$rowColor2,\%threshold,$cdom,$crs,\%res_title,\%show,$starttime);          &getitems(\%unread,\%ungraded,\%bombed,\%triggered,\%changed,\@newdiscussions,\@tograde,\@bombs,\@warnings,$rowColor1,$rowColor2,\%threshold,$cdom,$crs,\%res_title,\%show,$starttime);
     }      }
Line 288  sub display_actions_box() { Line 346  sub display_actions_box() {
         &getcritmail(\@critmsgs);          &getcritmail(\@critmsgs);
     }      }
   
     $r->print(qq|<a href="javascript:changeAll('hide');">Hide All</a>&nbsp;&nbsp;<a href="javascript:changeAll('show');">Show All</a>|);      $r->print(qq|<a href="javascript:changeAll('hide');">$lt{'hial'}</a>
        &nbsp;&nbsp;<a href="javascript:changeAll('show');">$lt{'shal'}</a>
        <form method="post" name="visible" action="/adm/whatsnew">\n|);
       foreach my $item (keys(%{$checkallowed})) {
           if ($$checkallowed{$item}) {
               $r->print('<input type="hidden" name="display_'.$item.'" />'."\n");
           }
       }
   
     $r->print('<br /><table border="0" width="100%" cellpadding="2" cellspacing="4"><tr><td align="left" valign="top" width="45%">');      $r->print('</form><br /><table border="0" width="100%" cellpadding="2" cellspacing="4"><tr><td align="left" valign="top" width="45%">');
   
     my $displayed = 0;      my $displayed = 0;
     my $totalboxes = keys(%checkallowed);      my $totalboxes = keys(%{$checkallowed});
     my $halfway = int($totalboxes/2) + $totalboxes%2;      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 width="5%">&nbsp;</td><td align="left" valign="top" width-"50%">');                  $r->print('</td><td width="5%">&nbsp;</td><td align="left" valign="top" width-"50%">');
             }              }
             &display_launcher($r,$actionitem,\%checkallowed,$tabbg,$rowColor1,$rowColor2,\%show,\%headings,\%res_title,\@tograde,\%ungraded,\@bombs,\%bombed,\%changed,\@warnings,\%triggered,\@newdiscussions,\%unread,$msgcount,\@newmsgs,$critmsgcount,\@critmsgs,$interval);              &display_launcher($r,$actionitem,$checkallowed,$tabbg,$rowColor1,$rowColor2,\%show,\%headings,\%res_title,\@tograde,\%ungraded,\@bombs,\%bombed,\%changed,\@warnings,\%triggered,\@newdiscussions,\%unread,$msgcount,\@newmsgs,$critmsgcount,\@critmsgs,$interval);
             $displayed ++;               $displayed ++; 
         }          }
     }      }
Line 315  sub display_actions_box() { Line 380  sub display_actions_box() {
 }  }
   
 #-------------------------------  #-------------------------------
 # display_config_box  # display_threshold_config
 #  #
 # Display the threshold setting screen   # Display the threshold setting screen 
 #  #
 #-------------------------------  #-------------------------------
                                                                                                                                                                   
 sub display_config_box() {  sub display_threshold_config {
     my ($r,$command,$tabbg,$threshold_titles,$cdom,$crs) = @_;      my ($r,$command,$tabbg,$threshold_titles,$cdom,$crs) = @_;
     my %threshold = ();      my %threshold = ();
     my $rowColor1 = "#ffffff";      my $rowColor1 = "#ffffff";
Line 336  sub display_config_box() { Line 401  sub display_config_box() {
                          );                           );
     &get_curr_thresholds(\%threshold,$cdom,$crs);      &get_curr_thresholds(\%threshold,$cdom,$crs);
   
     $r->print('<br /><form name="thresholdform" method="post"><table border="0" cellpadding="2" cellspacing="4"><tr><td align="left" valign="top" width="45%">      $r->print('<br /><form name="thresholdform" method="post" action="/adm/whatsnew">
           <table border="0" cellpadding="2" cellspacing="4">
            <tr>
             <td align="left" valign="top" width="45%">
            <table border="0" cellpadding="0" cellspacing="0" bgcolor="#000000">             <table border="0" cellpadding="0" cellspacing="0" bgcolor="#000000">
             <tr>              <tr>
              <td>               <td>
Line 375  sub display_config_box() { Line 443  sub display_config_box() {
     }      }
     $r->print('</table></td></tr></table></td></tr></table>      $r->print('</table></td></tr></table></td></tr></table>
            <br /><input type="submit" name="threshold" value="Make changes" />             <br /><input type="submit" name="threshold" value="Make changes" />
                  <input type="hidden" name="action" value="update" />                   <input type="hidden" name="command" value="update" />
                </form>');                 </form>');
 }  }
   
   #-------------------------------
   # display_interval_config
   #
   # Display the interval setting screen
   #
   #-------------------------------
                                                                                      
   sub display_interval_config {
       my ($r,$interval_titles) = @_;
       my $current = &get_curr_interval($env{'user.name'},
                                   $env{'user.domain'},$env{'request.course.id'});
       $r->print('<br />'.&mt('Choose the time window to use for display of version changes for resources in the course.'));
       unless ($current eq '') {
           $r->print(' '.&mt('Current value is ').$$interval_titles{$current}.'<br /><br />');
       }
       $r->print('<br /><br />
   <form method="post" name="intervalswitch" action="/adm/whatsnew">
   <input type="hidden" name="command" value="newinterval" />
   <select name="interval">
   ');
       foreach my $key (reverse sort ({$a cmp $b} (keys(%{$interval_titles})))) {
           $r->print('<option value="'.$key.'">Version changes '.$$interval_titles{$key}.
                     '</option>'."\n");
       }
       $r->print('</select>&nbsp;&nbsp;
                  <input type="submit" name="display" value="'.
                  &mt('Change interval').'" /></form>');
       return;
   }
   
 sub display_launcher {  sub display_launcher {
     my ($r,$action,$checkallowed,$tabbg,$rowColor1,$rowColor2,$show,      my ($r,$action,$checkallowed,$tabbg,$rowColor1,$rowColor2,$show,
         $headings,$res_title,$tograde,$ungraded,$bombs,$bombed,$changed,          $headings,$res_title,$tograde,$ungraded,$bombs,$bombed,$changed,
Line 403  sub display_launcher { Line 501  sub display_launcher {
                                                         $rowColor1,$rowColor2);                                                          $rowColor1,$rowColor2);
             } elsif ($action eq 'coursediscussion') { # UNREAD COURSE DISCUSSION              } elsif ($action eq 'coursediscussion') { # UNREAD COURSE DISCUSSION
                 &display_coursediscussion($r,$newdiscussions,$unread,                  &display_coursediscussion($r,$newdiscussions,$unread,
                                                                    $res_title);                                               $res_title,$rowColor1,$rowColor2);
             } elsif ($action eq 'coursenormalmail') { # NORMAL MESSAGES              } elsif ($action eq 'coursenormalmail') { # NORMAL MESSAGES
                 &display_coursenormalmail($r,$msgcount,$newmsgs,$rowColor1,                  &display_coursenormalmail($r,$msgcount,$newmsgs,$rowColor1,
                                                                    $rowColor2);                                                                     $rowColor2);
Line 653  sub get_curr_thresholds { Line 751  sub get_curr_thresholds {
     }      }
 }  }
   
   sub get_curr_interval {
       my ($uname,$udom,$cid);
       my $interval;
       my %settings = &Apache::lonnet::dump('nohist_whatsnew',$uname,$udom,$cid,':interval');
       my ($tmp) = %settings;
       if ($tmp =~ /^Error/) {
           &logthis();
       } else {
           $interval = $settings{$cid.':interval'};
       }
       return $interval;
   }
   
 sub process_reset {  sub process_reset {
     my ($dom,$crs) = @_;      my ($dom,$crs) = @_;
     my $result = '<b>Counters reset for following problems (and parts):</b><br />';      my $result = '<b>Counters reset for following problems (and parts):</b><br />';
Line 900  sub display_abovethreshold { Line 1011  sub display_abovethreshold {
     my $warningnum = 0;      my $warningnum = 0;
     if (@{$warnings} > 0) {      if (@{$warnings} > 0) {
         @{$warnings} = sort { &cmp_title($a,$b,$res_title) } @{$warnings};          @{$warnings} = sort { &cmp_title($a,$b,$res_title) } @{$warnings};
         $r->print('<form name="reset_tracking" method="post">'.          $r->print('<form name="reset_tracking" method="post" action="/adm/whatsnew">'.
                 '  <input type="hidden" name="action" value="reset" />'."\n");                  '  <input type="hidden" name="command" value="reset" />'."\n");
         $r->print('<tr bgcolor="#cccccc"><td><b><small>'.$lt{'reso'}.'</small></b></td><td align="right"><b><small>'.$lt{'part'}.'</small></b></td><td align="right"><b><small>'.$lt{'nust'}.'</small></b></td><td align="right"><b><small>'.$lt{'avat'}.'</small></b></td><td align="right"><b><small>'.$lt{'dedi'}.'</small></b></td><td align="right"><b><small>'.$lt{'lare'}.'</small></b></td><td align="right"><b><small>'.$lt{'reco'}.'</small></b></td></tr>');          $r->print('<tr bgcolor="#cccccc"><td><b><small>'.$lt{'reso'}.'</small></b></td><td align="right"><b><small>'.$lt{'part'}.'</small></b></td><td align="right"><b><small>'.$lt{'nust'}.'</small></b></td><td align="right"><b><small>'.$lt{'avat'}.'</small></b></td><td align="right"><b><small>'.$lt{'dedi'}.'</small></b></td><td align="right"><b><small>'.$lt{'lare'}.'</small></b></td><td align="right"><b><small>'.$lt{'reco'}.'</small></b></td></tr>');
         foreach my $res (@{$warnings}) {          foreach my $res (@{$warnings}) {
             if ($warningnum %2 == 1) {              if ($warningnum %2 == 1) {
Line 1055  sub cmp_title { Line 1166  sub cmp_title {
 }  }
   
 sub get_display_settings {  sub get_display_settings {
     my $udom = $env{'user.domain'};      my ($uname,$udom,$cid) = @_;
     my $uname = $env{'user.name'};  
     my $cid = $env{'request.course.id'};  
     my %settings = &Apache::lonnet::dump('nohist_whatsnew',$udom,$uname,$cid);       my %settings = &Apache::lonnet::dump('nohist_whatsnew',$udom,$uname,$cid); 
     my ($tmp) = keys(%settings);      my ($tmp) = keys(%settings);
     if ($tmp=~/^error:/) {      if ($tmp=~/^error:/) {
Line 1070  sub get_display_settings { Line 1179  sub get_display_settings {
     return %settings;      return %settings;
 }  }
   
   sub store_display_settings {
       my ($uname,$udom,$cid,$checkallowed) = @_;
       my %whatsnew_settings;
       my $result;
       foreach my $key (keys(%{$checkallowed})) {
           if (exists($env{'form.display_'.$key})) {
               unless ($env{'form.display_'.$key} eq '') {
                   $whatsnew_settings{$cid.':'.$key} = $env{'form.display_'.$key};
               }
           }
       }
       if (keys(%whatsnew_settings)) {
           $result = &Apache::lonnet::put('nohist_whatsnew',\%whatsnew_settings,
                                                                    $udom,$uname);
       } else {
           $result = 'ok';
       }
       return $result;
   }
   
   sub store_interval_setting {
       my ($uname,$udom,$cid,$interval_titles) = @_;
       my %interval_settings = ();
       my $result;
       if (defined($env{'form.interval'})) {
           $interval_settings{$cid.':interval'} = $env{'form.interval'};
           my $outcome = &Apache::lonnet::put('nohist_whatsnew',
                                                \%interval_settings,$udom,$uname);
           if ($outcome eq 'ok') {
               $result = &mt('Interval set to version changes [_1]',
                     '<b>'.$$interval_titles{$env{'form.interval'}}.'</b><br />');
   
           } else {
               &Apache::lonnet::logthis('Error storing whatsnew interval setting'.
                        ' '.$outcome.' for '.$uname.':'.$udom.' in course '.$cid);
               $result = &mt('Unable to set interval to [_1] due to [_2].',
                            '<b>'.$$interval_titles{$env{'form.interval'}}.'</b>',
                            '<tt>'.$outcome.'</tt>.<br />');
           }
       }
       return $result;
   }
   
 sub start_box {  sub start_box {
     my ($r,$tabbg,$show,$heading,$caller) = @_;      my ($r,$tabbg,$show,$heading,$caller) = @_;
     my %lt = &Apache::lonlocal::texthash(       my %lt = &Apache::lonlocal::texthash( 
Line 1078  sub start_box { Line 1230  sub start_box {
     );      );
     my $showhide;      my $showhide;
     if ($$show{$caller}) {      if ($$show{$caller}) {
         $showhide = '<b><a href="javascript:change_display('."'".$caller.          $showhide = '<b><a href="javascript:change_display(document.visible.'.
                                            "','hide'".');">Hide</a></b>';                                 'display_'.$caller.",'hide'".');">Hide</a></b>';
         
     } else {      } else {
         $showhide = '<b><a href="javascript:change_display('."'".$caller.          $showhide = '<b><a href="javascript:change_display(document.visible.'.
                                             "','show'".');">Show</a></b>';                                 'display_'.$caller.",'show'".');">Show</a></b>';
     }      }
           
     $r->print('      $r->print('

Removed from v.1.35  
changed lines
  Added in v.1.36


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