--- loncom/interface/lonfeedback.pm 2012/03/17 14:49:29 1.351 +++ loncom/interface/lonfeedback.pm 2022/01/18 16:55:30 1.388 @@ -1,7 +1,7 @@ # The LearningOnline Network # Feedback # -# $Id: lonfeedback.pm,v 1.351 2012/03/17 14:49:29 raeburn Exp $ +# $Id: lonfeedback.pm,v 1.388 2022/01/18 16:55:30 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -44,8 +44,8 @@ use HTML::LCParser(); #use HTML::Tidy::libXML; use Apache::lonspeller(); use Apache::longroup; -use Cwd; -use LONCAPA; +use Archive::Zip qw( :ERROR_CODES ); +use LONCAPA qw(:DEFAULT :match); sub discussion_open { my ($status,$symb)=@_; @@ -118,10 +118,16 @@ sub list_discussion { $outputtarget = 'export'; } } + my ($nofooter,$nodisclink,$nofdbklink); if (not &discussion_visible($status)) { if ($mode ne 'board') { - &Apache::lonenc::check_encrypt(\$ressymb); - return '
"; + ($nofooter,$nodisclink,$nofdbklink) = &check_menucoll(); + if ($nofooter || $nofdbklink) { + return '
'; + } else { + &Apache::lonenc::check_encrypt(\$ressymb); + return '
"; + } } } if ($group ne '' && $mode eq 'board') { @@ -130,17 +136,27 @@ sub list_discussion { } } - my ($blocked,$blocktext) = - &Apache::loncommon::blocking_status('boards'); - if ($blocked) { - $blocktext = '
'; - }else{ - $blocktext.=""; + unless ($outputtarget eq 'export') { + ($nofooter,$nodisclink,$nofdbklink) = &check_menucoll(); + } + + unless ($nofooter) { + my ($blocked,$blocktext) = + &Apache::loncommon::blocking_status('boards'); + if ($blocked) { + my $footer = '
'; + return $footer; } - return $blocktext; } my @bgcols = ("LC_disc_old_item","LC_disc_new_item"); @@ -336,12 +352,15 @@ sub list_discussion { 'aner' => 'An error occurred opening the manifest file.', 'difo' => 'Discussion for', 'aerr' => 'An error occurred opening the export file for posting', + 'discussions' => 'DISCUSSIONS' + ); + my %js_lt = &Apache::lonlocal::texthash( 'aysu' => 'Are you sure you want to delete this post?', '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' ); + &js_escape(\%js_lt); my $currdisp = $lt{'allposts'}; my $currmark = $lt{'onmark'}; @@ -447,12 +466,12 @@ imscp_v1p1.xsd http://www.imsglobal.org/ prevparm = "&previous="+previous } if (caller == 'studentdelete') { - if (confirm("$lt{'aysu'}\\n$lt{'dpwn'},\\n$lt{'bwco'}")) { + if (confirm("$js_lt{'aysu'}\\n$js_lt{'dpwn'},\\n$js_lt{'bwco'}")) { document.location.href = "/adm/feedback?hide="+symbparm+prevparm+groupparm } } else { if (caller == 'seeiddelete') { - if (confirm("$lt{'aysu'}\\n$lt{'depo'}")) { + if (confirm("$js_lt{'aysu'}\\n$js_lt{'depo'}")) { document.location.href = "/adm/feedback?deldisc="+symbparm+prevparm+groupparm } } @@ -468,18 +487,18 @@ imscp_v1p1.xsd http://www.imsglobal.org/ my $numhidden = keys(%notshown); if ($numhidden > 0) { my $colspan = $maxdepth+1; - $discussion.="\n".''. - ''; + my $href = '/adm/feedback?allposts=1&symb='.$escsymb; if ($newpostsflag) { - $discussion .= '&previous='.$prevread; + $href .= '&previous='.$prevread; } - $discussion .= &group_args($group); - $discussion .= '">'.&mt('Show all posts').' '.&mt('to display').' '. - $numhidden.' '; + $href .= &group_args($group); if ($showunmark) { - $discussion .= &mt('posts previously marked read'); + $discussion .= &mt('[_1]Show all posts[_2] to display [quant,_3,post] previously marked read', + '','',$numhidden); } else { - $discussion .= &mt('previously viewed posts'); + $discussion .= &mt('[_1]Show all posts[_2] to display [quant,_3,post] previously viewed', + '','',$numhidden); } $discussion .= '
'; } @@ -562,7 +581,7 @@ imscp_v1p1.xsd http://www.imsglobal.org/ my $postingfile; my $postingfilename = $tempexport.'/'.$postfilename; if ($postingfile = Apache::File->new('>'.$postingfilename)) { - print $postingfile 'Discussion Post'. + print $postingfile ''.&mt('Discussion Post').''. $imsitems{$alldiscussion{$post}}{'title'}.' '. $imsitems{$alldiscussion{$post}}{'sender'}. $imsitems{$alldiscussion{$post}}{'timestamp'}.'

'. @@ -671,7 +690,7 @@ END $newpostsflag,$group, $prevread,$markondisp,$seehidden); $discussion .= "\n"; - } + } if ($outputtarget eq 'export') { if ($manifestok) { while ($currdepth > 0) { @@ -693,22 +712,34 @@ END #Create zip file in prtspool - my $imszipfile = '/prtspool/'. - $env{'user.name'}.'_'.$env{'user.domain'}.'_'. - time.'_'.rand(1000000000).'.zip'; - my $cwd = &getcwd(); - my $imszip = '/home/httpd/'.$imszipfile; - chdir $tempexport; - open(OUTPUT, "zip -r $imszip * 2> /dev/null |"); - close(OUTPUT); - chdir $cwd; - $discussion .= &mt('Download the zip file from [_1]Discussion Posting Archive','').'
'; - if ($copyresult) { - $discussion .= &mt('The following errors occurred during export').' -
'.$copyresult; + if (($env{'user.name'} =~ /^$match_username$/) + && ($env{'user.domain'} =~ /^$match_domain$/)) { + my $now = time(); + my $imszipfile = '/prtspool/'. + join('_',$env{'user.name'},$env{'user.domain'},$now). + '_'.rand(1000000000).'.zip'; + my $zip = Archive::Zip->new(); + $zip->addTree($tempexport); + my $imszip = '/home/httpd/'.$imszipfile; + if ($zip->writeToFileNamed($imszip) == AZ_OK) { + $discussion .= &mt('Download the zip file from [_1]Discussion Posting Archive[_2]', + '','').'
'; + } else { + $discussion .= &mt('Failed to create zip file').'
'; + } + if ($copyresult) { + $discussion .= ''. + &mt('The following errors occurred during export:'). + '
'.$copyresult; + } + } else { + $discussion .= '

'. + &mt('Unfortunately you will not be able to retrieve an archive of the discussion posts at this time, because there was a problem creating the zip file.').'

'; } } } else { - $discussion .= '
'.&mt('Unfortunately you will not be able to retrieve an archive of the discussion posts at this time, because there was a problem creating a manifest file.').'
'; + $discussion .= '

'. + &mt('Unfortunately you will not be able to retrieve an archive of the discussion posts at this time, because there was a problem creating a manifest file.').'

'; } return $discussion; } @@ -759,33 +790,60 @@ END &mt('This discussion is closed.').''; } } elsif ($outputtarget ne 'tex') { - $discussion.=''; } return $discussion; } +sub check_menucoll { + my ($nofooter,$nodisclink,$nofdbklink); + my ($menucoll,$deeplinkmenu,$menuref) = &Apache::loncommon::menucoll_in_effect(); + if ($menucoll) { + if (ref($menuref) eq 'HASH') { + if ($menuref->{'foot'} eq 'n') { + $nofooter = 1; + } else { + unless ($menuref->{'disc'}) { + $nodisclink = 1; + } + unless ($menuref->{'fdbk'}) { + $nofdbklink = 1; + } + } + } + } + return ($nofooter,$nodisclink,$nofdbklink); +} + sub can_see_hidden { my ($mode,$ressymb,$feedurl,$group,$cdom,$cnum,$crs) = @_; my $seehidden; @@ -821,7 +879,7 @@ sub can_see_hidden { sub discussion_link { my ($ressymb,$linktext,$cmd,$item,$flag,$prev,$adds,$title)=@_; - my $link='/adm/feedback?inhibitmenu=yes&modal=yes&'.$cmd.'='.&escape($ressymb).':::'.$item; + my $link='/adm/feedback?inhibitmenu=yes&modal=yes&'.$cmd.'='.&escape($ressymb).':::'.$item; if ($flag) { $link .= '&previous='.$prev; } if ($adds) { $link .= $adds; } my $width=600; @@ -840,7 +898,7 @@ sub send_feedback_link { &discussion_link($ressymb, ''.&mt('Post Discussion').'', + '" />'.&mt('Post Discussion').'', 'replydisc'). ''; } @@ -851,7 +909,7 @@ sub send_message_link { &discussion_link($ressymb, ''.&mt('Send Feedback').'', + '" />'.&mt('Send Feedback').'', 'sendmessageonly'). ''; return $output; @@ -926,7 +984,7 @@ sub postingform_display { $currnewattach,$currdelold,$group,$crstype) = @_; my $newattachmsg; my %lt = &Apache::lonlocal::texthash( - 'note' => 'Note: in anonymous discussion, your name is visible only to course faculty', + 'note' => 'Note: in anonymous discussion, your name is visible only to course faculty', 'title' => 'Title', 'podi' => 'Post Discussion', 'poan' => 'Post Anonymous Discussion', @@ -945,9 +1003,14 @@ sub postingform_display { } } } + my $postanon; + if (&Apache::lonnet::allowed('pac',$env{'request.course.id'}. + ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) { + $postanon = ''; + } $postingform .= (< - +$postanon @@ -1056,6 +1119,7 @@ sub build_posting_display { &filter_regexp($rolefilter,$sectionpick,$statusfilter); $rolematch = $roleregexp.':'.$secregexp.':'.$statusregexp; } + my %votestyle; 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++) { @@ -1063,8 +1127,8 @@ sub build_posting_display { 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 '') { - push(@theselikes,$likes{$symb.':'.$idx.':likes'}); if (ref($likes{$symb.':'.$idx.':likers'}) eq 'HASH') { if (exists($likes{$symb.':'.$idx.':likers'}{$thisuser})) { $userlikes{$idx} = 1; @@ -1101,6 +1165,29 @@ sub build_posting_display { $twoplus=$ave+2.*$stddev; $oneminus=$ave-$stddev; $twominus=$ave-2.*$stddev; + if ($#theselikes>1) { + foreach my $class ('twoplus','oneplus','zero','oneminus','twominus') { + my $fontstyle = $env{'course.'.$env{'request.course.id'}.'.discussion_post_fonts_'.$class}; + if ($fontstyle ne '') { + my ($size,$weight,$style,$other) = split(/,/,$fontstyle); + if ($size ne '') { + $votestyle{$class} .= 'font-size: '.$size.';'; + } + if ($weight ne '') { + $votestyle{$class} .= 'font-weight: '.$weight.';'; + } + if ($style ne '') { + $votestyle{$class} .= 'font-style: '.$style.';'; + } + if ($other ne '') { + $votestyle{$class} .= $other; + } + if ($votestyle{$class} ne '') { + $votestyle{$class} = 'style="'.$votestyle{$class}.'"'; + } + } + } + } } # # This is now the real loop. Go through all entries, pick up what we need @@ -1254,7 +1341,7 @@ sub build_posting_display { if (&editing_allowed($escsymb.':::'.$idx,$group)) { if (($env{'user.domain'} eq $contrib{$idx.':senderdomain'}) && ($env{'user.name'} eq $contrib{$idx.':sendername'})) { $sender.=' '. - &discussion_link($symb,&mt('Edit'),'editdisc',$idx,$$newpostsflag,$prevread,&group_args($group)); + &discussion_link($ressymb,&mt('Edit'),'editdisc',$idx,$$newpostsflag,$prevread,&group_args($group)); unless ($seehidden) { my $grpargs = &group_args($group); $sender.=" $twoplus) { - $likesize="200"; + $class = 'twoplus'; } elsif ($thislikes>$oneplus) { - $likesize="150"; + $class = 'oneplus'; } if ($thislikes<$twominus) { - $likesize="50"; + $class = 'twominus'; } elsif ($thislikes<$oneminus) { - $likesize="75"; + $class = 'oneminus'; } + $likestyle = $votestyle{$class}; } # Actually glue in the message itself $$discussionitems[$idx].= '
'. - "
". + "
". $message. '
'; if ($canvote) { @@ -1470,6 +1559,7 @@ sub build_posting_display { } else { $novote = &mt('No voting for hidden posts.'); } + &html_escape(\$novote); $$discussionitems[$idx].= '
'. ''.$novote.' '. @@ -1479,12 +1569,12 @@ sub build_posting_display { 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")); + $$discussionitems[$idx].=' '.&discussion_link($ressymb,''.&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")); + $$discussionitems[$idx].=' '.&discussion_link($ressymb,''.&mt('Unlike').'','unlike',$idx,$$newpostsflag,$prevread,&group_args($group),&mt("Unlike this posting")); } } } @@ -1502,7 +1592,7 @@ sub build_posting_display { $$discussionitems[$idx] .= '  '.&mt('This post has been edited by the author.'); if ($seehidden) { $$discussionitems[$idx] .= '  '. - &discussion_link($symb,&mt('Display all versions'),'allversions',$idx,$$newpostsflag,$prevread,&group_args($group)); + &discussion_link($ressymb,&mt('Display all versions'),'allversions',$idx,$$newpostsflag,$prevread,&group_args($group)); } $$discussionitems[$idx].='
'.&mt('Earlier version(s) were posted on: '); if ($contrib{$idx.':history'} =~ m/:/) { @@ -1734,14 +1824,11 @@ sub mail_screen { my %lt = &Apache::lonlocal::texthash( 'myqu' => 'Question/comment/feedback:', - 'title' => 'Title', 'reta' => 'Retained attachments', 'atta' => 'Attachment', ); - if($env{'form.editdisc'} || $env{'form.replydisc'}){ - %lt = &Apache::lonlocal::texthash( - 'myqu' => 'Post Discussion', - ); + if ($env{'form.editdisc'} || $env{'form.replydisc'}){ + $lt{'myqu'} = &mt('Post Discussion'); } my $restitle = &get_resource_title($caller_symb,$feedurl); my $quote=''; @@ -1807,6 +1894,7 @@ 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'}); @@ -1815,36 +1903,25 @@ END $numoldver = 1; } } - if ($env{'form.replydisc'}) { - if ($contrib{$idx.':history'}) { - if ($contrib{$idx.':history'} =~ /:/) { - my @oldversions = split(/:/,$contrib{$idx.':history'}); - $numoldver = @oldversions; - } else { - $numoldver = 1; - } + if ($idx > 0) { + my (%msgversions,%subversions,$htmldecode); + $htmldecode = 0; + if ($env{'form.replydisc'}) { + $htmldecode = 1; } - if ($idx > 0) { - my %msgversions = (); - &get_post_versions(\%msgversions,$contrib{$idx.':message'},0,$numoldver); + &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'}) { $quote = $msgversions{$numoldver}; - } - 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); + $subject = &HTML::Entities::encode(&mt('Re: ').$subject,'<>&"'); + } else { $comment = $msgversions{$numoldver}; - my %subversions = (); - &get_post_versions(\%subversions,$contrib{$idx.':subject'},0,$numoldver); - $subject = $subversions{$numoldver}; } + } + if ($env{'form.editdisc'}) { + $attachmenturls = $contrib{$idx.':attachmenturl'}; if (defined($contrib{$idx.':replyto'})) { $parentmsg = $contrib{$idx.':replyto'}; } @@ -1880,6 +1957,7 @@ END my $latexHelp=&Apache::loncommon::helpLatexCheatsheet(undef,undef,1,($env{'form.modal'}?'popup':0)); my $send=&mt('Send'); my $alert = &mt('Please select a feedback type.'); + &js_escape(\$alert); my $js= < // + END my ($textareaheader,$textareaclass); @@ -1936,7 +2015,7 @@ END my %onload = ('onload' => 'window.focus();setposttype();'); my %parms=('add_entries' => \%onload); - if ($env{'form.modal'} ne 'yes') { 'bread_crumbs' => $brcrum } + if ($env{'form.modal'} ne 'yes') { $parms{'bread_crumbs'} = $brcrum; } my $start_page= &Apache::loncommon::start_page('Resource Feedback and Discussion',$js,\%parms); @@ -1945,7 +2024,11 @@ END unless (&contains_block_html($quote)) { &newline_to_br(\$quote); } - $quote='
'.&Apache::lontexconvert::msgtexconverted($quote).'
'; + $quote=&Apache::lonhtmlcommon::start_pick_box(). + &Apache::lonhtmlcommon::row_title(&mt('Quote')). + &Apache::lontexconvert::msgtexconverted($quote). + &Apache::lonhtmlcommon::row_closure(1). + &Apache::lonhtmlcommon::end_pick_box(); } my $header=''; unless ($env{'form.modal'}) { @@ -1973,24 +2056,27 @@ END } $r->print(< +END +$r->print(&Apache::lonhtmlcommon::start_pick_box()); +$r->print(< $textareaheader

-

$latexHelp

END - $r->print(&Apache::lonhtmlcommon::start_pick_box()); + $r->print(&Apache::lonhtmlcommon::row_title(&mt('Subject'))); $r->print('

'); $r->print(&Apache::lonhtmlcommon::row_closure()); $r->print(&Apache::lonhtmlcommon::row_title(&mt('Message'))); - $r->print(''); $r->print(&Apache::lonhtmlcommon::row_closure(1)); @@ -2017,7 +2103,8 @@ END } else { $r->print(< -$lt{'atta'} $attachmaxtext: +$lt{'atta'} $attachmaxtext: +

END } @@ -2028,10 +2115,8 @@ END $r->print(''); } $r->print(< - +

-

END if ($env{'form.editdisc'} || $env{'form.replydisc'}) { @@ -2046,7 +2131,6 @@ END $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').'
'; @@ -2066,9 +2150,10 @@ END $r->print("
$lt{'reta'}:$attachmsg
\n"); } if ($newattachmsg) { - $r->print("$newattachmsg
"); + $r->print("$newattachmsg"); } } + $r->print(&generate_attachments_button($postidx,$attachnum,$ressymb,$now,\@currnewattach,\@currdelold,$numoldver,'',$blockblog)); } $r->print(&generate_preview_button(). &Apache::loncommon::end_page()); @@ -2108,6 +2193,11 @@ sub print_display_options { '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 %js_lt = &Apache::lonlocal::texthash( + '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.' + ); + &js_escape(\%js_lt); my $dispchangeA = $lt{'unread'}; my $dispchangeB = $lt{'unmark'}; @@ -2201,7 +2291,7 @@ function setDisp() { if (chktotal > 0) { document.modifydisp.submit() } else { - if(confirm("$lt{'yhni'}. \\n$lt{'ywbr'}")) { + if(confirm("$js_lt{'yhni'}. \\n$js_lt{'ywbr'}")) { if (prev > 0) { location.href = "$feedurl?previous=$previous" } else { @@ -2561,7 +2651,7 @@ sub print_showposters { my $table_start =&Apache::loncommon::start_data_table(); $r->print(< +

$table_start @@ -2661,29 +2751,49 @@ sub get_post_attachments { $$attachments{'0'}{'filename'} = $attachmenturls; $$attachments{'0'}{'0'} = 'n'; } - return; } sub fail_redirect { - my ($r,$feedurl) = @_; + my ($r,$feedurl,$delay) = @_; 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,})); + my %parms=('only_body' => 1); + if ($delay !~ /^\d+(|\.\d+)$/) { + $delay = 0; + } + if ($env{'form.modal'}) { + my $onload = 'document.forms.reldt.submit()'; + if ($delay) { + my $js_delay = int(1000 * $delay); + $onload = "setTimeout(function(){ + document.forms.reldt.submit(); + },$js_delay);"; + } + $parms{'add_entries'}={'onload' => $onload}; + } else { + $parms{'redirect'}=[$delay,$feedurl]; + } + $r->print(&Apache::loncommon::start_page('Feedback not sent',undef,\%parms)); + my $windowname = 'loncapaclient'; + if ($env{'request.lti.login'}) { + $windowname .= 'lti'; + } $r->print(< -$lt{'sorr'} +

$lt{'sorr'}

+ + ENDFAILREDIR $r->print(&Apache::loncommon::end_page()); } sub redirect_back { - my ($r,$feedurl,$typestyle,$sendsomething,$sendposts,$blog,$status,$previous,$sort,$rolefilter,$statusfilter,$sectionpick,$grouppick,$numpicks,$group,$toolarge) = @_; + my ($r,$feedurl,$typestyle,$sendsomething,$sendposts,$blog,$status,$previous,$sort, + $rolefilter,$statusfilter,$sectionpick,$grouppick,$numpicks,$group,$toolarge) = @_; my $sorttag = ''; my $roletag = ''; my $statustag = ''; @@ -2783,13 +2893,18 @@ sub redirect_back { my $logo=&Apache::loncommon::lonhttpdurl('/adm/lonIcons/lonlogos.gif'); my %parms=('only_body' => 1); if ($env{'form.modal'}) { - $parms{'add_entries'}={'onLoad' => 'document.forms.reldt.submit()'}; + my $onload = 'document.forms.reldt.submit()'; + $parms{'add_entries'}={'onload' => $onload}; } else { $parms{'redirect'}=[0,$feedurl]; } my $start_page= &Apache::loncommon::start_page('Feedback sent',undef,\%parms); my $end_page = &Apache::loncommon::end_page(); + my $windowname = 'loncapaclient'; + if ($env{'request.lti.login'}) { + $windowname .= 'lti'; + } $r->print(< @@ -2798,7 +2913,7 @@ $typestyle $blog $toolarge $status -
+ $prevtag $sorttag $statustag @@ -2813,39 +2928,63 @@ ENDREDIR } sub no_redirect_back { - my ($r,$feedurl) = @_; + my ($r,$feedurl,$delay) = @_; my $nofeed=&mt('Sorry, no feedback possible on this resource ...'); - - my %onload; - - my %body_options = ('only_body' => 1, - 'bgcolor' => '#FFFFFF', - 'add_entries' => \%onload,); - - if ($feedurl !~ m{^/adm/feedback}) { - $body_options{'redirect'} = [2,$feedurl]; + my $form_for_modal; + my %parms=('only_body' => 1, + 'bgcolor' => '#FFFFFF',); + if ($delay !~ /^\d+(|\.\d+)$/) { + $delay = 0; + } + if ($env{'form.modal'}) { + if (($feedurl !~ m{^/adm/feedback}) && ($feedurl ne '')) { + my $onload = 'document.forms.reldt.submit()'; + if ($delay) { + my $js_delay = int(1000 * $delay); + $onload = "setTimeout(function(){ + document.forms.reldt.submit(); + },$js_delay);"; + } + $parms{'add_entries'}={'onload' => $onload}; + my $windowname = 'loncapaclient'; + if ($env{'request.lti.login'}) { + $windowname .= 'lti'; + } + $form_for_modal = < + +ENDFORM + } + } else { + if (($feedurl !~ m{^/adm/feedback}) && ($feedurl ne '')) { + $parms{'redirect'}=[$delay,$feedurl]; + } } + my $start_page= &Apache::loncommon::start_page('Feedback not sent',undef, - \%body_options); - + \%parms); + my $end_page = &Apache::loncommon::end_page(); - &Apache::lonenc::check_encrypt(\$feedurl); my $logo=&Apache::loncommon::lonhttpdurl('/adm/lonIcons/lonlogos.gif'); $r->print (< $nofeed
+$form_for_modal $end_page ENDNOREDIRTWO } sub screen_header { my ($feedurl,$symb,$group) = @_; - my $crscontent = &mt('Question/Comment/Feedback about course content'); - my $crspolicy = &mt('Question/Comment/Feedback about course policy'); + my %default = &Apache::lonlocal::texthash ( + question => 'Question about resource content', + comment => 'Question/Comment/Feedback about course content', + policy => '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'); @@ -2853,8 +2992,8 @@ sub screen_header { 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'); + $default{'comment'} = &mt('Question/Comment/Feedback about community content'); + $default{'policy'} = &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'); @@ -2862,54 +3001,79 @@ sub screen_header { } my $msgoptions=''; my $discussoptions=''; + my $checkradio = ''; + my $blockblog; + my (%fdbkoptions,%discoptions); 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 (($feedurl=~/^\/res\//) && ($feedurl!~/^\/res\/adm/) && ($env{'user.adv'})) { + $fdbkoptions{'author'} = 1; + } + if (&feedback_available(1)) { + $fdbkoptions{'question'} = 1; + } + if (&feedback_available(0,1)) { + $fdbkoptions{'course'} = 1; + } + if (&feedback_available(0,0,1)) { + $fdbkoptions{'policy'} = 1; + } } 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', - $env{'request.course.id'}. - ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')) || + if (!$blocked && &discussion_open(undef,$realsymb) && + (&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')))) { - $discussoptions='
'. - '
'.&mt('Change Screenname').''; - my $blockblog = &Apache::loncommon::blocking_status('blogs'); - if (!$blockblog) { - $discussoptions.= &add_blog_checkbox($crstype); - } + $discoptions{'nonanon'} = 1; + if (&Apache::lonnet::allowed('pac',$env{'request.course.id'}. + ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) { + $discoptions{'anon'} = 1; + } + $blockblog = &Apache::loncommon::blocking_status('blogs'); + } + } + my $total = scalar(keys(%fdbkoptions)) + scalar(keys(%discoptions)); + return if (!$total); + if ($total == 1) { + $checkradio = ' checked="checked"'; + } + if (keys(%fdbkoptions)) { + if ($fdbkoptions{'author'}) { + $msgoptions = + '
'; + } + foreach my $item ('question','comment','policy') { + my $type = $item; + if ($item eq 'comment') { + $type = 'course'; + } + my $optionhash=$env{'course.'.$env{'request.course.id'}.'.'.$item.'.email.text'}; + if ($fdbkoptions{$type}) { + $msgoptions .= + '
'; + } + } + } + if (keys(%discoptions)) { + if ($discoptions{'nonanon'}) { + $discussoptions=''; + } + if ($discoptions{'anon'}) { + $discussoptions .= '
'. + ''.&mt('Change Screenname').''; + } + if (!$blockblog) { + $discussoptions.= &add_blog_checkbox($crstype); } } if ($msgoptions) { @@ -3128,7 +3292,7 @@ sub adddiscuss { if (($symb) && ($email)) { my $now = time; if ($env{'form.editdisc'}) { - $contrib{'ip'}=$ENV{'REMOTE_ADDR'}; + $contrib{'ip'}=&Apache::lonnet::get_requestor_ip(); $contrib{'host'}=$Apache::lonnet::perlvar{'lonHostID'}; $contrib{'timestamp'} = $now; $contrib{'history'} = ''; @@ -3463,13 +3627,14 @@ sub modify_attachments { document.modattachments.submit(); } + END # Breadcrumbs my $brcrum = [{'href' => '', 'text' => 'Discussion Post Attachments'}]; my %parms=('only_body' => 1); - if ($env{'form.modal'} ne 'yes') { 'bread_crumbs' => $brcrum } + if ($env{'form.modal'} ne 'yes') { $parms{'bread_crumbs'} = $brcrum; } my $start_page = &Apache::loncommon::start_page('Discussion Post Attachments',$js,\%parms); @@ -3496,7 +3661,7 @@ END $start_page $toolarge
-
+

$lt{'clic'}

END $r->print(&Apache::lonhtmlcommon::start_pick_box()); @@ -3504,7 +3669,10 @@ END $r->print(''.$subject.''); $r->print(&Apache::lonhtmlcommon::row_closure()); $r->print(&Apache::lonhtmlcommon::row_title($lt{'adda'})); - $r->print(' '.$attachmaxtext); + $r->print('' + .'' + .' '.$attachmaxtext); if(($idx)||(ref($currnewattach) eq 'ARRAY') && (@{$currnewattach} > 0)){ $r->print(&Apache::lonhtmlcommon::row_closure()); $r->print(&Apache::lonhtmlcommon::row_title(&mt('Attachments'))); @@ -3845,8 +4013,9 @@ sub handler { my $symb=(split(/\:\:\:/,$env{'form.editdisc'}))[0]; my ($map,$id,$url)=&Apache::lonnet::decode_symb($symb); my $feedurl=&Apache::lonnet::clutter($url); - &redirect_back($r,$feedurl,&mt('Editing not permitted').'
', '0','0','','',$env{'form.previous'},undef,undef,undef, - undef,undef,undef,$group); + &redirect_back($r,$feedurl,&mt('Editing not permitted').'
', + '0','0','','',$env{'form.previous'},undef,undef,undef, + undef,undef,undef,$group); return OK; } } @@ -3887,7 +4056,7 @@ sub handler { 'text' => 'Discussion Post Versions'}]; my %parms=(); - if ($env{'form.modal'} ne 'yes') { 'bread_crumbs' => $brcrum } + if ($env{'form.modal'} ne 'yes') { $parms{'bread_crumbs'} = $brcrum; } $r->print(&Apache::loncommon::start_page('Discussion Post Versions',undef,\%parms)); @@ -3960,8 +4129,6 @@ sub handler { my $feedurl = '/adm/navmaps'; if ($env{'form.navurl'}) { $feedurl .= '?'.$env{'form.navurl'}; } my %lt = &Apache::lonlocal::texthash( - 'mnpa' => 'Marked "New" posts as read in a total of', - 'robb' => 'resources/bulletin boards.', 'twnp' => 'There are currently no resources or discussion boards with unread discussion postings.' ); foreach my $res (@resources) { @@ -3970,7 +4137,10 @@ sub handler { my $lastkey = $ressymb.'_lastread'; $discinfo{$lastkey} = $env{'form.navtime'}; } - my $textline = "$lt{'mnpa'} $numitems $lt{'robb'}"; + my $textline = ''. + &mt('Marked "New" posts as read in a total of [_1] resources/discussion boards.', + $numitems). + ''; if ($numitems > 0) { &Apache::lonnet::put('nohist_'.$env{'request.course.id'}.'_discuss', \%discinfo,$env{'user.domain'},$env{'user.name'}); @@ -3988,11 +4158,15 @@ sub handler { 'only_body' => 1, 'add_entries' => \%onload}); my $end_page = &Apache::loncommon::end_page(); + my $windowname = 'loncapaclient'; + if ($env{'request.lti.login'}) { + $windowname .= 'lti'; + } $r->print (< $textline - +
$end_page @@ -4052,7 +4226,7 @@ ENDREDIR unless (($seehidden) || (&editing_allowed($env{'form.hide'},$group))) { &redirect_back($r,$feedurl,&mt('Hiding not permitted').'
', '0','0','','',$env{'form.previous'},'','','','', - undef,undef,$group,); + undef,undef,$group); return OK; } @@ -4401,6 +4575,7 @@ ENDREDIR $cdom,$cnum); $contrib{'deleted'} =~ s/^\.//; $contrib{'deleted'} =~ s/\.$//; + my $confirm_msg; if ($contrib{'deleted'} ne '') { if (&Apache::lonnet::store({'deleted' => ''},$symb,$env{'request.course.id'}, $cdom,$cnum) eq 'ok') { @@ -4428,14 +4603,19 @@ ENDREDIR $uname,$udom,$env{'request.course.id'}, 'undelete'); } - $r->print(&Apache::lonhtmlcommon::confirm_success(&mt("Undeleted all entries"))); + $confirm_msg = &Apache::lonhtmlcommon::confirm_success(&mt("Undeleted all entries")); } else { - $r->print(&Apache::lonhtmlcommon::confirm_success(&mt("Failed to undelete entries"),1)); + $confirm_msg = &Apache::lonhtmlcommon::confirm_success(&mt("Failed to undelete entries"),1); } } else { - $r->print(&Apache::lonhtmlcommon::confirm_success(&mt("No entries to undelete"),1)); + $confirm_msg = &Apache::lonhtmlcommon::confirm_success(&mt("No entries to undelete"),1); } - $r->print("
".&mt("Return and reload").""); + $r->print( + '
' + .&Apache::loncommon::confirmwrapper($confirm_msg) + .&Apache::lonhtmlcommon::actionbox( + ["".&mt("Return and reload").""]) + ); } $r->print(&Apache::loncommon::end_page()); return OK; @@ -4478,6 +4658,12 @@ ENDREDIR $r->internal_redirect('/adm/ambiguous'); return OK; } + if ($feedurl eq '') { + &Apache::loncommon::content_type($r,'text/html'); + $r->send_http_header; + &no_redirect_back($r); + return OK; + } # Go ahead with feedback, no ambiguous reference unless ( ( @@ -4487,12 +4673,14 @@ ENDREDIR ($env{'request.course.id'} && ($feedurl!~m:^/adm:)) || ($env{'request.course.id'} && ($symb=~/^bulletin\_\_\_/)) + || + (($env{'request.course.id'}) && ($feedurl =~ /ext\.tool$/)) ) { &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); + &no_redirect_back($r,$feedurl,2); return OK; } # --------------------------------------------------- Print login screen header @@ -4512,7 +4700,7 @@ ENDREDIR if ($options) { &mail_screen($r,$feedurl,$options,$symb,$attachmax{'text'}); } else { - &fail_redirect($r,$feedurl); + &fail_redirect($r,$feedurl,1); } return OK; } @@ -4588,7 +4776,11 @@ ENDREDIR && $env{'form.discuss'} !~ /^(?:author|question|course|policy)/) || $env{'form.anondiscuss'} ne '') { my $subject = &clear_out_html($env{'form.subject'}); - my $anonmode=($env{'form.discuss'} eq 'anon' || $env{'form.anondiscuss'} ); + my $anonmode; + if (&Apache::lonnet::allowed('pac',$env{'request.course.id'}. + ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) { + $anonmode=($env{'form.discuss'} eq 'anon' || $env{'form.anondiscuss'} ); + } $typestyle.=&adddiscuss($symb,$message,$anonmode,$attachmenturl, $subject,$group); $numpost++; @@ -4611,7 +4803,8 @@ ENDREDIR } # Receipt screen and redirect back to where came from - &redirect_back($r,$feedurl,$typestyle,$numsent,$numpost,$blog,$status,$env{'form.previous'},undef,undef,undef,undef,undef,undef,$group,$toolarge); + &redirect_back($r,$feedurl,$typestyle,$numsent,$numpost,$blog,$status,$env{'form.previous'}, + undef,undef,undef,undef,undef,undef,$group,$toolarge); } return OK; } @@ -4794,7 +4987,9 @@ None =item list_discussion() -=item can_see_discussion() +=item can_see_hidden() + +=item discussion_link() =item send_feedback_link()