--- loncom/interface/lonfeedback.pm 2004/07/09 23:05:52 1.99 +++ loncom/interface/lonfeedback.pm 2004/10/07 19:55:52 1.99.2.10 @@ -1,7 +1,7 @@ # The LearningOnline Network # Feedback # -# $Id: lonfeedback.pm,v 1.99 2004/07/09 23:05:52 raeburn Exp $ +# $Id: lonfeedback.pm,v 1.99.2.10 2004/10/07 19:55:52 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -36,6 +36,7 @@ use Apache::loncommon(); use Apache::lontexconvert(); use Apache::lonlocal; # must not have () use Apache::lonhtmlcommon(); +use Apache::lonnavmaps(); sub discussion_open { my ($status)=@_; @@ -92,15 +93,13 @@ sub list_discussion { # Get discussion display settings for this discussion my $lastkey = $ressymb.'_lastread'; my $showkey = $ressymb.'_showonlyunread'; - my $visitkey = $ressymb.'_visit'; my $ondispkey = $ressymb.'_markondisp'; - my %dischash = &Apache::lonnet::get('nohist_'.$ENV{'request.course.id'}.'_discuss',[$lastkey,$showkey,$visitkey,$ondispkey],$ENV{'user.domain'},$ENV{'user.name'}); + my %dischash = &Apache::lonnet::get('nohist_'.$ENV{'request.course.id'}.'_discuss',[$lastkey,$showkey,$ondispkey],$ENV{'user.domain'},$ENV{'user.name'}); my %discinfo = (); my $showonlyunread = 0; my $markondisp = 0; my $prevread = 0; my $previous = 0; - my $visit = 0; my $newpostsflag = 0; # Retain identification of "NEW" posts identified in last display, if continuing 'previous' browsing of posts. @@ -115,32 +114,28 @@ 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{$showkey} eq '') { + $markondisp = $dischash{$ondispkey}; + } } if ($markondisp) { $discinfo{$lastkey} = time; } if (defined($dischash{$showkey})) { - $showonlyunread = $dischash{$showkey}; - } - - if (defined($dischash{$visitkey})) { - $visit = $dischash{$visitkey}; + unless ($dischash{$showkey} eq '') { + $showonlyunread = $dischash{$showkey}; + } } - $visit ++; my $seeid=&Apache::lonnet::allowed('rin',$crs); my $viewgrades=(&Apache::lonnet::allowed('vgr',$crs) @@ -166,9 +161,9 @@ sub list_discussion { } my $now = time; - $discinfo{$visitkey} = $visit; - - &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%discinfo,$ENV{'user.domain'},$ENV{'user.name'}); + if (%discinfo) { + &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%discinfo,$ENV{'user.domain'},$ENV{'user.name'}); + } if ($contrib{'version'}) { my $oldest = $contrib{'1:timestamp'}; @@ -223,13 +218,14 @@ sub list_discussion { if ($hidden) { $message=''.$message.''; } - my $screenname=&Apache::loncommon::screenname( - $contrib{$idx.':sendername'}, - $contrib{$idx.':senderdomain'}); - my $plainname=&Apache::loncommon::nickname( - $contrib{$idx.':sendername'}, - $contrib{$idx.':senderdomain'}); - +# my $screenname=&Apache::loncommon::screenname( +# $contrib{$idx.':sendername'}, +# $contrib{$idx.':senderdomain'}); +# my $plainname=&Apache::loncommon::nickname( +# $contrib{$idx.':sendername'}, +# $contrib{$idx.':senderdomain'}); + my ($screenname,$plainname)=($contrib{$idx.':screenname'}, + $contrib{$idx.':plainname'}); my $sender=&mt('Anonymous'); if ((!$contrib{$idx.':anonymous'}) || ($seeid)) { $sender=&Apache::loncommon::aboutmewrapper( @@ -552,11 +548,6 @@ sub mail_screen { } my $latexHelp=&Apache::loncommon::helpLatexCheatsheet(); my $htmlheader=&Apache::lonhtmlcommon::htmlareaheaders(); - my $onsubmit=''; - if ((&Apache::lonhtmlcommon::htmlareabrowser()) && - (!&Apache::lonhtmlcommon::htmlareablocked())) { - $onsubmit='document.mailform.onsubmit();'; - } my $send=&mt('Send'); $r->print(< @@ -600,7 +591,9 @@ $htmlheader } if (rec) { - $onsubmit + if (typeof(document.mailform.onsubmit)=='function') { + document.mailform.onsubmit(); + } document.mailform.submit(); } else { alert('Please check a feedback type.'); @@ -782,6 +775,7 @@ sub fail_redirect { Sorry, no recipients ... +
Continue ENDFAILREDIR @@ -821,6 +815,7 @@ $typestyle
$prevtag
+
Continue ENDREDIR @@ -843,6 +838,7 @@ ENDNOREDIR Sorry, no feedback possible on this resource ... +
Continue ENDNOREDIRTWO @@ -1120,11 +1116,29 @@ sub generate_preview_button { +onClick="if (typeof(document.mailform.onsubmit)=='function') {document.mailform.onsubmit();};this.form.comment.value=document.mailform.comment.value;this.form.subject.value=document.mailform.subject.value;this.form.submit();" /> ENDPREVIEW } +sub has_discussion { + my $resourcesref = shift; + my $navmap = Apache::lonnavmaps::navmap->new(); + my @allres=$navmap->retrieveResources(); + foreach my $resource (@allres) { + if ($resource->hasDiscussion()) { + my $ressymb; + if ($resource->symb() =~ m-(___adm/\w+/\w+)/(\d+)/bulletinboard$-) { + $ressymb = 'bulletin___'.$2.$1.'/'.$2.'/bulletinboard'; + } else { + $ressymb = $resource->symb(); + } + push @{$resourcesref}, $ressymb; + } + } + return; +} + sub handler { my $r = shift; if ($r->header_only) { @@ -1136,15 +1150,11 @@ sub handler { # --------------------------- Get query string for limited number of parameters &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, - ['hide','unhide','deldisc','postdata','preview','replydisc','threadedon','threadedoff','onlyunread','allposts','previous','markread','markonread','markondisp','modifydisp','changes','navmaps','navurl']); - if ($ENV{'form.navmaps'}) { + ['hide','unhide','deldisc','postdata','preview','replydisc','threadedon','threadedoff','onlyunread','allposts','previous','markread','markonread','markondisp','modifydisp','changes','navtime','navurl']); + if ($ENV{'form.navtime'}) { my %discinfo = (); my @resources = (); - if ($ENV{'form.navmaps'} =~ /:/) { - @resources = split/:/,$ENV{'form.navmaps'}; - } else { - @resources = ("$ENV{'form.navmaps'}"); - } + &has_discussion(\@resources); my $numitems = @resources; my $feedurl = '/adm/navmaps'; if ($ENV{'form.navurl'}) { @@ -1152,7 +1162,8 @@ sub handler { } my %lt = &Apache::lonlocal::texthash( 'mnpa' => 'Marked "New" posts as read in a total of', - 'robb' => 'resources/bulletin boards.' + 'robb' => 'resources/bulletin boards.', + 'twnp' => 'There are currently no resources or bulletin boards with unread discussion postings.' ); foreach (@resources) { # backward compatibility (bulletin boards used to be 'wrapped') @@ -1163,9 +1174,14 @@ sub handler { } } my $lastkey = $ressymb.'_lastread'; - $discinfo{$lastkey} = time; + $discinfo{$lastkey} = $ENV{'form.navtime'}; + } + my $textline = "$lt{'mnpa'} $numitems $lt{'robb'}"; + if ($numitems > 0) { + &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%discinfo,$ENV{'user.domain'},$ENV{'user.name'}); + } else { + $textline = "$lt{'twnp'}"; } - &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%discinfo,$ENV{'user.domain'},$ENV{'user.name'}); &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; $r->print (< -$lt{'mnpa'} $numitems $lt{'robb'} +$textline
+
Continue ENDREDIR