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