--- loncom/interface/lonsupportreq.pm 2004/09/09 05:58:42 1.8 +++ loncom/interface/lonsupportreq.pm 2004/12/30 16:18:16 1.19 @@ -17,11 +17,14 @@ sub handler { if ($r->header_only) { return OK; } - - &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['action','origurl','function']); - my $action = $ENV{'form.action'}; + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['origurl','function']); + if ($r->uri eq '/adm/helpdesk') { + &Apache::loncommon::get_posted_cgi($r); + } my $function = $ENV{'form.function'}; my $origurl = &Apache::lonnet::unescape($ENV{'form.origurl'}); + my $action = $ENV{'form.action'}; + if ($action eq 'process') { &print_request_receipt($r,$origurl,$function); } else { @@ -36,8 +39,9 @@ sub print_request_form { my $bodytag = &Apache::loncommon::bodytag('',$function,'topmargin="0",marginheight="0"',1); my $tablecolor = &Apache::loncommon::designparm($function.'.tabbg'); if (($tablecolor eq '') || ($tablecolor eq '#FFFFFF')) { - $tablecolor = '#CCCCFF'; + $tablecolor = '#EEEE99'; } + $ccode = ''; $os = $ENV{'browser.os'}; $browser = $ENV{'browser.type'}; $bversion = $ENV{'browser.version'}; @@ -49,14 +53,35 @@ sub print_request_form { $usec = $ENV{'request.course.sec'}; $cid = $ENV{'request.course.id'}; $server = $ENV{'SERVER_NAME'}; - my $scripttag = (<= 0) { + return true; + } + return false; + } +} END if ($cid =~ m/_/) { ($cdom,$cnum) = split/_/,$cid; @@ -85,8 +110,11 @@ END my ($sec,$grp) = split/:/,$_; $groupid{$sec} = $grp; } - my $defdom = $Apache::lonnet::perlvar{'lonDefDomain'}; - my $codedom = $defdom; + my $codedom = $Apache::lonnet::perlvar{'lonDefDomain'}; + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['codedom']); + if (exists($ENV{'form.codedom'})) { + $codedom = $ENV{'form.codedom'}; + } my %coursecodes = (); my %codes = (); my @codetitles = (); @@ -99,7 +127,7 @@ END my $totcodes = 0; my $format_reply; my $jscript = ''; - + if ($cdom) { $codedom = $cdom; } @@ -123,16 +151,22 @@ END &javascript_code_selections($numtypes,\$jscript,\%idlist,\%idnums,\%idlist_titles,\@codetitles); } } - $r->print(<print(< LON-CAPA support request - $bodytag +ENDHEAD + if ($r->uri eq '/adm/helpdesk') { + &print_header($r,$origurl); + } + $r->print(<<"END"); +
@@ -143,7 +177,6 @@ $bodytag
-
@@ -168,9 +201,10 @@ END } elsif (defined($lastname) && $lastname ne '') { $fullname= " $lastname"; } - $r->print('
'); + $r->print(''); } $r->print(< 
@@ -233,10 +267,10 @@ END } if ($udomform eq '') { $udomform = 'domain: '; - $udomform .= &Apache::loncommon::select_dom_form('','udom'); + $udomform .= &Apache::loncommon::select_dom_form($codedom,'udom'); } if ($unameform eq '') { - $unameform= 'username  '; + $unameform= 'username  '; } $r->print($unameform.$udomform.'
Enter the username you use to log-in to your LON-CAPA system, and choose your domain.'); } @@ -264,7 +298,7 @@ END
- http://$server$origurl + http://$server$origurl
@@ -313,20 +347,66 @@ END
END - if ($coursecodes{$cnum}) { - foreach (@codetitles) { - $r->print(''.$_.': '.$codes{$cnum}{$_}.'; '); + if ($cnum) { + if ($coursecodes{$cnum}) { + foreach (@codetitles) { + $r->print(''.$_.': '.$codes{$cnum}{$_}.'; '); + } + $r->print(' '); + } else { + $r->print('Enter institutional course code:  + '); } - $r->print(' '); } else { - $r->print('Enter institutional course code:  + if ($totcodes > 0) { + my $numtitles = @codetitles; + if ($numtitles == 0) { + $r->print('Enter institutional course code:  '); + } else { + my $lasttitle = $numtitles; + if ($numtitles > 4) { + $lasttitle = 4; + } + $r->print(''); + for (my $i=1; $i<$numtitles; $i++) { + $r->print('' + ); + } + $r->print('
'.$codetitles[0].'
'."\n". + '
'.$codetitles[$i].'
'."\n". + ''."\n". + '
'); + if ($numtitles > 4) { + $r->print('

'.$codetitles[$numtitles].'
'."\n". + ''."\n"); + } + } + } else { + $r->print('Enter institutional course code:  + '); + } } if ($ctitle) { $r->print('
Title: '.$ctitle.''); } else { $r->print('
Enter course title:  - '); + '); } $r->print(< @@ -469,7 +549,7 @@ END
-   +     @@ -489,6 +569,9 @@ END
+ + + END return; } @@ -506,18 +589,32 @@ sub print_request_receipt { my $fontcolor = &Apache::loncommon::designparm($function.'.font'); my $vlinkcolor = &Apache::loncommon::designparm($function.'.vlink'); my $tablecolor = &Apache::loncommon::designparm($function.'.tabbg'); - my @formvars = ('username','email','uname','udom','origurl','phone','section','coursecode','title','subject','description','screenshot'); + my @formvars = ('username','email','uname','udom','sourceurl','phone','section','coursecode','title','subject','description','screenshot'); &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},\@formvars); - + my $coursecode = $ENV{'form.coursecode'}; + if ($coursecode eq '') { + if (defined($ENV{'form.Year'})) { + $coursecode .= $ENV{'form.Year'}; + } + if (defined($ENV{'form.Semester'})) { + $coursecode .= $ENV{'form.Semester'}; + } + if (defined($ENV{'form.Department'})) { + $coursecode .= $ENV{'form.Department'}; + } + if (defined($ENV{'form.Number'})) { + $coursecode .= $ENV{'form.Number'}; + } + } my $supportmsg = qq| Name: $ENV{'form.username'} Email: $ENV{'form.email'} Username/domain: $ENV{'form.uname'} - $ENV{'form.udom'} Tel: $ENV{'form.phone'} -Course Information: $ENV{'form.title'} - $ENV{'form.coursecode'} - section: $ENV{'form.section'} +Course Information: $ENV{'form.title'} - $coursecode - section: $ENV{'form.section'} Subject: $ENV{'form.subject'} Description: $ENV{'form.description'} -URL: $ENV{'form.origurl'} +URL: $ENV{'form.sourceurl'} Date/Time: $reporttime |; @@ -528,33 +625,39 @@ Date/Time: $reporttime Email: $ENV{'form.email'}
Username/domain: $ENV{'form.uname'} - $ENV{'form.udom'}
Tel: $ENV{'form.phone'}
-Course Information: $ENV{'form.title'} - $ENV{'form.coursecode'} - section: $ENV{'form.section'}
+Course Information: $ENV{'form.title'} - $coursecode - section: $ENV{'form.section'}
Subject: $ENV{'form.subject'}
Description: $descrip
-URL: $ENV{'form.origurl'}
+URL: $ENV{'form.sourceurl'}
Date/Time: $reporttime
|; - - if ($to =~ m/^[^\@]+\@[^\@]+$/) { - $r->print(<print(<<"END"); LON-CAPA support request recorded $bodytag -

A support request has been sent to $to

+
+ +
END - } else { - $r->print(< - - LON-CAPA support request recorded - -$bodytag + if ($r->uri eq '/adm/helpdesk') { + &print_header($r,$url,'process'); + } + if ($to =~ m/^[^\@]+\@[^\@]+$/) { + $r->print("

A support request has been sent to $to

"); + } else { + $to = $admin; + if ($to =~ m/^[^\@]+\@[^\@]+$/) { + $r->print("

A support request has been sent to $to

"); +END + } else { + $r->print(<Warning: Problem with support e-mail address -As the e-mail address provided for this LON-CAPA server ($to) does not appear to be a valid e-mail address, your support request has not been sent to the LON-CAPA support staff at your institution. Instead a copy has been sent to the LON-CAPA support team at Michigan State University. +As the e-mail address provided for this LON-CAPA server ($to) does not appear to be a valid e-mail address, your support request has not been sent to the LON-CAPA support staff or administrator at your institution. Instead a copy has been sent to the LON-CAPA support team at Michigan State University. END - $to = 'helpdesk@lon-capa.org'; + $to = 'helpdesk@lon-capa.org'; + } } if (defined($ENV{'form.email'})) { if ($ENV{'form.email'} =~ m/^[^\@]+\@[^\@]+$/) { @@ -701,14 +804,82 @@ END
+ + "); } +sub print_header { + my ($r,$origurl,$action) = @_; + my $location=&Apache::loncommon::lonhttpdurl("/adm"); + my $tablecolor = '#EEEE99'; + my ($component_url); + my $helpdesk_link = ''; + if ($action eq 'process') { + $helpdesk_link = ''; + } + my %lt = &Apache::lonlocal::texthash ( + login => 'Log-in help', + ask => 'Ask helpdesk', + getst => 'Getting started guide', + back => 'Back to last location' + ); + $r->print(<   + +
  LON-CAPA help/support + + + + +
+ + + + +
+ + + + +
+ + + + + + + +
(Login help) $lt{'login'} $helpdesk_link(Ask helpdesk) $lt{'ask'}  $lt{'getst'} (Back to last location) $lt{'back'} 
+
+
+
+
+ +   + + +   + +END + unless ($action eq 'process') { + $r->print(' + + '.&mt(' +Please read the "Log-in help" and "Getting started guide" if you can not log-in').'. '.&mt('If your problem is still unresolved, the form below can be used to send a question to the LON-CAPA helpdesk').'.
'.&mt('Note').': '.&mt('Student questions about course content should be directed to the course instructor').'.

+ + '); + } + $r->print(' +'); + return; +} + sub retrieve_instcodes { my ($coursecodes,$codedom,$totcodes) = @_; - my %courses = &Apache::lonnet::courseiddump($codedom,'.',1); + my %courses = &Apache::lonnet::courseiddump($codedom,'.',1,'.','.'); foreach my $course (keys %courses) { - if ($courses{$course} =~ m/^[^:]*:([^:]+)$/) { + if ($courses{$course} =~ m/^[^:]*:([^:]+)/) { $$coursecodes{$course} = &Apache::lonnet::unescape($1); $totcodes ++; } @@ -768,9 +939,9 @@ sub build_code_selections { my @sorted_b = (); my @sorted_b_titles = (); &sort_cats($num,$cat_order,$codetitles,\@{$idarrays{$$codetitles[2]}{$key_a}{$key_b}},\@sorted_b); - if (defined($$cat_titles{$$codetitles[1]})) { + if (defined($$cat_titles{$$codetitles[2]})) { foreach (@sorted_b) { - push @sorted_b_titles, $$cat_titles{$$codetitles[1]}{$_}; + push @sorted_b_titles, $$cat_titles{$$codetitles[2]}{$_}; } } $$idlist{$$codetitles[2]}{$key_a}{$key_b} = join('","',@sorted_b); @@ -911,18 +1082,25 @@ sub recurse_list { sub javascript_code_selections { my ($numcats,$script_tag,$idlist,$idnums,$idlist_titles,$codetitles) = @_; + my $numtitles = @{$codetitles}; + my @seltitles = (); + for (my $j=0; $j<$numtitles; $j++) { + $seltitles[$j] = 'id'.$$codetitles[$j]; + } + my $seltitle_str = join('","',@seltitles); $$script_tag .= <