version 1.236, 2006/12/11 18:50:40
|
version 1.247, 2007/05/02 01:33:49
|
Line 637 END
|
Line 637 END
|
} |
} |
} |
} |
if ($dischash{$toggkey}) { |
if ($dischash{$toggkey}) { |
my $storebutton = &mt('Store read/unread changes'); |
my $storebutton = &mt('Save read/unread changes'); |
$discussion.='<td align="right">'. |
$discussion.='<td align="right">'. |
'<input type="hidden" name="discsymb" value="'.$ressymb.'">'."\n". |
'<input type="hidden" name="discsymb" value="'.$ressymb.'">'."\n". |
'<input type="button" name="readoptions" value="'.$storebutton.'"'. |
'<input type="button" name="readoptions" value="'.$storebutton.'"'. |
Line 1012 sub build_posting_display {
|
Line 1012 sub build_posting_display {
|
$sender.=' <font color="red"><b>['.$$anonhash{$key}.']</b></font> '. |
$sender.=' <font color="red"><b>['.$$anonhash{$key}.']</b></font> '. |
$screenname; |
$screenname; |
} |
} |
|
$sender.=&Apache::loncommon::student_image_tag($contrib{$idx.':senderdomain'},$contrib{$idx.':sendername'}); |
# Set up for sorting by domain, then username |
# Set up for sorting by domain, then username |
unless (defined($$usernamesort{$contrib{$idx.':senderdomain'}})) { |
unless (defined($$usernamesort{$contrib{$idx.':senderdomain'}})) { |
%{$$usernamesort{$contrib{$idx.':senderdomain'}}} = (); |
%{$$usernamesort{$contrib{$idx.':senderdomain'}}} = (); |
Line 1468 sub replicate_attachments {
|
Line 1468 sub replicate_attachments {
|
} |
} |
|
|
sub mail_screen { |
sub mail_screen { |
my ($r,$feedurl,$options) = @_; |
my ($r,$feedurl,$options,$caller_symb) = @_; |
if (exists($env{'form.origpage'})) { |
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']); |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['subject','comment','currnewattach','addnewattach','deloldattach','delnewattach','timestamp','idx','anondiscuss','discuss','blog','group','ref']); |
} |
} |
Line 1479 sub mail_screen {
|
Line 1479 sub mail_screen {
|
'title' => 'Title', |
'title' => 'Title', |
'reta' => 'Retained attachments', |
'reta' => 'Retained attachments', |
'atta' => 'Attachment (128 KB max size)', |
'atta' => 'Attachment (128 KB max size)', |
); |
); |
my $title=&Apache::lonnet::gettitle($feedurl); |
my $restitle = &get_resource_title($caller_symb,$feedurl); |
if (!$title) { $title = $feedurl; } |
|
my $quote=''; |
my $quote=''; |
my $subject = ''; |
my $subject = ''; |
my $comment = ''; |
my $comment = ''; |
Line 1669 END
|
Line 1668 END
|
|
|
$r->print(<<END); |
$r->print(<<END); |
$start_page |
$start_page |
<h2><tt>$title</tt></h2> |
<h2><tt>$restitle</tt></h2> |
<form action="/adm/feedback" method="post" name="mailform" |
<form action="/adm/feedback" method="post" name="mailform" |
enctype="multipart/form-data"> |
enctype="multipart/form-data"> |
$prevtag |
$prevtag |
Line 1968 END
|
Line 1967 END
|
<input type="hidden" name="$dispchgB" value=""/> |
<input type="hidden" name="$dispchgB" value=""/> |
<input type="hidden" name="$markchg" value=""/> |
<input type="hidden" name="$markchg" value=""/> |
<input type="hidden" name="$toggchg" value="" /> |
<input type="hidden" name="$toggchg" value="" /> |
<input type="button" name="sub" value="Store Changes" onClick="javascript:setDisp()" /> |
<input type="button" name="sub" value="Save Changes" onClick="javascript:setDisp()" /> |
END |
END |
if (exists($env{'form.group'})) { |
if (exists($env{'form.group'})) { |
$r->print('<input type="hidden" name="group" value="'.$env{'form.group'}.'" />'); |
$r->print('<input type="hidden" name="group" value="'.$env{'form.group'}.'" />'); |
Line 2056 sub print_sortfilter_options {
|
Line 2055 sub print_sortfilter_options {
|
'spgr' => 'Specific groups', |
'spgr' => 'Specific groups', |
'psub' => 'Pick specific users (by name)', |
'psub' => 'Pick specific users (by name)', |
'shal' => 'Show a list of current posters', |
'shal' => 'Show a list of current posters', |
'stor' => 'Store changes', |
'stor' => 'Save changes', |
); |
); |
|
|
my %sort_types = (); |
my %sort_types = (); |
Line 2560 sub screen_header {
|
Line 2559 sub screen_header {
|
'<p><label><input type="radio" name="discuss" value="author" /> '. |
'<p><label><input type="radio" name="discuss" value="author" /> '. |
&mt('Feedback to resource author').'</label></p>'; |
&mt('Feedback to resource author').'</label></p>'; |
} |
} |
|
my %optionhash=(); |
|
foreach my $type ('question','comment','policy') { |
|
$optionhash{$type}=$env{'course.'.$env{'request.course.id'}.'.'.$type.'.email.text'}; |
|
} |
if (&feedback_available(1)) { |
if (&feedback_available(1)) { |
$msgoptions.= |
$msgoptions.= |
'<p><label><input type="radio" name="discuss" value="question" /> '. |
'<p><label><input type="radio" name="discuss" value="question" /> '. |
&mt('Question about resource content').'</label></p>'; |
($optionhash{'question'}?$optionhash{'question'}:&mt('Question about resource content')).'</label></p>'; |
} |
} |
if (&feedback_available(0,1)) { |
if (&feedback_available(0,1)) { |
$msgoptions.= |
$msgoptions.= |
'<p><label><input type="radio" name="discuss" value="course" /> '. |
'<p><label><input type="radio" name="discuss" value="course" /> '. |
&mt('Question/Comment/Feedback about course content'). |
($optionhash{'comment'}?$optionhash{'comment'}:&mt('Question/Comment/Feedback about course content')). |
'</label></p>'; |
'</label></p>'; |
} |
} |
if (&feedback_available(0,0,1)) { |
if (&feedback_available(0,0,1)) { |
$msgoptions.= |
$msgoptions.= |
'<p><label><input type="radio" name="discuss" value="policy" /> '. |
'<p><label><input type="radio" name="discuss" value="policy" /> '. |
&mt('Question/Comment/Feedback about course policy'). |
($optionhash{'policy'}?$optionhash{'policy'}:&mt('Question/Comment/Feedback about course policy')). |
'</label></p>'; |
'</label></p>'; |
} |
} |
} |
} |
if (($env{'request.course.id'}) && (!$env{'form.sendmessageonly'})) { |
if (($env{'request.course.id'}) && (!$env{'form.sendmessageonly'})) { |
if (&discussion_open(undef,$symb) && |
my ($blocked,$blocktext) = &Apache::loncommon::blocking_status('boards'); |
|
if (!$blocked && &discussion_open(undef,$symb) && |
&Apache::lonnet::allowed('pch', |
&Apache::lonnet::allowed('pch', |
$env{'request.course.id'}. |
$env{'request.course.id'}. |
($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) { |
($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) { |
Line 2589 sub screen_header {
|
Line 2593 sub screen_header {
|
&mt('Anonymous contribution to course discussion of resource'). |
&mt('Anonymous contribution to course discussion of resource'). |
' <i>('.&mt('name only visible to course faculty').')</i></label> '. |
' <i>('.&mt('name only visible to course faculty').')</i></label> '. |
'<a href="/adm/preferences?action=changescreenname">'.&mt('Change Screenname').'</a>'; |
'<a href="/adm/preferences?action=changescreenname">'.&mt('Change Screenname').'</a>'; |
} |
my $blockblog = &Apache::loncommon::blocking_status('blogs'); |
my $blockblog = &Apache::loncommon::blocking_status('blogs'); |
if (!$blockblog) { |
if (!$blockblog) { |
$discussoptions.= &add_blog_checkbox(); |
$discussoptions.= &add_blog_checkbox(); |
} |
} |
} |
} |
} |
if ($msgoptions) { $msgoptions='<h2><img src="'.&Apache::loncommon::lonhttpdurl('/adm/lonMisc/feedback.gif').'" />'.&mt('Sending Messages').'</h2>'.$msgoptions; } |
if ($msgoptions) { $msgoptions='<h2><img src="'.&Apache::loncommon::lonhttpdurl('/adm/lonMisc/feedback.gif').'" />'.&mt('Sending Messages').'</h2>'.$msgoptions; } |
Line 2641 sub clear_out_html {
|
Line 2645 sub clear_out_html {
|
} |
} |
|
|
sub assemble_email { |
sub assemble_email { |
my ($feedurl,$message,$prevattempts,$usersaw,$useranswer)=@_; |
my ($message,$prevattempts,$usersaw,$useranswer)=@_; |
my %lt = &Apache::lonlocal::texthash( |
my %lt = &Apache::lonlocal::texthash( |
'prev' => 'Previous attempts of student (if applicable)', |
'prev' => 'Previous attempts of student (if applicable)', |
'orig' => 'Original screen output (if applicable)', |
'orig' => 'Original screen output (if applicable)', |
Line 2662 ENDCITE
|
Line 2666 ENDCITE
|
return ($email,$citations); |
return ($email,$citations); |
} |
} |
|
|
sub secapply { |
|
my $rec=shift; |
|
my $defaultflag=shift; |
|
$rec=~s/\s+//g; |
|
$rec=~s/\@/\:/g; |
|
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; |
|
} |
|
return ''; |
|
} |
|
|
|
=pod |
|
|
|
=over 4 |
|
|
|
=item * |
|
|
|
decide_receiver($feedurl,$author,$question,$course,$policy,$defaultflag); |
|
|
|
Arguments |
|
$feedurl - /res/ url of resource (only need if $author is true) |
|
$author,$question,$course,$policy - all true/false parameters |
|
if true will attempt to find the addresses of user that should receive |
|
this type of feedback (author - feedback to author of resource $feedurl, |
|
$question 'Resource Content Questions', $course 'Course Content Question', |
|
$policy 'Course Policy') |
|
(Additionally it also checks $env for whether the corresponding form.<name> |
|
element exists, for ease of use in a html response context) |
|
|
|
$defaultflag - (internal should be left blank) if true gather addresses |
|
that aren't for a section even if I have a section |
|
(used for reccursion internally, first we look for |
|
addresses for our specific section then we recurse |
|
and look for non section addresses) |
|
|
|
Returns |
|
$typestyle - string of html text, describing what addresses were found |
|
%to - a hash, which keys are addresses of users to send messages to |
|
the keys will look like name:domain |
|
|
|
=cut |
|
|
|
sub decide_receiver { |
|
my ($feedurl,$author,$question,$course,$policy,$defaultflag) = @_; |
|
my $typestyle=''; |
|
my %to=(); |
|
if ($env{'form.discuss'} eq 'author' ||$author) { |
|
$typestyle.='Submitting as Author Feedback<br />'; |
|
$feedurl=~ m{^/res/($LONCAPA::domain_re)/($LONCAPA::username_re)/}; |
|
$to{$2.':'.$1}=1; |
|
} |
|
if ($env{'form.discuss'} eq 'question' ||$question) { |
|
$typestyle.=&mt('Submitting as Question').'<br />'; |
|
foreach my $item (split(/\,/, |
|
$env{'course.'.$env{'request.course.id'}.'.question.email'}) |
|
) { |
|
my $rec=&secapply($item,$defaultflag); |
|
if ($rec) { $to{$rec}=1; } |
|
} |
|
} |
|
if ($env{'form.discuss'} eq 'course' ||$course) { |
|
$typestyle.=&mt('Submitting as Comment').'<br />'; |
|
foreach my $item (split(/\,/, |
|
$env{'course.'.$env{'request.course.id'}.'.comment.email'}) |
|
) { |
|
my $rec=&secapply($item,$defaultflag); |
|
if ($rec) { $to{$rec}=1; } |
|
} |
|
} |
|
if ($env{'form.discuss'} eq 'policy' ||$policy) { |
|
$typestyle.=&mt('Submitting as Policy Feedback').'<br />'; |
|
foreach my $item (split(/\,/, |
|
$env{'course.'.$env{'request.course.id'}.'.policy.email'}) |
|
) { |
|
my $rec=&secapply($item,$defaultflag); |
|
if ($rec) { $to{$rec}=1; } |
|
} |
|
} |
|
if ((scalar(%to) eq '0') && (!$defaultflag)) { |
|
($typestyle,%to)= |
|
&decide_receiver($feedurl,$author,$question,$course,$policy,1); |
|
} |
|
return ($typestyle,%to); |
|
} |
|
|
|
sub feedback_available { |
sub feedback_available { |
my ($question,$course,$policy)=@_; |
my ($question,$course,$policy)=@_; |
my ($typestyle,%to)=&decide_receiver('',0,$question,$course,$policy); |
my ($typestyle,%to)=&Apache::lonmsg::decide_receiver('',0,$question, |
|
$course,$policy); |
return scalar(%to); |
return scalar(%to); |
} |
} |
|
|
sub send_msg { |
sub send_msg { |
my ($title,$feedurl,$email,$citations,$attachmenturl,%to)=@_; |
my ($title,$feedurl,$email,$citations,$attachmenturl,$symb,%to)=@_; |
my $status=''; |
my $status=''; |
my $sendsomething=0; |
my $sendsomething=0; |
if ($title=~/^Error/) { $title=&mt('Feedback').': '.$title; } |
my $restitle = &get_resource_title($symb,$feedurl); |
unless ($title=~/\w/) { $title=&mt('Feedback'); } |
if ($title=~/^Error/) { $title=&mt('Feedback').': '.$title; } |
foreach my $key (keys(%to)) { |
unless ($title=~/\w/) { $title=&mt('Feedback'); } |
if ($key) { |
foreach my $key (keys(%to)) { |
my $declutter=&Apache::lonnet::declutter($feedurl); |
if ($key) { |
unless (&Apache::lonmsg::user_normal_msg(split(/\:/,$key), |
my ($user,$domain) = split(/\:/,$key,2); |
$title.' ['.$declutter.']',$email,$citations,$feedurl, |
if (!defined($user)) { |
$attachmenturl)=~/ok/) { |
$status.='<br />'.&mt('Error sending message to [_1], no user specified.',$key); |
$status.='<br />'.&mt('Error sending message to').' '.$key.'<br />'; |
} elsif (!defined($domain)) { |
} else { |
$status.='<br />'.&mt('Error sending message to [_1], no domain specified.',$key); |
$sendsomething++; |
} else { |
} |
unless (&Apache::lonmsg::user_normal_msg($user,$domain, |
|
$title.' ['.$restitle.']',$email,$citations,$feedurl, |
|
$attachmenturl,undef,undef,$symb,$restitle)=~/ok/) { |
|
$status.='<br />'.&mt('Error sending message to').' '.$key.'<br />'; |
|
} else { |
|
$sendsomething++; |
|
} |
|
} |
|
} |
} |
} |
} |
|
|
|
my %record=&Apache::lonnet::restore('_feedback'); |
my %record=&Apache::lonnet::restore('_feedback'); |
my ($temp)=keys(%record); |
my ($temp)=keys(%record); |
unless ($temp=~/^error\:/) { |
unless ($temp=~/^error\:/) { |
my %newrecord=(); |
my %newrecord=(); |
$newrecord{'resource'}=$feedurl; |
$newrecord{'resource'}=$feedurl; |
$newrecord{'subnumber'}=$record{'subnumber'}+1; |
$newrecord{'subnumber'}=$record{'subnumber'}+1; |
unless (&Apache::lonnet::cstore(\%newrecord,'_feedback') eq 'ok') { |
unless (&Apache::lonnet::cstore(\%newrecord,'_feedback') eq 'ok') { |
$status.='<br />'.&mt('Not registered').'<br />'; |
$status.='<br />'.&mt('Not registered').'<br />'; |
} |
} |
} |
} |
|
|
return ($status,$sendsomething); |
return ($status,$sendsomething); |
} |
} |
|
|
sub adddiscuss { |
sub adddiscuss { |
Line 3019 sub modify_attachments {
|
Line 2935 sub modify_attachments {
|
'chth' => 'Check the checkboxes for any you wish to remove.', |
'chth' => 'Check the checkboxes for any you wish to remove.', |
'thef' => 'The following attachments have been uploaded for inclusion with this posting.', |
'thef' => 'The following attachments have been uploaded for inclusion with this posting.', |
'adda' => 'Add a new attachment to this post.', |
'adda' => 'Add a new attachment to this post.', |
'stch' => 'Store Changes', |
'stch' => 'Save Changes', |
); |
); |
my $js = <<END; |
my $js = <<END; |
<script type="text/javascript"> |
<script type="text/javascript"> |
Line 3725 ENDREDIR
|
Line 3641 ENDREDIR
|
my $symb; |
my $symb; |
if ($env{'form.replydisc'}) { |
if ($env{'form.replydisc'}) { |
$symb=(split(/\:\:\:/,$env{'form.replydisc'}))[0]; |
$symb=(split(/\:\:\:/,$env{'form.replydisc'}))[0]; |
my ($map,$id,$url)=&Apache::lonnet::decode_symb($symb); |
|
$feedurl=&Apache::lonnet::clutter($url); |
|
} elsif ($env{'form.editdisc'}) { |
} elsif ($env{'form.editdisc'}) { |
$symb=(split(/\:\:\:/,$env{'form.editdisc'}))[0]; |
$symb=(split(/\:\:\:/,$env{'form.editdisc'}))[0]; |
my ($map,$id,$url)=&Apache::lonnet::decode_symb($symb); |
|
$feedurl=&Apache::lonnet::clutter($url); |
|
} elsif ($env{'form.origpage'}) { |
} elsif ($env{'form.origpage'}) { |
$symb=""; |
$symb=""; |
} else { |
} else { |
Line 3738 ENDREDIR
|
Line 3650 ENDREDIR
|
} |
} |
unless ($symb) { |
unless ($symb) { |
$symb=$env{'form.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; |
my $goahead=1; |
if ($feedurl=~/\.(problem|exam|quiz|assess|survey|form|task)$/) { |
if ($feedurl=~/\.(problem|exam|quiz|assess|survey|form|task)$/) { |
unless ($symb) { $goahead=0; } |
unless ($symb) { $goahead=0; } |
} |
} |
# backward compatibility (bulletin boards used to be 'wrapped') |
|
&dewrapper(\$feedurl); |
|
if (!$goahead) { |
if (!$goahead) { |
# Ambiguous Problem Resource |
# Ambiguous Problem Resource |
$r->internal_redirect('/adm/ambiguous'); |
$r->internal_redirect('/adm/ambiguous'); |
Line 3787 ENDREDIR
|
Line 3699 ENDREDIR
|
} |
} |
my $options=&screen_header($feedurl,$symb); |
my $options=&screen_header($feedurl,$symb); |
if ($options) { |
if ($options) { |
&mail_screen($r,$feedurl,$options); |
&mail_screen($r,$feedurl,$options,$symb); |
} else { |
} else { |
&fail_redirect($r,$feedurl); |
&fail_redirect($r,$feedurl); |
} |
} |
Line 3800 ENDREDIR
|
Line 3712 ENDREDIR
|
$env{'request.course.id'}); |
$env{'request.course.id'}); |
|
|
# Get output from resource |
# Get output from resource |
|
&Apache::lonenc::check_encrypt(\$feedurl); |
my $usersaw=&resource_output($feedurl); |
my $usersaw=&resource_output($feedurl); |
|
|
# Get resource answer (need to allow student to view grades for this to work) |
# Get resource answer (need to allow student to view grades for this to work) |
&Apache::lonnet::appenv(('allowed.vgr'=>'F')); |
&Apache::lonnet::appenv(('allowed.vgr'=>'F')); |
my $useranswer=&Apache::loncommon::get_student_answers( |
my $usersymb = &Apache::lonenc::check_encrypt($symb); |
$symb,$env{'user.name'},$env{'user.domain'}, |
my $useranswer= |
$env{'request.course.id'}); |
&Apache::loncommon::get_student_answers( |
|
$usersymb,$env{'user.name'},$env{'user.domain'}, |
|
$env{'request.course.id'}); |
&Apache::lonnet::delenv('allowed.vgr'); |
&Apache::lonnet::delenv('allowed.vgr'); |
# Get attachments, if any, and not too large |
# Get attachments, if any, and not too large |
my $attachmenturl=''; |
my $attachmenturl=''; |
Line 3836 ENDREDIR
|
Line 3751 ENDREDIR
|
my $message=&clear_out_html($env{'form.comment'}); |
my $message=&clear_out_html($env{'form.comment'}); |
|
|
# Assemble email |
# Assemble email |
my ($email,$citations)=&assemble_email($feedurl,$message,$prevattempts, |
my ($email,$citations)=&assemble_email($message,$prevattempts, |
$usersaw,$useranswer); |
$usersaw,$useranswer); |
|
|
# Who gets this? |
# Who gets this? |
my ($typestyle,%to) = &decide_receiver($feedurl); |
my ($typestyle,%to) = &Apache::lonmsg::decide_receiver($feedurl); |
|
|
# Actually send mail |
# Actually send mail |
my ($status,$numsent)=&send_msg(&clear_out_html($env{'form.subject'}, |
my ($status,$numsent)=&send_msg(&clear_out_html($env{'form.subject'}, |
undef,1), |
undef,1), |
$feedurl,$email,$citations, |
$feedurl,$email,$citations, |
$attachmenturl,%to); |
$attachmenturl,$usersymb,%to); |
|
|
# Discussion? Store that. |
# Discussion? Store that. |
my $numpost=0; |
my $numpost=0; |
Line 3989 sub group_args {
|
Line 3904 sub group_args {
|
return $extra_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; |
1; |
__END__ |
__END__ |