[LON-CAPA-cvs] cvs: loncom /interface lonfeedback.pm lonparmset.pm /misc releaseslist.xml /publisher packages.tab rat/client parameter.html

raeburn raeburn at source.lon-capa.org
Tue Mar 13 01:38:09 EDT 2012


raeburn		Tue Mar 13 05:38:09 2012 EDT

  Modified files:              
    /loncom/interface	lonfeedback.pm lonparmset.pm 
    /rat/client	parameter.html 
    /loncom/publisher	packages.tab 
    /loncom/misc	releaseslist.xml 
  Log:
  - Like/Unlike discussion posts.
    - Parameter: discussvote: possible values: yes, notended, no.
      (i.e., voting like/unlike possible, only possible if discussion
       open for posting, or not available (default).
    - Setting of discussvote to yes or notended for course/map/resource
      will require session hosting on LON-CAPA 2.11 or newer.   
  
  
-------------- next part --------------
Index: loncom/interface/lonfeedback.pm
diff -u loncom/interface/lonfeedback.pm:1.338 loncom/interface/lonfeedback.pm:1.339
--- loncom/interface/lonfeedback.pm:1.338	Fri Mar  9 15:02:31 2012
+++ loncom/interface/lonfeedback.pm	Tue Mar 13 05:37:49 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Feedback
 #
-# $Id: lonfeedback.pm,v 1.338 2012/03/09 15:02:31 raeburn Exp $
+# $Id: lonfeedback.pm,v 1.339 2012/03/13 05:37:49 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -82,6 +82,26 @@
     return 1;
 }
 
+sub discussion_vote_available {
+    my ($status,$symb)=@_;
+    my $canvote=&Apache::lonnet::EXT('resource.0.discussvote',$symb);
+    if ((lc($canvote) eq 'yes') || 
+        ((lc($canvote) eq 'notended') && (&discussion_open($status,$symb)))) {
+        return 1;
+    }
+}
+
+sub get_realsymb {
+    my ($symb) = @_;
+    my $realsymb = $symb;
+    if ($symb=~/^bulletin___/) {
+        my $filename=(&Apache::lonnet::decode_symb($symb))[2];
+        $filename=~s{^adm/wrapper/}{};
+        $realsymb=&Apache::lonnet::symbread($filename);
+    }
+    return $realsymb;
+}
+
 sub list_discussion {
     my ($mode,$status,$ressymb,$imsextras,$group)=@_;
     unless ($ressymb) { $ressymb=&Apache::lonnet::symbread(); }
@@ -265,6 +285,11 @@
     } else {
         $seeid=&Apache::lonnet::allowed('rin',$crs);
     }
+
+# Is voting on discussions available
+    my $realsymb = &get_realsymb($ressymb);
+    my $canvote = &discussion_vote_available($status,$realsymb);
+
     my @discussionitems=();
     my %shown = ();
     my @posteridentity=();
@@ -286,7 +311,7 @@
     $discinfo{$visitkey} = $visit;
 
     &Apache::lonnet::put('nohist_'.$cid.'_discuss',\%discinfo,$env{'user.domain'},$env{'user.name'});
-    &build_posting_display(\%usernamesort,\%subjectsort,\%namesort,\%notshown,\%newitem,\%dischash,\%shown,\%alldiscussion,\%imsitems,\%imsfiles,\%roleinfo,\@discussionitems,\@replies,\@depth,\@posters,\$maxdepth,\$visible,\$newpostsflag,\$current,$status,$viewgrades,$seeid,$prevread,$sortposts,$encsymb,$readkey,$showunmark,$showonlyunread,$totposters,\@rolefilter,\@sectionpick,\@grouppick,$classgroups,$statusfilter,$toggkey,$outputtarget,\%anonhash,$anoncnt,$group);
+    &build_posting_display(\%usernamesort,\%subjectsort,\%namesort,\%notshown,\%newitem,\%dischash,\%shown,\%alldiscussion,\%imsitems,\%imsfiles,\%roleinfo,\@discussionitems,\@replies,\@depth,\@posters,\$maxdepth,\$visible,\$newpostsflag,\$current,$status,$viewgrades,$seeid,$canvote,$prevread,$sortposts,$encsymb,$readkey,$showunmark,$showonlyunread,$totposters,\@rolefilter,\@sectionpick,\@grouppick,$classgroups,$statusfilter,$toggkey,$outputtarget,\%anonhash,$anoncnt,$group);
 
     my $discussion='';
     my $manifestfile;
@@ -744,9 +769,15 @@
             $discussion.= &send_feedback_link($ressymb);
             if ($env{'request.role.adv'}) {
                 my $close = &Apache::lonnet::EXT('resource.0.discussend',$ressymb);
+                my $canvote = &Apache::lonnet::EXT('resource.0.discussvote',$ressymb);
                 if (defined($close) && $close ne '' && $close < time) {
-                    $discussion .= ' '.&mt('(Closed for [_1] roles)',
-                                                &Apache::lonnet::plaintext('st',$crstype));
+                    if ($canvote eq 'notended') {
+                        $discussion .= ' '.&mt('(Posting and voting closed for [_1] roles)',
+                                                    &Apache::lonnet::plaintext('st',$crstype));
+                    } else {
+                        $discussion .= ' '.&mt('(Closed for [_1] roles)',
+                                                    &Apache::lonnet::plaintext('st',$crstype));
+                    }
                 }
             }
 	} else {
@@ -937,7 +968,7 @@
 }
 
 sub build_posting_display {
-    my ($usernamesort,$subjectsort,$namesort,$notshown,$newitem,$dischash,$shown,$alldiscussion,$imsitems,$imsfiles,$roleinfo,$discussionitems,$replies,$depth,$posters,$maxdepth,$visible,$newpostsflag,$current,$status,$viewgrades,$seeid,$prevread,$sortposts,$ressymb,$readkey,$showunmark,$showonlyunread,$totposters,$rolefilter,$sectionpick,$grouppick,$classgroups,$statusfilter,$toggkey,$outputtarget,$anonhash,$anoncnt,$group) = @_;
+    my ($usernamesort,$subjectsort,$namesort,$notshown,$newitem,$dischash,$shown,$alldiscussion,$imsitems,$imsfiles,$roleinfo,$discussionitems,$replies,$depth,$posters,$maxdepth,$visible,$newpostsflag,$current,$status,$viewgrades,$seeid,$canvote,$prevread,$sortposts,$ressymb,$readkey,$showunmark,$showonlyunread,$totposters,$rolefilter,$sectionpick,$grouppick,$classgroups,$statusfilter,$toggkey,$outputtarget,$anonhash,$anoncnt,$group) = @_;
     my @original=();
     my @index=();
     my $skip_group_check = 0;
@@ -947,17 +978,20 @@
     my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'},
 			  $env{'course.'.$env{'request.course.id'}.'.domain'},
 			  $env{'course.'.$env{'request.course.id'}.'.num'});
+    my (%likes,%userlikes,%userunlikes, at theselikes,$oneplus,$twoplus,$oneminus,$twominus);
+    my $thisuser=$env{'user.name'}.':'.$env{'user.domain'};
+    if ($seeid || $canvote) {
 # And these are the likes/unlikes
-    my %likes=&Apache::lonnet::dump('disclikes',
+        %likes=&Apache::lonnet::dump('disclikes',
                           $env{'course.'.$env{'request.course.id'}.'.domain'},
                           $env{'course.'.$env{'request.course.id'}.'.num'},
                           '^'.$symb.':');
-    my $thisuser=$env{'user.name'}.':'.$env{'user.domain'};
 # Array with likes to figure out averages, etc.
-    my @theselikes=();
+        @theselikes=();
 # Hashes containing likes and unlikes for this user.
-    my %userlikes=();
-    my %userunlikes=();
+        %userlikes=();
+        %userunlikes=();
+    }
 # Is the user allowed to see the real name behind anonymous postings?
     my $see_anonymous = 
 	&Apache::lonnet::allowed('rin',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''));
@@ -991,50 +1025,52 @@
                      &filter_regexp($rolefilter,$sectionpick,$statusfilter);
             $rolematch = $roleregexp.':'.$secregexp.':'.$statusregexp;
         }
+        if ($seeid || $canvote) {
 # We need to go through this twice, first to get the likes/dislikes, then to actually build the display
-        for (my $id=1;$id<=$contrib{'version'};$id++) {
-            my $idx=$id;
-            next if ($contrib{$idx.':deleted'});
-            next if ($contrib{$idx.':hidden'});
-            unless ((($hiddens{$idx}) && (!$seeid)) || ($deletions{$idx}) || (!$contrib{$idx.':message'})) {
-                if ($likes{$symb.':'.$idx.':likes'} ne '') {
-                    push(@theselikes,$likes{$symb.':'.$idx.':likes'});
-                    if (ref($likes{$symb.':'.$idx.':likers'}) eq 'HASH') {
-                        if (exists($likes{$symb.':'.$idx.':likers'}{$thisuser})) {
-                            $userlikes{$idx} = 1;
+            for (my $id=1;$id<=$contrib{'version'};$id++) {
+                my $idx=$id;
+                next if ($contrib{$idx.':deleted'});
+                next if ($contrib{$idx.':hidden'});
+                unless ((($hiddens{$idx}) && (!$seeid)) || ($deletions{$idx}) || (!$contrib{$idx.':message'})) {
+                    if ($likes{$symb.':'.$idx.':likes'} ne '') {
+                        push(@theselikes,$likes{$symb.':'.$idx.':likes'});
+                        if (ref($likes{$symb.':'.$idx.':likers'}) eq 'HASH') {
+                            if (exists($likes{$symb.':'.$idx.':likers'}{$thisuser})) {
+                                $userlikes{$idx} = 1;
+                            }
                         }
-                    }
-                    if (ref($likes{$symb.':'.$idx.':unlikers'}) eq 'HASH') {
-                        if (exists($likes{$symb.':'.$idx.':unlikers'}{$thisuser})) {
-                            $userunlikes{$idx} = 1;
+                        if (ref($likes{$symb.':'.$idx.':unlikers'}) eq 'HASH') {
+                            if (exists($likes{$symb.':'.$idx.':unlikers'}{$thisuser})) {
+                                $userunlikes{$idx} = 1;
+                            }
                         }
                     }
                 }
             }
-        }
 # Figure out average likes and standard deviation if there are enough 
 # discussions to warrant that
-        my $ave=0;
-        my $stddev=10000;
-        if ($#theselikes>1) {
-            my $sum=0;
-            my $num=$#theselikes+1;
-            foreach my $thislike (@theselikes) {
-                $sum+=$thislike;
-            }
-            $ave=$sum/$num;
-            my $sumsq=0;
-            foreach my $thislike (@theselikes) {
-                $sumsq+=($thislike-$ave)*($thislike-$ave);
+            my $ave=0;
+            my $stddev=10000;
+            if ($#theselikes>1) {
+                my $sum=0;
+                my $num=$#theselikes+1;
+                foreach my $thislike (@theselikes) {
+                    $sum+=$thislike;
+                }
+                $ave=$sum/$num;
+                my $sumsq=0;
+                foreach my $thislike (@theselikes) {
+                    $sumsq+=($thislike-$ave)*($thislike-$ave);
+                }
+                $stddev=sqrt($sumsq/$num);
             }
-            $stddev=sqrt($sumsq/$num);
-        }
 # Now we know the average likes $ave and the standard deviation $stddev
 # Get the boundaries for markup
-        my $oneplus=$ave+$stddev;
-        my $twoplus=$ave+2.*$stddev;
-        my $oneminus=$ave-$stddev;
-        my $twominus=$ave-2.*$stddev;
+            $oneplus=$ave+$stddev;
+            $twoplus=$ave+2.*$stddev;
+            $oneminus=$ave-$stddev;
+            $twominus=$ave-2.*$stddev;
+        }
 #
 # This is now the real loop. Go through all entries, pick up what we need
 #
@@ -1365,40 +1401,47 @@
                             if ($$dischash{$toggkey}) {
                                 $$discussionitems[$idx].='  '.$ctlink;
                             }
-# Figure out size based on likes
                             my $thislikes=$likes{$symb.':'.$idx.':likes'};
                             my $likesize="100";
-                            if ($thislikes>$twoplus) {
-                                $likesize="200";
-                            } elsif ($thislikes>$oneplus) {
-                                $likesize="150";
-                            }
-                            if ($thislikes<$twominus) {
-                                $likesize="50";
-                            } elsif ($thislikes<$oneminus) {
-                                $likesize="75";
+                            if ($seeid || $canvote) {
+# Figure out size based on likes
+                                my $thislikes=$likes{$symb.':'.$idx.':likes'};
+                                if ($thislikes>$twoplus) {
+                                    $likesize="200";
+                                } elsif ($thislikes>$oneplus) {
+                                    $likesize="150";
+                                }
+                                if ($thislikes<$twominus) {
+                                    $likesize="50";
+                                } elsif ($thislikes<$oneminus) {
+                                    $likesize="75";
+                                }
                             }
 # Actually glue in the message itself
                             $$discussionitems[$idx].= '<br /><blockquote>'.
                                     "<div style='font-size:$likesize%'>".
                                     $message.
                                     '</div></blockquote>';
+                            if ($canvote) {
 # Put in the like and unlike buttons
-                            if ($userlikes{$idx}) {
-                                $$discussionitems[$idx].='<img border="0" src="/res/adm/pages/thumbsup_gray.png" alt="'.&mt('You like this posting').'" />';
-                            } else {
-                                $$discussionitems[$idx].=' '.&discussion_link($symb,'<img border="0" src="/res/adm/pages/thumbsup.png" alt="'.&mt('Like').'" />','like',$idx,$$newpostsflag,$prevread,&group_args($group),&mt("Like this posting"));
-                            }
-                            if ($userunlikes{$idx}) {
-                                $$discussionitems[$idx].='<img border="0" src="/res/adm/pages/thumbsdown_gray.png" alt="'.&mt('You unlike this posting').'" />';
-                            } else {
-                                $$discussionitems[$idx].=' '.&discussion_link($symb,'<img border="0" src="/res/adm/pages/thumbsdown.png" alt="'.&mt('Unlike').'" />','unlike',$idx,$$newpostsflag,$prevread,&group_args($group),&mt("Unlike this posting"));
+                                if ($userlikes{$idx}) {
+                                    $$discussionitems[$idx].='<img border="0" src="/res/adm/pages/thumbsup_gray.png" alt="'.&mt('You like this posting').'" />';
+                                } else {
+                                    $$discussionitems[$idx].=' '.&discussion_link($symb,'<img border="0" src="/res/adm/pages/thumbsup.png" alt="'.&mt('Like').'" />','like',$idx,$$newpostsflag,$prevread,&group_args($group),&mt("Like this posting"));
+                                }
+                                if ($userunlikes{$idx}) {
+                                    $$discussionitems[$idx].='<img border="0" src="/res/adm/pages/thumbsdown_gray.png" alt="'.&mt('You unlike this posting').'" />';
+                                } else {
+                                    $$discussionitems[$idx].=' '.&discussion_link($symb,'<img border="0" src="/res/adm/pages/thumbsdown.png" alt="'.&mt('Unlike').'" />','unlike',$idx,$$newpostsflag,$prevread,&group_args($group),&mt("Unlike this posting"));
+                                }
                             }
-                            my $thislikes=$likes{$symb.':'.$idx.':likes'};
-                            if ($thislikes>0) {
-                                $$discussionitems[$idx].=' ('.&mt("[_1] likes",$thislikes).')';
-                            } elsif ($thislikes<0) {
-                                $$discussionitems[$idx].=' ('.&mt("[_1] unlikes",abs($thislikes)).')';
+                            if ($seeid || $canvote) {
+                                my $thislikes=$likes{$symb.':'.$idx.':likes'};
+                                if ($thislikes>0) {
+                                    $$discussionitems[$idx].=' ('.&mt("[_1] likes",$thislikes).')';
+                                } elsif ($thislikes<0) {
+                                    $$discussionitems[$idx].=' ('.&mt("[_1] unlikes",abs($thislikes)).')';
+                                }
                             }
 # If there is any history to this post, inform the reader
                             if ($contrib{$idx.':history'}) {
@@ -2795,12 +2838,7 @@
         my ($blocked,$blocktext) = &Apache::loncommon::blocking_status('boards');
         my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
         my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
-        my $realsymb = $symb;
-        if ($symb=~/^bulletin___/) {
-            my $filename=(&Apache::lonnet::decode_symb($symb))[2];
-            $filename=~s|^adm/wrapper/||;
-            $realsymb=&Apache::lonnet::symbread($filename);
-        }
+        my $realsymb = &get_realsymb($symb);
         if (!$blocked && &discussion_open(undef,$realsymb) && 
 	    (&Apache::lonnet::allowed('pch',
 				      $env{'request.course.id'}.
@@ -3003,12 +3041,7 @@
 sub adddiscuss {
     my ($symb,$email,$anon,$attachmenturl,$subject,$group)=@_;
     my $status='';
-    my $realsymb;
-    if ($symb=~/^bulletin___/) {
-	my $filename=(&Apache::lonnet::decode_symb($symb))[2];
-	$filename=~s|^adm/wrapper/||;
-	$realsymb=&Apache::lonnet::symbread($filename);
-    }
+    my $realsymb = &get_realsymb($symb);
     my ($cnum,$cdom);
     if ($env{'request.course.id'}) {
         $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
@@ -4025,89 +4058,99 @@
       my $entry=$env{'form.like'}?$env{'form.like'}:$env{'form.unlike'};
       my ($symb,$idx)=split(/\:\:\:/,$entry);
       ($symb,my $feedurl)=&get_feedurl_and_clean_symb($symb);
+      my $status='OPEN';
+      if ($Apache::lonhomework::parsing_a_problem ||
+          $Apache::lonhomework::parsing_a_task) {
+          $status=$Apache::inputtags::status[-1];
+      }
+      my $result;
+      my $realsymb = &get_realsymb($symb);
+      if (&discussion_vote_available($status,$realsymb)) {
 #
 # Likes and unlikes are in db-file "disclikes" of the course
 # The prefix is the $symb to identify the resource discussion,
 # and the $idx to identify the entry
 #
-      my $prefix=$symb.':'.$idx.':';
-      my %contrib=&Apache::lonnet::dump('disclikes',
+          my $prefix=$symb.':'.$idx.':';
+          my %contrib=&Apache::lonnet::dump('disclikes',
                                         $env{'course.'.$env{'request.course.id'}.'.domain'},
                                         $env{'course.'.$env{'request.course.id'}.'.num'},
                                         '^'.$prefix);
 
 # Get current like or unlike status for the $idx for this user.
-      my $thisuser=$env{'user.name'}.':'.$env{'user.domain'};
-      my ($userlikes,$userunlikes);
-      if (ref($contrib{$prefix.'likers'}) eq 'HASH') {
-          if (exists($contrib{$prefix.'likers'}{$thisuser})) {
-              $userlikes = 1;
+          my $thisuser=$env{'user.name'}.':'.$env{'user.domain'};
+          my ($userlikes,$userunlikes);
+          if (ref($contrib{$prefix.'likers'}) eq 'HASH') {
+              if (exists($contrib{$prefix.'likers'}{$thisuser})) {
+                  $userlikes = 1;
+              }
           }
-      }
-      if (ref($contrib{$prefix.'unlikers'}) eq 'HASH') {
-          if (exists($contrib{$prefix.'unlikers'}{$thisuser})) {
-              $userunlikes = 1;
+          if (ref($contrib{$prefix.'unlikers'}) eq 'HASH') {
+              if (exists($contrib{$prefix.'unlikers'}{$thisuser})) {
+                  $userunlikes = 1;
+              }
           }
-      }
 # Get the current "likes" count
-      my $likes=$contrib{$prefix.'likes'};
+          my $likes=$contrib{$prefix.'likes'};
 # Find out if they already voted
 # Users cannot like a post twice, or unlike it twice.
 # They can change their mind, though.
-      my $alreadyflag=0;
-      my $thisuser=$env{'user.name'}.':'.$env{'user.domain'};
-      if ($env{'form.like'}) {
-          if ($userlikes) {
-              $alreadyflag=1;
-          } elsif ($userunlikes) {
-              delete($contrib{$prefix.'unlikers'}{$thisuser});
-              $likes++;
-          } else {
-              if (ref($contrib{$prefix.'likers'}) eq 'HASH') {
-                  $contrib{$prefix.'likers'}{$thisuser} = 1;
+          my $alreadyflag=0;
+          my $thisuser=$env{'user.name'}.':'.$env{'user.domain'};
+          if ($env{'form.like'}) {
+              if ($userlikes) {
+                  $alreadyflag=1;
+              } elsif ($userunlikes) {
+                  delete($contrib{$prefix.'unlikers'}{$thisuser});
+                  $likes++;
               } else {
-                  $contrib{$prefix.'likers'} = {$thisuser => 1};
+                  if (ref($contrib{$prefix.'likers'}) eq 'HASH') {
+                      $contrib{$prefix.'likers'}{$thisuser} = 1;
+                  } else {
+                      $contrib{$prefix.'likers'} = {$thisuser => 1};
+                  }
+                  $likes++;
               }
-              $likes++;
-          }
-      } else {
-          if ($userunlikes) {
-              $alreadyflag=1;
-          } elsif ($userlikes) {
-              delete($contrib{$prefix.'likers'}{$thisuser});
-              $likes--;
           } else {
-              if (ref($contrib{$prefix.'unlikers'}) eq 'HASH') {
-                  $contrib{$prefix.'unlikers'}{$thisuser} = 1;
+              if ($userunlikes) {
+                  $alreadyflag=1;
+              } elsif ($userlikes) {
+                  delete($contrib{$prefix.'likers'}{$thisuser});
+                  $likes--;
               } else {
-                  $contrib{$prefix.'unlikers'} = {$thisuser => 1};
+                  if (ref($contrib{$prefix.'unlikers'}) eq 'HASH') {
+                      $contrib{$prefix.'unlikers'}{$thisuser} = 1;
+                  } else {
+                      $contrib{$prefix.'unlikers'} = {$thisuser => 1};
+                  }
+                  $likes--;
               }
-              $likes--;
           }
-      }
-      my $result;
 # $alreadyflag would be 1 if they tried to double-like or double-unlike
-      unless ($alreadyflag) {
-          my %newhash=($prefix.'likes'    => $likes,
-                       $prefix.'likers'   => $contrib{$prefix.'likers'},
-                       $prefix.'unlikers' => $contrib{$prefix.'unlikers'});
+          unless ($alreadyflag) {
+              my %newhash=($prefix.'likes'    => $likes,
+                           $prefix.'likers'   => $contrib{$prefix.'likers'},
+                           $prefix.'unlikers' => $contrib{$prefix.'unlikers'});
 # Store data in db-file "disclikes"
-          if (&Apache::lonnet::put('disclikes',
-                                   \%newhash,
-                                   $env{'course.'.$env{'request.course.id'}.'.domain'},
-                                   $env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') {
+              if (&Apache::lonnet::put('disclikes',
+                                       \%newhash,
+                                       $env{'course.'.$env{'request.course.id'}.'.domain'},
+                                       $env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') {
 # Also store with the person who posted the liked/unliked entry
-              if ($env{'form.like'}) {
-                  &storediscussionlikes(1,$contrib{$idx.':sendername'},$contrib{$idx.':senderdomain'});
-                  $result=&mt("Registered 'Like'");
+                  if ($env{'form.like'}) {
+                      &storediscussionlikes(1,$contrib{$idx.':sendername'},$contrib{$idx.':senderdomain'});
+                      $result=&mt("Registered 'Like'");
+                  } else {
+                      &storediscussionlikes(-1,$contrib{$idx.':sendername'},$contrib{$idx.':senderdomain'});
+                      $result=&mt("Registered 'Unlike'");
+                  }
               } else {
-                  &storediscussionlikes(-1,$contrib{$idx.':sendername'},$contrib{$idx.':senderdomain'});
-                  $result=&mt("Registered 'Unlike'");
-              }
-          } else {
 # Oops, something went wrong
-              $result=&mt("Failed to register vote");
+                  $result=&mt("Failed to register vote");
+              }
           }
+      } else {
+          $result=&mt('Voting unavailable for this discussion');
       }
       &redirect_back($r,$feedurl,$result.'<br />',
                      '0','0','','',$env{'form.previous'},undef,undef,undef,
@@ -4562,6 +4605,10 @@
 
 =item discussion_visible()
 
+=item discussion_vote_available()
+
+=item get_realsymb()
+
 =item list_discussion()
 
 =item send_feedback_link()
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.520 loncom/interface/lonparmset.pm:1.521
--- loncom/interface/lonparmset.pm:1.520	Wed Dec 28 21:49:54 2011
+++ loncom/interface/lonparmset.pm	Tue Mar 13 05:37:49 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set parameters for assessments
 #
-# $Id: lonparmset.pm,v 1.520 2011/12/28 21:49:54 raeburn Exp $
+# $Id: lonparmset.pm,v 1.521 2012/03/13 05:37:49 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1295,8 +1295,9 @@
     }
 
     function checkdisset() {
-    checkthis('discussend','pscat');
+     checkthis('discussend','pscat');
      checkthis('discusshide','pscat');
+     checkthis('discussvote','pscat');
     }
 
     function checkcontdates() {
@@ -1395,6 +1396,7 @@
         'scoreformat' => 'misc',
         'lenient' => 'grading',
         'retrypartial' => 'tries',
+        'discussvote'  => 'misc',
 
     );    
 }
@@ -1942,10 +1944,11 @@
         'parameter_0_tol' => 16,
         'parameter_0_sig' => 17,
         'parameter_0_turnoffunit' => 18,
-            'parameter_0_discussend' => 19,
-            'parameter_0_discusshide' => 20,
-	'parameter_0_printopendate'  =>  21,
-	'parameter_0_printclosedate' =>  22);
+        'parameter_0_discussend' => 19,
+        'parameter_0_discusshide' => 20,
+        'parameter_0_discussvote' => 21,
+	'parameter_0_printopendate'  =>  22,
+	'parameter_0_printclosedate' =>  23);
 }
 
 
@@ -2146,7 +2149,7 @@
                         }
                     }
                 }
-            } elsif ($markers[$i] =~ /_(type|lenient|retrypartial)\&\d+$/) {
+            } elsif ($markers[$i] =~ /_(type|lenient|retrypartial|discussvote)\&\d+$/) {
                 $name = $1;
                 $needsrelease =
                     $Apache::lonnet::needsrelease{"parameter:$name:$values[$i]"};
@@ -2808,6 +2811,8 @@
                 $name = 'type';
             } elsif ($typeof eq 'string_lenient') {
                 $name = 'lenient';
+            } elsif ($typeof eq 'string_discussvote') {
+                $name = 'discussvote';
             } elsif ($typeof eq 'string_yesno') {
                 if ($thiskey =~ /\.retrypartial$/) {
                     $name = 'retrypartial';
@@ -3140,7 +3145,11 @@
      'string_lenient'
              => [['yes', 'Yes' ],
                  [ 'no', 'No' ],
-                 [ 'default', 'Default - only bubblesheet grading is lenient' ]] 
+                 [ 'default', 'Default - only bubblesheet grading is lenient' ]],
+     'string_discussvote'
+             => [['yes','Yes'],
+                 ['notended','Yes, unless discussion ended'],
+                 ['no','No']],
      );
 
 sub standard_string_options {
@@ -3161,6 +3170,7 @@
     my %skiptype;
     if (($thistype eq 'string_questiontype') || 
         ($thistype eq 'string_lenient') ||
+        ($thistype eq 'string_discussvote') ||
         ($name eq 'retrypartial')) {
         my ($got_chostname,$chostname,$cmajor,$cminor); 
         foreach my $possibilities (@{ $strings{$thistype} }) {
@@ -4625,6 +4635,7 @@
                         type         => 'string_questiontype',
                         lenient      => 'string_lenient',
                         retrypartial => 'string_yesno',
+                        discussvote  => 'string_discussvote',
                       );
     if (exists($stringtypes{$name})) {
         if (ref($strings{$stringtypes{$name}}) eq 'ARRAY') {
Index: rat/client/parameter.html
diff -u rat/client/parameter.html:1.63 rat/client/parameter.html:1.64
--- rat/client/parameter.html:1.63	Thu Dec  8 21:37:51 2011
+++ rat/client/parameter.html	Tue Mar 13 05:37:55 2012
@@ -5,7 +5,7 @@
 The LearningOnline Network with CAPA
 Parameter Input Window
 //
-// $Id: parameter.html,v 1.63 2011/12/08 21:37:51 www Exp $
+// $Id: parameter.html,v 1.64 2012/03/13 05:37:55 raeburn Exp $
 //
 // Copyright Michigan State University Board of Trustees
 //
@@ -681,6 +681,22 @@
            if (svalue=='default') { choicewrite(' checked="checked"'); }
            choicewrite(' /> Default (only bubblesheet grading is lenient)</label><br />');
         }
+        if (pscat=='discussvote') {
+           tablestart('Discussion Voting');
+           choicewrite('<tr><td>Value:</td><td colspan="2">');
+           choicewrite('<label><input name="stringval" value="yes"'+
+                  ' type="radio" '+callradiostringeval('yes'));
+           if (svalue=='yes') { choicewrite(' checked="checked"'); }
+           choicewrite(' /> Yes</label><br />');
+           choicewrite('<label><input name="stringval" value="notended"'+
+                  ' type="radio" '+callradiostringeval('notended'));
+           if (svalue=='notended') { choicewrite(' checked="checked"'); }
+           choicewrite(' /> Yes, unless discussion ended</label><br />');
+           choicewrite('<label><input name="stringval" value="no"'+
+                  ' type="radio" '+callradiostringeval('no'));
+           if (svalue=='no') { choicewrite(' checked="checked"'); }
+           choicewrite(' /> No</label><br />');
+        }
         if (pscat=='ip') {
            tablestart('IP Number/Name');
 	   choicewrite('<tr><td>Value:</td><td colspan="2">');
@@ -949,6 +965,7 @@
      else if (pscat == 'examtype')     { sopt('examtype','Exam Type'); }
      else if (pscat == 'questiontype') { sopt('questiontype','Question Type'); }
      else if (pscat == 'lenient')      { sopt('lenient','Lenient Grading (Partial Credit)'); }
+     else if (pscat == 'discussvote')  { sopt('discussvote','Discussion Voting'); }
      else if (pscat == 'ip')           { sopt('ip','IP Number/Name'); }
      else if (pscat == 'fileext')      { sopt('fileext','File Extension'); }
      else if (pscat == 'useslots')     { sopt('useslots','Slots control access'); }
Index: loncom/publisher/packages.tab
diff -u loncom/publisher/packages.tab:1.69 loncom/publisher/packages.tab:1.70
--- loncom/publisher/packages.tab:1.69	Thu Dec 15 01:21:37 2011
+++ loncom/publisher/packages.tab	Tue Mar 13 05:38:02 2012
@@ -62,6 +62,9 @@
 part_0&discusshide&display:Hide Closed Discussion
 part_0&discusshide&type:string_yesno
 part_0&discusshide&default:no
+part_0&discussvote&display:Discussion Voting
+part_0&discussvote&type:string_discussvote
+part_0&discussvote&default:no
 part_0&cssfile&display:CSS file to link
 part_0&cssfile&type:string
 numericalhint&tol&display:Numerical Tolerance
Index: loncom/misc/releaseslist.xml
diff -u loncom/misc/releaseslist.xml:1.5 loncom/misc/releaseslist.xml:1.6
--- loncom/misc/releaseslist.xml:1.5	Thu Dec 15 01:21:32 2011
+++ loncom/misc/releaseslist.xml	Tue Mar 13 05:38:08 2012
@@ -7,6 +7,8 @@
 <parameter name="lenient" value="yes">2.11</parameter>
 <parameter name="lenient" value="no">2.11</parameter>
 <parameter name="retrypartial" value="yes">2.11</parameter>
+<parameter name="discussvote" value="yes">2.11</parameter>
+<parameter name="discussvote" value="notended">2.11</parameter>
 <resourcetag name="responsetype" value="custom">2.1</resourcetag>
 <resourcetag name="responsetype" value="math">2.2</resourcetag>
 <resourcetag name="responsetype" value="functionplot">2.10</resourcetag>


More information about the LON-CAPA-cvs mailing list