Annotation of loncom/interface/lonsupportreq.pm, revision 1.12
1.1 raeburn 1: package Apache::lonsupportreq;
2:
3: use strict;
4: use lib qw(/home/httpd/lib/perl);
1.5 raeburn 5: use MIME::Types;
6: use MIME::Lite;
1.1 raeburn 7: use Apache::Constants qw(:common);
1.2 albertel 8: use Apache::loncommon();
9: use Apache::lonnet();
1.1 raeburn 10: use Apache::lonlocal;
11:
12: sub handler {
1.2 albertel 13: my ($r) = @_;
14: &Apache::loncommon::content_type($r,'text/html');
1.1 raeburn 15: $r->send_http_header;
16:
17: if ($r->header_only) {
18: return OK;
19: }
1.12 ! raeburn 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: }
1.1 raeburn 24: my $function = $ENV{'form.function'};
25: my $origurl = &Apache::lonnet::unescape($ENV{'form.origurl'});
1.12 ! raeburn 26: my $action = $ENV{'form.action'};
! 27:
1.1 raeburn 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');
1.5 raeburn 41: if (($tablecolor eq '') || ($tablecolor eq '#FFFFFF')) {
42: $tablecolor = '#CCCCFF';
43: }
1.10 raeburn 44: $ccode = '';
1.1 raeburn 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: $server = $ENV{'SERVER_NAME'};
1.5 raeburn 56: my $scripttag = (<<END);
57: function validate() {
58: if (document.logproblem.email.value.indexOf("\@") == -1) {
59: alert("You must enter a valid e-mail address");
60: return
61: }
62: document.logproblem.submit();
63: }
64: END
1.1 raeburn 65: if ($cid =~ m/_/) {
66: ($cdom,$cnum) = split/_/,$cid;
67: }
68: if ($cdom && $cnum) {
69: my %csettings = &Apache::lonnet::get('environment',['description','internal.coursecode','internal.sectionnums'],$cdom,$cnum);
70: $ctitle = $csettings{'description'};
71: $ccode = $csettings{'internal.coursecode'};
72: $sectionlist = $csettings{'internal.sectionnums'};
73: }
74: if ($ENV{'environment.critnotification'}) {
75: $email = $ENV{'environment.critnotification'};
76: }
77: if (!$email && $ENV{'environment.notification'}) {
78: $email = $ENV{'environment.notification'};
79: }
80: if ($ENV{'environment.lastname'}) {
81: $lastname = $ENV{'environment.lastname'};
82: }
83: if ($ENV{'environment.firstname'}) {
84: $firstname = $ENV{'environment.firstname'};
85: }
86: my @sections = split/,/,$sectionlist;
87: my %groupid = ();
88: foreach (@sections) {
89: my ($sec,$grp) = split/:/,$_;
90: $groupid{$sec} = $grp;
91: }
92: my $defdom = $Apache::lonnet::perlvar{'lonDefDomain'};
93: my $codedom = $defdom;
94: my %coursecodes = ();
95: my %codes = ();
96: my @codetitles = ();
97: my %cat_titles = ();
98: my %cat_order = ();
1.6 raeburn 99: my %idlist = ();
100: my %idnums = ();
101: my %idlist_titles = ();
1.1 raeburn 102: my $caller = 'global';
103: my $totcodes = 0;
104: my $format_reply;
1.6 raeburn 105: my $jscript = '';
1.1 raeburn 106:
107: if ($cdom) {
108: $codedom = $cdom;
109: }
110: if ($cnum) {
111: $coursecodes{$cnum} = $ccode;
112: if ($ccode eq '') {
113: $totcodes = &retrieve_instcodes(\%coursecodes,$codedom,$totcodes);
114: } else {
115: $coursecodes{$cnum} = $ccode;
116: $caller = $cnum;
117: $totcodes ++;
118: }
119: } else {
120: $totcodes = &retrieve_instcodes(\%coursecodes,$codedom,$totcodes);
121: }
122: if ($totcodes > 0) {
123: $format_reply = &Apache::lonnet::auto_instcode_format($caller,$codedom,\%coursecodes,\%codes,\@codetitles,\%cat_titles,\%cat_order);
1.6 raeburn 124: if ($ccode eq '') {
125: my $numtypes = @codetitles;
126: &build_code_selections(\%codes,\@codetitles,\%cat_titles,\%cat_order,\%idlist,\%idnums,\%idlist_titles);
127: &javascript_code_selections($numtypes,\$jscript,\%idlist,\%idnums,\%idlist_titles,\@codetitles);
128: }
1.1 raeburn 129: }
130: $r->print(<<END);
131: <html>
132: <head>
133: <title>LON-CAPA support request</title>
1.6 raeburn 134: <script>
1.1 raeburn 135: $scripttag
1.6 raeburn 136: $jscript
137: </script>
1.1 raeburn 138: </head>
139: $bodytag
140: <table width="580" border="0" cellpadding="0" cellspacing="0" bgcolor="#000000">
141: <tr>
142: <td>
143: <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
144: <tr>
145: <td>
146: <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff">
147: <tr>
148: <td>
149: <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#ffffff">
1.5 raeburn 150: <form method="post" name="logproblem" enctype="multipart/form-data">
1.1 raeburn 151: <tr>
152: <td width="140" bgcolor="$tablecolor">
153: <table width="140" border="0" cellpadding="8" cellspacing="0">
154: <tr>
155: <td align="right"><b>Name:</b>
156: </td>
157: </tr>
158: </table>
159: </td>
160: <td width="100%" valign="top">
161: <table width="100%" border="0" cellpadding="8" cellspacing="0">
162: <tr>
163: <td>
164: END
165: my $fullname = '';
166: if ((defined($lastname) && $lastname ne '') && (defined($firstname) && $firstname ne '')) {
167: $fullname = "$firstname $lastname";
168: $r->print("$fullname<input type=\"hidden\" name=\"username\" value=\"$fullname\" />");
169: } else {
170: if (defined($firstname) && $firstname ne '') {
171: $fullname = $firstname;
172: } elsif (defined($lastname) && $lastname ne '') {
173: $fullname= " $lastname";
174: }
175: $r->print('<input type="text" size="20" name="username" value="'.$fullname.'" /><br />');
176: }
177: $r->print(<<END);
178: </td>
179: </tr>
180: </table>
181: </td>
182: </tr>
183: <tr>
184: <td width="100%" colspan="2" bgcolor="#000000">
1.3 albertel 185: <img src="/adm/lonMisc/blackdot.gif" /><br />
1.1 raeburn 186: </td>
187: </tr>
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>E-mail address:</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: <input type="text" size="20" name="email" value="$email" /><br />
202: </td>
203: </tr>
204: </table>
205: </td>
206: </tr>
207: <tr>
208: <td width="100%" colspan="2" bgcolor="#000000">
1.3 albertel 209: <img src="/adm/lonMisc/blackdot.gif" /><br />
1.1 raeburn 210: </td>
211: </tr>
212: <tr>
213: <td width="140" bgcolor="$tablecolor">
214: <table width="140" border="0" cellpadding="8" cellspacing="0">
215: <tr>
216: <td align="right"><b>username/domain:</b>
217: </td>
218: </tr>
219: </table>
220: </td>
221: <td width="100%" valign="top">
222: <table width="100%" border="0" cellpadding="8" cellspacing="0">
223: <tr>
224: <td>
225: END
226: my $udom_input = '<input type="hidden" name="udom" value="'.$udom.'" />';
227: my $uname_input = '<input type="hidden" name="uname" value="'.$uname.'" />';
228: if (defined($uname) && defined($udom)) {
229: $r->print('<i>username</i>: '.$uname.' <i>domain</i>: '.$udom.$udom_input.$uname_input);
230: } else {
231: my $udomform = '';
232: my $unameform = '';
233: if (defined($udom)) {
234: $udomform = '<i>domain</i>: '.$udom.$udom_input;
235: } elsif (defined($uname)) {
236: $unameform = '<i>username</i>: '.$uname.' '.$uname_input;
237: }
238: if ($udomform eq '') {
239: $udomform = '<i>domain</i>: ';
240: $udomform .= &Apache::loncommon::select_dom_form('','udom');
241: }
242: if ($unameform eq '') {
243: $unameform= '<i>username</i>: <input type="text" size="20" name="loncname" value="'.$uname.'" /> ';
244: }
245: $r->print($unameform.$udomform.'<br />Enter the username you use to log-in to your LON-CAPA system, and choose your domain.');
246: }
247: $r->print(<<END);
248: </td>
249: </tr>
250: </table>
251: </td>
252: </tr>
253: <tr>
254: <td width="100%" colspan="2" bgcolor="#000000">
1.3 albertel 255: <img src="/adm/lonMisc/blackdot.gif" /><br />
1.1 raeburn 256: </td>
257: </tr>
258: <tr>
259: <td width="140" bgcolor="$tablecolor">
260: <table width="140" border="0" cellpadding="8" cellspacing="0">
261: <tr>
262: <td align="right"><b>URL of page:</b>
263: </td>
264: </tr>
265: </table>
266: </td>
267: <td width="100%" valign="top">
268: <table width="100%" border="0" cellpadding="8" cellspacing="0">
269: <tr>
270: <td>
1.5 raeburn 271: http://$server$origurl<input type="hidden" name="origurl" value="http://$server$origurl" />
1.1 raeburn 272: </td>
273: </tr>
274: </table>
275: </td>
276: </tr>
277: <tr>
278: <td width="100%" colspan="2" bgcolor="#000000">
1.3 albertel 279: <img src="/adm/lonMisc/blackdot.gif" /><br />
1.1 raeburn 280: </td>
281: </tr>
282: <tr>
283: <td width="140" bgcolor="$tablecolor">
284: <table width="140" border="0" cellpadding="8" cellspacing="0">
285: <tr>
286: <td align="right"><b>Phone #:</b>
287: </td>
288: </tr>
289: </table>
290: </td>
291: <td width="100%" valign="top">
292: <table width="100%" border="0" cellpadding="8" cellspacing="0">
293: <tr>
294: <td>
295: <input type="text" size="15" name="phone"><br>
296: </td>
297: </tr>
298: </table>
299: </td>
300: </tr>
301: <tr>
302: <td width="100%" colspan="2" bgcolor="#000000">
1.3 albertel 303: <img src="/adm/lonMisc/blackdot.gif" /><br />
1.1 raeburn 304: </td>
305: </tr>
306: <tr>
307: <td width="140" bgcolor="$tablecolor">
308: <table width="140" border="0" cellpadding="8" cellspacing="0">
309: <tr>
310: <td align="right"><b>Course Details:</b>
311: </td>
312: </tr>
313: </table>
314: </td>
315: <td width="100%" valign="top">
316: <table border="0" cellpadding="3" cellspacing="3">
317: <tr>
318: <td>
319: END
1.10 raeburn 320: if ($cnum) {
321: if ($coursecodes{$cnum}) {
322: foreach (@codetitles) {
323: $r->print('<i>'.$_.'</i>: '.$codes{$cnum}{$_}.'; ');
324: }
325: $r->print(' <input type="hidden" name="coursecode" value="'.$coursecodes{$cnum}.'" />');
326: } else {
327: $r->print('Enter institutional course code:
328: <input type="text" name="coursecode" size="15" value="" />');
1.1 raeburn 329: }
330: } else {
1.10 raeburn 331: if ($totcodes > 0) {
332: my $numtitles = @codetitles;
333: if ($numtitles == 0) {
334: $r->print('Enter institutional course code:
1.1 raeburn 335: <input type="text" name="coursecode" size="15" value="" />');
1.10 raeburn 336: } else {
337: my $lasttitle = $numtitles;
338: if ($numtitles > 4) {
339: $lasttitle = 4;
340: }
341: $r->print('<table><tr><td>'.$codetitles[0].'<br />'."\n".
342: '<select name="'.$codetitles[0].'" onChange="courseSet('."'$codetitles[0]'".')">'."\n".
343: ' <option value="-1" />Select'."\n");
344: my @items = ();
345: if ($idlist{$codetitles[0]} =~ /","/) {
346: @items = split/","/,$idlist{$codetitles[0]};
347: } else {
348: $items[0] = $idlist{$codetitles[0]};
349: }
350: foreach (@items) {
351: $r->print(' <option value="'.$_.'" />'.$_);
352: }
353: $r->print('</select></td>');
354: for (my $i=1; $i<$numtitles; $i++) {
355: $r->print('<td>'.$codetitles[$i].'<br />'."\n".
356: '<select name="'.$codetitles[$i].'" onChange="courseSet('."'$codetitles[$i]'".')">'."\n".
357: '<option value="-1"><-Pick '.$codetitles[$i-1].'</option>'."\n".
358: '</select>'."\n".
359: '</td>'
360: );
361: }
362: $r->print('</tr></table>');
363: if ($numtitles > 4) {
364: $r->print('<br /><br />'.$codetitles[$numtitles].'<br />'."\n".
365: '<select name="'.$codetitles[$numtitles].'" onChange="courseSet('."'$codetitles[$numtitles]'".')">'."\n".
366: '<option value="-1"><-Pick '.$codetitles[$numtitles-1].'</option>'."\n".
367: '</select>'."\n");
368: }
369: }
370: } else {
371: $r->print('Enter institutional course code:
372: <input type="text" name="coursecode" size="15" value="" />');
373: }
1.1 raeburn 374: }
375: if ($ctitle) {
376: $r->print('<br /><i>Title</i>: '.$ctitle.'<input type="hidden" name="title" value="'.$ctitle.'" />');
377: } else {
378: $r->print('<br />Enter course title:
1.10 raeburn 379: <input type="text" name="title" size="25" value="" />');
1.1 raeburn 380: }
381: $r->print(<<END);
382: </td>
383: </tr>
384: </table>
385: </td>
386: </tr>
387: <tr>
388: <td width="100%" colspan="2" bgcolor="#000000">
1.3 albertel 389: <img src="/adm/lonMisc/blackdot.gif" /><br />
1.1 raeburn 390: </td>
391: </tr>
392: <tr>
393: <td width="140" bgcolor="$tablecolor">
394: <table width="140" border="0" cellpadding="8" cellspacing="0">
395: <tr>
396: <td align="right"><b>Section Number: </b>
397: </td>
398: </tr>
399: </table>
400: </td>
401: <td width="100%" valign="top">
402: <table width="100%" border="0" cellpadding="8" cellspacing="0">
403: <tr>
404: <td>
405: END
406: if ($sectionlist) {
407: $r->print("<select name=\"section\">");
408: foreach (sort keys %groupid) {
409: if ($_ eq $groupid{$_} || $groupid{$_} eq '') {
410: $r->print("<option value=\"$_\" />$_");
411: } else {
1.5 raeburn 412: $r->print("<option value=\"$_\" />$_ - (LON-CAPA sec: $groupid{$_})");
1.1 raeburn 413: }
414: }
415: $r->print("</select>");
416: } else {
417: $r->print("<input type=\"text\" name=\"section\" size=\"10\"/>");
418: }
419: $r->print(<<END);
420: </td>
421: </tr>
422: </table>
423: </td>
424: </tr>
425: <tr>
426: <td width="100%" colspan="2" bgcolor="#000000">
1.3 albertel 427: <img src="/adm/lonMisc/blackdot.gif" /><br />
1.1 raeburn 428: </td>
429: </tr>
430: <tr>
431: <td width="140" bgcolor="$tablecolor">
432: <table width="140" border="0" cellpadding="8" cellspacing="0">
433: <tr>
434: <td align="right"><b>Subject</b>
435: </td>
436: </tr>
437: </table>
438: </td>
439: <td width="100%" valign="top">
440: <table width="100%" border="0" cellpadding="8" cellspacing="0">
441: <tr>
442: <td>
443: <input type="text" size="40" name="subject">
444: </td>
445: </tr>
446: </table>
447: </td>
448: </tr>
449: <tr>
450: <td width="100%" colspan="2" bgcolor="#000000">
1.3 albertel 451: <img src="/adm/lonMisc/blackdot.gif" /><br />
1.1 raeburn 452: </td>
453: </tr>
454: <tr>
455: <td width="140" bgcolor="$tablecolor">
456: <table width="140" border="0" cellpadding="8" cellspacing="0">
457: <tr>
458: <td align="right"><b>Detailed description:</b>
459: </td>
460: </tr>
461: </table>
462: </td>
463: <td width="100%" valign="top">
464: <table width="100%" border="0" cellpadding="8" cellspacing="0">
465: <tr>
466: <td>
467: <textarea rows="10" cols="45" name="description" wrap="virtual"></textarea>
468: </td>
469: </tr>
470: </table>
471: </td>
472: </tr>
473: <tr>
474: <td width="100%" colspan="2" bgcolor="#000000">
1.3 albertel 475: <img src="/adm/lonMisc/blackdot.gif" /><br />
1.1 raeburn 476: </td>
477: </tr>
1.5 raeburn 478: END
479: if (defined($ENV{'user.name'})) {
480: $r->print(<<END);
481: <tr>
482: <td width="140" bgcolor="$tablecolor">
483: <table width="140" border="0" cellpadding="8" cellspacing="0">
484: <tr>
485: <td align="right"><b>Optional file upload:</b>
486: </td>
487: </tr>
488: </table>
489: </td>
490: <td width="100%" valign="top">
491: <table width="100%" border="0" cellpadding="8" cellspacing="0">
492: <tr>
493: <td>
494: <input type="file" name="screenshot" size="20" /><br />Upload a file (e.g., a screenshot) relevant to your support request (128 KB max. size).
495: </td>
496: </tr>
497: </table>
498: </td>
499: </tr>
500: <tr>
501: <td width="100%" colspan="2" bgcolor="#000000">
502: <img src="/adm/lonMisc/blackdot.gif" /><br />
503: </td>
504: </tr>
505: END
506: }
507: $r->print(<<END);
1.1 raeburn 508: <tr>
509: <td width="140" bgcolor="$tablecolor">
510: <table width="140" border="0" cellpadding="8" cellspacing="0">
511: <tr>
512: <td align="right"><b>Finish:</b>
513: </td>
514: </tr>
515: </table>
516: </td>
517: <td width="100%" valign="top">
518: <table border="0" cellpadding="8" cellspacing="0">
519: <tr>
520: <td>
521: <input type="hidden" name="action" value="process" />
1.5 raeburn 522: <input type="button" value="Submit Request Form" onClick="validate()"/>
1.1 raeburn 523: </td>
524: <td> </td>
525: <td>
526: <input type="reset" value="Clear Form">
527: </td>
528: </tr>
529: </table>
530: </td>
531: </tr>
532: </table>
533: </td>
534: </tr>
535: </table>
536: </td>
537: </tr>
538: </table>
539: </td>
540: </tr>
541: </table>
542: END
1.5 raeburn 543: return;
1.1 raeburn 544: }
545:
546: sub print_request_receipt {
547: my ($r,$url,$function) = @_;
548: my @envvars = ('lonID','HTTP_HOST','HTTP_USER_AGENT','REMOTE_ADDR','SERVER_ADDR','SERVER_NAME','browser.os','browser.type','browser.version','user.home','request.role');
1.5 raeburn 549: my @loncvars = ('user.name','user.domain','request.course.sec','request.course.id');
550:
1.1 raeburn 551: my $bodytag = &Apache::loncommon::bodytag('',$function,'topmargin="0" marginheight="0"',1);
1.5 raeburn 552: my $admin = $Apache::lonnet::perlvar{'lonAdminMail'};
1.1 raeburn 553: my $to = $Apache::lonnet::perlvar{'lonSupportEMail'};
1.5 raeburn 554: my $from = $admin;
1.1 raeburn 555: my $reporttime = &Apache::lonlocal::locallocaltime(time);
556: my $fontcolor = &Apache::loncommon::designparm($function.'.font');
557: my $vlinkcolor = &Apache::loncommon::designparm($function.'.vlink');
558: my $tablecolor = &Apache::loncommon::designparm($function.'.tabbg');
1.5 raeburn 559: my @formvars = ('username','email','uname','udom','origurl','phone','section','coursecode','title','subject','description','screenshot');
1.1 raeburn 560: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},\@formvars);
561:
562: my $supportmsg = qq|
563: Name: $ENV{'form.username'}
564: Email: $ENV{'form.email'}
565: Username/domain: $ENV{'form.uname'} - $ENV{'form.udom'}
566: Tel: $ENV{'form.phone'}
567: Course Information: $ENV{'form.title'} - $ENV{'form.coursecode'} - section: $ENV{'form.section'}
568: Subject: $ENV{'form.subject'}
569: Description: $ENV{'form.description'}
570: URL: $ENV{'form.origurl'}
571: Date/Time: $reporttime
572:
573: |;
1.5 raeburn 574: my $descrip = $ENV{'form.description'};
575: $descrip =~ s#\n#<br />#g;
576: my $displaymsg = qq|
577: <font color="$fontcolor">Name:</font><font color="$vlinkcolor"> $ENV{'form.username'}</font><br />
578: <font color="$fontcolor">Email: </font><font color="$vlinkcolor">$ENV{'form.email'}</font><br />
579: <font color="$fontcolor">Username/domain: </font><font color="$vlinkcolor">$ENV{'form.uname'} - $ENV{'form.udom'}</font><br />
580: <font color="$fontcolor">Tel: </font><font color="$vlinkcolor">$ENV{'form.phone'}</font><br />
581: <font color="$fontcolor">Course Information: </font><font color="$vlinkcolor">$ENV{'form.title'} - $ENV{'form.coursecode'} - section: $ENV{'form.section'}</font><br />
582: <font color="$fontcolor">Subject: </font><font color="$vlinkcolor">$ENV{'form.subject'}</font><br />
583: <font color="$fontcolor">Description: </font><font color="$vlinkcolor">$descrip</font><br />
584: <font color="$fontcolor">URL: </font><font color="$vlinkcolor">$ENV{'form.origurl'}</font><br />
585: <font color="$fontcolor">Date/Time: </font><font color="$vlinkcolor">$reporttime</font><br />
586: |;
587:
1.1 raeburn 588: if ($to =~ m/^[^\@]+\@[^\@]+$/) {
589: $r->print(<<END);
590: <html>
591: <head>
592: <title>LON-CAPA support request recorded</title>
593: </head>
594: $bodytag
595: <h3>A support request has been sent to $to</h3>
596: END
1.9 raeburn 597: } else {
598: $to = $admin;
599: if ($to =~ m/^[^\@]+\@[^\@]+$/) {
600: $r->print(<<END);
601: <html>
602: <head>
603: <title>LON-CAPA support request recorded</title>
604: </head>
605: $bodytag
606: <h3>A support request has been sent to $to</h3>
607: END
608: } else {
609: $r->print(<<END);
1.1 raeburn 610: <html>
611: <head>
612: <title>LON-CAPA support request recorded</title>
613: </head>
614: $bodytag
615: <h3>Warning: Problem with support e-mail address</h3>
1.9 raeburn 616: 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.
1.1 raeburn 617: END
1.9 raeburn 618: $to = 'helpdesk@lon-capa.org';
619: }
1.1 raeburn 620: }
1.5 raeburn 621: if (defined($ENV{'form.email'})) {
622: if ($ENV{'form.email'} =~ m/^[^\@]+\@[^\@]+$/) {
623: $from = $ENV{'form.email'};
624: }
625: }
626:
627: my $subject = $ENV{'form.subject'};
628: $subject =~ s#(`)#'#g;
629: $subject =~ s#\$#\(\$\)#g;
630: $supportmsg =~ s#(`)#'#g;
631: $supportmsg =~ s#\$#\(\$\)#g;
632: $displaymsg =~ s#(`)#'#g;
633: $displaymsg =~ s#\$#\(\$\)#g;
634: my $fname;
635:
636: my $attachmentpath = '';
637: my $attachmentsize = '';
638: if (defined($ENV{'user.name'})) {
639: if ($ENV{'form.screenshot.filename'}) {
640: $attachmentsize = length($ENV{'form.screenshot'});
641: if ($attachmentsize > 131072) {
642: $displaymsg .= "<br />The uploaded screenshot file ($attachmentsize bytes) included with your request exceeded the maximum allowed size - 128 KB, and has therefore been discarded.";
643: } else {
644: $attachmentpath=&Apache::lonnet::userfileupload('screenshot',undef,'helprequests');
645: }
646: }
647: }
648:
649: if ($attachmentpath =~ m-/([^/]+)$-) {
650: $fname = $1;
651: $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'}";
652: $supportmsg .= "\n";
653: foreach (@envvars) {
654: $supportmsg .= "$_: $ENV{$_}\n";
655: }
656: }
657:
658: my $msg = MIME::Lite->new(
659: From => $from,
660: To => $to,
661: Subject => $subject,
662: Type =>'TEXT',
663: Data => $supportmsg,
664: );
665:
666: if ($attachmentpath) {
667: my ($type, $encoding) = MIME::Types::by_suffix($attachmentpath);
668: $msg->attach(Type => $type,
669: Path => $attachmentpath,
670: Filename => $fname
671: );
672:
673: } else {
674: my $envdata = '';
675: foreach (@envvars) {
676: $envdata .= "$_: $ENV{$_}\n";
677: }
678: foreach (@loncvars) {
679: $envdata .= "$_: $ENV{$_}\n";
680: }
681: $msg->attach(Type => 'TEXT',
682: Data => $envdata);
683: }
684:
685: ### Send it:
686: # ->send can cause an sh launch which can pass all of %ENV along
1.4 albertel 687: # which can be to large for /bin/sh's little mind
688: my %oldENV=%ENV;
689: undef(%ENV);
1.5 raeburn 690: $msg->send('sendmail');
1.4 albertel 691: %ENV=%oldENV;
692: undef(%oldENV);
1.5 raeburn 693:
694: if ($attachmentpath =~ m#$Apache::lonnet::perlvar{'lonDaemons'}/tmp/helprequests/(\d+)/[^/]+#) {
695: unlink($attachmentpath);
696: }
697: $r->print(qq|
1.1 raeburn 698: <b>Your support request contained the following information</b>:<br /><br />
699: <table width="580" border="0" cellpadding="0" cellspacing="0" bgcolor="#000000">
700: <tr>
701: <td>
702: <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
703: <tr>
704: <td>
705: <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff">
706: <tr>
707: <td>
708: <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#ffffff">
709: <tr>
710: <td width="140" bgcolor="$tablecolor">
711: <table width="140" border="0" cellpadding="8" cellspacing="0">
712: <tr>
713: <td align="right"><b>Information supplied</b>
714: </td>
715: </tr>
716: </table>
717: </td>
718: <td width="100%" valign="top">
719: <table width="100%" border="0" cellpadding="8" cellspacing="0">
720: <tr>
1.5 raeburn 721: <td>$displaymsg</td>
1.1 raeburn 722: </tr>
723: </table>
724: </td>
725: </tr>
726: <tr>
1.5 raeburn 727: <td width="100%" colspan="2" bgcolor="#000000">
728: <img src="/adm/lonMisc/blackdot.gif" /><br />
729: </td>
730: </tr>
731: <tr>
732: <td width="140" bgcolor="$tablecolor">
733: <table width="140" border="0" cellpadding="8" cellspacing="0">
1.1 raeburn 734: <tr>
735: <td align="right"><b>Additional information recorded</b>
736: </td>
737: </tr>
738: </table>
739: </td>
740: <td width="100%" valign="top">
741: <table width="100%" border="0" cellpadding="8" cellspacing="0">
742: <tr>
743: <td>
1.5 raeburn 744: |);
1.1 raeburn 745: foreach (@envvars) {
1.5 raeburn 746: unless($ENV{$_} eq '') {
747: $r->print("$_: <font color='$vlinkcolor'>$ENV{$_}</font>, ");
748: }
1.1 raeburn 749: }
750: $r->print("
751: </td>
752: </tr>
753: </table>
754: </td>
755: </tr>
756: </table>
757: </td>
758: </tr>
759: </table>
760: </td>
761: </tr>
762: </table>
763: </td>
764: </tr>
765: </table>
766: ");
767: }
768:
769: sub retrieve_instcodes {
770: my ($coursecodes,$codedom,$totcodes) = @_;
1.11 raeburn 771: my %courses = &Apache::lonnet::courseiddump($codedom,'.',1,'.','.');
1.1 raeburn 772: foreach my $course (keys %courses) {
1.11 raeburn 773: if ($courses{$course} =~ m/^[^:]*:([^:]+)/) {
1.1 raeburn 774: $$coursecodes{$course} = &Apache::lonnet::unescape($1);
775: $totcodes ++;
776: }
777: }
778: return $totcodes;
779: }
780:
1.6 raeburn 781: sub build_code_selections {
782: my ($codes,$codetitles,$cat_titles,$cat_order,$idlist,$idnums,$idlist_titles) = @_;
783: my %idarrays = ();
784: for (my $i=1; $i<@{$codetitles}; $i++) {
785: %{$idarrays{$$codetitles[$i]}} = ();
786: }
787: foreach my $cid (sort keys %{$codes}) {
788: &recurse_list($cid,$codetitles,$codes,0,\%idarrays);
789: }
790: for (my $num=0; $num<@{$codetitles}; $num++) {
791: if ($num == 0) {
792: my @contents = ();
793: my @contents_titles = ();
794: &sort_cats($num,$cat_order,$codetitles,\@{$idarrays{$$codetitles[0]}},\@contents);
795: if (defined($$cat_titles{$$codetitles[0]})) {
796: foreach (@contents) {
797: push @contents_titles, $$cat_titles{$$codetitles[0]}{$_};
798: }
799: }
800: $$idlist{$$codetitles[0]} = join('","',@contents);
801: $$idnums{$$codetitles[0]} = scalar(@contents);
802: if (defined($$cat_titles{$$codetitles[0]})) {
803: $$idlist_titles{$$codetitles[0]} = join('","',@contents_titles);
804: }
805: } elsif ($num == 1) {
806: %{$$idlist{$$codetitles[1]}} = ();
807: %{$$idlist_titles{$$codetitles[1]}} = ();
808: foreach my $key_a (keys %{$idarrays{$$codetitles[1]}}) {
809: my @sorted_a = ();
810: my @sorted_a_titles = ();
811: &sort_cats($num,$cat_order,$codetitles,\@{$idarrays{$$codetitles[1]}{$key_a}},\@sorted_a);
812: if (defined($$cat_titles{$$codetitles[1]})) {
813: foreach (@sorted_a) {
814: push @sorted_a_titles, $$cat_titles{$$codetitles[1]}{$_};
815: }
816: }
817: $$idlist{$$codetitles[1]}{$key_a} = join('","',@sorted_a);
818: $$idnums{$$codetitles[1]}{$key_a} = scalar(@sorted_a);
819: if (defined($$cat_titles{$$codetitles[1]})) {
820: $$idlist_titles{$$codetitles[1]}{$key_a} = join('","',@sorted_a_titles);
821: }
822: }
823: } elsif ($num == 2) {
824: %{$$idlist{$$codetitles[2]}} = ();
825: %{$$idlist_titles{$$codetitles[2]}} = ();
826: foreach my $key_a (keys %{$idarrays{$$codetitles[2]}}) {
827: %{$$idlist{$$codetitles[2]}{$key_a}} = ();
828: %{$$idlist_titles{$$codetitles[2]}{$key_a}} = ();
829: foreach my $key_b (keys %{$idarrays{$$codetitles[2]}{$key_a}}) {
830: my @sorted_b = ();
831: my @sorted_b_titles = ();
832: &sort_cats($num,$cat_order,$codetitles,\@{$idarrays{$$codetitles[2]}{$key_a}{$key_b}},\@sorted_b);
833: if (defined($$cat_titles{$$codetitles[1]})) {
834: foreach (@sorted_b) {
835: push @sorted_b_titles, $$cat_titles{$$codetitles[1]}{$_};
836: }
837: }
838: $$idlist{$$codetitles[2]}{$key_a}{$key_b} = join('","',@sorted_b);
839: $$idnums{$$codetitles[2]}{$key_a}{$key_b} = scalar(@sorted_b);
840: if (defined($$cat_titles{$$codetitles[2]})) {
841: $$idlist_titles{$$codetitles[2]}{$key_a}{$key_b} = join('","',@sorted_b_titles);
842: }
843: }
844: }
845: } elsif ($num == 3) {
846: %{$$idlist{$$codetitles[3]}} = ();
847: foreach my $key_a (keys %{$idarrays{$$codetitles[3]}}) {
848: %{$$idlist{$$codetitles[3]}{$key_a}} = ();
849: foreach my $key_b (keys %{$idarrays{$$codetitles[3]}{$key_a}}) {
850: %{$$idlist{$$codetitles[3]}{$key_a}{$key_b}} = ();
851: foreach my $key_c (keys %{$idarrays{$$codetitles[3]}{$key_a}{$key_b}}) {
852: my @sorted_c = ();
853: &sort_cats($num,$cat_order,$codetitles,\@{$idarrays{$$codetitles[3]}{$key_a}{$key_b}{$key_c}},\@sorted_c);
854: $$idlist{$$codetitles[3]}{$key_a}{$key_b}{$key_c} = join('","',@sorted_c);
855: $$idnums{$$codetitles[3]}{$key_a}{$key_b}{$key_c} = scalar(@sorted_c);
856: }
857: }
858: }
859: } elsif ($num == 4) {
860: %{$$idlist{$$codetitles[4]}} = ();
861: foreach my $key_a (keys %{$idarrays{$$codetitles[4]}}) {
862: %{$$idlist{$$codetitles[4]}{$key_a}} = ();
863: foreach my $key_b (keys %{$idarrays{$$codetitles[4]}{$key_a}}) {
864: %{$$idlist{$$codetitles[4]}{$key_a}{$key_b}} = ();
865: foreach my $key_c (keys %{$idarrays{$$codetitles[4]}{$key_a}{$key_b}}) {
866: %{$$idlist{$$codetitles[4]}{$key_a}{$key_b}{$key_c}} = ();
867: foreach my $key_d (keys %{$idarrays{$$codetitles[4]}{$key_a}{$key_b}{$key_c}}) {
868: my @sorted_d = ();
869: &sort_cats($num,$cat_order,$codetitles,$idarrays{$$codetitles[4]}{$key_a}{$key_b}{$key_c}{$key_d},\@sorted_d);
870: $$idlist{$$codetitles[4]}{$key_a}{$key_b}{$key_c}{$key_d} = join('","',@sorted_d);
871: $$idnums{$$codetitles[4]}{$key_a}{$key_b}{$key_c}{$key_d} = scalar(@sorted_d);
872: }
873: }
874: }
875: }
876: }
877: }
878: }
879:
880: sub sort_cats {
881: my ($num,$cat_order,$codetitles,$idsarrayref,$sorted) = @_;
882: my @unsorted = @{$idsarrayref};
883: if (defined($$cat_order{$$codetitles[$num]})) {
884: foreach (@{$$cat_order{$$codetitles[$num]}}) {
885: if (grep/^$_$/,@unsorted) {
886: push @{$sorted}, $_;
887: }
888: }
889: } else {
890: @{$sorted} = sort (@unsorted);
891: }
892: }
893:
894:
895: sub recurse_list {
896: my ($cid,$codetitles,$codes,$num,$idarrays) = @_;
897: if ($num == 0) {
898: if (!grep/^$$codes{$cid}{$$codetitles[0]}$/,@{$$idarrays{$$codetitles[0]}}) {
899: push @{$$idarrays{$$codetitles[0]}}, $$codes{$cid}{$$codetitles[0]};
900: }
901: } elsif ($num == 1) {
902: if (defined($$idarrays{$$codetitles[1]}{$$codes{$cid}{$$codetitles[0]}})) {
903: if (!grep/^$$codes{$cid}{$$codetitles[1]}$/,@{$$idarrays{$$codetitles[1]}{$$codes{$cid}{$$codetitles[0]}}}) {
904: push @{$$idarrays{$$codetitles[1]}{$$codes{$cid}{$$codetitles[0]}}}, $$codes{$cid}{$$codetitles[1]};
905: }
906: } else {
907: @{$$idarrays{$$codetitles[1]}{$$codes{$cid}{$$codetitles[0]}}} = ("$$codes{$cid}{$$codetitles[1]}");
908: }
909: } elsif ($num == 2) {
910: if (defined($$idarrays{$$codetitles[2]}{$$codes{$cid}{$$codetitles[0]}})) {
911: if (defined($$idarrays{$$codetitles[2]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}})) {
912: if (!grep/^$$codes{$cid}{$$codetitles[2]}$/,@{$$idarrays{$$codetitles[2]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}}) {
913: push @{$$idarrays{$$codetitles[2]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}}, $$codes{$cid}{$$codetitles[2]};
914: }
915: } else {
916: @{$$idarrays{$$codetitles[2]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}} = ("$$codes{$cid}{$$codetitles[2]}");
917: }
918: } else {
919: %{$$idarrays{$$codetitles[2]}{$$codes{$cid}{$$codetitles[0]}}} = ();
920: @{$$idarrays{$$codetitles[2]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}} = ("$$codes{$cid}{$$codetitles[2]}");
921: }
922: } elsif ($num == 3) {
923: if (defined($$idarrays{$$codetitles[3]}{$$codes{$cid}{$$codetitles[0]}})) {
924: if (defined($$idarrays{$$codetitles[3]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}})) {
925: if (defined($$idarrays{$$codetitles[3]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}})) {
926: if (!grep/^$$codes{$cid}{$$codetitles[3]}$/,@{$$idarrays{$$codetitles[3]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}}}) {
927: push @{$$idarrays{$$codetitles[3]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}}}, $$codes{$cid}{$$codetitles[3]};
928: }
929: } else {
930: @{$$idarrays{$$codetitles[3]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}}} = ("$$codes{$cid}{$$codetitles[3]}");
931: }
932: } else {
933: %{$$idarrays{$$codetitles[3]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}} = ();
934: @{$$idarrays{$$codetitles[3]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}}} = ("$$codes{$cid}{$$codetitles[3]}");
935: }
936: } else {
937: %{$$idarrays{$$codetitles[3]}{$$codes{$cid}{$$codetitles[0]}}} = ();
938: %{$$idarrays{$$codetitles[3]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}} = ();
939: @{$$idarrays{$$codetitles[3]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}}} = ("$$codes{$cid}{$$codetitles[3]}");
940: }
941: } elsif ($num == 4) {
942: if (defined($$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}})) {
943: if (defined($$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}})) {
944: if (defined($$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}})) {
945: if (defined($$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}}{$$codes{$cid}{$$codetitles[3]}})) {
946: 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]}}}) {
947: push @{$$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}}{$$codes{$cid}{$$codetitles[3]}}}, $$codes{$cid}{$$codetitles[4]};
948: }
949: } else {
950: @{$$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}}{$$codes{$cid}{$$codetitles[3]}}} = ("$$codes{$cid}{$$codetitles[4]}");
951: }
952: } else {
953: %{$$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}}} = ();
954: @{$$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}}{$$codes{$cid}{$$codetitles[3]}}} = ("$$codes{$cid}{$$codetitles[4]}");
955: }
956: } else {
957: %{$$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}} = ();
958: %{$$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}}} = ();
959: @{$$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}}{$$codes{$cid}{$$codetitles[3]}}} = ("$$codes{$cid}{$$codetitles[4]}");
960: }
961: } else {
962: %{$$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}} = ();
963: %{$$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}} = ();
964: %{$$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}}} = ();
965: @{$$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[3]}}} = ("$$codes{$cid}{$$codetitles[3]}");
966: }
967: }
968: $num ++;
969: if ($num <@{$codetitles}) {
970: &recurse_list($cid,$codetitles,$codes,$num,$idarrays);
971: }
972: }
973:
974: sub javascript_code_selections {
975: my ($numcats,$script_tag,$idlist,$idnums,$idlist_titles,$codetitles) = @_;
1.10 raeburn 976: my $numtitles = @{$codetitles};
977: my @seltitles = ();
978: for (my $j=0; $j<$numtitles; $j++) {
979: $seltitles[$j] = 'id'.$$codetitles[$j];
980: }
981: my $seltitle_str = join('","',@seltitles);
1.6 raeburn 982: $$script_tag .= <<END;
983: function courseSet(caller) {
1.10 raeburn 984: var ids = new Array ("$seltitle_str");
985: var formitems = new Array ($numtitles);
986: var idyr = document.forms.logproblem.Year.selectedIndex
987: var idsem = document.forms.logproblem.Semester.selectedIndex
988: var iddept = document.forms.logproblem.Department.selectedIndex
989: var idclass = document.forms.logproblem.Number.selectedIndex
1.6 raeburn 990: var idyears = new Array("$$idlist{$$codetitles[0]}");
991: var idsems = new Array ($$idnums{$$codetitles[0]});
992: var idsemlongs = new Array ($$idnums{$$codetitles[0]});
993: var idcodes = new Array ($$idnums{$$codetitles[0]});
994: var idcourses = new Array ($$idnums{$$codetitles[0]});
995: END
996: my @sort_a = split/","/,$$idlist{$$codetitles[0]};
997: for (my $j=0; $j<@sort_a; $j++) {
998: $$script_tag .= qq| idsems[$j] = new Array("$$idlist{$$codetitles[1]}{$sort_a[$j]}")\n|;
999: $$script_tag .= qq| idsemlongs[$j] = new Array("$$idlist_titles{$$codetitles[1]}{$sort_a[$j]}")\n|;
1000: $$script_tag .= qq| idcodes[$j] = new Array($$idnums{$$codetitles[1]}{$sort_a[$j]})\n|;
1001: $$script_tag .= qq| idcourses[$j] = new Array($$idnums{$$codetitles[1]}{$sort_a[$j]})\n|;
1002: my @sort_b = split/","/,$$idlist{$$codetitles[1]}{$sort_a[$j]};
1003: for (my $k=0; $k<@sort_b; $k++) {
1004: my $idcode_entry = $$idlist{$$codetitles[2]}{$sort_a[$j]}{$sort_b[$k]};
1005: $$script_tag .= qq| idcodes[$j][$k] = new Array("$idcode_entry")\n|;
1006: $$script_tag .= qq| idcourses[$j][$k] = new Array($$idnums{$$codetitles[2]}{$sort_a[$j]}{$sort_b[$k]})\n|;
1007: my @sort_c = split/","/,$$idlist{$$codetitles[2]}{$sort_a[$j]}{$sort_b[$k]};
1008: for (my $l=0; $l<@sort_c; $l++) {
1009: my $idcourse_entry = $$idlist{$$codetitles[3]}{$sort_a[$j]}{$sort_b[$k]}{$sort_c[$l]};
1010: $$script_tag .= qq| idcourses[$j][$k][$l] = new Array("$idcourse_entry")\n|;
1011: }
1012: }
1013: }
1014: $$script_tag .= (<<END_OF_BLOCK);
1.10 raeburn 1015: if (caller == "Year") {
1016: document.forms.logproblem.Department.length = 0
1017: document.forms.logproblem.Number.length = 0
1018: document.forms.logproblem.Department.options[0] = new Option("<-Pick Semester.","-1",true,true)
1019: document.forms.logproblem.Number.options[0] = new Option("<-Pick Department","-1",true,true)
1.6 raeburn 1020: if (idyr == 0) {
1.10 raeburn 1021: document.forms.logproblem.Semester.length = 0
1022: document.forms.logproblem.Semester.options[0] = new Option("<-Pick Year","-1",true,true)
1.6 raeburn 1023: }
1024: else {
1.10 raeburn 1025: document.forms.logproblem.Semester.length = 0
1026: document.forms.logproblem.Semester.options[0] = new Option("Select","-1",true,true)
1.6 raeburn 1027: for (var i=0; i<idsems[idyr-1].length; i++) {
1.10 raeburn 1028: document.forms.logproblem.Semester.options[i+1] = new Option(idsemlongs[idyr-1][i],idsems[idyr-1][i],false,false)
1.6 raeburn 1029: }
1030: }
1.10 raeburn 1031: document.forms.logproblem.Semester.selectedIndex = 0;
1.6 raeburn 1032: }
1.10 raeburn 1033: if (caller == "Semester") {
1034: document.forms.logproblem.Department.length = 0
1035: document.forms.logproblem.Number.length = 0
1036: document.forms.logproblem.Number.options[0] = new Option("<-Pick Department.","-1",true,true)
1.6 raeburn 1037: if (idsem == 0) {
1.10 raeburn 1038: document.forms.logproblem.Department.options[0] = new Option("<-Pick Semester.","-1",true,true)
1039: document.forms.logproblem.Department.options[0] = new Option("<-Pick Semester","-1",true,true)
1.6 raeburn 1040: }
1041: else {
1.10 raeburn 1042: document.forms.logproblem.Department.options[0] = new Option("Select","-1",true,true)
1.6 raeburn 1043: for (var i=0; i<idcodes[idyr-1][idsem-1].length; i++) {
1.10 raeburn 1044: document.forms.logproblem.Department.options[i+1] = new Option(idcodes[idyr-1][idsem-1][i],idcodes[idyr-1][idsem-1][i],false,false)
1.6 raeburn 1045: }
1046: }
1.10 raeburn 1047: document.forms.logproblem.Department.selectedIndex = 0
1.6 raeburn 1048: }
1.10 raeburn 1049: if (caller == "Department") {
1050: document.forms.logproblem.Number.length = 0
1.6 raeburn 1051: if (iddept == 0) {
1.10 raeburn 1052: document.forms.logproblem.Number.options[0] = new Option("<-Pick Department.","-1",true,true)
1.6 raeburn 1053: }
1054: else {
1.10 raeburn 1055: document.forms.logproblem.Number.options[0] = new Option("Select","-1",true,true)
1.6 raeburn 1056: for (var i=0; i<idcourses[idyr-1][idsem-1][iddept-1].length; i++) {
1.10 raeburn 1057: document.forms.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)
1.6 raeburn 1058: }
1059: }
1.10 raeburn 1060: document.forms.logproblem.Number.selectedIndex = 0
1.6 raeburn 1061: }
1062: }
1063: END_OF_BLOCK
1064: }
1065:
1.1 raeburn 1066: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>