--- loncom/interface/lonfeedback.pm 2006/12/08 20:09:29 1.232 +++ loncom/interface/lonfeedback.pm 2007/01/04 20:35:15 1.239 @@ -1,7 +1,7 @@ # The LearningOnline Network # Feedback # -# $Id: lonfeedback.pm,v 1.232 2006/12/08 20:09:29 raeburn Exp $ +# $Id: lonfeedback.pm,v 1.239 2007/01/04 20:35:15 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -90,8 +90,8 @@ sub list_discussion { } if (not &discussion_visible($status)) { if ($mode ne 'board') { - my $encsymb=&Apache::lonenc::check_encrypt($ressymb); - return &send_message_link($encsymb); + &Apache::lonenc::check_encrypt(\$ressymb); + return &send_message_link($ressymb); } } if ($group ne '' && $mode eq 'board') { @@ -100,12 +100,14 @@ sub list_discussion { } } - my ($blocked,$blocktext) = &blocking_posts('boards',1); + my ($blocked,$blocktext) = + &Apache::loncommon::blocking_status('boards'); if ($blocked) { + &Apache::lonenc::check_encrypt(\$ressymb); if ($mode ne 'board') { - my $encsymb=&Apache::lonenc::check_encrypt($ressymb); - return $blocktext.'
'.&send_message_link($encsymb); + $blocktext.='
'.&send_message_link($ressymb); } + return $blocktext; } my @bgcols = ("#cccccc","#eeeeee"); @@ -822,25 +824,6 @@ sub action_links_bar { return $discussion; } -sub blocking_posts { - my ($type,$showstatus) = @_; - my %setters; - my ($blocked,$output); - my ($startblock,$endblock) = - &Apache::loncommon::blockcheck(\%setters,$type); - if ($startblock && $endblock) { - $blocked = 1; - if ($showstatus) { - my $showstart = &Apache::lonlocal::locallocaltime($startblock); - my $showend = &Apache::lonlocal::locallocaltime($endblock); - $output = &mt('Discussion postings will not be viewable for resources in this course between [_1] and [_2] because communication is being blocked.',$showstart, $showend).'
'. - &Apache::loncommon::build_block_table($startblock,$endblock, - \%setters); - } - } - return ($blocked,$output); -} - sub postingform_display { my ($mode,$ressymb,$now,$subject,$comment,$outputtarget,$attachnum, $currnewattach,$currdelold,$group) = @_; @@ -877,7 +860,7 @@ ENDDISCUSS if ($group ne '') { $postingform .=''; } - my ($blockblog) = &blocking_posts('blogs'); + my $blockblog = &Apache::loncommon::blocking_status('blogs'); if (!$blockblog) { $postingform .= &add_blog_checkbox(); } @@ -1485,7 +1468,7 @@ sub replicate_attachments { } sub mail_screen { - my ($r,$feedurl,$options) = @_; + my ($r,$feedurl,$options,$caller_symb) = @_; if (exists($env{'form.origpage'})) { &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['subject','comment','currnewattach','addnewattach','deloldattach','delnewattach','timestamp','idx','anondiscuss','discuss','blog','group','ref']); } @@ -1496,9 +1479,8 @@ sub mail_screen { 'title' => 'Title', 'reta' => 'Retained attachments', 'atta' => 'Attachment (128 KB max size)', - ); - my $title=&Apache::lonnet::gettitle($feedurl); - if (!$title) { $title = $feedurl; } + ); + my $restitle = &get_resource_title($caller_symb,$feedurl); my $quote=''; my $subject = ''; my $comment = ''; @@ -1686,7 +1668,7 @@ END $r->print(<$title +

$restitle

$prevtag @@ -1755,6 +1737,7 @@ 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; @@ -1762,7 +1745,7 @@ END if (@currnewattach > 0) { $attachnum += @currnewattach; } - my ($blockblog) = &blocking_posts('blogs'); + 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) { @@ -2498,7 +2481,7 @@ sub redirect_back { $feedurl .= '?group='.$group.$refarg; } } - $feedurl=&Apache::lonenc::check_encrypt($feedurl); + &Apache::lonenc::check_encrypt(\$feedurl); my $logo=&Apache::loncommon::lonhttpdurl('/adm/lonIcons/lonlogos.gif'); my %onload; if ($env{'environment.remote'} ne 'off') { @@ -2555,7 +2538,7 @@ sub no_redirect_back { my $end_page = &Apache::loncommon::end_page(); - $feedurl=&Apache::lonenc::check_encrypt($feedurl); + &Apache::lonenc::check_encrypt(\$feedurl); my $logo=&Apache::loncommon::lonhttpdurl('/adm/lonIcons/lonlogos.gif'); $r->print (<('.&mt('name only visible to course faculty').') '. - ''.&mt('Change Screenname').''; - } + &mt('Anonymous contribution to course discussion of resource'). + ' ('.&mt('name only visible to course faculty').') '. + ''.&mt('Change Screenname').''; } - my ($blockblog) = &blocking_posts('blogs'); + my $blockblog = &Apache::loncommon::blocking_status('blogs'); if (!$blockblog) { $discussoptions.= &add_blog_checkbox(); } @@ -2660,7 +2640,7 @@ sub clear_out_html { } sub assemble_email { - my ($feedurl,$message,$prevattempts,$usersaw,$useranswer)=@_; + my ($message,$prevattempts,$usersaw,$useranswer)=@_; my %lt = &Apache::lonlocal::texthash( 'prev' => 'Previous attempts of student (if applicable)', 'orig' => 'Original screen output (if applicable)', @@ -2686,13 +2666,18 @@ sub secapply { my $defaultflag=shift; $rec=~s/\s+//g; $rec=~s/\@/\:/g; - my ($adr,$sections)=($rec=~/^([^\(]+)\(([^\)]+)\)/); - if ($sections) { - foreach my $sec (split(/\;/,$sections)) { - if (($sec eq $env{'request.course.sec'}) || - ($defaultflag && ($sec eq '*'))) { + my ($adr,$sections_or_groups)=($rec=~/^([^\(]+)\(([^\)]+)\)/); + if ($sections_or_groups) { + foreach my $item (split(/\;/,$sections_or_groups)) { + if (($item eq $env{'request.course.sec'}) || + ($defaultflag && ($item eq '*'))) { return $adr; - } + } elsif ($env{'request.course.groups'}) { + my @usersgroups = split(/:/,$env{'request.course.groups'}); + if (grep(/^\Q$item\E$/,@usersgroups)) { + return $adr; + } + } } } else { return $rec; @@ -2733,6 +2718,7 @@ Returns sub decide_receiver { my ($feedurl,$author,$question,$course,$policy,$defaultflag) = @_; + &Apache::lonenc::check_decrypt(\$feedurl); my $typestyle=''; my %to=(); if ($env{'form.discuss'} eq 'author' ||$author) { @@ -2781,17 +2767,17 @@ sub feedback_available { } sub send_msg { - my ($title,$feedurl,$email,$citations,$attachmenturl,%to)=@_; + my ($title,$feedurl,$email,$citations,$attachmenturl,$symb,%to)=@_; my $status=''; my $sendsomething=0; + my $restitle = &get_resource_title($symb,$feedurl); if ($title=~/^Error/) { $title=&mt('Feedback').': '.$title; } unless ($title=~/\w/) { $title=&mt('Feedback'); } foreach my $key (keys(%to)) { if ($key) { - my $declutter=&Apache::lonnet::declutter($feedurl); unless (&Apache::lonmsg::user_normal_msg(split(/\:/,$key), - $title.' ['.$declutter.']',$email,$citations,$feedurl, - $attachmenturl)=~/ok/) { + $title.' ['.$restitle.']',$email,$citations,$feedurl, + $attachmenturl,undef,undef,$symb,$restitle)=~/ok/) { $status.='
'.&mt('Error sending message to').' '.$key.'
'; } else { $sendsomething++; @@ -3739,12 +3725,8 @@ ENDREDIR my $symb; if ($env{'form.replydisc'}) { $symb=(split(/\:\:\:/,$env{'form.replydisc'}))[0]; - my ($map,$id,$url)=&Apache::lonnet::decode_symb($symb); - $feedurl=&Apache::lonnet::clutter($url); } elsif ($env{'form.editdisc'}) { $symb=(split(/\:\:\:/,$env{'form.editdisc'}))[0]; - my ($map,$id,$url)=&Apache::lonnet::decode_symb($symb); - $feedurl=&Apache::lonnet::clutter($url); } elsif ($env{'form.origpage'}) { $symb=""; } else { @@ -3752,18 +3734,18 @@ ENDREDIR } unless ($symb) { $symb=$env{'form.symb'}; - if ($symb) { - my ($map,$id,$url)=&Apache::lonnet::decode_symb($symb); - $feedurl=&Apache::lonnet::clutter($url); - } } - &Apache::lonenc::check_decrypt(\$symb); + if (defined($symb)) { + ($symb,$feedurl)=&get_feedurl_and_clean_symb($symb); + } else { + # backward compatibility (bulletin boards used to be 'wrapped') + &Apache::lonenc::check_decrypt(\$feedurl); + &dewrapper(\$feedurl); + } my $goahead=1; if ($feedurl=~/\.(problem|exam|quiz|assess|survey|form|task)$/) { unless ($symb) { $goahead=0; } } - # backward compatibility (bulletin boards used to be 'wrapped') - &dewrapper(\$feedurl); if (!$goahead) { # Ambiguous Problem Resource $r->internal_redirect('/adm/ambiguous'); @@ -3782,16 +3764,26 @@ ENDREDIR &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; # Unable to give feedback + &Apache::lonenc::check_encrypt(\$feedurl); &no_redirect_back($r,$feedurl); return OK; } # --------------------------------------------------- Print login screen header unless ($env{'form.sendit'}) { + &Apache::lonenc::check_encrypt(\$feedurl); &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; + if (($env{'form.replydisc'}) || ($env{'form.editdisc'})) { + my ($blocked,$blocktext) = + &Apache::loncommon::blocking_status('boards'); + if ($blocked) { + $r->print(&blocked_reply_or_edit($blocktext)); + return OK; + } + } my $options=&screen_header($feedurl,$symb); if ($options) { - &mail_screen($r,$feedurl,$options); + &mail_screen($r,$feedurl,$options,$symb); } else { &fail_redirect($r,$feedurl); } @@ -3804,13 +3796,16 @@ ENDREDIR $env{'request.course.id'}); # Get output from resource + &Apache::lonenc::check_encrypt(\$feedurl); my $usersaw=&resource_output($feedurl); # Get resource answer (need to allow student to view grades for this to work) &Apache::lonnet::appenv(('allowed.vgr'=>'F')); - my $useranswer=&Apache::loncommon::get_student_answers( - $symb,$env{'user.name'},$env{'user.domain'}, - $env{'request.course.id'}); + my $usersymb = &Apache::lonenc::check_encrypt($symb); + my $useranswer= + &Apache::loncommon::get_student_answers( + $usersymb,$env{'user.name'},$env{'user.domain'}, + $env{'request.course.id'}); &Apache::lonnet::delenv('allowed.vgr'); # Get attachments, if any, and not too large my $attachmenturl=''; @@ -3840,7 +3835,7 @@ ENDREDIR my $message=&clear_out_html($env{'form.comment'}); # Assemble email - my ($email,$citations)=&assemble_email($feedurl,$message,$prevattempts, + my ($email,$citations)=&assemble_email($message,$prevattempts, $usersaw,$useranswer); # Who gets this? @@ -3850,7 +3845,7 @@ ENDREDIR my ($status,$numsent)=&send_msg(&clear_out_html($env{'form.subject'}, undef,1), $feedurl,$email,$citations, - $attachmenturl,%to); + $attachmenturl,$symb,%to); # Discussion? Store that. my $numpost=0; @@ -3880,6 +3875,15 @@ ENDREDIR &redirect_back($r,$feedurl,$typestyle,$numsent,$numpost,$blog,$status,$env{'form.previous'},undef,undef,undef,undef,undef,undef,$group); } return OK; +} + +sub blocked_reply_or_edit { + my ($blocktext) = @_; + return + &Apache::loncommon::start_page('Resource Feedback and Discussion'). + $blocktext.'

'. + &mt('Back to previous page'). + &Apache::loncommon::end_page(); } sub wrap_symb { @@ -3984,5 +3988,32 @@ sub group_args { return $extra_args; } +sub get_resource_title { + my ($symb,$feedurl) = @_; + my ($restitle,$plainurl); + if (defined($symb)) { + my $plain_symb = &Apache::lonenc::check_decrypt($symb); + $restitle = &Apache::lonnet::gettitle($plain_symb); + } + if (defined($feedurl)) { + $plainurl = &Apache::lonenc::check_decrypt($feedurl); + } + if (!defined($restitle)) { + if (defined($feedurl)) { + $restitle = &Apache::lonnet::gettitle($plainurl); + } + } + if ($plainurl ne $feedurl) { + my ($plain_filename) = ($plainurl =~ m-/([^/]+)$-); + if ($plain_filename eq $restitle) { + $restitle = &mt('Untitled resource'); + } + } + if ($restitle eq '') { + $restitle = &mt('Untitled resource'); + } + return $restitle; +} + 1; __END__