--- loncom/interface/lonfeedback.pm 2004/08/17 14:27:19 1.116
+++ loncom/interface/lonfeedback.pm 2004/10/04 21:35:52 1.128
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Feedback
#
-# $Id: lonfeedback.pm,v 1.116 2004/08/17 14:27:19 raeburn Exp $
+# $Id: lonfeedback.pm,v 1.128 2004/10/04 21:35:52 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -36,18 +36,19 @@ use Apache::loncommon();
use Apache::lontexconvert();
use Apache::lonlocal; # must not have ()
use Apache::lonhtmlcommon();
+use Apache::lonnavmaps;
use HTML::LCParser();
use Apache::lonspeller();
use Cwd;
sub discussion_open {
- my ($status)=@_;
+ my ($status,$symb)=@_;
if (defined($status) &&
!($status eq 'CAN_ANSWER' || $status eq 'CANNOT_ANSWER'
|| $status eq 'OPEN')) {
return 0;
}
- my $close=&Apache::lonnet::EXT('resource.0.discussend');
+ my $close=&Apache::lonnet::EXT('resource.0.discussend',$symb);
if (defined($close) && $close ne '' && $close < time) {
return 0;
}
@@ -59,7 +60,7 @@ sub discussion_visible {
if (not &discussion_open($status)) {
my $hidden=&Apache::lonnet::EXT('resource.0.discusshide');
if (lc($hidden) eq 'yes' or $hidden eq '' or !defined($hidden)) {
- return 0;
+ if (!$ENV{'request.role.adv'}) { return 0; }
}
}
return 1;
@@ -165,34 +166,39 @@ sub list_discussion {
}
# Get discussion display default settings for user
- my %userenv = &Apache::lonnet::get('environment',['discdisplay','discmarkread'],$ENV{'user.domain'},$ENV{'user.name'});
- my $discdisplay=$userenv{'discdisplay'};
- if ($discdisplay eq 'unread') {
+ if ($ENV{'environment.discdisplay'} eq 'unread') {
$showonlyunread = 1;
}
- my $discmarkread=$userenv{'discmarkread'};
- if ($discmarkread eq 'ondisp') {
+ if ($ENV{'environment.discmarkread'} eq 'ondisp') {
$markondisp = 1;
}
# Override user's default if user specified display setting for this discussion
if (defined($dischash{$ondispkey})) {
- $markondisp = $dischash{$ondispkey};
+ unless ($dischash{$ondispkey} eq '') {
+ $markondisp = $dischash{$ondispkey};
+ }
}
if ($markondisp) {
$discinfo{$lastkey} = time;
}
if (defined($dischash{$showkey})) {
- $showonlyunread = $dischash{$showkey};
+ unless ($dischash{$showkey} eq '') {
+ $showonlyunread = $dischash{$showkey};
+ }
}
if (defined($dischash{$markkey})) {
- $showunmark = $dischash{$markkey};
+ unless ($dischash{$markkey} eq '') {
+ $showunmark = $dischash{$markkey};
+ }
}
if (defined($dischash{$visitkey})) {
- $visit = $dischash{$visitkey};
+ unless ($dischash{$visitkey} eq '') {
+ $visit = $dischash{$visitkey};
+ }
}
$visit ++;
@@ -324,7 +330,6 @@ sub list_discussion {
# open manifest file
my $manifest = '/imsmanifest.xml';
my $manifestfilename = $tempexport.$manifest;
- print STDERR "manifestfilename is $manifestfilename\n";
if ($manifestfile = Apache::File->new('>'.$manifestfilename)) {
$manifestok=1;
print $manifestfile qq|
@@ -446,11 +451,11 @@ imscp_v1p1.xsd http://www.imsglobal.org/
$alldiscussion{$_} = $_;
}
unless ( ($notshown{$alldiscussion{$_}} eq '1') || ($shown{$alldiscussion{$_}} == 0) ) {
- unless ($outputtarget eq 'tex' && $outputtarget eq 'export') {
+ if ($outputtarget ne 'tex' && $outputtarget ne 'export') {
$discussion.="\n
";
}
my $thisdepth=$depth[$alldiscussion{$_}];
- unless ($outputtarget eq 'tex' || $outputtarget eq 'export') {
+ if ($outputtarget ne 'tex' && $outputtarget ne 'export') {
for (1..$thisdepth) {
$discussion.=' | ';
}
@@ -474,7 +479,6 @@ imscp_v1p1.xsd http://www.imsglobal.org/
my $postfilename = $alldiscussion{$_}.'-'.$imsitems{$alldiscussion{$_}}{'timestamp'}.'.html';
if ($manifestok) {
if (($depth[$alldiscussion{$_}] <= $currdepth) && ($alldiscussion{$_} != $firstidx)) {
- print STDERR "depth is $depth[$alldiscussion{$_}], currdepth is $currdepth, idx is $alldiscussion{$_}, firstidx is $firstidx\n";
print $manifestfile ' '."\n";
}
$currdepth = $depth[$alldiscussion{$_}];
@@ -600,7 +604,7 @@ END
undef(%oldENV);
$discussion .= 'Download the zip file from Discussion Posting Archive
';
if ($copyresult) {
- $discussion .= 'The following errors occurred during export - '.$copyresult;
+ $discussion .= 'The following errors occurred during export -
'.$copyresult;
}
} else {
$discussion .= '
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.
';
@@ -618,15 +622,16 @@ END
my $subject = '';
if ($ENV{'form.origpage'}) {
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['addnewattach','deloldattach','delnewattach','timestamp','idx','subject','comment']);
- $subject = &HTML::Entities::encode($ENV{'form.subject'},'<>&"');
- $comment = &HTML::Entities::encode($ENV{'form.comment'},'<>&"');
+ $subject = &Apache::lonnet::unescape($ENV{'form.subject'});
+ $comment = &Apache::lonnet::unescape($ENV{'form.comment'});
my @keepold = ();
&process_attachments(\@currnewattach,\@currdelold,\@keepold);
if (@currnewattach > 0) {
$attachnum += @currnewattach;
}
}
- $discussion.=(<
@@ -665,6 +670,7 @@ ENDDISCUSS
$discussion.=$newattachmsg;
$discussion.=&generate_preview_button();
}
+ }
} else {
if (&discussion_open($status) &&
&Apache::lonnet::allowed('pch',
@@ -1046,12 +1052,14 @@ sub get_post_contents {
return $discussion;
}
}
- $$screenname=&Apache::loncommon::screenname(
- $$contrib{$idx.':sendername'},
- $$contrib{$idx.':senderdomain'});
- $$plainname=&Apache::loncommon::nickname(
- $$contrib{$idx.':sendername'},
- $$contrib{$idx.':senderdomain'});
+# $$screenname=&Apache::loncommon::screenname(
+# $$contrib{$idx.':sendername'},
+# $$contrib{$idx.':senderdomain'});
+# $$plainname=&Apache::loncommon::nickname(
+# $$contrib{$idx.':sendername'},
+# $$contrib{$idx.':senderdomain'});
+ ($$screenname,$$plainname)=($$contrib{$idx.':screenname'},
+ $$contrib{$idx.':plainname'});
my $sender=&Apache::loncommon::aboutmewrapper(
$$plainname,
$$contrib{$idx.':sendername'},
@@ -1149,22 +1157,23 @@ sub replicate_attachments {
$i ++;
}
my ($content,$rtncode);
- print STDERR "File to replicate is $$attachrefs{$id}{'filename'} in $1,$2\n";
my $uploadreply = &Apache::lonnet::getuploaded('GET',$$attachrefs{$id}{'filename'},$1,$2,$content,$rtncode);
if ($uploadreply eq 'ok') {
- my $attachcopy;
- if ($attachcopy = Apache::File->new('>'.$destination)) {
- print $attachcopy $content;
- close($attachcopy);
- } else {
- $response .= 'Error copying a file attachment to IMS package: '.$!.'
'."\n";
- }
+ my $attachcopy;
+ if ($attachcopy = Apache::File->new('>'.$destination)) {
+ print $attachcopy $content;
+ close($attachcopy);
+ } else {
+ $response .= 'Error copying file attachment - '.$5.' to IMS package: '.$!.'
'."\n";
+ }
} else {
- print STDERR "return code from lonnet was $rtncode\n";
+ &Apache::lonnet::logthis("Replication of attachment failed when building IMS export of discussion posts - domain: $1, course: $2, file: $$attachrefs{$id}{'filename'} -error: $rtncode");
+ $response .= 'Error copying file attachment - '.$5.' to IMS package: '.$rtncode.'
'."\n";
}
}
}
}
+ return $response;
}
sub mail_screen {
@@ -1306,8 +1315,8 @@ END
}
if ($ENV{'form.origpage'}) {
- $subject = $ENV{'form.subject'};
- $comment = $ENV{'form.comment'};
+ $subject = &Apache::lonnet::unescape($ENV{'form.subject'});
+ $comment = &Apache::lonnet::unescape($ENV{'form.comment'});
&process_attachments(\@currnewattach,\@currdelold,\@keepold);
}
my $latexHelp=&Apache::loncommon::helpLatexCheatsheet();
@@ -1355,7 +1364,7 @@ $htmlheader
}
if (rec) {
- if (typeof(document.mailform.onsubmit)!='undefined') {
+ if (typeof(document.mailform.onsubmit)=='function') {
document.mailform.onsubmit();
}
document.mailform.submit();
@@ -1977,45 +1986,6 @@ sub get_post_attachments {
return;
}
-sub build_ims_export {
- my ($r,$symb,$previous,$feedurl) = @_;
- # backward compatibility (bulletin boards used to be 'wrapped')
- if ($feedurl=~m|^/adm/wrapper/adm/.*/bulletinboard$|) {
- $feedurl=~s|^/adm/wrapper||;
- }
- my %contrib=&Apache::lonnet::restore($symb,$ENV{'request.course.id'},
- $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
- $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
- my @depth=();
- my %alldiscussion=();
- my @discussionitems=();
- my %usernamesort = ();
- my %subjectsort = ();
- my %namesort = ();
- my %notshown = ();
- my %newitem = ();
- my %dischash = ();
- my %shown = ();
- my %roleinfo = ();
- my @posters=();
- my $maxdepth=0;
- my $visible=0;
- my $newpostsflag=0;
- my $status;
- my $viewgrades;
- my $seeid;
- my $prevread;
- my $sortposts;
- my $ressymb;
- my $target;
- my $readkey;
- my $showunmark;
- my $showonlyunread;
-
-}
-
-
-
sub fail_redirect {;
my ($r,$feedurl) = @_;
if ($feedurl=~/^\/adm\//) { $feedurl.='?register=1' };
@@ -2028,6 +1998,7 @@ sub fail_redirect {;
Sorry, no recipients ...
+
Continue