Annotation of loncom/interface/courseclassifier.pm, revision 1.3
1.1 raeburn 1: #
2: # Copyright Michigan State University Board of Trustees
3: #
4: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
5: #
6: # LON-CAPA is free software; you can redistribute it and/or modify
7: # it under the terms of the GNU General Public License as published by
8: # the Free Software Foundation; either version 2 of the License, or
9: # (at your option) any later version.
10: #
11: # LON-CAPA is distributed in the hope that it will be useful,
12: # but WITHOUT ANY WARRANTY; without even the implied warranty of
13: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14: # GNU General Public License for more details.
15: #
16: # You should have received a copy of the GNU General Public License
17: # along with LON-CAPA; if not, write to the Free Software
18: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA#
19: # /home/httpd/html/adm/gpl.txt
20: #
21: # http://www.lon-capa.org/
22: #
23:
24: package Apache::courseclassifier;
25:
26: use strict;
27: use lib '/home/httpd/lib/perl/';
28: use Apache::lonnet;
29: use LONCAPA;
30:
31: sub retrieve_instcodes {
1.2 raeburn 32: my ($coursecodes,$codedom) = @_;
33: my $totcodes;
1.1 raeburn 34: my %courses = &Apache::lonnet::courseiddump($codedom,'.',1,'.','.','.', undef,undef,'Course');
1.2 raeburn 35: foreach my $course (keys(%courses)) {
36: if (ref($courses{$course}) eq 'HASH') {
1.3 ! raeburn 37: $$coursecodes{$course} = $courses{$course}{'inst_code'};
1.1 raeburn 38: $totcodes ++;
39: }
40: }
41: return $totcodes;
42: }
43:
44: sub sort_cats {
45: my ($num,$cat_order,$codetitles,$idsarrayref,$sorted) = @_;
46: my @unsorted = @{$idsarrayref};
47: if (defined($$cat_order{$$codetitles[$num]})) {
48: foreach my $item (@{$$cat_order{$$codetitles[$num]}}) {
49: if (grep/^\Q$item\E$/,@unsorted) {
50: push @{$sorted}, $item;
51: }
52: }
53: } else {
54: @{$sorted} = sort (@unsorted);
55: }
56: }
57:
58: sub recurse_list {
59: my ($cid,$codetitles,$codes,$num,$idarrays) = @_;
60: if ($num == 0) {
61: if (!grep/^$$codes{$cid}{$$codetitles[0]}$/,@{$$idarrays{$$codetitles[0]}}) {
62: push @{$$idarrays{$$codetitles[0]}}, $$codes{$cid}{$$codetitles[0]};
63: }
64: } elsif ($num == 1) {
65: if (defined($$idarrays{$$codetitles[1]}{$$codes{$cid}{$$codetitles[0]}})) {
66: if (!grep/^$$codes{$cid}{$$codetitles[1]}$/,@{$$idarrays{$$codetitles[1]}{$$codes{$cid}{$$codetitles[0]}}}) {
67: push @{$$idarrays{$$codetitles[1]}{$$codes{$cid}{$$codetitles[0]}}}, $$codes{$cid}{$$codetitles[1]};
68: }
69: } else {
70: @{$$idarrays{$$codetitles[1]}{$$codes{$cid}{$$codetitles[0]}}} = ("$$codes{$cid}{$$codetitles[1]}");
71: }
72: } elsif ($num == 2) {
73: if (defined($$idarrays{$$codetitles[2]}{$$codes{$cid}{$$codetitles[0]}})) {
74: if (defined($$idarrays{$$codetitles[2]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}})) {
75: if (!grep/^$$codes{$cid}{$$codetitles[2]}$/,@{$$idarrays{$$codetitles[2]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}}) {
76: push @{$$idarrays{$$codetitles[2]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}}, $$codes{$cid}{$$codetitles[2]};
77: }
78: } else {
79: @{$$idarrays{$$codetitles[2]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}} = ("$$codes{$cid}{$$codetitles[2]}"); }
80: } else {
81: %{$$idarrays{$$codetitles[2]}{$$codes{$cid}{$$codetitles[0]}}} = ();
82: @{$$idarrays{$$codetitles[2]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}} = ("$$codes{$cid}{$$codetitles[2]}");
83: }
84: } elsif ($num == 3) {
85: if (defined($$idarrays{$$codetitles[3]}{$$codes{$cid}{$$codetitles[0]}})) {
86: if (defined($$idarrays{$$codetitles[3]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}})) {
87: if (defined($$idarrays{$$codetitles[3]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}})) {
88: if (!grep/^$$codes{$cid}{$$codetitles[3]}$/,@{$$idarrays{$$codetitles[3]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}}}) {
89: push @{$$idarrays{$$codetitles[3]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}}}, $$codes{$cid}{$$codetitles[3]};
90: }
91: } else {
92: @{$$idarrays{$$codetitles[3]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}}} = ("$$codes{$cid}{$$codetitles[3]}");
93: }
94: } else {
95: %{$$idarrays{$$codetitles[3]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}} = ();
96: @{$$idarrays{$$codetitles[3]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}}} = ("$$codes{$cid}{$$codetitles[3]}");
97: }
98: } else {
99: %{$$idarrays{$$codetitles[3]}{$$codes{$cid}{$$codetitles[0]}}} = ();
100: %{$$idarrays{$$codetitles[3]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}} = ();
101: @{$$idarrays{$$codetitles[3]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}}} = ("$$codes{$cid}{$$codetitles[3]}");
102: }
103: } elsif ($num == 4) {
104: if (defined($$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}})) {
105: if (defined($$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}})) {
106: if (defined($$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}})) {
107: if (defined($$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}}{$$codes{$cid}{$$codetitles[3]}})) {
108: 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]}}}) {
109: push @{$$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}}{$$codes{$cid}{$$codetitles[3]}}}, $$codes{$cid}{$$codetitles[4]};
110: }
111: } else {
112: @{$$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}}{$$codes{$cid}{$$codetitles[3]}}} = ("$$codes{$cid}{$$codetitles[4]}");
113: }
114: } else {
115: %{$$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}}} = ();
116: @{$$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}}{$$codes{$cid}{$$codetitles[3]}}} = ("$$codes{$cid}{$$codetitles[4]}");
117: }
118: } else {
119: %{$$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}} = ();
120: %{$$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}}} = (); @{$$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}}{$$codes{$cid}{$$codetitles[3]}}} = ("$$codes{$cid}{$$codetitles[4]}");
121: }
122: } else {
123: %{$$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}} = ();
124: %{$$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}} = ();
125: %{$$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}}} = ();
126: @{$$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[3]}}} = ("$$codes{$cid}{$$codetitles[3]}");
127: }
128: }
129: $num ++;
130: if ($num <@{$codetitles}) {
131: &recurse_list($cid,$codetitles,$codes,$num,$idarrays);
132: }
133: }
134:
135: sub build_code_selections {
136: my ($codes,$codetitles,$cat_titles,$cat_order,$idlist,$idnums,$idlist_titles) = @_;
137: my %idarrays = ();
138: for (my $i=1; $i<@{$codetitles}; $i++) {
139: %{$idarrays{$$codetitles[$i]}} = ();
140: }
141: foreach my $cid (sort keys %{$codes}) {
142: &recurse_list($cid,$codetitles,$codes,0,\%idarrays);
143: }
144: for (my $num=0; $num<@{$codetitles}; $num++) {
145: if ($num == 0) {
146: my @contents = ();
147: my @contents_titles = ();
148: &sort_cats($num,$cat_order,$codetitles,\@{$idarrays{$$codetitles[0]}},\@contents);
149: if (defined($$cat_titles{$$codetitles[0]})) {
150: foreach (@contents) {
151: push @contents_titles, $$cat_titles{$$codetitles[0]}{$_};
152: }
153: }
154: $$idlist{$$codetitles[0]} = join('","',@contents);
155: $$idnums{$$codetitles[0]} = scalar(@contents);
156: if (defined($$cat_titles{$$codetitles[0]})) {
157: $$idlist_titles{$$codetitles[0]} = join('","',@contents_titles);
158: }
159: } elsif ($num == 1) {
160: %{$$idlist{$$codetitles[1]}} = ();
161: %{$$idlist_titles{$$codetitles[1]}} = ();
162: foreach my $key_a (keys %{$idarrays{$$codetitles[1]}}) {
163: my @sorted_a = ();
164: my @sorted_a_titles = ();
165: &sort_cats($num,$cat_order,$codetitles,\@{$idarrays{$$codetitles[1]}{$key_a}},\@sorted_a);
166: if (defined($$cat_titles{$$codetitles[1]})) {
167: foreach (@sorted_a) {
168: push @sorted_a_titles, $$cat_titles{$$codetitles[1]}{$_};
169: }
170: }
171: $$idlist{$$codetitles[1]}{$key_a} = join('","',@sorted_a);
172: $$idnums{$$codetitles[1]}{$key_a} = scalar(@sorted_a);
173: if (defined($$cat_titles{$$codetitles[1]})) {
174: $$idlist_titles{$$codetitles[1]}{$key_a} = join('","',@sorted_a_titles);
175: }
176: }
177: } elsif ($num == 2) {
178: %{$$idlist{$$codetitles[2]}} = ();
179: %{$$idlist_titles{$$codetitles[2]}} = ();
180: foreach my $key_a (keys %{$idarrays{$$codetitles[2]}}) {
181: %{$$idlist{$$codetitles[2]}{$key_a}} = ();
182: %{$$idlist_titles{$$codetitles[2]}{$key_a}} = ();
183: foreach my $key_b (keys %{$idarrays{$$codetitles[2]}{$key_a}}) {
184: my @sorted_b = ();
185: my @sorted_b_titles = ();
186: &sort_cats($num,$cat_order,$codetitles,\@{$idarrays{$$codetitles[2]}{$key_a}{$key_b}},\@sorted_b);
187: if (defined($$cat_titles{$$codetitles[2]})) {
188: foreach (@sorted_b) {
189: push @sorted_b_titles, $$cat_titles{$$codetitles[2]}{$_};
190: }
191: }
192: $$idlist{$$codetitles[2]}{$key_a}{$key_b} = join('","',@sorted_b);
193: $$idnums{$$codetitles[2]}{$key_a}{$key_b} = scalar(@sorted_b);
194: if (defined($$cat_titles{$$codetitles[2]})) {
195: $$idlist_titles{$$codetitles[2]}{$key_a}{$key_b} = join('","',@sorted_b_titles);
196: }
197: }
198: }
199: } elsif ($num == 3) {
200: %{$$idlist{$$codetitles[3]}} = ();
201: foreach my $key_a (keys %{$idarrays{$$codetitles[3]}}) {
202: %{$$idlist{$$codetitles[3]}{$key_a}} = ();
203: foreach my $key_b (keys %{$idarrays{$$codetitles[3]}{$key_a}}) {
204: %{$$idlist{$$codetitles[3]}{$key_a}{$key_b}} = ();
205: foreach my $key_c (keys %{$idarrays{$$codetitles[3]}{$key_a}{$key_b}}) {
206: my @sorted_c = ();
207: my @sorted_c_titles = ();
208: &sort_cats($num,$cat_order,$codetitles,\@{$idarrays{$$codetitles[3]}{$key_a}{$key_b}{$key_c}},\@sorted_c);
209: if (defined($$cat_titles{$$codetitles[3]})) {
210: foreach (@sorted_c) {
211: push @sorted_c_titles, $$cat_titles{$$codetitles[3]}{$_};
212: }
213: }
214: $$idlist{$$codetitles[3]}{$key_a}{$key_b}{$key_c} = join('","',@sorted_c);
215: $$idnums{$$codetitles[3]}{$key_a}{$key_b}{$key_c} = scalar(@sorted_c);
216: if (defined($$cat_titles{$$codetitles[3]})) {
217: $$idlist_titles{$$codetitles[2]}{$key_a}{$key_b} = join('","',@sorted_c_titles);
218: }
219: }
220: }
221: }
222: } elsif ($num == 4) {
223: %{$$idlist{$$codetitles[4]}} = ();
224: foreach my $key_a (keys %{$idarrays{$$codetitles[4]}}) {
225: %{$$idlist{$$codetitles[4]}{$key_a}} = ();
226: foreach my $key_b (keys %{$idarrays{$$codetitles[4]}{$key_a}}) {
227: %{$$idlist{$$codetitles[4]}{$key_a}{$key_b}} = ();
228: foreach my $key_c (keys %{$idarrays{$$codetitles[4]}{$key_a}{$key_b}}) {
229: %{$$idlist{$$codetitles[4]}{$key_a}{$key_b}{$key_c}} = ();
230: foreach my $key_d (keys %{$idarrays{$$codetitles[4]}{$key_a}{$key_b}{$key_c}}) {
231: my @sorted_d = ();
232: my @sorted_d_titles = ();
233: &sort_cats($num,$cat_order,$codetitles,$idarrays{$$codetitles[4]}{$key_a}{$key_b}{$key_c}{$key_d},\@sorted_d);
234: if (defined($$cat_titles{$$codetitles[4]})) {
235: foreach (@sorted_d) {
236: push @sorted_d_titles, $$cat_titles{$$codetitles[4]}{$_};
237: }
238: }
239: $$idlist{$$codetitles[4]}{$key_a}{$key_b}{$key_c}{$key_d} = join('","',@sorted_d);
240: $$idnums{$$codetitles[4]}{$key_a}{$key_b}{$key_c}{$key_d} = scalar(@sorted_d);
241: }
242: }
243: }
244: }
245: }
246: }
247: }
248:
249: sub javascript_code_selections {
250: my ($formname,@codetitles) = @_;
251: my $numtitles = @codetitles;
252: my $output = (<<END_OF_BLOCK);
253: var display = new Array($numtitles)
254: if (caller == "" || caller == "$codetitles[0]") {
255: if (caller == "") {
256: document.$formname.Year.length = 0
257: document.$formname.Year.options[0] = new Option("Select","-1",true,true)
258: display[0] = new Array(idyears.length)
259: for (var i=0; i<idyears.length; i++) {
260: display[0][i] = idyears[i]
261: if (longtitles[0] == 1) {
262: if (idyearslongs[i] != "") {
263: display[0][i] = idyearslongs[i]
264: }
265: }
266: else {
267: if (idyearslongs[i] != "") {
268: display[0][i] = idyears[i]
269: }
270: }
271: document.$formname.Year.options[i+1] = new Option(display[0][i],idyears[i],false,false)
272: }
273: document.$formname.Year.selectedIndex = 0;
274: }
275: document.$formname.Semester.length = 0
276: document.$formname.Department.length = 0;
277: document.$formname.Number.length = 0
278: document.$formname.Department.options[0] = new Option("<-Pick $codetitles[1]","-1",true,true)
279: document.$formname.Number.options[0] = new Option("<-Pick $codetitles[2]","-1",true,true)
280: if (idyr == 0 || caller == "") {
281: document.$formname.Semester.options[0] = new Option("<-Pick $codetitles[0]","-1",true,true)
282: }
283: else {
284: document.$formname.Semester.options[0] = new Option("Select","-1",true,true)
285: display[1] = new Array(idsems[idyr-1].length)
286: for (var i=0; i<idsems[idyr-1].length; i++) {
287: display[1][i] = idsems[idyr-1][i]
288: if (longtitles[1] == 1) {
289: if (idsemslongs[idyr-1][i] != "") {
290: display[1][i] = idsemslongs[idyr-1][i]
291: }
292: }
293: document.$formname.Semester.options[i+1] = new Option(display[1][i],idsems[idyr-1][i],false,false)
294: }
295: }
296: document.$formname.Semester.selectedIndex = 0;
297: }
298: if (caller == "$codetitles[1]") {
299: document.$formname.Department.length = 0
300: document.$formname.Number.length = 0
301: document.$formname.Number.options[0] = new Option("<-Pick $codetitles[2]","-1",true,true)
302: if (idsem == 0) {
303: document.$formname.Department.options[0] = new Option("<-Pick $codetitles[1]","-1",true,true)
304: }
305: else {
306: document.$formname.Department.options[0] = new Option("Select","-1",true,true)
307: display[2] = new Array(idcodes[idyr-1][idsem-1].length)
308: for (var i=0; i<idcodes[idyr-1][idsem-1].length; i++) {
309: display[2][i] = idcodes[idyr-1][idsem-1][i]
310: if (longtitles[2] == 1) {
311: if (idcodeslongs[idyr-1][idsem-1][i] != "") {
312: display[2][i] = idcodeslongs[idyr-1][idsem-1][i]
313: }
314: }
315: document.$formname.Department.options[i+1] = new Option(display[2][i],idcodes[idyr-1][idsem-1][i],false,false)
316: }
317: }
318: document.$formname.Department.selectedIndex = 0
319: }
320: if (caller == "$codetitles[2]") {
321: document.$formname.Number.length = 0
322: if (iddept == 0) {
323: document.$formname.Number.options[0] = new Option("<-Pick $codetitles[2]","-1",true,true)
324: }
325: else {
326: document.$formname.Number.options[0] = new Option("Select","-1",true,true)
327: display[3] = new Array (idcourses[idyr-1][idsem-1][iddept-1].length)
328: for (var i=0; i<idcourses[idyr-1][idsem-1][iddept-1].length; i++) {
329: display[3][i] = idcourses[idyr-1][idsem-1][iddept-1][i]
330: if (longtitles[3] == 1) {
331: if (idcourseslongs[idyr-1][idsem-1][iddept-1][i] != "") {
332: display[3][i] = idcourseslongs[idyr-1][idsem-1][iddept-1][i]
333: }
334: }
335: document.$formname.Number.options[i+1] = new Option(display[3][i],idcourses[idyr-1][idsem-1][iddept-1][i],false,false)
336: }
337: }
338: document.$formname.Number.selectedIndex = 0
339: }
340: }
341:
342: function initialize_codes() {
343: courseSet();
344: return;
345: }
346: END_OF_BLOCK
347: }
348:
349:
350: sub javascript_definitions {
351: my ($codetitles,$idlist,$idlist_titles,$idnums,$cat_titles) = @_;
352: my $numtitles = @{$codetitles};
353: my $longtitles = [];
354: for (my $i=0; $i<$numtitles; $i++) {
355: if (defined($cat_titles->{$codetitles->[$i]})) {
356: $longtitles->[$i] = 1;
357: } else {
358: $longtitles->[$i] = 0;
359: }
360: }
361: my $scripttext;
362: if ($longtitles->[0]) {
363: $scripttext =
364: qq| var idyearslongs = new Array("$idlist_titles->{$codetitles->[0]}")\n|;
365: }
366: $scripttext .=
367: " var idsems = new Array ($idnums->{$codetitles->[0]})\n";
368: if ($longtitles->[1]) {
369: $scripttext .=
370: " var idsemslongs = new Array ($idnums->{$codetitles->[0]})\n"; }
371: $scripttext .=
372: " var idcodes = new Array ($idnums->{$codetitles->[0]})\n";
373: if ($longtitles->[2]) {
374: $scripttext .=
375: " var idcodeslongs = new Array ($idnums->{$codetitles->[0]})\n";
376: }
377: $scripttext .=
378: " var idcourses = new Array ($idnums->{$codetitles->[0]})\n";
379: if ($longtitles->[3]) {
380: $scripttext .=
381: " var idcourseslongs = new Array ($idnums->{$codetitles->[0]})\n";
382: }
383: my @sort_a = split/","/,$idlist->{$codetitles->[0]};
384: for (my $j=0; $j<@sort_a; $j++) {
385: $scripttext .= qq| idsems[$j] = new Array("$idlist->{$codetitles->[1]}{$sort_a[$j]}")\n|;
386: if ($longtitles->[1]) {
387: $scripttext .= qq| idsemslongs[$j] = new Array("$idlist_titles->{$codetitles->[1]}{$sort_a[$j]}")\n|;
388: }
389: $scripttext .= qq| idcodes[$j] = new Array($idnums->{$codetitles->[1]}{$sort_a[$j]})\n|;
390: if ($longtitles->[2]) {
391: $scripttext .= qq| idcodeslongs[$j] = new Array($idnums->{$codetitles->[1]}{$sort_a[$j]})\n|;
392: }
393: $scripttext .= qq| idcourses[$j] = new Array($idnums->{$codetitles->[1]}{$sort_a[$j]})\n|;
394: if ($longtitles->[3]) {
395: $scripttext .= qq| idcourseslongs[$j] = new Array($idnums->{$codetitles->[1]}{$sort_a[$j]})\n|;
396: }
397: my @sort_b = split/","/,$idlist->{$codetitles->[1]}{$sort_a[$j]};
398: for (my $k=0; $k<@sort_b; $k++) {
399: my $idcode_entry = $idlist->{$codetitles->[2]}{$sort_a[$j]}{$sort_b[$k]};
400: $scripttext .= qq| idcodes[$j][$k] = new Array("$idcode_entry")\n|;
401: if ($longtitles->[2]) {
402: my $idcodelong_entry = $idlist_titles->{$codetitles->[2]}{$sort_a[$j]}{$sort_b[$k]};
403: $scripttext .= qq| idcodeslongs[$j][$k] = new Array("$idcodelong_entry")\n|;
404: }
405: $scripttext .= qq| idcourses[$j][$k] = new Array($idnums->{$codetitles->[2]}{$sort_a[$j]}{$sort_b[$k]})\n|;
406: if ($longtitles->[3]) {
407: $scripttext .= qq| idcourseslongs[$j][$k] = new Array($idnums->{$codetitles->[2]}{$sort_a[$j]}{$sort_b[$k]})\n|;
408: }
409: my @sort_c = split/","/,$idlist->{$codetitles->[2]}{$sort_a[$j]}{$sort_b[$k]};
410: for (my $l=0; $l<@sort_c; $l++) {
411: my $idcourse_entry = $idlist->{$codetitles->[3]}{$sort_a[$j]}{$sort_b[$k]}{$sort_c[$l]};
412: $scripttext .= qq| idcourses[$j][$k][$l] = new Array("$idcourse_entry")\n|;
413: if ($longtitles->[3]) {
414: my $idcourselong_entry = $idlist_titles->{$codetitles->[3]}{$sort_a[$j]}{$sort_b[$k]}{$sort_c[$l]};
415: $scripttext .= qq| idcourseslongs[$j][$k][$l] = new Array("$idcourselong_entry")\n|;
416: }
417: }
418: }
419: }
420: return ($scripttext,$longtitles);
421: }
422:
423: sub courseset_js_start {
424: my ($formname,$longtitles_str,$allidlist) = @_;
425: my $output = <<END;
426: function courseSet(caller) {
427: var longtitles = new Array ("$longtitles_str");
428: var idyr = document.$formname.Year.selectedIndex
429: var idsem = document.$formname.Semester.selectedIndex
430: var iddept = document.$formname.Department.selectedIndex
431: var idclass = document.$formname.Number.selectedIndex
432: var idyears = new Array("$allidlist");
433: END
434: return $output;
435: }
436:
437: 1;
438:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>