--- loncom/interface/lonfeedback.pm 2012/06/17 15:35:15 1.290.2.7.2.6 +++ loncom/interface/lonfeedback.pm 2010/03/10 21:25:50 1.291 @@ -1,7 +1,7 @@ # The LearningOnline Network # Feedback # -# $Id: lonfeedback.pm,v 1.290.2.7.2.6 2012/06/17 15:35:15 raeburn Exp $ +# $Id: lonfeedback.pm,v 1.291 2010/03/10 21:25:50 droeschl Exp $ # # Copyright Michigan State University Board of Trustees # @@ -49,24 +49,15 @@ use LONCAPA; sub discussion_open { my ($status,$symb)=@_; -# Advanced roles can always discuss if ($env{'request.role.adv'}) { return 1; } -# Get discussion closing date - my $close=&Apache::lonnet::EXT('resource.0.discussend',$symb); -# If it is defined and in the future, the instructor wants this discussion to be open - if (defined($close) && $close ne '' && $close > time) { - return 1; - } -# It was not explicitly open, check if the problem is available. -# If the problem is not available, close the discussion if (defined($status) && - !($status eq 'CAN_ANSWER' || $status eq 'CANNOT_ANSWER' - || $status eq 'OPEN')) { - return 0; + !($status eq 'CAN_ANSWER' || $status eq 'CANNOT_ANSWER' + || $status eq 'OPEN')) { + return 0; } -# The problem is available, but check if the instructor explictly closed discussion + my $close=&Apache::lonnet::EXT('resource.0.discussend',$symb); if (defined($close) && $close ne '' && $close < time) { - return 0; + return 0; } return 1; } @@ -82,26 +73,6 @@ sub discussion_visible { 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(); } @@ -277,14 +248,14 @@ sub list_discussion { $visit ++; my $seeid; - if (&Apache::lonnet::allowed('rin',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) { - $seeid = 1; + if (($group ne '') && ($mode eq 'board') && + ($ressymb =~ m|^bulletin___\d+___adm/wrapper/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard$|)) { + if (&check_group_priv($group,'dgp') eq 'ok') { + $seeid = 1; + } + } else { + $seeid=&Apache::lonnet::allowed('rin',$crs); } - my $seehidden = &can_see_hidden($mode,$ressymb,undef,$group,$cdom,$cnum,$crs); -# Is voting on discussions available - my $realsymb = &get_realsymb($ressymb); - my $canvote = &discussion_vote_available($status,$realsymb); - my @discussionitems=(); my %shown = (); my @posteridentity=(); @@ -302,16 +273,12 @@ sub list_discussion { my %anonhash=(); my $anoncnt=0; my $target=''; - unless ($env{'browser.interface'} eq 'textual' || - $env{'environment.remote'} eq 'off' ) { - $target='target="LONcom"'; - } my $now = time; $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,$seehidden,$canvote,$prevread,$sortposts,$encsymb,$target,$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,$prevread,$sortposts,$encsymb,$target,$readkey,$showunmark,$showonlyunread,$totposters,\@rolefilter,\@sectionpick,\@grouppick,$classgroups,$statusfilter,$toggkey,$outputtarget,\%anonhash,$anoncnt,$group); my $discussion=''; my $manifestfile; @@ -346,7 +313,6 @@ sub list_discussion { 'dpwn' => 'Deleted posts will no longer be visible to you and other students', 'bwco' => 'but will continue to be visible to your instructor', 'depo' => 'Deleted posts will no longer be visible to you or anyone else.', - 'discussions' => 'DISCUSSIONS' ); my $currdisp = $lt{'allposts'}; @@ -398,7 +364,8 @@ sub list_discussion { # Print the discusssion if ($outputtarget eq 'tex') { $discussion.='{\tiny \vskip 0 mm\noindent\makebox[2 cm][b]{\hrulefill}'. - '\textbf{'.$lt{'discussions'}.'}\makebox[2 cm][b]{\hrulefill}\vskip 0 mm'. + '\textbf{DISCUSSIONS}\makebox[2 cm][b]{\hrulefill}'. + '\vskip 0 mm\noindent\textbf{'.$lt{'cuse'}.'}:\vskip 0 mm'. '\noindent\textbf{'.$lt{'disa'}.'}: \textit{'.$currdisp.'}\vskip 0 mm'. '\noindent\textbf{'.$lt{'npce'}.'}: \textit{'.$currmark.'}}'; } elsif ($outputtarget eq 'export') { @@ -470,7 +437,7 @@ imscp_v1p1.xsd http://www.imsglobal.org/ "\n".''; $discussion .= &action_links_bar($colspan,$ressymb,$visible, $newpostsflag,$group, - $prevread,$markondisp,$seehidden); + $prevread,$markondisp); my $escsymb=&escape($ressymb); my $numhidden = keys(%notshown); if ($numhidden > 0) { @@ -543,6 +510,7 @@ imscp_v1p1.xsd http://www.imsglobal.org/ $threadinsert='
Reply: '.$thisdepth.''; } $discussionitems[$alldiscussion{$post}]=~s/<\/td>]*)>/$threadinsert<\/td>
/; + $discussionitems[$alldiscussion{$post}]=~s/]+)>(Edit|Hide|Delete|Reply|Submissions)<\/a>//g; $discussionitems[$alldiscussion{$post}]=~s/(|<\/b>|<\/a>|]+)>)//g; $discussionitems[$alldiscussion{$post}]='\vskip 0 mm\noindent\makebox[2 cm][b]{\hrulefill}'.$discussionitems[$alldiscussion{$post}]; @@ -684,7 +652,7 @@ END END $discussion .= &action_links_bar($colspan,$ressymb,$visible, $newpostsflag,$group, - $prevread,$markondisp,$seehidden); + $prevread,$markondisp); $discussion .= "


\n"; @@ -747,10 +715,9 @@ END $attachnum += @{$currnewattach}; } } - if ((&discussion_open($status)) && ($outputtarget ne 'tex')) { - if (($group ne '') && ($mode eq 'board')) { - if ((&check_group_priv($group,'pgd') eq 'ok') && - ($ressymb =~ m{^bulletin___\d+___adm/wrapper/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard$})) { + if (&discussion_open($status)) { + if (($group ne '') && ($mode eq 'board')) { + if (&check_group_priv($group,'pgd') eq 'ok') { $discussion .= &postingform_display($mode,$ressymb,$now,$subject, $comment,$outputtarget,$attachnum, @@ -758,95 +725,30 @@ END $group,$crstype); } } else { - if (&Apache::lonnet::allowed('pch',$env{'request.course.id'}. - ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) { - - $discussion.= - &postingform_display($mode,$ressymb,$now,$subject, - $comment,$outputtarget,$attachnum, - $currnewattach,$currdelold,'',$crstype); - } else { - $discussion.= ''. - &mt('This discussion is closed.').''; - } + $discussion.= + &postingform_display($mode,$ressymb,$now,$subject, + $comment,$outputtarget,$attachnum, + $currnewattach,$currdelold,'',$crstype); } } - if (!(&discussion_open($status)) && ($outputtarget ne 'tex')) { - $discussion.= ''. - &mt('This discussion is closed.').''; - } - } elsif ($outputtarget ne 'tex') { + } else { $discussion.=''; + $discussion.=''; } return $discussion; } -sub can_see_hidden { - my ($mode,$ressymb,$feedurl,$group,$cdom,$cnum,$crs) = @_; - my $seehidden; - if ($env{'request.course.id'}) { - unless ($cdom ne '' && $cnum ne '') { - $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; - $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; - } - if ($crs eq '') { - $crs = '/'.$env{'request.course.id'}; - if ($env{'request.course.sec'}) { - $crs.='_'.$env{'request.course.sec'}; - } - $crs=~s{_}{/}g; - } - if ($mode eq '') { - $mode='board'; - if ($feedurl =~ /$LONCAPA::assess_re/) { - $mode='problem'; - } - } - if (($group ne '') && ($mode eq 'board') && - ($ressymb =~ m{^bulletin___\d+\Q___adm/wrapper/adm/$cdom/$cnum/\E\d+/bulletinboard$})) { - if (&check_group_priv($group,'dgp') eq 'ok') { - $seehidden = 1; - } - } else { - $seehidden=&Apache::lonnet::allowed('rin',$crs); - } - } - return $seehidden; -} - -sub discussion_link { - my ($ressymb,$linktext,$cmd,$item,$flag,$prev,$adds,$title) = @_; - my $link = ''; - return $link; -} - sub send_feedback_link { my ($ressymb,$target) = @_; my $output = ''. @@ -863,19 +765,18 @@ sub send_message_link { my $output = ''. ' '.&mt('Send Feedback').''; return $output; } sub action_links_bar { - my ($colspan,$ressymb,$visible,$newpostsflag,$group,$prevread,$markondisp, - $seehidden) = @_; + my ($colspan,$ressymb,$visible,$newpostsflag,$group,$prevread,$markondisp) = @_; my $discussion = ''. ''. ''; + $discussion .= '">'.&mt('Export').'?  '; if ($newpostsflag) { if (!$markondisp) { $discussion .='
'; my $escsymb=&escape($ressymb); - if ($visible) { + if ($visible>2) { $discussion .= ''.&mt('Export').''; - if ($seehidden) { - $discussion .= '  '; - $discussion .=''.&mt('Undelete all deleted entries').''; - } - $discussion.=' @@ -962,7 +843,7 @@ sub postingform_display {
$lt{'note'}
$lt{'title'}: 

- + ENDDISCUSS if ($env{'form.origpage'}) { $postingform .= '\n"; - $postingform .= &generate_attachments_button('',$attachnum,$ressymb, - $now,$currnewattach, - $currdelold,'',$mode, - $blockblog); - if ((ref($currnewattach) eq 'ARRAY') && (@{$currnewattach} > 0)) { - $newattachmsg = '
'.$lt{'newa'}.'
'; - if (@{$currnewattach} > 1) { - $newattachmsg .= '
    '; - foreach my $item (@{$currnewattach}) { - $item =~ m#.*/([^/]+)$#; - $newattachmsg .= '
  1. '.$1.'
  2. '."\n"; + if ($outputtarget ne 'tex') { + $postingform .= &generate_attachments_button('',$attachnum,$ressymb, + $now,$currnewattach, + $currdelold,'',$mode, + $blockblog); + if ((ref($currnewattach) eq 'ARRAY') && (@{$currnewattach} > 0)) { + $newattachmsg = '
    '.$lt{'newa'}.'
    '; + if (@{$currnewattach} > 1) { + $newattachmsg .= '
      '; + foreach my $item (@{$currnewattach}) { + $item =~ m#.*/([^/]+)$#; + $newattachmsg .= '
    1. '.$1.'
    2. '."\n"; + } + $newattachmsg .= '
    '."\n"; + } else { + $$currnewattach[0] =~ m#.*/([^/]+)$#; + $newattachmsg .= ''.$1.'
    '."\n"; } - $newattachmsg .= '
'."\n"; - } else { - $$currnewattach[0] =~ m#.*/([^/]+)$#; - $newattachmsg .= ''.$1.'
'."\n"; } + $postingform .= $newattachmsg; + $postingform .= &generate_preview_button(); } - $postingform .= $newattachmsg; - $postingform .= &generate_preview_button(); return $postingform; } 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,$seehidden,$canvote,$prevread,$sortposts,$ressymb,$target,$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,$prevread,$sortposts,$ressymb,$target,$readkey,$showunmark,$showonlyunread,$totposters,$rolefilter,$sectionpick,$grouppick,$classgroups,$statusfilter,$toggkey,$outputtarget,$anonhash,$anoncnt,$group) = @_; my @original=(); my @index=(); my $skip_group_check = 0; my $symb=&Apache::lonenc::check_decrypt($ressymb); my $escsymb=&escape($ressymb); -# These are the discussion contributions 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,@theselikes,$oneplus,$twoplus,$oneminus,$twominus); -# And these are the likes/unlikes - my $thisuser=$env{'user.name'}.':'.$env{'user.domain'}; - if ($seeid || $canvote) { - %likes=&Apache::lonnet::dump('disclikes', - $env{'course.'.$env{'request.course.id'}.'.domain'}, - $env{'course.'.$env{'request.course.id'}.'.num'}, - '^'.$symb.':'); -# Array with likes to figure out averages, etc. - @theselikes=(); -# Hashes containing likes and unlikes for this user. - %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'}:'')); if ((@{$grouppick} == 0) || (grep(/^all$/,@{$grouppick}))) { $skip_group_check = 1; } - my (%deletions,%hiddens); - if ($contrib{'deleted'}) { - my $deleted = $contrib{'deleted'}; - $deleted =~ s/^\.//; - $deleted =~ s/\.$//; - %deletions = map { $_ => 1 } (split(/\.\./,$deleted)); - } - if ($contrib{'hidden'}) { - my $hidden = $contrib{'hidden'}; - $hidden =~ s/^\.//; - $hidden =~ s/\.$//; - %hiddens = map { $_ => 1 } (split(/\.\./,$hidden)); - } if ($contrib{'version'}) { my $oldest = $contrib{'1:timestamp'}; if ($prevread eq '0') { @@ -1062,65 +917,16 @@ sub build_posting_display { ($skiptest,$roleregexp,$secregexp,$statusregexp) = &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}) && (!$seehidden)) || ($deletions{$idx}) || (!$contrib{$idx.':message'})) { - push(@theselikes,$likes{$symb.':'.$idx.':likes'}); - if ($likes{$symb.':'.$idx.':likes'} ne '') { - 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; - } - } - } - } - } -# 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); - } - $stddev=sqrt($sumsq/$num); - } -# Now we know the average likes $ave and the standard deviation $stddev -# Get the boundaries for markup - $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 -# + } for (my $id=1;$id<=$contrib{'version'};$id++) { my $idx=$id; - next if ($contrib{$idx.':deleted'}); - next if ($contrib{$idx.':hidden'}); my $posttime = $contrib{$idx.':timestamp'}; if ($prevread <= $posttime) { $$newpostsflag = 1; } + my $hidden=($contrib{'hidden'}=~/\.$idx\./); my $studenthidden=($contrib{'studenthidden'}=~/\.$idx\./); + my $deleted=($contrib{'deleted'}=~/\.$idx\./); my $origindex='0.'; my $numoldver=0; if ($contrib{$idx.':replyto'}) { @@ -1144,7 +950,7 @@ sub build_posting_display { } else { $$replies[$$depth[$idx]]=1; } - unless ((($hiddens{$idx}) && (!$seehidden)) || ($deletions{$idx})) { + unless ((($hidden) && (!$seeid)) || ($deleted)) { $$visible++; if ($contrib{$idx.':history'}) { if ($contrib{$idx.':history'} =~ /:/) { @@ -1159,7 +965,7 @@ sub build_posting_display { my %subjects = (); my %attachtxt = (); my %allattachments = (); - my ($screenname,$plainname,$showaboutme); + my ($screenname,$plainname); my $sender = &mt('Anonymous'); # Anonymous users getting number within a discussion # Since idx is in static order, this should give the same sequence every time. @@ -1169,7 +975,7 @@ sub build_posting_display { $$anonhash{$key}=&mt('Anonymous').' '.$anoncnt; } my ($message,$subject,$vgrlink,$ctlink); - &get_post_contents(\%contrib,$idx,$seeid,$seehidden,$outputtarget,\%messages,\%subjects,\%allattachments,\%attachtxt,$imsfiles,\$screenname,\$plainname,\$showaboutme,$numoldver); + &get_post_contents(\%contrib,$idx,$seeid,$outputtarget,\%messages,\%subjects,\%allattachments,\%attachtxt,$imsfiles,\$screenname,\$plainname,$numoldver); # Set up for sorting by subject @@ -1178,7 +984,7 @@ sub build_posting_display { $message.=$attachtxt{$numoldver}; $subject=$subjects{$numoldver}; if ($message) { - if ($hiddens{$idx}) { + if ($hidden) { $message=''.$message.''; if ($studenthidden) { $message .='

Deleted by poster (student).'; @@ -1199,18 +1005,12 @@ sub build_posting_display { } } if (!$contrib{$idx.':anonymous'} || $see_anonymous) { - if ($showaboutme) { - $sender = &Apache::loncommon::aboutmewrapper( - $plainname, - $contrib{$idx.':sendername'}, - $contrib{$idx.':senderdomain'}); - } else { - $sender = $plainname; - } - if ($see_anonymous) { - $sender .= ' ('.$contrib{$idx.':sendername'}.':'. - $contrib{$idx.':senderdomain'}.')'; - } + $sender=&Apache::loncommon::aboutmewrapper( + $plainname, + $contrib{$idx.':sendername'}, + $contrib{$idx.':senderdomain'}).' ('. + $contrib{$idx.':sendername'}.':'. + $contrib{$idx.':senderdomain'}.')'; $sender = ''.$sender.''; if ($contrib{$idx.':anonymous'}) { $sender.=' ['.$$anonhash{$key}.'] '. @@ -1248,48 +1048,46 @@ sub build_posting_display { } else { @{$$namesort{$lastname}{$firstname}} = ("$idx"); } - if ($outputtarget ne 'tex') { - if (&editing_allowed($escsymb.':::'.$idx,$group)) { - if (($env{'user.domain'} eq $contrib{$idx.':senderdomain'}) && ($env{'user.name'} eq $contrib{$idx.':sendername'})) { - $sender.=' '.&mt('Edit').''; + if (&editing_allowed($escsymb.':::'.$idx,$group)) { + if (($env{'user.domain'} eq $contrib{$idx.':senderdomain'}) && ($env{'user.name'} eq $contrib{$idx.':sendername'})) { + $sender.=' '.&mt('Edit').''; - unless ($seehidden) { - my $grpargs = &group_args($group); - $sender.=" '; - } + unless ($seeid) { + my $grpargs = &group_args($group); + $sender.=" '; } } - if ($seehidden) { - if ($hiddens{$idx}) { - unless ($studenthidden) { - $sender.=' '.&mt('Make Visible').''; - } - } else { - $sender.=' '; - } - my $grpargs = &group_args($group); - $sender.= - " "; - $sender .= &mt('Delete').''; - } + $sender .= '">'.&mt('Make Visible').''; + } + } else { + $sender.=' '.&mt('Hide').''; + } + my $grpargs = &group_args($group); + $sender.= + " "; + $sender .= &mt('Delete').''; } } else { if ($screenname) { @@ -1317,38 +1115,36 @@ sub build_posting_display { @{$$namesort{'__anon'}{'__anon'}} = ("$idx"); } } - if ($outputtarget ne 'tex') { - if (&discussion_open($status)) { - if (($group ne '') && - (&check_group_priv($group,'pgd') eq 'ok')) { - $sender.=' '.&mt('Reply').''; - } elsif (&Apache::lonnet::allowed('pch', - $env{'request.course.id'}. - ($env{'request.course.sec'}?'/'. - $env{'request.course.sec'}:''))) { - $sender.=' '.&mt('Reply').''; + if (&discussion_open($status)) { + if (($group ne '') && + (&check_group_priv($group,'pgd') eq 'ok')) { + $sender.=' '.&mt('Reply').''; + } elsif (&Apache::lonnet::allowed('pch', + $env{'request.course.id'}. + ($env{'request.course.sec'}?'/'. + $env{'request.course.sec'}:''))) { + $sender.=' '.&mt('Reply').''; } - if ($viewgrades) { + } + if ($viewgrades) { $vgrlink=&Apache::loncommon::submlink(&mt('Submissions'), - $contrib{$idx.':sendername'},$contrib{$idx.':senderdomain'},$ressymb); - } - if ($$dischash{$readkey}=~/\.$idx\./) { - $ctlink = ''; - } else { - $ctlink = ''; - } + $contrib{$idx.':sendername'},$contrib{$idx.':senderdomain'},$ressymb); + } + if ($$dischash{$readkey}=~/\.$idx\./) { + $ctlink = ''; + } else { + $ctlink = ''; } } #figure out at what position this needs to print @@ -1365,7 +1161,7 @@ sub build_posting_display { if ($outputtarget eq 'export') { %{$$imsitems{$idx}} = (); $$imsitems{$idx}{'isvisible'}='true'; - if ($hiddens{$idx}) { + if ($hidden) { $$imsitems{$idx}{'isvisible'}='false'; } $$imsitems{$idx}{'title'}=$subjects{$numoldver}; @@ -1387,15 +1183,14 @@ sub build_posting_display { } else { if ($message) { my $spansize = 2; - my ($uname,$udom); if ($showonlyunread && $prevread > $posttime) { $$notshown{$idx} = 1; } elsif ($showunmark && $$dischash{$readkey}=~/\.$idx\./) { $$notshown{$idx} = 1; } else { # apply filters - $uname = $contrib{$idx.':sendername'}; - $udom = $contrib{$idx.':senderdomain'}; + my $uname = $contrib{$idx.':sendername'}; + my $udom = $contrib{$idx.':senderdomain'}; my $poster = $uname.':'.$udom; if ($env{'form.totposters'} ne '') { if ($totposters == 0) { @@ -1448,7 +1243,7 @@ sub build_posting_display { $$newitem{$idx} = 1; $$discussionitems[$idx] .= ' - '; + '; } else { $$newitem{$idx} = 0; $$discussionitems[$idx] .= ' @@ -1463,70 +1258,12 @@ sub build_posting_display { $$discussionitems[$idx].=''; } - my $likesize="100"; - 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].= '
'.&mt('NEW').' 
'.&mt('NEW').'  '. $ctlink.'
'. - "
". - $message. - '
'; - if ($canvote) { - my $ownpost; - if (($uname eq $env{'user.name'}) && - ($udom eq $env{'user.domain'})) { - $ownpost = 1; - } -# Put in the like and unlike buttons - if ($ownpost || (($hiddens{$idx}) && ($seehidden))) { - my $novote; - if ($ownpost) { - $novote = &mt('No voting for your own posts.'); - } else { - $novote = &mt('No voting for hidden posts.'); - } - $$discussionitems[$idx].= - ''. - ''.$novote.' '. - ''.$novote.''; - } else { - if ($userlikes{$idx}) { - $$discussionitems[$idx].=''.&mt('You like this posting').''; - } else { - $$discussionitems[$idx].=' '.&discussion_link($symb,''.&mt('Like').'','like',$idx,$$newpostsflag,$prevread,&group_args($group),&mt("Like this posting")); - } - if ($userunlikes{$idx}) { - $$discussionitems[$idx].=''.&mt('You unlike this posting').''; - } else { - $$discussionitems[$idx].=' '.&discussion_link($symb,''.&mt('Unlike').'','unlike',$idx,$$newpostsflag,$prevread,&group_args($group),&mt("Unlike this posting")); - } - } - } - 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 + $message.''; if ($contrib{$idx.':history'}) { my @postversions = (); $$discussionitems[$idx] .= &mt('This post has been edited by the author.'); - if ($seehidden) { + if ($seeid) { $$discussionitems[$idx] .= '  '.&mt('Display all versions').''; @@ -1606,13 +1343,13 @@ sub filter_regexp { sub get_post_contents { - my ($contrib,$idx,$seeid,$seehidden,$type,$messages,$subjects,$allattachments,$attachtxt,$imsfiles,$screenname,$plainname,$showaboutme,$numver) = @_; + my ($contrib,$idx,$seeid,$type,$messages,$subjects,$allattachments,$attachtxt,$imsfiles,$screenname,$plainname,$numver) = @_; my $discussion = ''; my $start=$numver; my $end=$numver + 1; %{$$imsfiles{$idx}}=(); if ($type eq 'allversions') { - unless($seehidden) { + unless($seeid) { $discussion=&mt('You do not have privileges to view all versions of posts.').' '.&mt('Please select a different role.'); return $discussion; } @@ -1624,20 +1361,13 @@ sub get_post_contents { $$contrib{$idx.':sendername'}, $$contrib{$idx.':senderdomain'}); $$screenname=$$contrib{$idx.':screenname'}; - $$showaboutme = &Apache::lonnet::usertools_access($$contrib{$idx.':sendername'}, - $$contrib{$idx.':senderdomain'}, - 'aboutme'); - my $sender = $$plainname; - if ($$showaboutme) { - $sender = &Apache::loncommon::aboutmewrapper( + + my $sender=&Apache::loncommon::aboutmewrapper( $$plainname, $$contrib{$idx.':sendername'}, - $$contrib{$idx.':senderdomain'}); - } - if ($seeid) { - $sender .= ' ('.$$contrib{$idx.':sendername'}.':'. - $$contrib{$idx.':senderdomain'}.')'; - } + $$contrib{$idx.':senderdomain'}).' ('. + $$contrib{$idx.':sendername'}.':'. + $$contrib{$idx.':senderdomain'}.')'; my $attachmenturls = $$contrib{$idx.':attachmenturl'}; my @postversions = (); if ($type eq 'allversions' || $type eq 'export') { @@ -1822,7 +1552,6 @@ END $env{'course.'.$env{'request.course.id'}.'.domain'}, $env{'course.'.$env{'request.course.id'}.'.num'}); unless (($contrib{'hidden'}=~/\.$idx\./) || ($contrib{'deleted'}=~/\.$idx\./)) { - my $numoldver = 0; if ($contrib{$idx.':history'}) { if ($contrib{$idx.':history'} =~ /:/) { my @oldversions = split(/:/,$contrib{$idx.':history'}); @@ -1831,25 +1560,36 @@ END $numoldver = 1; } } - if ($idx > 0) { - my (%msgversions,%subversions,$htmldecode); - $htmldecode = 0; - if ($env{'form.replydisc'}) { - $htmldecode = 1; + if ($env{'form.replydisc'}) { + if ($contrib{$idx.':history'}) { + if ($contrib{$idx.':history'} =~ /:/) { + my @oldversions = split(/:/,$contrib{$idx.':history'}); + $numoldver = @oldversions; + } else { + $numoldver = 1; + } } - &get_post_versions(\%msgversions,$contrib{$idx.':message'},0,$numoldver); - &get_post_versions(\%subversions,$contrib{$idx.':subject'},$htmldecode, - $numoldver); - $subject = $subversions{$numoldver}; - if ($env{'form.replydisc'}) { + if ($idx > 0) { + my %msgversions = (); + &get_post_versions(\%msgversions,$contrib{$idx.':message'},0,$numoldver); $quote = $msgversions{$numoldver}; - $subject = &HTML::Entities::encode(&mt('Re: ').$subject,'<>&"'); - } else { - $comment = $msgversions{$numoldver}; } - } - if ($env{'form.editdisc'}) { + if ($idx > 0) { + my %subversions = (); + &get_post_versions(\%subversions,$contrib{$idx.':subject'},1,$numoldver); + $subject = &mt('Re: ').$subversions{$numoldver}; + } + $subject = &HTML::Entities::encode($subject,'<>&"'); + } else { $attachmenturls = $contrib{$idx.':attachmenturl'}; + if ($idx > 0) { + my %msgversions = (); + &get_post_versions(\%msgversions,$contrib{$idx.':message'},0,$numoldver); + $comment = $msgversions{$numoldver}; + my %subversions = (); + &get_post_versions(\%subversions,$contrib{$idx.':subject'},0,$numoldver); + $subject = $subversions{$numoldver}; + } if (defined($contrib{$idx.':replyto'})) { $parentmsg = $contrib{$idx.':replyto'}; } @@ -1924,17 +1664,6 @@ END END - my ($textareaheader,$textareaclass); - if (&Apache::lonhtmlcommon::htmlareabrowser()) { - $textareaheader = &Apache::lonhtmlcommon::htmlareaselectactive(); - $textareaclass = 'class="LC_richDefaultOff"'; - if ($env{'request.course.id'}) { - unless (($env{'course.'.$env{'request.course.id'}.'.allow_limited_html_in_feedback'} =~ /^\s*yes\s*$/i) || ($env{'form.sendmessageonly'})) { - undef($textareaclass); - } - } - } - # Breadcrumbs my $brcrum = [{'href' => '', 'text' => 'Resource Feedback and Discussion'}]; @@ -1974,16 +1703,14 @@ END $r->print(< $quote -

$lt{'myqu'} -$textareaheader -

+

$lt{'myqu'}

$latexHelp

$lt{'title'}:

-

END if ( ($env{'form.editdisc'}) || ($env{'form.replydisc'}) ) { @@ -2061,6 +1788,7 @@ END } } $r->print(&generate_preview_button(). + &Apache::lonhtmlcommon::htmlareaselectactive('comment'). &Apache::loncommon::end_page()); } @@ -2498,11 +2226,24 @@ sub print_showposters { $r->send_http_header; &Apache::lonenc::check_encrypt(\$symb); + my $crs='/'.$env{'request.course.id'}; + if ($env{'request.course.sec'}) { + $crs.='_'.$env{'request.course.sec'}; + } + $crs=~s/\_/\//g; + my $seeid; my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; my $group = $env{'form.group'}; my $ressymb = &wrap_symb($symb); - my $seehidden = &can_see_hidden('',$ressymb,$feedurl,$group,$cdom,$cnum); + if (($group ne '') && + ($ressymb =~ m|^bulletin___ \d+___adm/wrapper/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard$|)) { + if (&check_group_priv($group,'dgp') eq 'ok') { + $seeid = 1; + } + } else { + $seeid=&Apache::lonnet::allowed('rin',$crs); + } my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'}, $cdom,$cnum); my %namesort = (); @@ -2518,7 +2259,7 @@ sub print_showposters { for (my $idx=1;$idx<=$contrib{'version'};$idx++) { my $hidden=($contrib{'hidden'}=~/\.$idx\./); my $deleted=($contrib{'deleted'}=~/\.$idx\./); - unless ((($hidden) && (!$seehidden)) || ($deleted)) { + unless ((($hidden) && (!$seeid)) || ($deleted)) { if ((!$contrib{$idx.':anonymous'}) || (&Apache::lonnet::allowed('rin',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')))) { my %names = &Apache::lonnet::get('environment',['firstname','lastname'],$contrib{$idx.':senderdomain'},$contrib{$idx.':sendername'}); my $lastname = $names{'lastname'}; @@ -2770,10 +2511,6 @@ sub redirect_back { &Apache::lonenc::check_encrypt(\$feedurl); my $logo=&Apache::loncommon::lonhttpdurl('/adm/lonIcons/lonlogos.gif'); my %onload; - if ($env{'environment.remote'} ne 'off') { - $onload{'onload'} = - "if (window.name!='loncapaclient') { this.document.reldt.submit(); self.window.close(); }"; - } my $start_page= &Apache::loncommon::start_page('Feedback sent',undef, {'redirect' => [0,$feedurl], @@ -2807,17 +2544,13 @@ sub no_redirect_back { my $nofeed=&mt('Sorry, no feedback possible on this resource ...'); my %onload; - if ($env{'environment.remote'} ne 'off') { - $onload{'onload'} = - "if (window.name!='loncapaclient') { self.window.close(); }"; - } my %body_options = ('only_body' => 1, 'bgcolor' => '#FFFFFF', 'add_entries' => \%onload,); if ($feedurl !~ m{^/adm/feedback}) { - $body_options{'redirect'} = [2,$feedurl]; + $body_options{'rediect'} = [2,$feedurl]; } my $start_page= &Apache::loncommon::start_page('Feedback not sent',undef, @@ -2837,7 +2570,7 @@ ENDNOREDIRTWO } sub screen_header { - my ($feedurl,$symb,$group) = @_; + my ($feedurl,$symb) = @_; my $crscontent = &mt('Question/Comment/Feedback about course content'); my $crspolicy = &mt('Question/Comment/Feedback about course policy'); my $contribdisc = &mt('Contribution to course discussion of resource'); @@ -2886,14 +2619,10 @@ sub screen_header { } if (($env{'request.course.id'}) && (!$env{'form.sendmessageonly'})) { 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 = &get_realsymb($symb); - if (!$blocked && &discussion_open(undef,$realsymb) && - (&Apache::lonnet::allowed('pch', + if (!$blocked && &discussion_open(undef,$symb) && + &Apache::lonnet::allowed('pch', $env{'request.course.id'}. - ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')) || - (($group ne '') && ($symb =~ m{^bulletin___\d+___adm/wrapper/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard$}) && (&check_group_priv($group,'pgd') eq 'ok')))) { + ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) { $discussoptions='