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