[LON-CAPA-cvs] cvs: loncom /interface lonfeedback.pm

raeburn lon-capa-cvs@mail.lon-capa.org
Sun, 04 Jul 2004 23:56:58 -0000


This is a MIME encoded message

--raeburn1088985418
Content-Type: text/plain

raeburn		Sun Jul  4 19:56:58 2004 EDT

  Modified files:              
    /loncom/interface	lonfeedback.pm 
  Log:
  Bug 3091 fixes.
  Discussion settings now appear after posts, and made more succinct.  Change link goes to another page, where choices can be made.
  
  Not implemented: (a) filtering using ENV{'user.adv'} to disable these options for students - I actually think students might find these options useful rather than confusing. (b) Code to allow user to make any changes also the default option (PREF) - will add this tomorrow.
  
  Work still needed: (a) modify code that builds display when target is 'tex'
  
  
--raeburn1088985418
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20040704195658.txt"

Index: loncom/interface/lonfeedback.pm
diff -u loncom/interface/lonfeedback.pm:1.96 loncom/interface/lonfeedback.pm:1.97
--- loncom/interface/lonfeedback.pm:1.96	Mon Jun 28 12:41:08 2004
+++ loncom/interface/lonfeedback.pm	Sun Jul  4 19:56:58 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Feedback
 #
-# $Id: lonfeedback.pm,v 1.96 2004/06/28 16:41:08 albertel Exp $
+# $Id: lonfeedback.pm,v 1.97 2004/07/04 23:56:58 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -325,54 +325,50 @@
     my $color = &Apache::loncommon::designparm($function.'.tabbg',
                                                     $ENV{'user.domain'});
     my %lt = &Apache::lonlocal::texthash(
-        'cuse' => 'Current settings for this discussion',
+        'cuse' => 'Current discussion settings',
         'allposts' => 'All posts',
         'unread' => 'New posts only',
         'ondisp' => 'Once displayed',
         'onmark' => 'Once marked read',
         'disa' => 'Posts to be displayed',
         'npce' => 'Posts cease to be marked "NEW"',
-        'chgt' => 'Change to ',
+        'chgt' => 'Change',
+        'disp' => 'Display',
+        'nolo' => 'Not new',
     );
 
     my $currdisp = $lt{'allposts'};
     my $currmark = $lt{'onmark'};
     my $dispchange = $lt{'unread'};
     my $markchange = $lt{'ondisp'};
-    my $displink = '/adm/feedback?onlyunread='.$ressymb;
-    my $marklink = '/adm/feedback?markondisp='.$ressymb;
+    my $chglink = '/adm/feedback?modifydisp='.$ressymb;
+    my $displink = 'onlyunread';
+    my $marklink = 'markondisp';
 
     if ($markondisp) {
         $currmark = $lt{'ondisp'};
         $markchange = $lt{'onmark'};
-        $marklink = '/adm/feedback?markonread='.$ressymb;
-        if ($newpostsflag) {
-            $marklink .= '&previous='.$prevread;
-        }
+        $marklink = 'markonread';
     }
 
     if ($showonlyunread) {
         $currdisp = $lt{'unread'};
         $dispchange = $lt{'allposts'};
-        $displink = '/adm/feedback?allposts='.$ressymb;
+        $displink = 'allposts';
     }
+   
+    $chglink .= '&changes='.$displink.'_'.$marklink;
 
     if ($newpostsflag) {
-        $displink .= '&previous='.$prevread;
+        $chglink .= '&previous='.$prevread;
     }
 
     if ($visible) {
 # Print the discusssion
 	if ($outputtarget ne 'tex') {
+            my $colspan=$maxdepth+1;
 	    $discussion.='<table bgcolor="#AAAAAA" cellpadding="2" cellspacing="2" border="0">';
-	    my $colspan=$maxdepth+1;
-	    $discussion .= '<tr bgcolor="#FFFFFF"><td colspan="'.$colspan.'" valign="top">'.
-		'<table border="0" bgcolor="#FFFFFF" width="100%" cellspacing="2" cellpadding="2">'.
-		'<tr><td align="left"><b>'.$lt{'cuse'}.'</b></td><td>&nbsp;&nbsp;&nbsp;&nbsp;</td><td align="right"><b>'.$lt{'chgt'}.'</b></td></tr>'.
-		'<tr><td>'.$lt{'disa'}.':&nbsp;<i>'.$currdisp.'</i></td><td>&nbsp;&nbsp;&nbsp;&nbsp;</td><td align="right"><a href="'.$displink.'">'.$dispchange.'</a></td></tr>'.
-		'<tr><td>'.$lt{'npce'}.':&nbsp;<i>'.$currmark.'</i></td><td>&nbsp;&nbsp;&nbsp;&nbsp;</td><td align="right"><a href="'.$marklink.'">'.$markchange.'</a></td></tr>'.
-		'</table></td></tr>'.
-		'<tr><td bgcolor="#DDDDBB" colspan="'.$colspan.'">'.
+	    $discussion .='<tr><td bgcolor="#DDDDBB" colspan="'.$colspan.'">'.
 		'<table border="0" width="100%" bgcolor="#DDDDBB"><tr>';
 	    if ($visible>2) {
 		$discussion.='<td align="left">'.
@@ -456,7 +452,40 @@
 	    }
         }
 	if ($outputtarget ne 'tex') {
-	    $discussion.='</table><br /><br />';
+            my $colspan=$maxdepth+1;
+            $discussion .= <<END; 
+            <tr bgcolor="#FFFFFF">
+             <td colspan="'.$colspan.'" valign="top">
+              <table border="0" bgcolor="#FFFFFF" width="100%" cellspacing="2" cellpadding="2">
+               <tr>
+                <td align="left">
+                 <table border="0" cellpadding="0" cellspacing="4">
+                  <tr>
+                   <td>
+                    <font size="-1"><b>$lt{'cuse'}</b>:</td>
+                   <td>&nbsp;</td>
+END
+            if ($newpostsflag) {
+                $discussion .= 
+                   '<td><font size="-1">1.&nbsp;'.$lt{'disp'}.'&nbsp;-&nbsp;<i>'.$currdisp.'</i>&nbsp;&nbsp;2.&nbsp;'.$lt{'nolo'}.'&nbsp;-&nbsp;<i>'.$currmark.'</i></font></td>';
+            } else {
+                $discussion .=
+                   '<td><font size="-1">'.$lt{'disp'}.'&nbsp;-&nbsp;<i>'.$currdisp.'</i></font></td>';
+            }
+            $discussion .= <<END;
+                   <td>&nbsp;</td>
+                   <td>
+                    <font size="-1"><b><a href="$chglink">$lt{'chgt'}</a>?</font></b></td>
+                  </tr>
+                 </table>
+                </td>
+               </tr>
+              </table>
+             </td>
+            </tr>
+           </table>
+           <br /><br />
+END
 	}
     }
     if ($discussiononly) {
@@ -611,6 +640,131 @@
 '</body></html>');
 }
 
+sub print_display_options {
+    my ($r,$symb,$previous,$dispchg,$markchg,$feedurl) = @_;
+    my $function = &Apache::loncommon::get_users_function();
+    my $tabcolor = &Apache::loncommon::designparm($function.'.tabbg',
+                                                    $ENV{'user.domain'});
+    my $bodytag=&Apache::loncommon::bodytag('Discussion options',
+                                          '','');
+
+    my %lt = &Apache::lonlocal::texthash(
+        'dido' => 'Discussion display options',
+        'pref' => 'Display Preference',
+        'curr' => 'Current setting ',
+        'actn' => 'Action',
+        'deff' => 'Default for all discussions',
+        'prca' => 'Preferences can be set for this discussion that determine ....',
+        'whpo' => 'Which posts are displayed when you display this bulletin board or resource, and',
+        'unwh' => 'Under what circumstances posts are identfied as "New."',
+        'allposts' => 'All posts',
+        'unread' => 'New posts only',
+        'ondisp' => 'Once displayed',
+        'onmark' => 'Once marked as read',
+        'disa' => 'Posts displayed?',
+        'npmr' => 'New posts cease to be identified as "New"?',
+        'chgt' => 'Change to ',
+        'mkdf' => 'Set to ',
+        'yhni' => 'You have not indicated that you wish to change either of the discussion settings',
+        'ywbr' => 'You will be returned to the previous page if you click OK.'
+    );
+
+    my $dispchange = $lt{'unread'};
+    my $markchange = $lt{'ondisp'};
+    my $currdisp = $lt{'allposts'};
+    my $currmark = $lt{'onmark'};
+    my $discdisp = 'allposts';
+    my $discmark = 'onmark';
+                                                                                      
+    if ($dispchg eq 'allposts') {
+        $dispchange = $lt{'allposts'};
+        $currdisp = $lt{'unread'};
+        $discdisp = 'unread';
+    }
+                                                                                      
+    if ($markchg eq 'markonread') {
+        $markchange = $lt{'onmark'};
+        $currmark = $lt{'ondisp'};
+        $discmark = 'ondisp';
+    }
+    $r->print(<<END);
+<html>
+<head>
+<title>$lt{'dido'}</title>
+<meta http-equiv="pragma" content="no-cache" />
+<script>
+function setDisp() {
+    var prev = "$previous"
+    var chktotal = 0
+    if (document.modifydisp.discdisp.checked == true) {
+        document.modifydisp.$dispchg.value = "$symb"
+        chktotal ++
+    }
+    if (document.modifydisp.discmark.checked == true) {
+        document.modifydisp.$markchg.value = "$symb"
+        chktotal ++
+    }
+    if (chktotal > 0) { 
+        document.modifydisp.submit()
+    } else {
+        if(confirm("$lt{'yhni'}. \\n$lt{'ywbr'}"))      {
+            if (prev > 0) {
+                location.href = "$feedurl?previous=$previous"
+            } else {
+                location.href = "$feedurl"
+            }
+        }
+    }
+}
+</script>
+</head>
+$bodytag
+<form name="modifydisp" method="post" action="/adm/feedback">
+$lt{'sdpf'}<br/> $lt{'prca'}  <ol><li>$lt{'whpo'}</li><li>$lt{'unwh'}</li></ol>
+<br />
+<table border="0" cellpadding="0" cellspacing="0">
+ <tr>
+  <td width="100%" bgcolor="#000000">
+   <table width="100%" border="0" cellpadding="1" cellspacing="0">
+    <tr>
+     <td width="100%" bgcolor="#000000">
+      <table border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
+       <tr bgcolor="$tabcolor">
+        <td><b>$lt{'pref'}</b></td>
+        <td><b>$lt{'curr'}</b></td>
+        <td><b>$lt{'actn'}?</b></td>
+       </tr>
+       <tr bgcolor="#dddddd">
+       <td>$lt{'disa'}</td>
+       <td>$lt{$discdisp}</td>
+       <td><input type="checkbox" name="discdisp" />&nbsp;$lt{'chgt'} "$dispchange"</td>
+      </tr><tr bgcolor="#eeeeee">
+       <td>$lt{'npmr'}</td>
+       <td>$lt{$discmark}</td>
+       <td><input type="checkbox" name="discmark" />$lt{'chgt'} "$markchange"</td>
+      </tr>
+     </table>
+    </td>
+   </tr>
+  </table>
+ </td>
+</tr>
+</table>
+<br />
+<br />
+<input type="hidden" name="previous" value="$previous" />
+<input type="hidden" name="$dispchg" value=""/>
+<input type="hidden" name="$markchg" value=""/>
+<input type="button" name="sub" value="Store Changes" onClick="javascript:setDisp()" />
+<br />
+<br />
+</form>
+</body>
+</html>
+END
+    return;
+}
+
 sub fail_redirect {
   my ($r,$feedurl) = @_;
   if ($feedurl=~/^\/adm\//) { $feedurl.='?register=1' };
@@ -971,58 +1125,66 @@
 
 # --------------------------- Get query string for limited number of parameters
 
-   &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
-         ['hide','unhide','deldisc','postdata','preview','replydisc','threadedon','threadedoff','onlyunread','allposts','previous','markread','markonread','markondisp']);
-
-  if (($ENV{'form.markondisp'}) || ($ENV{'form.markonread'})) {
-# ---------------------- Modify setting for identification of 'NEW' posts in this discussion
-
+  &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
+         ['hide','unhide','deldisc','postdata','preview','replydisc','threadedon','threadedoff','onlyunread','allposts','previous','markread','markonread','markondisp','modifydisp','changes']);
+  if ($ENV{'form.modifydisp'}) {
       &Apache::loncommon::content_type($r,'text/html');
       $r->send_http_header;
-      my $symb=$ENV{'form.markondisp'}?$ENV{'form.markondisp'}:$ENV{'form.markonread'};
-      my $ressymb = $symb;
+      my $symb=$ENV{'form.modifydisp'};
       my ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
-      unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) {
-          $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|;
-      }
-                                                                                          
-      my %discinfo = ();
-      my $lastkey = $ressymb.'_lastread';
-      my $ondispkey = $ressymb.'_markondisp';
-      if ($ENV{'form.markondisp'}) {
-          $discinfo{$lastkey} = time;
-          $discinfo{$ondispkey} = 1;
-      } elsif ($ENV{'form.markonread'}) {
-          if ( defined($ENV{'previous'}) ) {
-              $discinfo{$lastkey} = $ENV{'previous'};
-          }
-          $discinfo{$ondispkey} = 0;
-      }
-      &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%discinfo,$ENV{'user.domain'},$ENV{'user.name'});
-      if ($ENV{'form.markondisp'}) {
-          &redirect_back($r,&Apache::lonnet::clutter($url),&mt('Changed display status').'<br />','0','0');
-      } else {
-          &redirect_back($r,&Apache::lonnet::clutter($url),&mt('Changed display status').'<br />','0','0','',$ENV{'form.previous'});
-      }
+      my $previous=$ENV{'form.previous'};
+      my ($dispchg,$markchg) = split/_/,$ENV{'form.changes'};
+      my $feedurl = &Apache::lonnet::clutter($url);
+      &print_display_options($r,$symb,$previous,$dispchg,$markchg,$feedurl);
       return OK;
-  } elsif (($ENV{'form.allposts'}) || ($ENV{'form.onlyunread'})) {
-# ----------------------------------------------------------------- Modify display setting for this discussion 
+  } elsif (($ENV{'form.markondisp'}) || ($ENV{'form.markonread'}) || ($ENV{'form.allposts'}) || ($ENV{'form.onlyunread'}) ) {
       &Apache::loncommon::content_type($r,'text/html');
       $r->send_http_header;
-      my $symb=$ENV{'form.allposts'}?$ENV{'form.allposts'}:$ENV{'form.onlyunread'};
-      my $ressymb = $symb;
-      my ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
-      unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) {
-          $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|;
+      my $previous=$ENV{'form.previous'};
+      my ($map,$ind,$url);
+      if (($ENV{'form.markondisp'}) || ($ENV{'form.markonread'})) {
+# ---------------------- Modify setting for identification of 'NEW' posts in this discussion
+          my $symb=$ENV{'form.markondisp'}?$ENV{'form.markondisp'}:$ENV{'form.markonread'};
+          my $ressymb = $symb;
+          ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
+          unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) {
+              $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|;
+          }
+          my %discinfo = ();
+          my $lastkey = $ressymb.'_lastread';
+          my $ondispkey = $ressymb.'_markondisp';
+          if ($ENV{'form.markondisp'}) {
+              $discinfo{$lastkey} = time;
+              $discinfo{$ondispkey} = 1;
+          } elsif ($ENV{'form.markonread'}) {
+              if ( $previous > 0 ) {
+                  $discinfo{$lastkey} = $previous;
+              }
+              $discinfo{$ondispkey} = 0;
+          }
+          &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%discinfo,$ENV{'user.domain'},$ENV{'user.name'});
       }
-      my %discinfo = ();
-      if ($ENV{'form.allposts'}) {
-          $discinfo{$ressymb.'_showonlyunread'} = 0;
-      } elsif ($ENV{'form.onlyunread'}) {
-          $discinfo{$ressymb.'_showonlyunread'} = 1;
+      if (($ENV{'form.allposts'}) || ($ENV{'form.onlyunread'})) {
+# ----------------------------------------------------------------- Modify display setting for this discussion 
+          my $symb=$ENV{'form.allposts'}?$ENV{'form.allposts'}:$ENV{'form.onlyunread'};
+          my $ressymb = $symb;
+          ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
+          unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) {
+              $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|;
+          }
+          my %discinfo = ();
+          if ($ENV{'form.allposts'}) {
+              $discinfo{$ressymb.'_showonlyunread'} = 0;
+          } elsif ($ENV{'form.onlyunread'}) {
+              $discinfo{$ressymb.'_showonlyunread'} = 1;
+          }
+          &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%discinfo,$ENV{'user.domain'},$ENV{'user.name'});
+      }
+      if (($ENV{'form.markonread'}) || ($ENV{'form.allposts'}) || ($ENV{'form.onlyunread'}) ) {
+          &redirect_back($r,&Apache::lonnet::clutter($url),&mt('Changed display status').'<br />','0','0','',$previous);
+      } else {
+          &redirect_back($r,&Apache::lonnet::clutter($url),&mt('Changed display status').'<br />','0','0');
       }
-      &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%discinfo,$ENV{'user.domain'},$ENV{'user.name'});
-      &redirect_back($r,&Apache::lonnet::clutter($url),&mt('Changed display status').'<br />','0','0','',$ENV{'form.previous'});
       return OK;
   } elsif ($ENV{'form.markread'}) {
 # ----------------------------------------------------------------- Mark new posts as read

--raeburn1088985418--