File:
[LON-CAPA] /
loncom /
interface /
lonsupportreq.pm
Revision
1.1:
download - view:
text,
annotated -
select for diffs
Sat Jul 3 18:49:42 2004 UTC (20 years, 1 month ago) by
raeburn
Branches:
MAIN
CVS tags:
HEAD
Integration of help icons in breadcrumb trail into a single icon. Click on icon to open new window with gateway to help options within frameset (or within main window if pop-ups blocked). Help options include inline topic help, support request form, FAQ-o-matic, and bug reporting (all contextualized). Option to collect form parameter information from page displaying help icon currently disabled.
Some work required:
lonsupportreq.pm - replace call to Mail::Send with more sophisticated CPAN module (e.g., Mail::Sender that allows specification of from: address and attachments.
1: package Apache::lonsupportreq;
2:
3: use strict;
4: use lib qw(/home/httpd/lib/perl);
5: use Apache::Constants qw(:common);
6: use Apache::loncommon;
7: use Apache::lonnet;
8: use localenroll;
9: use Apache::lonlocal;
10:
11: use Mail::Send;
12: # use MIME::Lite;
13: # use MIME::Types;
14:
15: sub handler {
16: my $r = shift;
17: $r->content_type('text/html');
18: $r->send_http_header;
19:
20: if ($r->header_only) {
21: return OK;
22: }
23:
24: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['action','origurl','function']);
25: my $action = $ENV{'form.action'};
26: my $function = $ENV{'form.function'};
27: my $origurl = &Apache::lonnet::unescape($ENV{'form.origurl'});
28: if ($action eq 'process') {
29: &print_request_receipt($r,$origurl,$function);
30: } else {
31: &print_request_form($r,$origurl,$function);
32: }
33: return OK;
34: }
35:
36: sub print_request_form {
37: my ($r,$origurl,$function) = @_;
38: my ($os,$browser,$bversion,$uhost,$uname,$udom,$uhome,$urole,$usec,$email,$cid,$cdom,$cnum,$ctitle,$ccode,$sectionlist,$lastname,$firstname,$server);
39: my $bodytag = &Apache::loncommon::bodytag('',$function,'topmargin="0",marginheight="0"',1);
40: my $tablecolor = &Apache::loncommon::designparm($function.'.tabbg');
41: $os = $ENV{'browser.os'};
42: $browser = $ENV{'browser.type'};
43: $bversion = $ENV{'browser.version'};
44: $uhost = $ENV{'request.host'};
45: $uname = $ENV{'user.name'};
46: $udom = $ENV{'user.domain'};
47: $uhome = $ENV{'user.home'};
48: $urole = $ENV{'request.role'};
49: $usec = $ENV{'request.course.sec'};
50: $cid = $ENV{'request.course.id'};
51: $server = $ENV{'SERVER_NAME'};
52: my $scripttag;
53: if ($cid =~ m/_/) {
54: ($cdom,$cnum) = split/_/,$cid;
55: }
56: if ($cdom && $cnum) {
57: my %csettings = &Apache::lonnet::get('environment',['description','internal.coursecode','internal.sectionnums'],$cdom,$cnum);
58: $ctitle = $csettings{'description'};
59: $ccode = $csettings{'internal.coursecode'};
60: $sectionlist = $csettings{'internal.sectionnums'};
61: }
62: if ($ENV{'environment.critnotification'}) {
63: $email = $ENV{'environment.critnotification'};
64: }
65: if (!$email && $ENV{'environment.notification'}) {
66: $email = $ENV{'environment.notification'};
67: }
68: if ($ENV{'environment.lastname'}) {
69: $lastname = $ENV{'environment.lastname'};
70: }
71: if ($ENV{'environment.firstname'}) {
72: $firstname = $ENV{'environment.firstname'};
73: }
74: my @sections = split/,/,$sectionlist;
75: my %groupid = ();
76: foreach (@sections) {
77: my ($sec,$grp) = split/:/,$_;
78: $groupid{$sec} = $grp;
79: }
80: $r->print(<<END);
81: <html>
82: <head>
83: <title>LON-CAPA support request</title>
84: END
85: my $defdom = $Apache::lonnet::perlvar{'lonDefDomain'};
86: my $codedom = $defdom;
87: my %coursecodes = ();
88: my %codes = ();
89: my @codetitles = ();
90: my %cat_titles = ();
91: my %cat_order = ();
92: my $caller = 'global';
93: my $totcodes = 0;
94: my $format_reply;
95:
96: if ($cdom) {
97: $codedom = $cdom;
98: }
99: if ($cnum) {
100: $coursecodes{$cnum} = $ccode;
101: if ($ccode eq '') {
102: $totcodes = &retrieve_instcodes(\%coursecodes,$codedom,$totcodes);
103: } else {
104: $coursecodes{$cnum} = $ccode;
105: $caller = $cnum;
106: $totcodes ++;
107: }
108: } else {
109: $totcodes = &retrieve_instcodes(\%coursecodes,$codedom,$totcodes);
110: }
111: if ($totcodes > 0) {
112: $format_reply = &Apache::lonnet::auto_instcode_format($caller,$codedom,\%coursecodes,\%codes,\@codetitles,\%cat_titles,\%cat_order);
113: }
114: $r->print(<<END);
115: <html>
116: <head>
117: <title>LON-CAPA support request</title>
118: $scripttag
119: </head>
120: $bodytag
121: <table width="580" border="0" cellpadding="0" cellspacing="0" bgcolor="#000000">
122: <tr>
123: <td>
124: <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
125: <tr>
126: <td>
127: <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff">
128: <tr>
129: <td>
130: <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#ffffff">
131: <form method="post" name="logproblem" onSubmit="return validate()">
132: <tr>
133: <td width="140" bgcolor="$tablecolor">
134: <table width="140" border="0" cellpadding="8" cellspacing="0">
135: <tr>
136: <td align="right"><b>Name:</b>
137: </td>
138: </tr>
139: </table>
140: </td>
141: <td width="100%" valign="top">
142: <table width="100%" border="0" cellpadding="8" cellspacing="0">
143: <tr>
144: <td>
145: END
146: my $fullname = '';
147: if ((defined($lastname) && $lastname ne '') && (defined($firstname) && $firstname ne '')) {
148: $fullname = "$firstname $lastname";
149: $r->print("$fullname<input type=\"hidden\" name=\"username\" value=\"$fullname\" />");
150: } else {
151: if (defined($firstname) && $firstname ne '') {
152: $fullname = $firstname;
153: } elsif (defined($lastname) && $lastname ne '') {
154: $fullname= " $lastname";
155: }
156: $r->print('<input type="text" size="20" name="username" value="'.$fullname.'" /><br />');
157: }
158: $r->print(<<END);
159: </td>
160: </tr>
161: </table>
162: </td>
163: </tr>
164: <tr>
165: <td width="100%" colspan="2" bgcolor="#000000">
166: <img src="/adm/lonMisc/blackdot.jpg" /><br />
167: </td>
168: </tr>
169: <tr>
170: <td width="140" bgcolor="$tablecolor">
171: <table width="140" border="0" cellpadding="8" cellspacing="0">
172: <tr>
173: <td align="right"><b>E-mail address:</b>
174: </td>
175: </tr>
176: </table>
177: </td>
178: <td width="100%" valign="top">
179: <table width="100%" border="0" cellpadding="8" cellspacing="0">
180: <tr>
181: <td>
182: <input type="text" size="20" name="email" value="$email" /><br />
183: </td>
184: </tr>
185: </table>
186: </td>
187: </tr>
188: <tr>
189: <td width="100%" colspan="2" bgcolor="#000000">
190: <img src="/adm/lonMisc/blackdot.jpg" /><br />
191: </td>
192: </tr>
193: <tr>
194: <td width="140" bgcolor="$tablecolor">
195: <table width="140" border="0" cellpadding="8" cellspacing="0">
196: <tr>
197: <td align="right"><b>username/domain:</b>
198: </td>
199: </tr>
200: </table>
201: </td>
202: <td width="100%" valign="top">
203: <table width="100%" border="0" cellpadding="8" cellspacing="0">
204: <tr>
205: <td>
206: END
207: my $udom_input = '<input type="hidden" name="udom" value="'.$udom.'" />';
208: my $uname_input = '<input type="hidden" name="uname" value="'.$uname.'" />';
209: if (defined($uname) && defined($udom)) {
210: $r->print('<i>username</i>: '.$uname.' <i>domain</i>: '.$udom.$udom_input.$uname_input);
211: } else {
212: my $udomform = '';
213: my $unameform = '';
214: if (defined($udom)) {
215: $udomform = '<i>domain</i>: '.$udom.$udom_input;
216: } elsif (defined($uname)) {
217: $unameform = '<i>username</i>: '.$uname.' '.$uname_input;
218: }
219: if ($udomform eq '') {
220: $udomform = '<i>domain</i>: ';
221: $udomform .= &Apache::loncommon::select_dom_form('','udom');
222: }
223: if ($unameform eq '') {
224: $unameform= '<i>username</i>: <input type="text" size="20" name="loncname" value="'.$uname.'" /> ';
225: }
226: $r->print($unameform.$udomform.'<br />Enter the username you use to log-in to your LON-CAPA system, and choose your domain.');
227: }
228: $r->print(<<END);
229: </td>
230: </tr>
231: </table>
232: </td>
233: </tr>
234: <tr>
235: <td width="100%" colspan="2" bgcolor="#000000">
236: <img src="/adm/lonMisc/blackdot.jpg" /><br />
237: </td>
238: </tr>
239: <tr>
240: <td width="140" bgcolor="$tablecolor">
241: <table width="140" border="0" cellpadding="8" cellspacing="0">
242: <tr>
243: <td align="right"><b>URL of page:</b>
244: </td>
245: </tr>
246: </table>
247: </td>
248: <td width="100%" valign="top">
249: <table width="100%" border="0" cellpadding="8" cellspacing="0">
250: <tr>
251: <td>
252: $server$origurl<input type="hidden" name="origurl" value="$server$origurl" />
253: </td>
254: </tr>
255: </table>
256: </td>
257: </tr>
258: <tr>
259: <td width="100%" colspan="2" bgcolor="#000000">
260: <img src="/adm/lonMisc/blackdot.jpg" /><br />
261: </td>
262: </tr>
263: <tr>
264: <td width="140" bgcolor="$tablecolor">
265: <table width="140" border="0" cellpadding="8" cellspacing="0">
266: <tr>
267: <td align="right"><b>Phone #:</b>
268: </td>
269: </tr>
270: </table>
271: </td>
272: <td width="100%" valign="top">
273: <table width="100%" border="0" cellpadding="8" cellspacing="0">
274: <tr>
275: <td>
276: <input type="text" size="15" name="phone"><br>
277: </td>
278: </tr>
279: </table>
280: </td>
281: </tr>
282: <tr>
283: <td width="100%" colspan="2" bgcolor="#000000">
284: <img src="/adm/lonMisc/blackdot.jpg" /><br />
285: </td>
286: </tr>
287: <tr>
288: <td width="140" bgcolor="$tablecolor">
289: <table width="140" border="0" cellpadding="8" cellspacing="0">
290: <tr>
291: <td align="right"><b>Course Details:</b>
292: </td>
293: </tr>
294: </table>
295: </td>
296: <td width="100%" valign="top">
297: <table border="0" cellpadding="3" cellspacing="3">
298: <tr>
299: <td>
300: END
301: if ($coursecodes{$cnum}) {
302: foreach (@codetitles) {
303: $r->print('<i>'.$_.'</i>: '.$codes{$cnum}{$_});
304: }
305: $r->print('. <input type="hidden" name="coursecode" value="'.$coursecodes{$cnum}.'" />');
306: } else {
307: $r->print('Enter institutional course code:
308: <input type="text" name="coursecode" size="15" value="" />');
309: }
310: if ($ctitle) {
311: $r->print('<br /><i>Title</i>: '.$ctitle.'<input type="hidden" name="title" value="'.$ctitle.'" />');
312: } else {
313: $r->print('<br />Enter course title:
314: <input type="text" name="title" size="15" value="" />');
315: }
316: $r->print(<<END);
317: </td>
318: </tr>
319: </table>
320: </td>
321: </tr>
322: <tr>
323: <td width="100%" colspan="2" bgcolor="#000000">
324: <img src="/adm/lonMisc/blackdot.jpg" /><br />
325: </td>
326: </tr>
327: <tr>
328: <td width="140" bgcolor="$tablecolor">
329: <table width="140" border="0" cellpadding="8" cellspacing="0">
330: <tr>
331: <td align="right"><b>Section Number: </b>
332: </td>
333: </tr>
334: </table>
335: </td>
336: <td width="100%" valign="top">
337: <table width="100%" border="0" cellpadding="8" cellspacing="0">
338: <tr>
339: <td>
340: END
341: if ($sectionlist) {
342: $r->print("<select name=\"section\">");
343: foreach (sort keys %groupid) {
344: if ($_ eq $groupid{$_} || $groupid{$_} eq '') {
345: $r->print("<option value=\"$_\" />$_");
346: } else {
347: $r->print("<option value=\"$_\" />$_ - (LON-CAPA sec: $groupid{$_}");
348: }
349: }
350: $r->print("</select>");
351: } else {
352: $r->print("<input type=\"text\" name=\"section\" size=\"10\"/>");
353: }
354: $r->print(<<END);
355: </td>
356: </tr>
357: </table>
358: </td>
359: </tr>
360: <tr>
361: <td width="100%" colspan="2" bgcolor="#000000">
362: <img src="/adm/lonMisc/blackdot.jpg" /><br />
363: </td>
364: </tr>
365: <tr>
366: <td width="140" bgcolor="$tablecolor">
367: <table width="140" border="0" cellpadding="8" cellspacing="0">
368: <tr>
369: <td align="right"><b>Subject</b>
370: </td>
371: </tr>
372: </table>
373: </td>
374: <td width="100%" valign="top">
375: <table width="100%" border="0" cellpadding="8" cellspacing="0">
376: <tr>
377: <td>
378: <input type="text" size="40" name="subject">
379: </td>
380: </tr>
381: </table>
382: </td>
383: </tr>
384: <tr>
385: <td width="100%" colspan="2" bgcolor="#000000">
386: <img src="/adm/lonMisc/blackdot.jpg" /><br />
387: </td>
388: </tr>
389: <tr>
390: <td width="140" bgcolor="$tablecolor">
391: <table width="140" border="0" cellpadding="8" cellspacing="0">
392: <tr>
393: <td align="right"><b>Detailed description:</b>
394: </td>
395: </tr>
396: </table>
397: </td>
398: <td width="100%" valign="top">
399: <table width="100%" border="0" cellpadding="8" cellspacing="0">
400: <tr>
401: <td>
402: <textarea rows="10" cols="45" name="description" wrap="virtual"></textarea>
403: </td>
404: </tr>
405: </table>
406: </td>
407: </tr>
408: <tr>
409: <td width="100%" colspan="2" bgcolor="#000000">
410: <img src="/adm/lonMisc/blackdot.jpg" /><br />
411: </td>
412: </tr>
413: <tr>
414: <td width="140" bgcolor="$tablecolor">
415: <table width="140" border="0" cellpadding="8" cellspacing="0">
416: <tr>
417: <td align="right"><b>Finish:</b>
418: </td>
419: </tr>
420: </table>
421: </td>
422: <td width="100%" valign="top">
423: <table border="0" cellpadding="8" cellspacing="0">
424: <tr>
425: <td>
426: <input type="hidden" name="action" value="process" />
427: <input type="submit" value="Submit Request Form" />
428: </td>
429: <td> </td>
430: <td>
431: <input type="reset" value="Clear Form">
432: </td>
433: </tr>
434: </table>
435: </td>
436: </tr>
437: </table>
438: </td>
439: </tr>
440: </table>
441: </td>
442: </tr>
443: </table>
444: </td>
445: </tr>
446: </table>
447: END
448:
449:
450: # What do we know about this user?
451: # foreach (sort keys %ENV) {
452: # if ($_ =~ m/^browser/) {
453: # $r->print("key is $_, value is $ENV{$_}");
454: # } elsif ($_ =~ m/^environment/) {
455: # $r->print("key is $_, value is $ENV{$_}");
456: # } elsif ($_ =~ m/^request/) {
457: # $r->print("key is $_, value is $ENV{$_}");
458: # } elsif ($_ =~ m/^user\.(domain|home|name)/) {
459: # $r->print("key is $_, value is $ENV{$_}");
460: # } elsif ($_ =~ /^[A-Z]/) {
461: # $r->print("key is $_, value is $ENV{$_}");
462: # }
463: # }
464: return
465: }
466:
467: sub print_request_receipt {
468: my ($r,$url,$function) = @_;
469: my @envvars = ('lonID','HTTP_HOST','HTTP_USER_AGENT','REMOTE_ADDR','SERVER_ADDR','SERVER_NAME','browser.os','browser.type','browser.version','user.home','request.role');
470: my $bodytag = &Apache::loncommon::bodytag('',$function,'topmargin="0" marginheight="0"',1);
471: my $to = $Apache::lonnet::perlvar{'lonSupportEMail'};
472: my $reporttime = &Apache::lonlocal::locallocaltime(time);
473: my $fontcolor = &Apache::loncommon::designparm($function.'.font');
474: my $vlinkcolor = &Apache::loncommon::designparm($function.'.vlink');
475: my $tablecolor = &Apache::loncommon::designparm($function.'.tabbg');
476: my @formvars = ('username','email','uname','udom','origurl','phone','section','coursecode','title','subject','description');
477: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},\@formvars);
478:
479: # if ($ENV{'request.course.fn'}) {
480: # my $formdatafile = $ENV{'request.course.fn'}.'.formdata';
481: # if (-e $formdatafile) {
482: # open(FILE,"<$formdatafile");
483: # my @buffer =<FILE>;
484: # close(FILE);
485: # foreach (@buffer) {
486: # print STDERR $_;
487: # }
488: # }
489: # }
490:
491: my $supportmsg = qq|
492: Name: $ENV{'form.username'}
493: Email: $ENV{'form.email'}
494: Username/domain: $ENV{'form.uname'} - $ENV{'form.udom'}
495: Tel: $ENV{'form.phone'}
496: Course Information: $ENV{'form.title'} - $ENV{'form.coursecode'} - section: $ENV{'form.section'}
497: Subject: $ENV{'form.subject'}
498: Description: $ENV{'form.description'}
499: URL: $ENV{'form.origurl'}
500: Date/Time: $reporttime
501:
502: |;
503: if ($to =~ m/^[^\@]+\@[^\@]+$/) {
504: $r->print(<<END);
505: <html>
506: <head>
507: <title>LON-CAPA support request recorded</title>
508: </head>
509: $bodytag
510: <h3>A support request has been sent to $to</h3>
511: END
512: } else {
513: $to = 'helpdesk@lon-capa.org';
514: $r->print(<<END);
515: <html>
516: <head>
517: <title>LON-CAPA support request recorded</title>
518: </head>
519: $bodytag
520: <h3>Warning: Problem with support e-mail address</h3>
521: 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.
522: END
523: }
524: my $msg = new Mail::Send;
525: $msg->to($to);
526: # if (defined($ENV{'form.email'})) {
527: # if ($ENV{'form.email'} =~ m/^[^\@]+\@[^\@]+$/) {
528: # $msg->from($ENV{'form.email'});
529: # }
530: # }
531: $msg->subject('[LON-CAPA] - support request');
532: if (my $fh = $msg->open()) {
533: print $fh $supportmsg;
534: $fh->close;
535: }
536: $r->print(<<END);
537: <b>Your support request contained the following information</b>:<br /><br />
538: <table width="580" border="0" cellpadding="0" cellspacing="0" bgcolor="#000000">
539: <tr>
540: <td>
541: <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
542: <tr>
543: <td>
544: <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff">
545: <tr>
546: <td>
547: <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#ffffff">
548: <tr>
549: <td width="140" bgcolor="$tablecolor">
550: <table width="140" border="0" cellpadding="8" cellspacing="0">
551: <tr>
552: <td align="right"><b>Information supplied</b>
553: </td>
554: </tr>
555: </table>
556: </td>
557: <td width="100%" valign="top">
558: <table width="100%" border="0" cellpadding="8" cellspacing="0">
559: <tr>
560: <td>
561: END
562: my @textmsg = split/\n/,$supportmsg;
563: foreach my $line (@textmsg) {
564: $line =~ s|^|<font color="$fontcolor">|;
565: $line =~ s|:|:</font><font color="$vlinkcolor">|;
566: $r->print("$line</font><br />");
567: }
568: $r->print('</td>
569: </tr>
570: </table>
571: </td>
572: </tr>
573: <tr>
574: <td width="130" bgcolor="'.$tablecolor.'">
575: <table width="130" border="0" cellpadding="8" cellspacing="0">
576: <tr>
577: <td align="right"><b>Additional information recorded</b>
578: </td>
579: </tr>
580: </table>
581: </td>
582: <td width="100%" valign="top">
583: <table width="100%" border="0" cellpadding="8" cellspacing="0">
584: <tr>
585: <td>
586: ');
587: foreach (@envvars) {
588: $r->print("$_: <font color='$vlinkcolor>$ENV{$_}</font>, ");
589: $supportmsg .= "$_: $ENV{$_}\n";
590: }
591: $r->print("
592: </td>
593: </tr>
594: </table>
595: </td>
596: </tr>
597: </table>
598: </td>
599: </tr>
600: </table>
601: </td>
602: </tr>
603: </table>
604: </td>
605: </tr>
606: </table>
607: ");
608: }
609:
610: sub retrieve_instcodes {
611: my ($coursecodes,$codedom,$totcodes) = @_;
612: my %courses = &Apache::lonnet::courseiddump($codedom,'.',1);
613: foreach my $course (keys %courses) {
614: if ($courses{$course} =~ m/^[^:]*:([^:]+)$/) {
615: $$coursecodes{$course} = &Apache::lonnet::unescape($1);
616: $totcodes ++;
617: }
618: }
619: return $totcodes;
620: }
621:
622: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>