--- loncom/interface/lonfeedback.pm 2001/07/25 16:08:38 1.10
+++ loncom/interface/lonfeedback.pm 2010/06/08 16:56:57 1.296
@@ -1,19 +1,31 @@
# The LearningOnline Network
# Feedback
#
-# (Internal Server Error Handler
+# $Id: lonfeedback.pm,v 1.296 2010/06/08 16:56:57 www Exp $
#
-# (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)
+# Copyright Michigan State University Board of Trustees
#
-# 3/1/1 Gerd Kortemeyer)
+# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
#
-# 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
+# LON-CAPA is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# LON-CAPA is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with LON-CAPA; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# /home/httpd/html/adm/gpl.txt
+#
+# http://www.lon-capa.org/
+#
+###
package Apache::lonfeedback;
@@ -21,158 +33,2634 @@ 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 mail_screen {
- my ($r,$feedurl,$options) = @_;
- $r->print(<
-
-The LearningOnline Network with CAPA
-
-
+END
+
+ # 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::lonhtmlcommon::htmlareaselectactive('comment').
+ &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"
+ }
+ }
+ }
+}
+
+END
+
+
+ my $start_page =
+ &Apache::loncommon::start_page('Discussion display options',$js);
+ my $end_page =
+ &Apache::loncommon::end_page();
+ $r->print(<
+$lt{'sdpf'} $lt{'prca'} $lt{'whpo'} $lt{'unwh'} $lt{'wipa'}
+
+END
+ $r->print(&Apache::loncommon::start_data_table());
+ $r->print(<
+ $lt{'pref'}
+ $lt{'curr'}
+ $lt{'actn'}?
+
+END
+ $r->print(&Apache::loncommon::start_data_table_row());
+ $r->print(<$lt{'disa'}
+ $lt{$discdisp}
+ $lt{'chgt'} "$dispchangeA"
+
+ $lt{'chgt'} "$dispchangeB"
+
+END
+ $r->print(&Apache::loncommon::end_data_table_row());
+ $r->print(&Apache::loncommon::start_data_table_row());
+ $r->print(<$lt{'npmr'}
+ $lt{$discmark}
+ $lt{'chgt'} "$markchange"
+END
+ $r->print(&Apache::loncommon::end_data_table_row());
+ $r->print(&Apache::loncommon::start_data_table_row());
+ $r->print(<$lt{'dotm'}
+ $lt{$disctogg}
+ $lt{'chgt'} "$toggchange"
+END
+ my $save = &mt('Save');
+ $r->print(&Apache::loncommon::end_data_table_row());
+ $r->print(&Apache::loncommon::end_data_table());
+ $r->print(<
+
+
+
+
+
+
+
+
+END
+ if (exists($env{'form.group'})) {
+ $r->print(' ');
+ }
+ if (exists($env{'form.ref'})) {
+ $r->print(' ');
+ }
+ $r->print("
+
+
+
+$end_page
+ ");
+ return;
+}
+
+sub print_sortfilter_options {
+ my ($r,$symb,$previous,$feedurl) = @_;
+
+ &Apache::loncommon::content_type($r,'text/html');
+ $r->send_http_header;
+
+ &Apache::lonenc::check_encrypt(\$symb);
+ my @sections;
+ my $section_sel = '';
+ my $numvisible = 5;
+ my @groups;
+ my $group_sel = '';
+ my $numgroupvis = 5;
+ my %sectioncount = &Apache::loncommon::get_sections();
+ my @courseroles = qw(st ad ep ta in);
+ my $crstype = &Apache::loncommon::course_type();
+ my $ccrole = 'cc';
+ if ($crstype eq 'Community') {
+ $ccrole = 'co';
+ }
+ push(@courseroles,$ccrole);
+
+ if ($env{'request.course.sec'} !~ /^\s*$/) { #Restrict section choice to current section
+ @sections = ('all',$env{'request.course.sec'});
+ $numvisible = 2;
+ } else {
+ @sections = sort {$a cmp $b} keys(%sectioncount);
+ if (scalar(@sections) < 4) {
+ $numvisible = scalar(@sections) + 1;
+ }
+ unshift(@sections,'all'); # Put 'all' at the front of the list
+
+ }
+ foreach my $sec (@sections) {
+ $section_sel .= " $sec \n";
+ }
+
+ if (&check_group_priv() eq 'ok') {
+ my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+ my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum);
+ @groups = sort {$a cmp $b} keys(%curr_groups);
+ if (scalar(@groups) < 4) {
+ $numgroupvis = scalar(@groups) + 1;
+ }
+ unshift(@groups,'all'); # Put 'all' at the front of the list
+ } else {
+ my @coursegroups = split(/:/,$env{'request.course.groups'});
+ if (@coursegroups > 0) {
+ @coursegroups = sort {$a cmp $b} @coursegroups;
+ @groups = ('all',@coursegroups);
+ if (scalar(@groups) < 4) {
+ $numgroupvis = scalar(@groups) + 1;
+ }
+ } else {
+ @groups = ('all');
+ $numgroupvis = 1;
+ }
+ }
+ foreach my $group (@groups) {
+ $group_sel .= " $group \n";
+ }
+
+ my $function = &Apache::loncommon::get_users_function();
+ my $tabcolor = &Apache::loncommon::designparm($function.'.tabbg',
+ $env{'user.domain'});
+ my %lt = &Apache::lonlocal::texthash(
+ 'diop' => 'Display Options',
+ 'curr' => 'Current setting ',
+ 'actn' => 'Action',
+ 'prca' => 'Set options that control the sort order of posts, and/or which posts are displayed.',
+ 'soor' => 'Sort order',
+ 'spur' => 'Specific user roles',
+ 'sprs' => 'Specific role status',
+ 'spse' => 'Specific sections',
+ 'spgr' => 'Specific groups',
+ 'psub' => 'Pick specific users (by name)',
+ 'shal' => 'Show a list of current posters',
+ 'stor' => 'Save changes',
+ );
+
+ my %sort_types = ();
+ my %role_types = ();
+ my %status_types = ();
+ &sort_filter_names(\%sort_types,\%role_types,\%status_types,$crstype);
+
+ my $js = <
+function verifyFilter() {
+ var rolenum = 0
+ for (var i=0; i
-
-
-
-Feedback
-$feedurl
-
-
-