File:
[LON-CAPA] /
loncom /
interface /
lonsupportreq.pm
Revision
1.21:
download - view:
text,
annotated -
select for diffs
Fri Dec 31 02:46:18 2004 UTC (19 years, 7 months ago) by
raeburn
Branches:
MAIN
CVS tags:
HEAD
Only display 'Getting started guide' link if a file exists at /home/httpd/html/adm/gettingstarted.html. Also allow 'Back to last location' to point to a different server -- allows linking from an institution's custom LON-CAP help page (e.g., loncapa.msu.edu or help.loncapa.org).
1: package Apache::lonsupportreq;
2:
3: use strict;
4: use lib qw(/home/httpd/lib/perl);
5: use MIME::Types;
6: use MIME::Lite;
7: use Apache::Constants qw(:common);
8: use Apache::loncommon();
9: use Apache::lonnet();
10: use Apache::lonlocal;
11:
12: sub handler {
13: my ($r) = @_;
14: &Apache::loncommon::content_type($r,'text/html');
15: $r->send_http_header;
16:
17: if ($r->header_only) {
18: return OK;
19: }
20: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['origurl','function']);
21: if ($r->uri eq '/adm/helpdesk') {
22: &Apache::loncommon::get_posted_cgi($r);
23: }
24: my $function = $ENV{'form.function'};
25: my $origurl = &Apache::lonnet::unescape($ENV{'form.origurl'});
26: my $action = $ENV{'form.action'};
27:
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: if (($tablecolor eq '') || ($tablecolor eq '#FFFFFF')) {
42: $tablecolor = '#EEEE99';
43: }
44: $ccode = '';
45: $os = $ENV{'browser.os'};
46: $browser = $ENV{'browser.type'};
47: $bversion = $ENV{'browser.version'};
48: $uhost = $ENV{'request.host'};
49: $uname = $ENV{'user.name'};
50: $udom = $ENV{'user.domain'};
51: $uhome = $ENV{'user.home'};
52: $urole = $ENV{'request.role'};
53: $usec = $ENV{'request.course.sec'};
54: $cid = $ENV{'request.course.id'};
55: if ($origurl =~ m-^http://-) {
56: $server = $origurl;
57: } else {
58: $server = 'http://'.$ENV{'SERVER_NAME'}.$origurl;
59: }
60: my $scripttag = (<<'END');
61: function validate() {
62: if (validmail(document.logproblem.email) == false) {
63: alert("The e-mail address you entered: "+document.logproblem.email.value+" is not a valid e-mail address.");
64: return;
65: }
66: document.logproblem.submit();
67: }
68:
69: function validmail(field) {
70: var str = field.value;
71: if (window.RegExp) {
72: var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
73: var reg2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$";
74: var reg1 = new RegExp(reg1str);
75: var reg2 = new RegExp(reg2str);
76: if (!reg1.test(str) && reg2.test(str)) {
77: return true;
78: }
79: return false;
80: }
81: else
82: {
83: if(str.indexOf("@") >= 0) {
84: return true;
85: }
86: return false;
87: }
88: }
89: END
90: if ($cid =~ m/_/) {
91: ($cdom,$cnum) = split/_/,$cid;
92: }
93: if ($cdom && $cnum) {
94: my %csettings = &Apache::lonnet::get('environment',['description','internal.coursecode','internal.sectionnums'],$cdom,$cnum);
95: $ctitle = $csettings{'description'};
96: $ccode = $csettings{'internal.coursecode'};
97: $sectionlist = $csettings{'internal.sectionnums'};
98: }
99: if ($ENV{'environment.critnotification'}) {
100: $email = $ENV{'environment.critnotification'};
101: }
102: if (!$email && $ENV{'environment.notification'}) {
103: $email = $ENV{'environment.notification'};
104: }
105: if ($ENV{'environment.lastname'}) {
106: $lastname = $ENV{'environment.lastname'};
107: }
108: if ($ENV{'environment.firstname'}) {
109: $firstname = $ENV{'environment.firstname'};
110: }
111: my @sections = split/,/,$sectionlist;
112: my %groupid = ();
113: foreach (@sections) {
114: my ($sec,$grp) = split/:/,$_;
115: $groupid{$sec} = $grp;
116: }
117: my $codedom = $Apache::lonnet::perlvar{'lonDefDomain'};
118: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['codedom']);
119: if (exists($ENV{'form.codedom'})) {
120: $codedom = $ENV{'form.codedom'};
121: }
122: my $details_title;
123: if ($codedom) {
124: $details_title = '<br />('.$codedom.')';
125: }
126: my %coursecodes = ();
127: my %codes = ();
128: my @codetitles = ();
129: my %cat_titles = ();
130: my %cat_order = ();
131: my %idlist = ();
132: my %idnums = ();
133: my %idlist_titles = ();
134: my $caller = 'global';
135: my $totcodes = 0;
136: my $format_reply;
137: my $jscript = '';
138:
139: if ($cdom) {
140: $codedom = $cdom;
141: }
142: if ($cnum) {
143: $coursecodes{$cnum} = $ccode;
144: if ($ccode eq '') {
145: $totcodes = &retrieve_instcodes(\%coursecodes,$codedom,$totcodes);
146: } else {
147: $coursecodes{$cnum} = $ccode;
148: $caller = $cnum;
149: $totcodes ++;
150: }
151: } else {
152: $totcodes = &retrieve_instcodes(\%coursecodes,$codedom,$totcodes);
153: }
154: if ($totcodes > 0) {
155: $format_reply = &Apache::lonnet::auto_instcode_format($caller,$codedom,\%coursecodes,\%codes,\@codetitles,\%cat_titles,\%cat_order);
156: if ($ccode eq '') {
157: my $numtypes = @codetitles;
158: &build_code_selections(\%codes,\@codetitles,\%cat_titles,\%cat_order,\%idlist,\%idnums,\%idlist_titles);
159: &javascript_code_selections($numtypes,\%cat_titles,\$jscript,\%idlist,\%idnums,\%idlist_titles,\@codetitles);
160: }
161: }
162: $r->print(<<ENDHEAD);
163: <html>
164: <head>
165: <title>LON-CAPA support request</title>
166: <script type"text/javascript">
167: $scripttag
168: $jscript
169: </script>
170: </head>
171: $bodytag
172: ENDHEAD
173: if ($r->uri eq '/adm/helpdesk') {
174: &print_header($r,$origurl);
175: }
176: $r->print(<<"END");
177: <form method="post" name="logproblem" enctype="multipart/form-data">
178: <table width="580" border="0" cellpadding="0" cellspacing="0" bgcolor="#000000">
179: <tr>
180: <td>
181: <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
182: <tr>
183: <td>
184: <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff">
185: <tr>
186: <td>
187: <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#ffffff">
188: <tr>
189: <td width="140" bgcolor="$tablecolor">
190: <table width="140" border="0" cellpadding="8" cellspacing="0">
191: <tr>
192: <td align="right"><b>Name:</b>
193: </td>
194: </tr>
195: </table>
196: </td>
197: <td width="100%" valign="top">
198: <table width="100%" border="0" cellpadding="8" cellspacing="0">
199: <tr>
200: <td>
201: END
202: my $fullname = '';
203: if ((defined($lastname) && $lastname ne '') && (defined($firstname) && $firstname ne '')) {
204: $fullname = "$firstname $lastname";
205: $r->print("$fullname<input type=\"hidden\" name=\"username\" value=\"$fullname\" />");
206: } else {
207: if (defined($firstname) && $firstname ne '') {
208: $fullname = $firstname;
209: } elsif (defined($lastname) && $lastname ne '') {
210: $fullname= " $lastname";
211: }
212: $r->print('<input type="text" size="20" name="username" value="'.$fullname.'" />');
213: }
214: $r->print(<<END);
215: <input type="button" value="Submit Request" onClick="validate()" />
216: </td>
217: </tr>
218: </table>
219: </td>
220: </tr>
221: <tr>
222: <td width="100%" colspan="2" bgcolor="#000000">
223: <img src="/adm/lonMisc/blackdot.gif" /><br />
224: </td>
225: </tr>
226: <tr>
227: <td width="140" bgcolor="$tablecolor">
228: <table width="140" border="0" cellpadding="8" cellspacing="0">
229: <tr>
230: <td align="right"><b>E-mail address:</b>
231: </td>
232: </tr>
233: </table>
234: </td>
235: <td width="100%" valign="top">
236: <table width="100%" border="0" cellpadding="8" cellspacing="0">
237: <tr>
238: <td>
239: <input type="text" size="20" name="email" value="$email" /><br />
240: </td>
241: </tr>
242: </table>
243: </td>
244: </tr>
245: <tr>
246: <td width="100%" colspan="2" bgcolor="#000000">
247: <img src="/adm/lonMisc/blackdot.gif" /><br />
248: </td>
249: </tr>
250: <tr>
251: <td width="140" bgcolor="$tablecolor">
252: <table width="140" border="0" cellpadding="8" cellspacing="0">
253: <tr>
254: <td align="right"><b>username/domain:</b>
255: </td>
256: </tr>
257: </table>
258: </td>
259: <td width="100%" valign="top">
260: <table width="100%" border="0" cellpadding="8" cellspacing="0">
261: <tr>
262: <td>
263: END
264: my $udom_input = '<input type="hidden" name="udom" value="'.$udom.'" />';
265: my $uname_input = '<input type="hidden" name="uname" value="'.$uname.'" />';
266: if (defined($uname) && defined($udom)) {
267: $r->print('<i>username</i>: '.$uname.' <i>domain</i>: '.$udom.$udom_input.$uname_input);
268: } else {
269: my $udomform = '';
270: my $unameform = '';
271: if (defined($udom)) {
272: $udomform = '<i>domain</i>: '.$udom.$udom_input;
273: } elsif (defined($uname)) {
274: $unameform = '<i>username</i>: '.$uname.' '.$uname_input;
275: }
276: if ($udomform eq '') {
277: $udomform = '<i>domain</i>: ';
278: $udomform .= &Apache::loncommon::select_dom_form($codedom,'udom');
279: }
280: if ($unameform eq '') {
281: $unameform= '<i>username</i>: <input type="text" size="12" name="uname" value="'.$uname.'" /> ';
282: }
283: $r->print($unameform.$udomform.'<br />Enter the username you use to log-in to your LON-CAPA system, and choose your domain.');
284: }
285: $r->print(<<END);
286: </td>
287: </tr>
288: </table>
289: </td>
290: </tr>
291: <tr>
292: <td width="100%" colspan="2" bgcolor="#000000">
293: <img src="/adm/lonMisc/blackdot.gif" /><br />
294: </td>
295: </tr>
296: <tr>
297: <td width="140" bgcolor="$tablecolor">
298: <table width="140" border="0" cellpadding="8" cellspacing="0">
299: <tr>
300: <td align="right"><b>URL of page:</b>
301: </td>
302: </tr>
303: </table>
304: </td>
305: <td width="100%" valign="top">
306: <table width="100%" border="0" cellpadding="8" cellspacing="0">
307: <tr>
308: <td>
309: $server<input type="hidden" name="sourceurl" value="$server" />
310: </td>
311: </tr>
312: </table>
313: </td>
314: </tr>
315: <tr>
316: <td width="100%" colspan="2" bgcolor="#000000">
317: <img src="/adm/lonMisc/blackdot.gif" /><br />
318: </td>
319: </tr>
320: <tr>
321: <td width="140" bgcolor="$tablecolor">
322: <table width="140" border="0" cellpadding="8" cellspacing="0">
323: <tr>
324: <td align="right"><b>Phone #:</b>
325: </td>
326: </tr>
327: </table>
328: </td>
329: <td width="100%" valign="top">
330: <table width="100%" border="0" cellpadding="8" cellspacing="0">
331: <tr>
332: <td>
333: <input type="text" size="15" name="phone"><br>
334: </td>
335: </tr>
336: </table>
337: </td>
338: </tr>
339: <tr>
340: <td width="100%" colspan="2" bgcolor="#000000">
341: <img src="/adm/lonMisc/blackdot.gif" /><br />
342: </td>
343: </tr>
344: <tr>
345: <td width="140" bgcolor="$tablecolor">
346: <table width="140" border="0" cellpadding="8" cellspacing="0">
347: <tr>
348: <td align="right"><b>Course Details:</b>$details_title
349: </td>
350: </tr>
351: </table>
352: </td>
353: <td width="100%" valign="top">
354: <table border="0" cellpadding="3" cellspacing="3">
355: <tr>
356: <td>
357: END
358: if ($cnum) {
359: if ($coursecodes{$cnum}) {
360: foreach (@codetitles) {
361: $r->print('<i>'.$_.'</i>: '.$codes{$cnum}{$_}.'; ');
362: }
363: $r->print(' <input type="hidden" name="coursecode" value="'.$coursecodes{$cnum}.'" />');
364: } else {
365: $r->print('Enter institutional course code:
366: <input type="text" name="coursecode" size="15" value="" />');
367: }
368: } else {
369: if ($totcodes > 0) {
370: my $numtitles = @codetitles;
371: if ($numtitles == 0) {
372: $r->print('Enter institutional course code:
373: <input type="text" name="coursecode" size="15" value="" />');
374: } else {
375: my $lasttitle = $numtitles;
376: if ($numtitles > 4) {
377: $lasttitle = 4;
378: }
379: $r->print('<table><tr><td>'.$codetitles[0].'<br />'."\n".
380: '<select name="'.$codetitles[0].'" onChange="courseSet('."'$codetitles[0]'".')">'."\n".
381: ' <option value="-1" />Select'."\n");
382: my @items = ();
383: my @longitems = ();
384: if ($idlist{$codetitles[0]} =~ /","/) {
385: @items = split/","/,$idlist{$codetitles[0]};
386: } else {
387: $items[0] = $idlist{$codetitles[0]};
388: }
389: if (defined($idlist_titles{$codetitles[0]})) {
390: if ($idlist_titles{$codetitles[0]} =~ /","/) {
391: @longitems = split/","/,$idlist_titles{$codetitles[0]};
392: } else {
393: $longitems[0] = $idlist_titles{$codetitles[0]};
394: }
395: } else {
396: @longitems = @items;
397: }
398: for (my $i=0; $i<@items; $i++) {
399: $r->print(' <option value="'.$items[$i].'">'.$longitems[$i].'</option>');
400: }
401: $r->print('</select></td>');
402: for (my $i=1; $i<$numtitles; $i++) {
403: $r->print('<td>'.$codetitles[$i].'<br />'."\n".
404: '<select name="'.$codetitles[$i].'" onChange="courseSet('."'$codetitles[$i]'".')">'."\n".
405: '<option value="-1"><-Pick '.$codetitles[$i-1].'</option>'."\n".
406: '</select>'."\n".
407: '</td>'
408: );
409: }
410: $r->print('</tr></table>');
411: if ($numtitles > 4) {
412: $r->print('<br /><br />'.$codetitles[$numtitles].'<br />'."\n".
413: '<select name="'.$codetitles[$numtitles].'" onChange="courseSet('."'$codetitles[$numtitles]'".')">'."\n".
414: '<option value="-1"><-Pick '.$codetitles[$numtitles-1].'</option>'."\n".
415: '</select>'."\n");
416: }
417: }
418: } else {
419: $r->print('Enter institutional course code:
420: <input type="text" name="coursecode" size="15" value="" />');
421: }
422: }
423: if ($ctitle) {
424: $r->print('<br /><i>Title</i>: '.$ctitle.'<input type="hidden" name="title" value="'.$ctitle.'" />');
425: } else {
426: $r->print('<br />Enter course title:
427: <input type="text" name="title" size="25" value="" />');
428: }
429: $r->print(<<END);
430: </td>
431: </tr>
432: </table>
433: </td>
434: </tr>
435: <tr>
436: <td width="100%" colspan="2" bgcolor="#000000">
437: <img src="/adm/lonMisc/blackdot.gif" /><br />
438: </td>
439: </tr>
440: <tr>
441: <td width="140" bgcolor="$tablecolor">
442: <table width="140" border="0" cellpadding="8" cellspacing="0">
443: <tr>
444: <td align="right"><b>Section Number: </b>
445: </td>
446: </tr>
447: </table>
448: </td>
449: <td width="100%" valign="top">
450: <table width="100%" border="0" cellpadding="8" cellspacing="0">
451: <tr>
452: <td>
453: END
454: if ($sectionlist) {
455: $r->print("<select name=\"section\">");
456: foreach (sort keys %groupid) {
457: if ($_ eq $groupid{$_} || $groupid{$_} eq '') {
458: $r->print("<option value=\"$_\" />$_");
459: } else {
460: $r->print("<option value=\"$_\" />$_ - (LON-CAPA sec: $groupid{$_})");
461: }
462: }
463: $r->print("</select>");
464: } else {
465: $r->print("<input type=\"text\" name=\"section\" size=\"10\"/>");
466: }
467: $r->print(<<END);
468: </td>
469: </tr>
470: </table>
471: </td>
472: </tr>
473: <tr>
474: <td width="100%" colspan="2" bgcolor="#000000">
475: <img src="/adm/lonMisc/blackdot.gif" /><br />
476: </td>
477: </tr>
478: <tr>
479: <td width="140" bgcolor="$tablecolor">
480: <table width="140" border="0" cellpadding="8" cellspacing="0">
481: <tr>
482: <td align="right"><b>Subject</b>
483: </td>
484: </tr>
485: </table>
486: </td>
487: <td width="100%" valign="top">
488: <table width="100%" border="0" cellpadding="8" cellspacing="0">
489: <tr>
490: <td>
491: <input type="text" size="40" name="subject">
492: </td>
493: </tr>
494: </table>
495: </td>
496: </tr>
497: <tr>
498: <td width="100%" colspan="2" bgcolor="#000000">
499: <img src="/adm/lonMisc/blackdot.gif" /><br />
500: </td>
501: </tr>
502: <tr>
503: <td width="140" bgcolor="$tablecolor">
504: <table width="140" border="0" cellpadding="8" cellspacing="0">
505: <tr>
506: <td align="right"><b>Detailed description:</b>
507: </td>
508: </tr>
509: </table>
510: </td>
511: <td width="100%" valign="top">
512: <table width="100%" border="0" cellpadding="8" cellspacing="0">
513: <tr>
514: <td>
515: <textarea rows="10" cols="45" name="description" wrap="virtual"></textarea>
516: </td>
517: </tr>
518: </table>
519: </td>
520: </tr>
521: <tr>
522: <td width="100%" colspan="2" bgcolor="#000000">
523: <img src="/adm/lonMisc/blackdot.gif" /><br />
524: </td>
525: </tr>
526: END
527: if (defined($ENV{'user.name'})) {
528: $r->print(<<END);
529: <tr>
530: <td width="140" bgcolor="$tablecolor">
531: <table width="140" border="0" cellpadding="8" cellspacing="0">
532: <tr>
533: <td align="right"><b>Optional file upload:</b>
534: </td>
535: </tr>
536: </table>
537: </td>
538: <td width="100%" valign="top">
539: <table width="100%" border="0" cellpadding="8" cellspacing="0">
540: <tr>
541: <td>
542: <input type="file" name="screenshot" size="20" /><br />Upload a file (e.g., a screenshot) relevant to your support request (128 KB max. size).
543: </td>
544: </tr>
545: </table>
546: </td>
547: </tr>
548: <tr>
549: <td width="100%" colspan="2" bgcolor="#000000">
550: <img src="/adm/lonMisc/blackdot.gif" /><br />
551: </td>
552: </tr>
553: END
554: }
555: $r->print(<<END);
556: <tr>
557: <td width="140" bgcolor="$tablecolor">
558: <table width="140" border="0" cellpadding="8" cellspacing="0">
559: <tr>
560: <td align="right"><b>Finish:</b>
561: </td>
562: </tr>
563: </table>
564: </td>
565: <td width="100%" valign="top">
566: <table border="0" cellpadding="8" cellspacing="0">
567: <tr>
568: <td>
569: <input type="hidden" name="action" value="process" />
570: <input type="button" value="Submit Request" onClick="validate()"/>
571: </td>
572: <td> </td>
573: <td>
574: <input type="reset" value="Clear Form">
575: </td>
576: </tr>
577: </table>
578: </td>
579: </tr>
580: </table>
581: </td>
582: </tr>
583: </table>
584: </td>
585: </tr>
586: </table>
587: </td>
588: </tr>
589: </table>
590: </form>
591: </body>
592: </html>
593: END
594: return;
595: }
596:
597: sub print_request_receipt {
598: my ($r,$url,$function) = @_;
599: my @envvars = ('lonID','HTTP_HOST','HTTP_USER_AGENT','REMOTE_ADDR','SERVER_ADDR','SERVER_NAME','browser.os','browser.type','browser.version','user.home','request.role');
600: my @loncvars = ('user.name','user.domain','request.course.sec','request.course.id');
601:
602: my $bodytag = &Apache::loncommon::bodytag('',$function,'topmargin="0" marginheight="0"',1);
603: my $admin = $Apache::lonnet::perlvar{'lonAdminMail'};
604: my $to = $Apache::lonnet::perlvar{'lonSupportEMail'};
605: my $from = $admin;
606: my $reporttime = &Apache::lonlocal::locallocaltime(time);
607: my $fontcolor = &Apache::loncommon::designparm($function.'.font');
608: my $vlinkcolor = &Apache::loncommon::designparm($function.'.vlink');
609: my $tablecolor = &Apache::loncommon::designparm($function.'.tabbg');
610: my @formvars = ('username','email','uname','udom','sourceurl','phone','section','coursecode','title','subject','description','screenshot');
611:
612: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},\@formvars);
613: my $coursecode = $ENV{'form.coursecode'};
614: if ($coursecode eq '') {
615: if (defined($ENV{'form.Year'})) {
616: $coursecode .= $ENV{'form.Year'};
617: }
618: if (defined($ENV{'form.Semester'})) {
619: $coursecode .= $ENV{'form.Semester'};
620: }
621: if (defined($ENV{'form.Department'})) {
622: $coursecode .= $ENV{'form.Department'};
623: }
624: if (defined($ENV{'form.Number'})) {
625: $coursecode .= $ENV{'form.Number'};
626: }
627: }
628: my $supportmsg = qq|
629: Name: $ENV{'form.username'}
630: Email: $ENV{'form.email'}
631: Username/domain: $ENV{'form.uname'} - $ENV{'form.udom'}
632: Tel: $ENV{'form.phone'}
633: Course Information: $ENV{'form.title'} - $coursecode - section: $ENV{'form.section'}
634: Subject: $ENV{'form.subject'}
635: Description: $ENV{'form.description'}
636: URL: $ENV{'form.sourceurl'}
637: Date/Time: $reporttime
638:
639: |;
640: my $descrip = $ENV{'form.description'};
641: $descrip =~ s#\n#<br />#g;
642: my $displaymsg = qq|
643: <font color="$fontcolor">Name:</font><font color="$vlinkcolor"> $ENV{'form.username'}</font><br />
644: <font color="$fontcolor">Email: </font><font color="$vlinkcolor">$ENV{'form.email'}</font><br />
645: <font color="$fontcolor">Username/domain: </font><font color="$vlinkcolor">$ENV{'form.uname'} - $ENV{'form.udom'}</font><br />
646: <font color="$fontcolor">Tel: </font><font color="$vlinkcolor">$ENV{'form.phone'}</font><br />
647: <font color="$fontcolor">Course Information: </font><font color="$vlinkcolor">$ENV{'form.title'} - $coursecode - section: $ENV{'form.section'}</font><br />
648: <font color="$fontcolor">Subject: </font><font color="$vlinkcolor">$ENV{'form.subject'}</font><br />
649: <font color="$fontcolor">Description: </font><font color="$vlinkcolor">$descrip</font><br />
650: <font color="$fontcolor">URL: </font><font color="$vlinkcolor">$ENV{'form.sourceurl'}</font><br />
651: <font color="$fontcolor">Date/Time: </font><font color="$vlinkcolor">$reporttime</font><br />
652: |;
653: $r->print(<<"END");
654: <html>
655: <head>
656: <title>LON-CAPA support request recorded</title>
657: </head>
658: $bodytag
659: <form name="logproblem">
660: <input type="hidden" name="action" value="result" />
661: </form>
662: END
663: if ($r->uri eq '/adm/helpdesk') {
664: &print_header($r,$url,'process');
665: }
666: if ($to =~ m/^[^\@]+\@[^\@]+$/) {
667: $r->print("<h3>A support request has been sent to $to</h3>");
668: } else {
669: $to = $admin;
670: if ($to =~ m/^[^\@]+\@[^\@]+$/) {
671: $r->print("<h3>A support request has been sent to $to</h3>");
672: END
673: } else {
674: $r->print(<<END);
675: <h3>Warning: Problem with support e-mail address</h3>
676: 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 <b>not</b> 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.
677: END
678: $to = 'helpdesk@lon-capa.org';
679: }
680: }
681: if (defined($ENV{'form.email'})) {
682: if ($ENV{'form.email'} =~ m/^[^\@]+\@[^\@]+$/) {
683: $from = $ENV{'form.email'};
684: }
685: }
686:
687: my $subject = $ENV{'form.subject'};
688: $subject =~ s#(`)#'#g;
689: $subject =~ s#\$#\(\$\)#g;
690: $supportmsg =~ s#(`)#'#g;
691: $supportmsg =~ s#\$#\(\$\)#g;
692: $displaymsg =~ s#(`)#'#g;
693: $displaymsg =~ s#\$#\(\$\)#g;
694: my $fname;
695:
696: my $attachmentpath = '';
697: my $attachmentsize = '';
698: if (defined($ENV{'user.name'})) {
699: if ($ENV{'form.screenshot.filename'}) {
700: $attachmentsize = length($ENV{'form.screenshot'});
701: if ($attachmentsize > 131072) {
702: $displaymsg .= "<br />The uploaded screenshot file ($attachmentsize bytes) included with your request exceeded the maximum allowed size - 128 KB, and has therefore been discarded.";
703: } else {
704: $attachmentpath=&Apache::lonnet::userfileupload('screenshot',undef,'helprequests');
705: }
706: }
707: }
708:
709: if ($attachmentpath =~ m-/([^/]+)$-) {
710: $fname = $1;
711: $displaymsg .= "<br />An uploaded screenshot file - $fname ($attachmentsize bytes) was included in the request sent by $ENV{'user.name'} from LON-CAPA domain: $ENV{'user.domain'}";
712: $supportmsg .= "\n";
713: foreach (@envvars) {
714: $supportmsg .= "$_: $ENV{$_}\n";
715: }
716: }
717:
718: my $msg = MIME::Lite->new(
719: From => $from,
720: To => $to,
721: Subject => $subject,
722: Type =>'TEXT',
723: Data => $supportmsg,
724: );
725:
726: if ($attachmentpath) {
727: my ($type, $encoding) = MIME::Types::by_suffix($attachmentpath);
728: $msg->attach(Type => $type,
729: Path => $attachmentpath,
730: Filename => $fname
731: );
732:
733: } else {
734: my $envdata = '';
735: foreach (@envvars) {
736: $envdata .= "$_: $ENV{$_}\n";
737: }
738: foreach (@loncvars) {
739: $envdata .= "$_: $ENV{$_}\n";
740: }
741: $msg->attach(Type => 'TEXT',
742: Data => $envdata);
743: }
744:
745: ### Send it:
746: # ->send can cause an sh launch which can pass all of %ENV along
747: # which can be to large for /bin/sh's little mind
748: my %oldENV=%ENV;
749: undef(%ENV);
750: $msg->send('sendmail');
751: %ENV=%oldENV;
752: undef(%oldENV);
753:
754: if ($attachmentpath =~ m#$Apache::lonnet::perlvar{'lonDaemons'}/tmp/helprequests/(\d+)/[^/]+#) {
755: unlink($attachmentpath);
756: }
757: $r->print(qq|
758: <b>Your support request contained the following information</b>:<br /><br />
759: <table width="580" border="0" cellpadding="0" cellspacing="0" bgcolor="#000000">
760: <tr>
761: <td>
762: <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
763: <tr>
764: <td>
765: <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff">
766: <tr>
767: <td>
768: <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#ffffff">
769: <tr>
770: <td width="140" bgcolor="$tablecolor">
771: <table width="140" border="0" cellpadding="8" cellspacing="0">
772: <tr>
773: <td align="right"><b>Information supplied</b>
774: </td>
775: </tr>
776: </table>
777: </td>
778: <td width="100%" valign="top">
779: <table width="100%" border="0" cellpadding="8" cellspacing="0">
780: <tr>
781: <td>$displaymsg</td>
782: </tr>
783: </table>
784: </td>
785: </tr>
786: <tr>
787: <td width="100%" colspan="2" bgcolor="#000000">
788: <img src="/adm/lonMisc/blackdot.gif" /><br />
789: </td>
790: </tr>
791: <tr>
792: <td width="140" bgcolor="$tablecolor">
793: <table width="140" border="0" cellpadding="8" cellspacing="0">
794: <tr>
795: <td align="right"><b>Additional information recorded</b>
796: </td>
797: </tr>
798: </table>
799: </td>
800: <td width="100%" valign="top">
801: <table width="100%" border="0" cellpadding="8" cellspacing="0">
802: <tr>
803: <td>
804: |);
805: foreach (@envvars) {
806: unless($ENV{$_} eq '') {
807: $r->print("$_: <font color='$vlinkcolor'>$ENV{$_}</font>, ");
808: }
809: }
810: $r->print("
811: </td>
812: </tr>
813: </table>
814: </td>
815: </tr>
816: </table>
817: </td>
818: </tr>
819: </table>
820: </td>
821: </tr>
822: </table>
823: </td>
824: </tr>
825: </table>
826: </body>
827: </html>
828: ");
829: }
830:
831: sub print_header {
832: my ($r,$origurl,$action) = @_;
833: my $location=&Apache::loncommon::lonhttpdurl("/adm");
834: my $tablecolor = '#EEEE99';
835: my ($component_url);
836: my $helpdesk_link = '<a href="javascript:validate()">';
837: if ($action eq 'process') {
838: $helpdesk_link = '<a href="/adm/helpdesk">';
839: }
840: my %lt = &Apache::lonlocal::texthash (
841: login => 'Log-in help',
842: ask => 'Ask helpdesk',
843: getst => 'Getting started guide',
844: back => 'Back to last location'
845: );
846: my ($getstartlink,$getstarttext);
847: if (-e $Apache::lonnet::perlvar{'lonDocRoot'}.'/adm/gettingstarted.html') {
848: $getstartlink = qq|<td align="center"> <b><a href="/adm/gettingstarted.html">$lt{'getst'}</a></td>|;
849: $getstarttext = ' '.&mt('and the "Getting started" guide').' ';
850: }
851: $r->print(<<END);
852: <table width="620" border="0" cellspacing="0" cellpadding="0" height="55"> <tr height="50"> <td width='5'> </td>
853: <td>
854: <fieldset><legend><img src="$location/lonIcons/minilogo.gif" height='20' width='29' valign='bottom' /> <b><font size="+1">LON-CAPA help/support</font></b></legend>
855: <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#000000">
856: <tr>
857: <td>
858: <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
859: <tr>
860: <td>
861: <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff">
862: <tr>
863: <td>
864: <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#ffffff">
865: <tr bgcolor="$tablecolor">
866: <td align="center"><img src="$location/help/gif/smallHelp.gif" border="0" alt="(Login help)" valign="middle" /> <b><a href="/adm/loginproblems.html">$lt{'login'}</a></td>
867: <td align="center"> <b>$helpdesk_link<img src="$location/lonIcons/helpdesk.gif" border="0" alt="(Ask helpdesk)" valign="middle" /> $lt{'ask'}</a></b> </td>$getstartlink
868: <td align="center"> <b><a href="$origurl" target="_top"><img src="$location/lonIcons/move_up.gif" border="0" alt="(Back to last location)" valign="middle" /> $lt{'back'}</a></b> </td>
869: </tr>
870: </table>
871: </td>
872: </tr>
873: </table>
874: </td>
875: </tr>
876: </table>
877: </td>
878: </tr>
879: </table>
880: </fieldset>
881: </td>
882: <td width='5'> </td>
883: </tr>
884: <tr height='5'>
885: <td colspan='3' height='5'> </td>
886: </tr>
887: END
888: unless ($action eq 'process') {
889: $r->print('
890: <tr>
891: <td colspan="3">'.&mt('
892: 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').'.<br /><font size="-1"><b>'.&mt('Note').':</b> '.&mt('Student questions about course content should be directed to the course instructor').'.</font><br /><br />
893: </td>
894: </tr>');
895: }
896: $r->print('
897: </table>');
898: return;
899: }
900:
901: sub retrieve_instcodes {
902: my ($coursecodes,$codedom,$totcodes) = @_;
903: my %courses = &Apache::lonnet::courseiddump($codedom,'.',1,'.','.');
904: foreach my $course (keys %courses) {
905: if ($courses{$course} =~ m/^[^:]*:([^:]+)/) {
906: $$coursecodes{$course} = &Apache::lonnet::unescape($1);
907: $totcodes ++;
908: }
909: }
910: return $totcodes;
911: }
912:
913: sub build_code_selections {
914: my ($codes,$codetitles,$cat_titles,$cat_order,$idlist,$idnums,$idlist_titles) = @_;
915: my %idarrays = ();
916: for (my $i=1; $i<@{$codetitles}; $i++) {
917: %{$idarrays{$$codetitles[$i]}} = ();
918: }
919: foreach my $cid (sort keys %{$codes}) {
920: &recurse_list($cid,$codetitles,$codes,0,\%idarrays);
921: }
922: for (my $num=0; $num<@{$codetitles}; $num++) {
923: if ($num == 0) {
924: my @contents = ();
925: my @contents_titles = ();
926: &sort_cats($num,$cat_order,$codetitles,\@{$idarrays{$$codetitles[0]}},\@contents);
927: if (defined($$cat_titles{$$codetitles[0]})) {
928: foreach (@contents) {
929: push @contents_titles, $$cat_titles{$$codetitles[0]}{$_};
930: }
931: }
932: $$idlist{$$codetitles[0]} = join('","',@contents);
933: $$idnums{$$codetitles[0]} = scalar(@contents);
934: if (defined($$cat_titles{$$codetitles[0]})) {
935: $$idlist_titles{$$codetitles[0]} = join('","',@contents_titles);
936: }
937: } elsif ($num == 1) {
938: %{$$idlist{$$codetitles[1]}} = ();
939: %{$$idlist_titles{$$codetitles[1]}} = ();
940: foreach my $key_a (keys %{$idarrays{$$codetitles[1]}}) {
941: my @sorted_a = ();
942: my @sorted_a_titles = ();
943: &sort_cats($num,$cat_order,$codetitles,\@{$idarrays{$$codetitles[1]}{$key_a}},\@sorted_a);
944: if (defined($$cat_titles{$$codetitles[1]})) {
945: foreach (@sorted_a) {
946: push @sorted_a_titles, $$cat_titles{$$codetitles[1]}{$_};
947: }
948: }
949: $$idlist{$$codetitles[1]}{$key_a} = join('","',@sorted_a);
950: $$idnums{$$codetitles[1]}{$key_a} = scalar(@sorted_a);
951: if (defined($$cat_titles{$$codetitles[1]})) {
952: $$idlist_titles{$$codetitles[1]}{$key_a} = join('","',@sorted_a_titles);
953: }
954: }
955: } elsif ($num == 2) {
956: %{$$idlist{$$codetitles[2]}} = ();
957: %{$$idlist_titles{$$codetitles[2]}} = ();
958: foreach my $key_a (keys %{$idarrays{$$codetitles[2]}}) {
959: %{$$idlist{$$codetitles[2]}{$key_a}} = ();
960: %{$$idlist_titles{$$codetitles[2]}{$key_a}} = ();
961: foreach my $key_b (keys %{$idarrays{$$codetitles[2]}{$key_a}}) {
962: my @sorted_b = ();
963: my @sorted_b_titles = ();
964: &sort_cats($num,$cat_order,$codetitles,\@{$idarrays{$$codetitles[2]}{$key_a}{$key_b}},\@sorted_b);
965: if (defined($$cat_titles{$$codetitles[2]})) {
966: foreach (@sorted_b) {
967: push @sorted_b_titles, $$cat_titles{$$codetitles[2]}{$_};
968: }
969: }
970: $$idlist{$$codetitles[2]}{$key_a}{$key_b} = join('","',@sorted_b);
971: $$idnums{$$codetitles[2]}{$key_a}{$key_b} = scalar(@sorted_b);
972: if (defined($$cat_titles{$$codetitles[2]})) {
973: $$idlist_titles{$$codetitles[2]}{$key_a}{$key_b} = join('","',@sorted_b_titles);
974: }
975: }
976: }
977: } elsif ($num == 3) {
978: %{$$idlist{$$codetitles[3]}} = ();
979: foreach my $key_a (keys %{$idarrays{$$codetitles[3]}}) {
980: %{$$idlist{$$codetitles[3]}{$key_a}} = ();
981: foreach my $key_b (keys %{$idarrays{$$codetitles[3]}{$key_a}}) {
982: %{$$idlist{$$codetitles[3]}{$key_a}{$key_b}} = ();
983: foreach my $key_c (keys %{$idarrays{$$codetitles[3]}{$key_a}{$key_b}}) {
984: my @sorted_c = ();
985: my @sorted_c_titles = ();
986: &sort_cats($num,$cat_order,$codetitles,\@{$idarrays{$$codetitles[3]}{$key_a}{$key_b}{$key_c}},\@sorted_c);
987: if (defined($$cat_titles{$$codetitles[3]})) {
988: foreach (@sorted_c) {
989: push @sorted_c_titles, $$cat_titles{$$codetitles[3]}{$_};
990: }
991: }
992: $$idlist{$$codetitles[3]}{$key_a}{$key_b}{$key_c} = join('","',@sorted_c);
993: $$idnums{$$codetitles[3]}{$key_a}{$key_b}{$key_c} = scalar(@sorted_c);
994: if (defined($$cat_titles{$$codetitles[3]})) {
995: $$idlist_titles{$$codetitles[2]}{$key_a}{$key_b} = join('","',@sorted_c_titles);
996: }
997: }
998: }
999: }
1000: } elsif ($num == 4) {
1001: %{$$idlist{$$codetitles[4]}} = ();
1002: foreach my $key_a (keys %{$idarrays{$$codetitles[4]}}) {
1003: %{$$idlist{$$codetitles[4]}{$key_a}} = ();
1004: foreach my $key_b (keys %{$idarrays{$$codetitles[4]}{$key_a}}) {
1005: %{$$idlist{$$codetitles[4]}{$key_a}{$key_b}} = ();
1006: foreach my $key_c (keys %{$idarrays{$$codetitles[4]}{$key_a}{$key_b}}) {
1007: %{$$idlist{$$codetitles[4]}{$key_a}{$key_b}{$key_c}} = ();
1008: foreach my $key_d (keys %{$idarrays{$$codetitles[4]}{$key_a}{$key_b}{$key_c}}) {
1009: my @sorted_d = ();
1010: my @sorted_d_titles = ();
1011: &sort_cats($num,$cat_order,$codetitles,$idarrays{$$codetitles[4]}{$key_a}{$key_b}{$key_c}{$key_d},\@sorted_d);
1012: if (defined($$cat_titles{$$codetitles[4]})) {
1013: foreach (@sorted_d) {
1014: push @sorted_d_titles, $$cat_titles{$$codetitles[4]}{$_};
1015: }
1016: }
1017: $$idlist{$$codetitles[4]}{$key_a}{$key_b}{$key_c}{$key_d} = join('","',@sorted_d);
1018: $$idnums{$$codetitles[4]}{$key_a}{$key_b}{$key_c}{$key_d} = scalar(@sorted_d);
1019: }
1020: }
1021: }
1022: }
1023: }
1024: }
1025: }
1026:
1027: sub sort_cats {
1028: my ($num,$cat_order,$codetitles,$idsarrayref,$sorted) = @_;
1029: my @unsorted = @{$idsarrayref};
1030: if (defined($$cat_order{$$codetitles[$num]})) {
1031: foreach (@{$$cat_order{$$codetitles[$num]}}) {
1032: if (grep/^$_$/,@unsorted) {
1033: push @{$sorted}, $_;
1034: }
1035: }
1036: } else {
1037: @{$sorted} = sort (@unsorted);
1038: }
1039: }
1040:
1041:
1042: sub recurse_list {
1043: my ($cid,$codetitles,$codes,$num,$idarrays) = @_;
1044: if ($num == 0) {
1045: if (!grep/^$$codes{$cid}{$$codetitles[0]}$/,@{$$idarrays{$$codetitles[0]}}) {
1046: push @{$$idarrays{$$codetitles[0]}}, $$codes{$cid}{$$codetitles[0]};
1047: }
1048: } elsif ($num == 1) {
1049: if (defined($$idarrays{$$codetitles[1]}{$$codes{$cid}{$$codetitles[0]}})) {
1050: if (!grep/^$$codes{$cid}{$$codetitles[1]}$/,@{$$idarrays{$$codetitles[1]}{$$codes{$cid}{$$codetitles[0]}}}) {
1051: push @{$$idarrays{$$codetitles[1]}{$$codes{$cid}{$$codetitles[0]}}}, $$codes{$cid}{$$codetitles[1]};
1052: }
1053: } else {
1054: @{$$idarrays{$$codetitles[1]}{$$codes{$cid}{$$codetitles[0]}}} = ("$$codes{$cid}{$$codetitles[1]}");
1055: }
1056: } elsif ($num == 2) {
1057: if (defined($$idarrays{$$codetitles[2]}{$$codes{$cid}{$$codetitles[0]}})) {
1058: if (defined($$idarrays{$$codetitles[2]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}})) {
1059: if (!grep/^$$codes{$cid}{$$codetitles[2]}$/,@{$$idarrays{$$codetitles[2]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}}) {
1060: push @{$$idarrays{$$codetitles[2]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}}, $$codes{$cid}{$$codetitles[2]};
1061: }
1062: } else {
1063: @{$$idarrays{$$codetitles[2]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}} = ("$$codes{$cid}{$$codetitles[2]}");
1064: }
1065: } else {
1066: %{$$idarrays{$$codetitles[2]}{$$codes{$cid}{$$codetitles[0]}}} = ();
1067: @{$$idarrays{$$codetitles[2]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}} = ("$$codes{$cid}{$$codetitles[2]}");
1068: }
1069: } elsif ($num == 3) {
1070: if (defined($$idarrays{$$codetitles[3]}{$$codes{$cid}{$$codetitles[0]}})) {
1071: if (defined($$idarrays{$$codetitles[3]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}})) {
1072: if (defined($$idarrays{$$codetitles[3]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}})) {
1073: if (!grep/^$$codes{$cid}{$$codetitles[3]}$/,@{$$idarrays{$$codetitles[3]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}}}) {
1074: push @{$$idarrays{$$codetitles[3]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}}}, $$codes{$cid}{$$codetitles[3]};
1075: }
1076: } else {
1077: @{$$idarrays{$$codetitles[3]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}}} = ("$$codes{$cid}{$$codetitles[3]}");
1078: }
1079: } else {
1080: %{$$idarrays{$$codetitles[3]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}} = ();
1081: @{$$idarrays{$$codetitles[3]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}}} = ("$$codes{$cid}{$$codetitles[3]}");
1082: }
1083: } else {
1084: %{$$idarrays{$$codetitles[3]}{$$codes{$cid}{$$codetitles[0]}}} = ();
1085: %{$$idarrays{$$codetitles[3]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}} = ();
1086: @{$$idarrays{$$codetitles[3]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}}} = ("$$codes{$cid}{$$codetitles[3]}");
1087: }
1088: } elsif ($num == 4) {
1089: if (defined($$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}})) {
1090: if (defined($$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}})) {
1091: if (defined($$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}})) {
1092: if (defined($$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}}{$$codes{$cid}{$$codetitles[3]}})) {
1093: if (!grep/^$$codes{$cid}{$$codetitles[4]}$/,@{$$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}}{$$codes{$cid}{$$codetitles[3]}}}) {
1094: push @{$$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}}{$$codes{$cid}{$$codetitles[3]}}}, $$codes{$cid}{$$codetitles[4]};
1095: }
1096: } else {
1097: @{$$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}}{$$codes{$cid}{$$codetitles[3]}}} = ("$$codes{$cid}{$$codetitles[4]}");
1098: }
1099: } else {
1100: %{$$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}}} = ();
1101: @{$$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}}{$$codes{$cid}{$$codetitles[3]}}} = ("$$codes{$cid}{$$codetitles[4]}");
1102: }
1103: } else {
1104: %{$$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}} = ();
1105: %{$$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}}} = ();
1106: @{$$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}}{$$codes{$cid}{$$codetitles[3]}}} = ("$$codes{$cid}{$$codetitles[4]}");
1107: }
1108: } else {
1109: %{$$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}} = ();
1110: %{$$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}} = ();
1111: %{$$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}}} = ();
1112: @{$$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[3]}}} = ("$$codes{$cid}{$$codetitles[3]}");
1113: }
1114: }
1115: $num ++;
1116: if ($num <@{$codetitles}) {
1117: &recurse_list($cid,$codetitles,$codes,$num,$idarrays);
1118: }
1119: }
1120:
1121: sub javascript_code_selections {
1122: my ($numcats,$cat_titles,$script_tag,$idlist,$idnums,$idlist_titles,$codetitles) = @_;
1123: my $numtitles = @{$codetitles};
1124: my @seltitles = ();
1125: for (my $j=0; $j<$numtitles; $j++) {
1126: $seltitles[$j] = 'id'.$$codetitles[$j];
1127: }
1128: my $seltitle_str = join('","',@seltitles);
1129: my @longtitles = ();
1130: for (my $i=0; $i<$numtitles; $i++) {
1131: if (defined($$cat_titles{$$codetitles[$i]})) {
1132: $longtitles[$i] = 1;
1133: } else {
1134: $longtitles[$i] = 0;
1135: }
1136: }
1137: my $longtitles_str = join('","',@longtitles);
1138: $$script_tag .= <<END;
1139: function courseSet(caller) {
1140: var ids = new Array ("$seltitle_str");
1141: var formitems = new Array ($numtitles);
1142: var longtitles = new Array ("$longtitles_str");
1143: var idyr = document.logproblem.Year.selectedIndex
1144: var idsem = document.logproblem.Semester.selectedIndex
1145: var iddept = document.logproblem.Department.selectedIndex
1146: var idclass = document.logproblem.Number.selectedIndex
1147: var idyears = new Array("$$idlist{$$codetitles[0]}");
1148: END
1149: if ($longtitles[0]) {
1150: $$script_tag .=
1151: qq| var idyearslongs = new Array("$$idlist_titles{$$codetitles[0]}")\n|;
1152: }
1153: $$script_tag .=
1154: " var idsems = new Array ($$idnums{$$codetitles[0]})\n";
1155: if ($longtitles[1]) {
1156: $$script_tag .=
1157: " var idsemslongs = new Array ($$idnums{$$codetitles[0]})\n";
1158: }
1159: $$script_tag .=
1160: " var idcodes = new Array ($$idnums{$$codetitles[0]})\n";
1161: if ($longtitles[2]) {
1162: $$script_tag .=
1163: " var idcodeslongs = new Array ($$idnums{$$codetitles[0]})\n";
1164: }
1165: $$script_tag .=
1166: " var idcourses = new Array ($$idnums{$$codetitles[0]})\n";
1167: if ($longtitles[3]) {
1168: $$script_tag .=
1169: " var idcourseslongs = new Array ($$idnums{$$codetitles[0]})\n";
1170: }
1171: my @sort_a = split/","/,$$idlist{$$codetitles[0]};
1172: for (my $j=0; $j<@sort_a; $j++) {
1173: $$script_tag .= qq| idsems[$j] = new Array("$$idlist{$$codetitles[1]}{$sort_a[$j]}")\n|;
1174: if ($longtitles[1]) {
1175: $$script_tag .= qq| idsemslongs[$j] = new Array("$$idlist_titles{$$codetitles[1]}{$sort_a[$j]}")\n|;
1176: }
1177: $$script_tag .= qq| idcodes[$j] = new Array($$idnums{$$codetitles[1]}{$sort_a[$j]})\n|;
1178: if ($longtitles[2]) {
1179: $$script_tag .= qq| idcodeslongs[$j] = new Array($$idnums{$$codetitles[1]}{$sort_a[$j]})\n|;
1180: }
1181: $$script_tag .= qq| idcourses[$j] = new Array($$idnums{$$codetitles[1]}{$sort_a[$j]})\n|;
1182: if ($longtitles[3]) {
1183: $$script_tag .= qq| idcourseslongs[$j] = new Array($$idnums{$$codetitles[1]}{$sort_a[$j]})\n|;
1184: }
1185: my @sort_b = split/","/,$$idlist{$$codetitles[1]}{$sort_a[$j]};
1186: for (my $k=0; $k<@sort_b; $k++) {
1187: my $idcode_entry = $$idlist{$$codetitles[2]}{$sort_a[$j]}{$sort_b[$k]};
1188: $$script_tag .= qq| idcodes[$j][$k] = new Array("$idcode_entry")\n|;
1189: if ($longtitles[2]) {
1190: my $idcodelong_entry = $$idlist_titles{$$codetitles[2]}{$sort_a[$j]}{$sort_b[$k]};
1191: $$script_tag .= qq| idcodeslongs[$j][$k] = new Array("$idcodelong_entry")\n|;
1192: }
1193: $$script_tag .= qq| idcourses[$j][$k] = new Array($$idnums{$$codetitles[2]}{$sort_a[$j]}{$sort_b[$k]})\n|;
1194: if ($longtitles[3]) {
1195: $$script_tag .= qq| idcourseslongs[$j][$k] = new Array($$idnums{$$codetitles[2]}{$sort_a[$j]}{$sort_b[$k]})\n|;
1196: }
1197: my @sort_c = split/","/,$$idlist{$$codetitles[2]}{$sort_a[$j]}{$sort_b[$k]};
1198: for (my $l=0; $l<@sort_c; $l++) {
1199: my $idcourse_entry = $$idlist{$$codetitles[3]}{$sort_a[$j]}{$sort_b[$k]}{$sort_c[$l]};
1200: $$script_tag .= qq| idcourses[$j][$k][$l] = new Array("$idcourse_entry")\n|;
1201: if ($longtitles[3]) {
1202: my $idcourselong_entry = $$idlist_titles{$$codetitles[3]}{$sort_a[$j]}{$sort_b[$k]}{$sort_c[$l]};
1203: $$script_tag .= qq| idcourseslongs[$j][$k][$l] = new Array("$idcourselong_entry")\n|;
1204: }
1205: }
1206: }
1207: }
1208: $$script_tag .= (<<END_OF_BLOCK);
1209: if (caller == "$$codetitles[0]") {
1210: document.logproblem.Department.length = 0
1211: document.logproblem.Number.length = 0
1212: document.logproblem.Department.options[0] = new Option("<-Pick $$codetitles[1]","-1",true,true)
1213: document.logproblem.Number.options[0] = new Option("<-Pick $$codetitles[2]","-1",true,true)
1214: if (idyr == 0) {
1215: document.logproblem.Semester.length = 0
1216: document.logproblem.Semester.options[0] = new Option("<-Pick $$codetitles[0]","-1",true,true)
1217: }
1218: else {
1219: document.logproblem.Semester.length = 0
1220: document.logproblem.Semester.options[0] = new Option("Select","-1",true,true)
1221: for (var i=0; i<idsems[idyr-1].length; i++) {
1222: if (longtitles[1] == 1) {
1223: document.logproblem.Semester.options[i+1] = new Option(idsemslongs[idyr-1][i],idsems[idyr-1][i],false,false)
1224: }
1225: else {
1226: document.logproblem.Semester.options[i+1] = new Option(idsems[idyr-1][i],idsems[idyr-1][i],false,false)
1227: }
1228: }
1229: }
1230: document.logproblem.Semester.selectedIndex = 0;
1231: }
1232: if (caller == "$$codetitles[1]") {
1233: document.logproblem.Department.length = 0
1234: document.logproblem.Number.length = 0
1235: document.logproblem.Number.options[0] = new Option("<-Pick $$codetitles[2]","-1",true,true)
1236: if (idsem == 0) {
1237: document.logproblem.Department.options[0] = new Option("<-Pick $$codetitles[1]","-1",true,true)
1238: }
1239: else {
1240: document.logproblem.Department.options[0] = new Option("Select","-1",true,true)
1241: for (var i=0; i<idcodes[idyr-1][idsem-1].length; i++) {
1242: if (longtitles[2] == 1) {
1243: document.logproblem.Department.options[i+1] = new Option(idcodeslongs[idyr-1][idsem-1][i],idcodes[idyr-1][idsem-1][i],false,false)
1244: }
1245: else {
1246: document.logproblem.Department.options[i+1] = new Option(idcodes[idyr-1][idsem-1][i],idcodes[idyr-1][idsem-1][i],false,false)
1247: }
1248: }
1249: }
1250: document.logproblem.Department.selectedIndex = 0
1251: }
1252: if (caller == "$$codetitles[2]") {
1253: document.logproblem.Number.length = 0
1254: if (iddept == 0) {
1255: document.logproblem.Number.options[0] = new Option("<-Pick $$codetitles[2]","-1",true,true)
1256: }
1257: else {
1258: document.logproblem.Number.options[0] = new Option("Select","-1",true,true)
1259: for (var i=0; i<idcourses[idyr-1][idsem-1][iddept-1].length; i++) {
1260: if (longtitles[3] == 1) {
1261: document.logproblem.Number.options[i+1] = new Option(idcourseslongs[idyr-1][idsem-1][iddept-1][i],idcourses[idyr-1][idsem-1][iddept-1][i],false,false)
1262: }
1263: else {
1264: document.logproblem.Number.options[i+1] = new Option(idcourses[idyr-1][idsem-1][iddept-1][i],idcourses[idyr-1][idsem-1][iddept-1][i],false,false)
1265: }
1266: }
1267: }
1268: document.logproblem.Number.selectedIndex = 0
1269: }
1270: }
1271: END_OF_BLOCK
1272: }
1273:
1274: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>