--- loncom/interface/lonfeedback.pm 2003/06/20 14:50:34 1.47 +++ loncom/interface/lonfeedback.pm 2010/06/19 19:06:42 1.282.2.1 @@ -1,7 +1,7 @@ # The LearningOnline Network # Feedback # -# $Id: lonfeedback.pm,v 1.47 2003/06/20 14:50:34 bowersj2 Exp $ +# $Id: lonfeedback.pm,v 1.282.2.1 2010/06/19 19:06:42 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -25,24 +25,7 @@ # # http://www.lon-capa.org/ # -# (Internal Server Error Handler -# -# (Login Screen -# 5/21/99,5/22,5/25,5/26,5/31,6/2,6/10,7/12,7/14, -# 1/14/00,5/29,5/30,6/1,6/29,7/1,11/9 Gerd Kortemeyer) -# -# 3/1/1 Gerd Kortemeyer) -# -# 3/1,2/3,2/5,2/6,2/8 Gerd Kortemeyer -# 2/9 Guy Albertelli -# 2/10 Gerd Kortemeyer -# 2/13 Guy Albertelli -# 7/25 Gerd Kortemeyer -# 7/26 Guy Albertelli -# 7/26,8/10,10/1,11/5,11/6,12/27,12/29 Gerd Kortemeyer -# YEAR=2002 -# 1/1,1/16 Gerd Kortemeyer -# +### package Apache::lonfeedback; @@ -51,172 +34,2632 @@ use Apache::Constants qw(:common); use Apache::lonmsg(); use Apache::loncommon(); use Apache::lontexconvert(); +use Apache::lonlocal; # must not have () +use Apache::lonnet; +use Apache::lonhtmlcommon(); +use Apache::lonnavmaps; +use Apache::lonenc(); +use Apache::lonrss(); +use HTML::LCParser(); +use Apache::lonspeller(); +use Apache::longroup; +use Cwd; +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; + } +# The problem is available, but check if the instructor explictly closed discussion + if (defined($close) && $close ne '' && $close < time) { + return 0; + } + return 1; +} -sub mail_screen { - my ($r,$feedurl,$options) = @_; - my $bodytag=&Apache::loncommon::bodytag('Resource Feedback and Discussion', - '','onLoad="window.focus();"'); - my $latexHelp = Apache::loncommon::helpLatexCheatsheet(); - $r->print(< - -The LearningOnline Network with CAPA - - - -$bodytag -

$feedurl

+END + + # Breadcrumbs + my $brcrum = [{'href' => '', + 'text' => 'Resource Feedback and Discussion'}]; + + my %onload = ('onload' => 'window.focus();setposttype();'); + my $start_page= + &Apache::loncommon::start_page('Resource Feedback and Discussion',$js, + {'add_entries' => \%onload, + 'bread_crumbs' => $brcrum,}); + + if ($quote ne '') { + &newline_to_br(\$quote); + $quote='
'.&Apache::lontexconvert::msgtexconverted($quote).'
'; + } + + $r->print(<$restitle
- -Please check at least one of the following feedback types: -$options
-My question/comment/feedback:

+$prevtag + +END + if ($env{'form.replydisc'}) { + $r->print(< +END + } elsif ($env{'form.editdisc'}) { + $r->print(< + +END + } + $r->print(< +$quote +

$lt{'myqu'}

+

$latexHelp -

-Attachment (128 KB max size):

+$lt{'title'}:

+

+

+

+END + if ( ($env{'form.editdisc'}) || ($env{'form.replydisc'}) ) { + if ($env{'form.origpage'}) { + foreach my $attach (@currnewattach) { + $r->print(''."\n"); + } + foreach my $oldatt (@currdelold) { + $r->print(''."\n"); + } + } + if ($env{'form.editdisc'}) { + if ($attachmenturls) { + &extract_attachments($attachmenturls,$idx,$numoldver,\$attachmsg,\%attachments,\%currattach,\@currdelold); + $attachnum = scalar(keys(%currattach)); + foreach my $key (keys(%currattach)) { + $r->print(''."\n"); + } + } + } + } else { + $r->print(< +

+END + } + if (exists($env{'form.group'})) { + $r->print(''); + } + if (exists($env{'form.ref'})) { + $r->print(''); + } + $r->print(< - +

-ENDDOCUMENT -$r->print(&generate_preview_button().''); +END + if ($env{'form.editdisc'} || $env{'form.replydisc'}) { + my $now = time; + my $ressymb = $symb; + &Apache::lonenc::check_encrypt(\$ressymb); + my $postidx = ''; + if ($env{'form.editdisc'}) { + $postidx = $idx; + } + if (@currnewattach > 0) { + $attachnum += @currnewattach; + } + my $blockblog = &Apache::loncommon::blocking_status('blogs'); + $r->print(&generate_attachments_button($postidx,$attachnum,$ressymb,$now,\@currnewattach,\@currdelold,$numoldver,'',$blockblog)); + if ($attachnum > 0) { + if (@currnewattach > 0) { + $newattachmsg .= '
'.&mt('New attachments').'
'; + if (@currnewattach > 1) { + $newattachmsg .= '
    '; + foreach my $item (@currnewattach) { + $item =~ m#.*/([^/]+)$#; + $newattachmsg .= '
  1. '.$1.'
  2. '."\n"; + } + $newattachmsg .= '
'."\n"; + } else { + $currnewattach[0] =~ m#.*/([^/]+)$#; + $newattachmsg .= ''.$1.'
'."\n"; + } + } + if ($attachmsg) { + $r->print("
$lt{'reta'}:$attachmsg
\n"); + } + if ($newattachmsg) { + $r->print("$newattachmsg
"); + } + } + } + $r->print(&generate_preview_button(). + &Apache::lonhtmlcommon::htmlareaselectactive('comment'). + &Apache::loncommon::end_page()); + +} + +sub print_display_options { + my ($r,$symb,$previous,$dispchgA,$dispchgB,$markchg,$toggchg,$feedurl) = @_; + &Apache::loncommon::content_type($r,'text/html'); + $r->send_http_header; + + my $function = &Apache::loncommon::get_users_function(); + my $tabcolor = &Apache::loncommon::designparm($function.'.tabbg', + $env{'user.domain'}); + + my %lt = &Apache::lonlocal::texthash( + '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 discussion board or resource, and', + 'unwh' => 'Under what circumstances posts are identified as "NEW", and', + 'wipa' => 'Whether individual posts can be marked as read/unread', + 'allposts' => 'All posts', + 'unread' => 'New posts only', + 'unmark' => 'Posts not marked read', + 'ondisp' => 'Once displayed', + 'onmark' => 'Once marked not NEW', + 'toggon' => 'Shown', + 'toggoff' => 'Not shown', + 'disa' => 'Posts displayed?', + 'npmr' => 'New posts cease to be identified as "NEW"?', + 'dotm' => 'Option to mark each post as read/unread?', + 'chgt' => 'Change to ', + 'mkdf' => 'Set to ', + 'yhni' => 'You have not indicated that you wish to change any of the discussion settings', + 'ywbr' => 'You will be returned to the previous page if you click OK.' + ); + + my $dispchangeA = $lt{'unread'}; + my $dispchangeB = $lt{'unmark'}; + my $markchange = $lt{'ondisp'}; + my $toggchange = $lt{'toggon'}; + my $currdisp = $lt{'allposts'}; + my $currmark = $lt{'onmark'}; + my $discdisp = 'allposts'; + my $discmark = 'onmark'; + my $currtogg = $lt{'toggoff'}; + my $disctogg = 'toggoff'; + + if ($dispchgA eq 'allposts') { + $dispchangeA = $lt{'allposts'}; + $currdisp = $lt{'unread'}; + $discdisp = 'unread'; + } + + if ($markchg eq 'markonread') { + $markchange = $lt{'onmark'}; + $currmark = $lt{'ondisp'}; + $discmark = 'ondisp'; + } + + if ($dispchgB eq 'onlyunread') { + $dispchangeB = $lt{'unread'}; + $currdisp = $lt{'unmark'}; + $discdisp = 'unmark'; + } + if ($toggchg eq 'toggoff') { + $toggchange = $lt{'toggoff'}; + $currtogg = $lt{'toggon'}; + $disctogg = 'toggon'; + } + + my $js = < +function discdispChk(caller) { + var disctogg = '$toggchg' + if (caller == 0) { + if (document.modifydisp.discdisp[0].checked == true) { + if (document.modifydisp.discdisp[1].checked == true) { + document.modifydisp.discdisp[1].checked = false + } + } + } + if (caller == 1) { + if (document.modifydisp.discdisp[1].checked == true) { + if (document.modifydisp.discdisp[0].checked == true) { + document.modifydisp.discdisp[0].checked = false + } + if (disctogg == 'toggon') { + document.modifydisp.disctogg.checked = true + } + if (disctogg == 'toggoff') { + document.modifydisp.disctogg.checked = false + } + } + } + if (caller == 2) { + var dispchgB = '$dispchgB' + if (disctogg == 'toggoff') { + if (document.modifydisp.disctogg.checked == true) { + if (dispchgB == 'onlyunmark') { + document.modifydisp.discdisp[1].checked = false + } + } + } + } +} + +function setDisp() { + var prev = "$previous" + var chktotal = 0 + if (document.modifydisp.discdisp[0].checked == true) { + document.modifydisp.$dispchgA.value = "$symb" + chktotal ++ + } + if (document.modifydisp.discdisp[1].checked == true) { + document.modifydisp.$dispchgB.value = "$symb" + chktotal ++ + } + if (document.modifydisp.discmark.checked == true) { + document.modifydisp.$markchg.value = "$symb" + chktotal ++ + } + if (document.modifydisp.disctogg.checked == true) { + document.modifydisp.$toggchg.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" + } + } + } +} + +END + + + my $start_page = + &Apache::loncommon::start_page('Discussion display options',$js); + my $end_page = + &Apache::loncommon::end_page(); + $r->print(< +$lt{'sdpf'}
$lt{'prca'}
  1. $lt{'whpo'}
  2. $lt{'unwh'}
  3. $lt{'wipa'}
+
+END + $r->print(&Apache::loncommon::start_data_table()); + $r->print(< + $lt{'pref'} + $lt{'curr'} + $lt{'actn'}? + +END + $r->print(&Apache::loncommon::start_data_table_row()); + $r->print(<$lt{'disa'} + $lt{$discdisp} + +
+ + +END + $r->print(&Apache::loncommon::end_data_table_row()); + $r->print(&Apache::loncommon::start_data_table_row()); + $r->print(<$lt{'npmr'} + $lt{$discmark} + +END + $r->print(&Apache::loncommon::end_data_table_row()); + $r->print(&Apache::loncommon::start_data_table_row()); + $r->print(<$lt{'dotm'} + $lt{$disctogg} + +END + my $save = &mt('Save'); + $r->print(&Apache::loncommon::end_data_table_row()); + $r->print(&Apache::loncommon::end_data_table()); + $r->print(< +
+ + + + + + + +END + if (exists($env{'form.group'})) { + $r->print(''); + } + if (exists($env{'form.ref'})) { + $r->print(''); + } + $r->print(" +
+
+ +$end_page + "); + return; +} + +sub print_sortfilter_options { + my ($r,$symb,$previous,$feedurl) = @_; + + &Apache::loncommon::content_type($r,'text/html'); + $r->send_http_header; + + &Apache::lonenc::check_encrypt(\$symb); + my @sections; + my $section_sel = ''; + my $numvisible = 5; + my @groups; + my $group_sel = ''; + my $numgroupvis = 5; + my %sectioncount = &Apache::loncommon::get_sections(); + my @courseroles = qw(st ad ep ta in); + my $crstype = &Apache::loncommon::course_type(); + my $ccrole = 'cc'; + if ($crstype eq 'Community') { + $ccrole = 'co'; + } + push(@courseroles,$ccrole); + + if ($env{'request.course.sec'} !~ /^\s*$/) { #Restrict section choice to current section + @sections = ('all',$env{'request.course.sec'}); + $numvisible = 2; + } else { + @sections = sort {$a cmp $b} keys(%sectioncount); + if (scalar(@sections) < 4) { + $numvisible = scalar(@sections) + 1; + } + unshift(@sections,'all'); # Put 'all' at the front of the list + + } + foreach my $sec (@sections) { + $section_sel .= " \n"; + } + + if (&check_group_priv() eq 'ok') { + my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum); + @groups = sort {$a cmp $b} keys(%curr_groups); + if (scalar(@groups) < 4) { + $numgroupvis = scalar(@groups) + 1; + } + unshift(@groups,'all'); # Put 'all' at the front of the list + } else { + my @coursegroups = split(/:/,$env{'request.course.groups'}); + if (@coursegroups > 0) { + @coursegroups = sort {$a cmp $b} @coursegroups; + @groups = ('all',@coursegroups); + if (scalar(@groups) < 4) { + $numgroupvis = scalar(@groups) + 1; + } + } else { + @groups = ('all'); + $numgroupvis = 1; + } + } + foreach my $group (@groups) { + $group_sel .= " \n"; + } + + my $function = &Apache::loncommon::get_users_function(); + my $tabcolor = &Apache::loncommon::designparm($function.'.tabbg', + $env{'user.domain'}); + my %lt = &Apache::lonlocal::texthash( + 'diop' => 'Display Options', + 'curr' => 'Current setting ', + 'actn' => 'Action', + 'prca' => 'Set options that control the sort order of posts, and/or which posts are displayed.', + 'soor' => 'Sort order', + 'spur' => 'Specific user roles', + 'sprs' => 'Specific role status', + 'spse' => 'Specific sections', + 'spgr' => 'Specific groups', + 'psub' => 'Pick specific users (by name)', + 'shal' => 'Show a list of current posters', + 'stor' => 'Save changes', + ); + + my %sort_types = (); + my %role_types = (); + my %status_types = (); + &sort_filter_names(\%sort_types,\%role_types,\%status_types,$crstype); + + my $js = < +function verifyFilter() { + var rolenum = 0 + for (var i=0; i +END + + my $start_page= + &Apache::loncommon::start_page('Discussion options',$js); + my $end_page= + &Apache::loncommon::end_page(); + + $r->print(< +$lt{'diso'}
$lt{'prca'} +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
$lt{'soor'} $lt{'sprs'} $lt{'spur'} $lt{'spse'} $lt{'spgr'} $lt{'psub'}
+ +   + +   + +   + +   + +  
+
+
+ + + +END + if (exists($env{'form.group'})) { + $r->print(''); + } + if (exists($env{'form.ref'})) { + $r->print(''); + } + $r->print(" +
+
+ +$end_page +"); +} + +sub print_showposters { + my ($r,$symb,$previous,$feedurl,$sortposts) = @_; + + &Apache::loncommon::content_type($r,'text/html'); + $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); + 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 = (); + my %postcounts = (); + + my %lt = &Apache::lonlocal::texthash( + sele => 'Select', + full => 'Fullname', + usdo => 'Username:domain', + post => 'Posts', + ); + if ($contrib{'version'}) { + for (my $idx=1;$idx<=$contrib{'version'};$idx++) { + my $hidden=($contrib{'hidden'}=~/\.$idx\./); + my $deleted=($contrib{'deleted'}=~/\.$idx\./); + 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'}; + my $firstname = $names{'firstname'}; + if ($lastname eq '') { + $lastname = '_'; + } + if ($firstname eq '') { + $firstname = '_'; + } + unless (defined($namesort{$lastname})) { + %{$namesort{$lastname}} = (); + } + my $poster = $contrib{$idx.':sendername'}.':'.$contrib{$idx.':senderdomain'}; + $postcounts{$poster} ++; + if (defined($namesort{$lastname}{$firstname})) { + if (!grep/^$poster$/,@{$namesort{$lastname}{$firstname}}) { + push(@{$namesort{$lastname}{$firstname}}, $poster); + } + } else { + @{$namesort{$lastname}{$firstname}} = ("$poster"); + } + } + } + } + } + + my $start_page = &Apache::loncommon::start_page('Discussion options'); + my $table_start =&Apache::loncommon::start_data_table(); + $r->print(< +
+ $table_start + + # + $lt{'sele'} + $lt{'full'} ($lt{'usdo'}) + $lt{'post'} + +END + my $count = 0; + foreach my $last (sort(keys(%namesort))) { + foreach my $first (sort(keys(%{$namesort{$last}}))) { + foreach my $user (sort(@{$namesort{$last}{$first}})) { + my ($uname,$udom) = split(/:/,$user); + if (!$uname || !$udom) { + next; + } else { + $count ++; + $r->print(&Apache::loncommon::start_data_table_row(). + ''.$count.' + + '.$postcounts{$user}.''. + &Apache::loncommon::end_data_table_row()); + } + } + } + } + $r->print(&Apache::loncommon::end_data_table()); + my $end_page = &Apache::loncommon::end_page(); + $r->print(< + + + + +$end_page +END +} + +sub get_post_versions { + my ($versions,$incoming,$htmldecode,$numver) = @_; + if ($incoming =~ /^/) { + my $p = HTML::LCParser->new(\$incoming); + my $done = 0; + + while ( (my $token = $p->get_tag("version")) && (!$done)) { + my $num = $token->[1]{num}; + my $text = $p->get_text("/version"); + if (defined($numver)) { + if ($num == $numver) { + if ($htmldecode) { + $text = &HTML::Entities::decode($text); + } + $$versions{$numver}=$text; + $done = 1; + } + } else { + if ($htmldecode) { + $text = &HTML::Entities::decode($text); + } + $$versions{$num}=$text; + } + } + } else { + if (!defined($numver)) { + $numver = 0; + } + if ($htmldecode) { + $$versions{$numver} = $incoming; + } else { + $$versions{$numver} = &HTML::Entities::encode($incoming,'<>&"'); + } + } + return; +} + +sub get_post_attachments { + my ($attachments,$attachmenturls) = @_; + my $num; + if ($attachmenturls =~ m/^/) { + my $p = HTML::LCParser->new(\$attachmenturls); + while (my $token = $p->get_tag("attachment","filename","post")) { + if ($token->[0] eq "attachment") { + $num = $token->[1]{id}; + %{$$attachments{$num}} =(); + } elsif ($token->[0] eq "filename") { + $$attachments{$num}{'filename'} = $p->get_text("/filename"); + } elsif ($token->[0] eq "post") { + my $id = $token->[1]{id}; + $$attachments{$num}{$id} = $p->get_text("/post"); + } + } + } else { + %{$$attachments{'0'}} = (); + $$attachments{'0'}{'filename'} = $attachmenturls; + $$attachments{'0'}{'0'} = 'n'; + } + + return; } sub fail_redirect { my ($r,$feedurl) = @_; - $r->print (<Feedback not sent - - - - - - -Sorry, no recipients ... - - + if ($feedurl=~/^\/adm\//) { $feedurl.='?register=1' }; + my %lt = &Apache::lonlocal::texthash( + 'sorr' => 'Sorry, no recipients ...', + ); + my $logo=&Apache::loncommon::lonhttpdurl('/adm/lonIcons/lonlogos.gif'); + $r->print(&Apache::loncommon::start_page('Feedback not sent',undef, + {'redirect' => [2,$feedurl], + 'only_body' => 1,})); + $r->print(< +$lt{'sorr'} ENDFAILREDIR + $r->print(&Apache::loncommon::end_page()); } sub redirect_back { - my ($r,$feedurl,$typestyle,$sendsomething,$sendposts,$status) = @_; - $r->print (< -Feedback sent - - - - - - + my ($r,$feedurl,$typestyle,$sendsomething,$sendposts,$blog,$status,$previous,$sort,$rolefilter,$statusfilter,$sectionpick,$grouppick,$numpicks,$group,$toolarge) = @_; + my $sorttag = ''; + my $roletag = ''; + my $statustag = ''; + my $sectag = ''; + my $grptag = ''; + my $userpicktag = ''; + my $qrystr = ''; + my $prevtag = ''; + + &Apache::loncommon::content_type($r,'text/html'); + $r->send_http_header; + &dewrapper(\$feedurl); + if ($feedurl=~/^\/adm\//) { $feedurl.='?register=1' }; + if ($previous > 0) { + $qrystr = 'previous='.$previous; + if ($feedurl =~ /\?register=1/) { + $feedurl .= '&'.$qrystr; + } else { + $feedurl .= '?'.$qrystr; + } + $prevtag = ''; + } + if (defined($sort)) { + my $sortqry = 'sortposts='.$sort; + if (($feedurl =~ /\?register=1/) || ($feedurl =~ /\?previous=/)) { + $feedurl .= '&'.$sortqry; + } else { + $feedurl .= '?'.$sortqry; + } + $sorttag = ''; + if (defined($numpicks)) { + my $userpickqry = 'totposters='.$numpicks; + $feedurl .= '&'.$userpickqry; + $userpicktag = ''; + } else { + if (ref($sectionpick) eq 'ARRAY') { + $feedurl .= '&sectionpick='; + $sectag .= ''; + } else { + $feedurl .= '&sectionpick='.$sectionpick; + $sectag = ''; + } + if (ref($grouppick) eq 'ARRAY') { + $feedurl .= '&grouppick='; + $sectag .= ''; + } else { + $feedurl .= '&grouppick='.$grouppick; + $grptag = ''; + } + if (ref($rolefilter) eq 'ARRAY') { + $feedurl .= '&rolefilter='; + $roletag .= ''; + } else { + $feedurl .= '&rolefilter='.$rolefilter; + $roletag = ''; + } + $feedurl .= '&statusfilter='.$statusfilter; + $statustag =''; + } + } + my $grouptag; + if ($group ne '') { + $grouptag = ''; + my $refarg; + if (exists($env{'form.ref'})) { + $refarg = '&ref='.$env{'form.ref'}; + $grouptag .= ''; + } + if ($feedurl =~ /\?/) { + $feedurl .= '&group='.$group.$refarg; + } else { + $feedurl .= '?group='.$group.$refarg; + } + } + &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], + 'only_body' => 1, + 'add_entries' => \%onload}); + my $end_page = &Apache::loncommon::end_page(); + $r->print(< $typestyle Sent $sendsomething message(s), and $sendposts post(s). -$status - - +$blog +$toolarge +$status +
+$prevtag +$sorttag +$statustag +$roletag +$sectag +$grptag +$userpicktag +$grouptag +
+$end_page ENDREDIR } sub no_redirect_back { my ($r,$feedurl) = @_; - $r->print (<Feedback not sent - -ENDNOREDIR + 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!~/^\/adm\/feedback/) { - $r->print(''); + if ($feedurl !~ m{^/adm/feedback}) { + $body_options{'rediect'} = [2,$feedurl]; } - + my $start_page= + &Apache::loncommon::start_page('Feedback not sent',undef, + \%body_options); + + my $end_page = &Apache::loncommon::end_page(); + + &Apache::lonenc::check_encrypt(\$feedurl); + my $logo=&Apache::loncommon::lonhttpdurl('/adm/lonIcons/lonlogos.gif'); $r->print (< - - - -Sorry, no feedback possible on this resource ... - - +$start_page + +$nofeed +
+$end_page ENDNOREDIRTWO } sub screen_header { - my ($feedurl) = @_; - my $options=''; - if (($feedurl=~/^\/res\//) && ($feedurl!~/^\/res\/adm/)) { - $options= - '

Feedback to resource author'; - } - if (&feedback_available(1)) { - $options.= - '
Question about resource content'; - } - if (&feedback_available(0,1)) { - $options.= - '
'. - 'Question/Comment/Feedback about course content'; - } - if (&feedback_available(0,0,1)) { - $options.= - '
'. - 'Question/Comment/Feedback about course policy'; - } - - if ($ENV{'request.course.id'}) { - if (&Apache::lonnet::allowed('pch', - $ENV{'request.course.id'}. - ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) { - $options.='
'. - 'Contribution to course discussion of resource'; - $options.='
'. - 'Anonymous contribution to course discussion of resource'. - ' (name only visible to course faculty)'; - } - } - return $options; + 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'); + my $anoncontrib = &mt('Anonymous contribution to course discussion of resource'); + my $namevis = &mt('name only visible to course faculty'); + my $crstype; + if ($env{'request.course.id'}) { + $crstype = &Apache::loncommon::course_type(); + if ($crstype eq 'Community') { + $crscontent = &mt('Question/Comment/Feedback about community content'); + $crspolicy = &mt('Question/Comment/Feedback about community policy'); + $contribdisc = &mt('Contribution to community discussion of resource'); + $anoncontrib = &mt('Anonymous contribution to community discussion of resource'); + $namevis = &mt('name only visible to community facilitators'); + } + } + my $msgoptions=''; + my $discussoptions=''; + unless (($env{'form.replydisc'}) || ($env{'form.editdisc'})) { + if (($feedurl=~/^\/res\//) && ($feedurl!~/^\/res\/adm/) && ($env{'user.adv'})) { + $msgoptions= + '

'; + } + my %optionhash=(); + foreach my $type ('question','comment','policy') { + $optionhash{$type}=$env{'course.'.$env{'request.course.id'}.'.'.$type.'.email.text'}; + } + if (&feedback_available(1)) { + $msgoptions.= + '

'; + } + if (&feedback_available(0,1)) { + $msgoptions.= + '

'; + } + if (&feedback_available(0,0,1)) { + $msgoptions.= + '

'; + } + } + if (($env{'request.course.id'}) && (!$env{'form.sendmessageonly'})) { + my ($blocked,$blocktext) = &Apache::loncommon::blocking_status('boards'); + if (!$blocked && &discussion_open(undef,$symb) && + &Apache::lonnet::allowed('pch', + $env{'request.course.id'}. + ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) { + $discussoptions='
'. + ''.&mt('Change Screenname').''; + my $blockblog = &Apache::loncommon::blocking_status('blogs'); + if (!$blockblog) { + $discussoptions.= &add_blog_checkbox($crstype); + } + } + } + if ($msgoptions) { + $msgoptions='

' + .' '.&mt('Send Feedback').'

'.&Apache::lonhtmlcommon::coursepreflink(&mt('Feedback Settings'),'feedback').'

' + .$msgoptions; + } + if ($discussoptions) { + $discussoptions='

' + .' '.&mt('Discussion Contributions').'

'.&Apache::lonhtmlcommon::coursepreflink(&mt('Discussion Settings'),'discussion').'

' + .$discussoptions; + } + return $msgoptions.$discussoptions; } sub resource_output { @@ -233,388 +2676,1522 @@ sub resource_output { } sub clear_out_html { - my ($message,$override)=@_; - my $cid=$ENV{'request.course.id'}; - if (($ENV{"course.$cid.allow_limited_html_in_feedback"} =~ m/yes/i) || + my ($message,$override,$ignore_htmlarea)=@_; + if (!$ignore_htmlarea + && !&Apache::lonhtmlcommon::htmlareablocked()) { return $message; } +# Always allow the -tag + my %html=(M=>1); +# Check if more is allowed + my $cid=$env{'request.course.id'}; + if (($env{"course.$cid.allow_limited_html_in_feedback"} =~ m/yes/i) || ($override)) { # allows