--- loncom/interface/lonsupportreq.pm 2004/12/18 22:30:28 1.13 +++ loncom/interface/lonsupportreq.pm 2005/02/17 08:29:43 1.23 @@ -36,10 +36,10 @@ sub handler { sub print_request_form { my ($r,$origurl,$function) = @_; my ($os,$browser,$bversion,$uhost,$uname,$udom,$uhome,$urole,$usec,$email,$cid,$cdom,$cnum,$ctitle,$ccode,$sectionlist,$lastname,$firstname,$server); - my $bodytag = &Apache::loncommon::bodytag('',$function,'topmargin="0",marginheight="0"',1); + my $bodytag = &Apache::loncommon::bodytag('',$function,'topmargin="0" marginheight="0" onLoad="initialize_codes()"',1); my $tablecolor = &Apache::loncommon::designparm($function.'.tabbg'); if (($tablecolor eq '') || ($tablecolor eq '#FFFFFF')) { - $tablecolor = '#CCCCFF'; + $tablecolor = '#EEEE99'; } $ccode = ''; $os = $ENV{'browser.os'}; @@ -52,7 +52,11 @@ sub print_request_form { $urole = $ENV{'request.role'}; $usec = $ENV{'request.course.sec'}; $cid = $ENV{'request.course.id'}; - $server = $ENV{'SERVER_NAME'}; + if ($origurl =~ m-^http://-) { + $server = $origurl; + } else { + $server = 'http://'.$ENV{'SERVER_NAME'}.$origurl; + } my $scripttag = (<<'END'); function validate() { if (validmail(document.logproblem.email) == false) { @@ -110,8 +114,15 @@ 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 $details_title; + if ($codedom) { + $details_title = '
('.$codedom.')'; + } my %coursecodes = (); my %codes = (); my @codetitles = (); @@ -124,7 +135,11 @@ END my $totcodes = 0; my $format_reply; my $jscript = ''; - + my $loaditems = qq| +function initialize_codes() { + return; +} + |; if ($cdom) { $codedom = $cdom; } @@ -141,23 +156,33 @@ END $totcodes = &retrieve_instcodes(\%coursecodes,$codedom,$totcodes); } if ($totcodes > 0) { - $format_reply = &Apache::lonnet::auto_instcode_format($caller,$codedom,\%coursecodes,\%codes,\@codetitles,\%cat_titles,\%cat_order); if ($ccode eq '') { - my $numtypes = @codetitles; - &build_code_selections(\%codes,\@codetitles,\%cat_titles,\%cat_order,\%idlist,\%idnums,\%idlist_titles); - &javascript_code_selections($numtypes,\$jscript,\%idlist,\%idnums,\%idlist_titles,\@codetitles); + $format_reply = &Apache::lonnet::auto_instcode_format($caller,$codedom,\%coursecodes,\%codes,\@codetitles,\%cat_titles,\%cat_order); + if ($format_reply eq 'ok') { + my $numtypes = @codetitles; + &build_code_selections(\%codes,\@codetitles,\%cat_titles,\%cat_order,\%idlist,\%idnums,\%idlist_titles); + &javascript_code_selections($numtypes,\%cat_titles,\$jscript,\%idlist,\%idnums,\%idlist_titles,\@codetitles); + $loaditems = ''; + } } } - $r->print(< + my $html=&Apache::lonxml::xmlbegin(); + $r->print(< LON-CAPA support request - $bodytag +ENDHEAD + if ($r->uri eq '/adm/helpdesk') { + &print_header($r,$origurl); + } + $r->print(<<"END"); +
@@ -168,7 +193,6 @@ $bodytag
- '); for (my $i=1; $i<$numtitles; $i++) { @@ -425,12 +465,13 @@ END
@@ -193,9 +217,10 @@ END } elsif (defined($lastname) && $lastname ne '') { $fullname= " $lastname"; } - $r->print('
'); + $r->print(''); } $r->print(< 
@@ -258,10 +283,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.'); } @@ -289,7 +314,7 @@ END
- http://$server$origurl + $server
@@ -328,7 +353,7 @@ END
-
Course Details: + Course Details:$details_title
@@ -363,13 +388,28 @@ END '
END if ($sectionlist) { - $r->print("". + " \n"); foreach (sort keys %groupid) { if ($_ eq $groupid{$_} || $groupid{$_} eq '') { - $r->print("\n"); } else { - $r->print("\n"); } } $r->print(""); @@ -540,7 +581,7 @@ END
-   +     @@ -560,6 +601,9 @@ END
+ + + END return; } @@ -577,18 +621,33 @@ 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'); - &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},\@formvars); + 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 |; @@ -599,40 +658,35 @@ 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(< + my $html=&Apache::lonxml::xmlbegin(); + $r->print(<<"END"); +$html LON-CAPA support request recorded $bodytag -

A support request has been sent to $to

+
+ +
END + 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(< - - LON-CAPA support request recorded - -$bodytag -

A support request has been sent to $to

+ $r->print("

A support request has been sent to $to

"); END } else { $r->print(< - - LON-CAPA support request recorded - -$bodytag

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 or administrator at your institution. Instead a copy has been sent to the LON-CAPA support team at Michigan State University. END @@ -784,9 +838,81 @@ 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' + ); + my ($getstartlink,$getstarttext); + if (-e $Apache::lonnet::perlvar{'lonDocRoot'}.'/adm/gettingstarted.html') { + $getstartlink = qq| $lt{'getst'}|; + $getstarttext = ' '.&mt('and the "Getting started" guide').' '; + } + $r->print(<   + +
  LON-CAPA help/support + + + + +
+ + + + +
+ + + + +
+ + + + $getstartlink + + +
(Login help) $lt{'login'} $helpdesk_link(Ask helpdesk) $lt{'ask'}  (Back to last location) $lt{'back'} 
+
+
+
+
+ +   + + +   + +END + unless ($action eq 'process') { + $r->print(' + + '.&mt(' +Please review the information in "Log-in help"').$getstarttext.' '.&mt('if you are unable to 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,'.','.'); @@ -851,9 +977,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); @@ -871,9 +997,18 @@ sub build_code_selections { %{$$idlist{$$codetitles[3]}{$key_a}{$key_b}} = (); foreach my $key_c (keys %{$idarrays{$$codetitles[3]}{$key_a}{$key_b}}) { my @sorted_c = (); + my @sorted_c_titles = (); &sort_cats($num,$cat_order,$codetitles,\@{$idarrays{$$codetitles[3]}{$key_a}{$key_b}{$key_c}},\@sorted_c); + if (defined($$cat_titles{$$codetitles[3]})) { + foreach (@sorted_c) { + push @sorted_c_titles, $$cat_titles{$$codetitles[3]}{$_}; + } + } $$idlist{$$codetitles[3]}{$key_a}{$key_b}{$key_c} = join('","',@sorted_c); $$idnums{$$codetitles[3]}{$key_a}{$key_b}{$key_c} = scalar(@sorted_c); + if (defined($$cat_titles{$$codetitles[3]})) { + $$idlist_titles{$$codetitles[2]}{$key_a}{$key_b} = join('","',@sorted_c_titles); + } } } } @@ -887,7 +1022,13 @@ sub build_code_selections { %{$$idlist{$$codetitles[4]}{$key_a}{$key_b}{$key_c}} = (); foreach my $key_d (keys %{$idarrays{$$codetitles[4]}{$key_a}{$key_b}{$key_c}}) { my @sorted_d = (); + my @sorted_d_titles = (); &sort_cats($num,$cat_order,$codetitles,$idarrays{$$codetitles[4]}{$key_a}{$key_b}{$key_c}{$key_d},\@sorted_d); + if (defined($$cat_titles{$$codetitles[4]})) { + foreach (@sorted_d) { + push @sorted_d_titles, $$cat_titles{$$codetitles[4]}{$_}; + } + } $$idlist{$$codetitles[4]}{$key_a}{$key_b}{$key_c}{$key_d} = join('","',@sorted_d); $$idnums{$$codetitles[4]}{$key_a}{$key_b}{$key_c}{$key_d} = scalar(@sorted_d); } @@ -993,94 +1134,182 @@ sub recurse_list { } sub javascript_code_selections { - my ($numcats,$script_tag,$idlist,$idnums,$idlist_titles,$codetitles) = @_; + my ($numcats,$cat_titles,$script_tag,$idlist,$idnums,$idlist_titles,$codetitles) = @_; my $numtitles = @{$codetitles}; - my @seltitles = (); + my @seltitles = (); for (my $j=0; $j<$numtitles; $j++) { $seltitles[$j] = 'id'.$$codetitles[$j]; } my $seltitle_str = join('","',@seltitles); + my @longtitles = (); + for (my $i=0; $i<$numtitles; $i++) { + if (defined($$cat_titles{$$codetitles[$i]})) { + $longtitles[$i] = 1; + } else { + $longtitles[$i] = 0; + } + } + my $longtitles_str = join('","',@longtitles); $$script_tag .= <