--- loncom/interface/lonfeedback.pm 2002/03/02 03:50:27 1.24
+++ loncom/interface/lonfeedback.pm 2010/08/27 16:37:23 1.290.2.5
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Feedback
#
-# $Id: lonfeedback.pm,v 1.24 2002/03/02 03:50:27 harris41 Exp $
+# $Id: lonfeedback.pm,v 1.290.2.5 2010/08/27 16:37:23 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;
@@ -50,171 +33,2686 @@ use strict;
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 HTML::Tidy::libXML;
+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) = @_;
- $r->print(<
-
-The LearningOnline Network with CAPA
-
-
+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'}];
+
+ 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 '') {
+ $quote = &HTML::Entities::decode($quote);
+ unless (&contains_block_html($quote)) {
+ &newline_to_br(\$quote);
+ }
+ $quote=''.&Apache::lontexconvert::msgtexconverted($quote).'
';
+ }
+
+ $r->print(<$restitle
+
+END
+ }
+ if (exists($env{'form.group'})) {
+ $r->print('');
+ }
+ if (exists($env{'form.ref'})) {
+ $r->print('');
+ }
+ $r->print(<
+
+
+
+
+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.'
'."\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::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"
+ }
+ }
+ }
+}
-
-
-
-Feedback
-$feedurl
-