Annotation of loncom/interface/courseclassifier.pm, revision 1.4
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]}}} = ();
1.4 ! raeburn 120: %{$$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}}} = ();
! 121: @{$$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 122: }
123: } else {
124: %{$$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}} = ();
125: %{$$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}} = ();
126: %{$$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[2]}}} = ();
127: @{$$idarrays{$$codetitles[4]}{$$codes{$cid}{$$codetitles[0]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[1]}}{$$codes{$cid}{$$codetitles[3]}}} = ("$$codes{$cid}{$$codetitles[3]}");
128: }
129: }
130: $num ++;
131: if ($num <@{$codetitles}) {
132: &recurse_list($cid,$codetitles,$codes,$num,$idarrays);
133: }
134: }
135:
136: sub build_code_selections {
137: my ($codes,$codetitles,$cat_titles,$cat_order,$idlist,$idnums,$idlist_titles) = @_;
138: my %idarrays = ();
139: for (my $i=1; $i<@{$codetitles}; $i++) {
140: %{$idarrays{$$codetitles[$i]}} = ();
141: }
142: foreach my $cid (sort keys %{$codes}) {
143: &recurse_list($cid,$codetitles,$codes,0,\%idarrays);
144: }
145: for (my $num=0; $num<@{$codetitles}; $num++) {
146: if ($num == 0) {
147: my @contents = ();
148: my @contents_titles = ();
149: &sort_cats($num,$cat_order,$codetitles,\@{$idarrays{$$codetitles[0]}},\@contents);
150: if (defined($$cat_titles{$$codetitles[0]})) {
151: foreach (@contents) {
152: push @contents_titles, $$cat_titles{$$codetitles[0]}{$_};
153: }
154: }
155: $$idlist{$$codetitles[0]} = join('","',@contents);
156: $$idnums{$$codetitles[0]} = scalar(@contents);
157: if (defined($$cat_titles{$$codetitles[0]})) {
158: $$idlist_titles{$$codetitles[0]} = join('","',@contents_titles);
159: }
160: } elsif ($num == 1) {
161: %{$$idlist{$$codetitles[1]}} = ();
162: %{$$idlist_titles{$$codetitles[1]}} = ();
163: foreach my $key_a (keys %{$idarrays{$$codetitles[1]}}) {
164: my @sorted_a = ();
165: my @sorted_a_titles = ();
166: &sort_cats($num,$cat_order,$codetitles,\@{$idarrays{$$codetitles[1]}{$key_a}},\@sorted_a);
167: if (defined($$cat_titles{$$codetitles[1]})) {
168: foreach (@sorted_a) {
169: push @sorted_a_titles, $$cat_titles{$$codetitles[1]}{$_};
170: }
171: }
172: $$idlist{$$codetitles[1]}{$key_a} = join('","',@sorted_a);
173: $$idnums{$$codetitles[1]}{$key_a} = scalar(@sorted_a);
174: if (defined($$cat_titles{$$codetitles[1]})) {
175: $$idlist_titles{$$codetitles[1]}{$key_a} = join('","',@sorted_a_titles);
176: }
177: }
178: } elsif ($num == 2) {
179: %{$$idlist{$$codetitles[2]}} = ();
180: %{$$idlist_titles{$$codetitles[2]}} = ();
181: foreach my $key_a (keys %{$idarrays{$$codetitles[2]}}) {
182: %{$$idlist{$$codetitles[2]}{$key_a}} = ();
183: %{$$idlist_titles{$$codetitles[2]}{$key_a}} = ();
184: foreach my $key_b (keys %{$idarrays{$$codetitles[2]}{$key_a}}) {
185: my @sorted_b = ();
186: my @sorted_b_titles = ();
187: &sort_cats($num,$cat_order,$codetitles,\@{$idarrays{$$codetitles[2]}{$key_a}{$key_b}},\@sorted_b);
188: if (defined($$cat_titles{$$codetitles[2]})) {
189: foreach (@sorted_b) {
190: push @sorted_b_titles, $$cat_titles{$$codetitles[2]}{$_};
191: }
192: }
193: $$idlist{$$codetitles[2]}{$key_a}{$key_b} = join('","',@sorted_b);
194: $$idnums{$$codetitles[2]}{$key_a}{$key_b} = scalar(@sorted_b);
195: if (defined($$cat_titles{$$codetitles[2]})) {
196: $$idlist_titles{$$codetitles[2]}{$key_a}{$key_b} = join('","',@sorted_b_titles);
197: }
198: }
199: }
200: } elsif ($num == 3) {
201: %{$$idlist{$$codetitles[3]}} = ();
202: foreach my $key_a (keys %{$idarrays{$$codetitles[3]}}) {
203: %{$$idlist{$$codetitles[3]}{$key_a}} = ();
204: foreach my $key_b (keys %{$idarrays{$$codetitles[3]}{$key_a}}) {
205: %{$$idlist{$$codetitles[3]}{$key_a}{$key_b}} = ();
206: foreach my $key_c (keys %{$idarrays{$$codetitles[3]}{$key_a}{$key_b}}) {
207: my @sorted_c = ();
208: my @sorted_c_titles = ();
209: &sort_cats($num,$cat_order,$codetitles,\@{$idarrays{$$codetitles[3]}{$key_a}{$key_b}{$key_c}},\@sorted_c);
210: if (defined($$cat_titles{$$codetitles[3]})) {
211: foreach (@sorted_c) {
212: push @sorted_c_titles, $$cat_titles{$$codetitles[3]}{$_};
213: }
214: }
215: $$idlist{$$codetitles[3]}{$key_a}{$key_b}{$key_c} = join('","',@sorted_c);
216: $$idnums{$$codetitles[3]}{$key_a}{$key_b}{$key_c} = scalar(@sorted_c);
217: if (defined($$cat_titles{$$codetitles[3]})) {
1.4 ! raeburn 218: $$idlist_titles{$$codetitles[3]}{$key_a}{$key_b}{$key_c} = join('","',@sorted_c_titles);
1.1 raeburn 219: }
220: }
221: }
222: }
223: } elsif ($num == 4) {
224: %{$$idlist{$$codetitles[4]}} = ();
225: foreach my $key_a (keys %{$idarrays{$$codetitles[4]}}) {
226: %{$$idlist{$$codetitles[4]}{$key_a}} = ();
227: foreach my $key_b (keys %{$idarrays{$$codetitles[4]}{$key_a}}) {
228: %{$$idlist{$$codetitles[4]}{$key_a}{$key_b}} = ();
229: foreach my $key_c (keys %{$idarrays{$$codetitles[4]}{$key_a}{$key_b}}) {
230: %{$$idlist{$$codetitles[4]}{$key_a}{$key_b}{$key_c}} = ();
231: foreach my $key_d (keys %{$idarrays{$$codetitles[4]}{$key_a}{$key_b}{$key_c}}) {
232: my @sorted_d = ();
233: my @sorted_d_titles = ();
234: &sort_cats($num,$cat_order,$codetitles,$idarrays{$$codetitles[4]}{$key_a}{$key_b}{$key_c}{$key_d},\@sorted_d);
235: if (defined($$cat_titles{$$codetitles[4]})) {
236: foreach (@sorted_d) {
237: push @sorted_d_titles, $$cat_titles{$$codetitles[4]}{$_};
238: }
239: }
240: $$idlist{$$codetitles[4]}{$key_a}{$key_b}{$key_c}{$key_d} = join('","',@sorted_d);
241: $$idnums{$$codetitles[4]}{$key_a}{$key_b}{$key_c}{$key_d} = scalar(@sorted_d);
1.4 ! raeburn 242: if (defined($$cat_titles{$$codetitles[4]})) {
! 243: $$idlist_titles{$$codetitles[3]}{$key_a}{$key_b}{$key_c}{$key_d} = join('","',@sorted_d_titles);
! 244: }
1.1 raeburn 245: }
246: }
247: }
248: }
249: }
250: }
251: }
252:
253: sub javascript_code_selections {
254: my ($formname,@codetitles) = @_;
255: my $numtitles = @codetitles;
256: my $output = (<<END_OF_BLOCK);
257: var display = new Array($numtitles)
258: if (caller == "" || caller == "$codetitles[0]") {
259: if (caller == "") {
260: document.$formname.Year.length = 0
261: document.$formname.Year.options[0] = new Option("Select","-1",true,true)
262: display[0] = new Array(idyears.length)
263: for (var i=0; i<idyears.length; i++) {
264: display[0][i] = idyears[i]
265: if (longtitles[0] == 1) {
266: if (idyearslongs[i] != "") {
267: display[0][i] = idyearslongs[i]
268: }
269: }
270: else {
271: if (idyearslongs[i] != "") {
272: display[0][i] = idyears[i]
273: }
274: }
275: document.$formname.Year.options[i+1] = new Option(display[0][i],idyears[i],false,false)
276: }
277: document.$formname.Year.selectedIndex = 0;
278: }
279: document.$formname.Semester.length = 0
280: document.$formname.Department.length = 0;
281: document.$formname.Number.length = 0
282: document.$formname.Department.options[0] = new Option("<-Pick $codetitles[1]","-1",true,true)
283: document.$formname.Number.options[0] = new Option("<-Pick $codetitles[2]","-1",true,true)
284: if (idyr == 0 || caller == "") {
285: document.$formname.Semester.options[0] = new Option("<-Pick $codetitles[0]","-1",true,true)
286: }
287: else {
288: document.$formname.Semester.options[0] = new Option("Select","-1",true,true)
289: display[1] = new Array(idsems[idyr-1].length)
290: for (var i=0; i<idsems[idyr-1].length; i++) {
291: display[1][i] = idsems[idyr-1][i]
292: if (longtitles[1] == 1) {
293: if (idsemslongs[idyr-1][i] != "") {
294: display[1][i] = idsemslongs[idyr-1][i]
295: }
296: }
297: document.$formname.Semester.options[i+1] = new Option(display[1][i],idsems[idyr-1][i],false,false)
298: }
299: }
300: document.$formname.Semester.selectedIndex = 0;
301: }
302: if (caller == "$codetitles[1]") {
303: document.$formname.Department.length = 0
304: document.$formname.Number.length = 0
305: document.$formname.Number.options[0] = new Option("<-Pick $codetitles[2]","-1",true,true)
306: if (idsem == 0) {
307: document.$formname.Department.options[0] = new Option("<-Pick $codetitles[1]","-1",true,true)
308: }
309: else {
310: document.$formname.Department.options[0] = new Option("Select","-1",true,true)
311: display[2] = new Array(idcodes[idyr-1][idsem-1].length)
312: for (var i=0; i<idcodes[idyr-1][idsem-1].length; i++) {
313: display[2][i] = idcodes[idyr-1][idsem-1][i]
314: if (longtitles[2] == 1) {
315: if (idcodeslongs[idyr-1][idsem-1][i] != "") {
316: display[2][i] = idcodeslongs[idyr-1][idsem-1][i]
317: }
318: }
319: document.$formname.Department.options[i+1] = new Option(display[2][i],idcodes[idyr-1][idsem-1][i],false,false)
320: }
321: }
322: document.$formname.Department.selectedIndex = 0
323: }
324: if (caller == "$codetitles[2]") {
325: document.$formname.Number.length = 0
326: if (iddept == 0) {
327: document.$formname.Number.options[0] = new Option("<-Pick $codetitles[2]","-1",true,true)
328: }
329: else {
330: document.$formname.Number.options[0] = new Option("Select","-1",true,true)
331: display[3] = new Array (idcourses[idyr-1][idsem-1][iddept-1].length)
332: for (var i=0; i<idcourses[idyr-1][idsem-1][iddept-1].length; i++) {
333: display[3][i] = idcourses[idyr-1][idsem-1][iddept-1][i]
334: if (longtitles[3] == 1) {
335: if (idcourseslongs[idyr-1][idsem-1][iddept-1][i] != "") {
336: display[3][i] = idcourseslongs[idyr-1][idsem-1][iddept-1][i]
337: }
338: }
339: document.$formname.Number.options[i+1] = new Option(display[3][i],idcourses[idyr-1][idsem-1][iddept-1][i],false,false)
340: }
341: }
342: document.$formname.Number.selectedIndex = 0
343: }
344: }
345:
346: function initialize_codes() {
347: courseSet();
348: return;
349: }
350: END_OF_BLOCK
351: }
352:
353:
354: sub javascript_definitions {
355: my ($codetitles,$idlist,$idlist_titles,$idnums,$cat_titles) = @_;
356: my $numtitles = @{$codetitles};
357: my $longtitles = [];
358: for (my $i=0; $i<$numtitles; $i++) {
359: if (defined($cat_titles->{$codetitles->[$i]})) {
360: $longtitles->[$i] = 1;
361: } else {
362: $longtitles->[$i] = 0;
363: }
364: }
365: my $scripttext;
366: if ($longtitles->[0]) {
367: $scripttext =
368: qq| var idyearslongs = new Array("$idlist_titles->{$codetitles->[0]}")\n|;
369: }
370: $scripttext .=
371: " var idsems = new Array ($idnums->{$codetitles->[0]})\n";
372: if ($longtitles->[1]) {
373: $scripttext .=
374: " var idsemslongs = new Array ($idnums->{$codetitles->[0]})\n"; }
375: $scripttext .=
376: " var idcodes = new Array ($idnums->{$codetitles->[0]})\n";
377: if ($longtitles->[2]) {
378: $scripttext .=
379: " var idcodeslongs = new Array ($idnums->{$codetitles->[0]})\n";
380: }
381: $scripttext .=
382: " var idcourses = new Array ($idnums->{$codetitles->[0]})\n";
383: if ($longtitles->[3]) {
384: $scripttext .=
385: " var idcourseslongs = new Array ($idnums->{$codetitles->[0]})\n";
386: }
387: my @sort_a = split/","/,$idlist->{$codetitles->[0]};
388: for (my $j=0; $j<@sort_a; $j++) {
389: $scripttext .= qq| idsems[$j] = new Array("$idlist->{$codetitles->[1]}{$sort_a[$j]}")\n|;
390: if ($longtitles->[1]) {
391: $scripttext .= qq| idsemslongs[$j] = new Array("$idlist_titles->{$codetitles->[1]}{$sort_a[$j]}")\n|;
392: }
393: $scripttext .= qq| idcodes[$j] = new Array($idnums->{$codetitles->[1]}{$sort_a[$j]})\n|;
394: if ($longtitles->[2]) {
395: $scripttext .= qq| idcodeslongs[$j] = new Array($idnums->{$codetitles->[1]}{$sort_a[$j]})\n|;
396: }
397: $scripttext .= qq| idcourses[$j] = new Array($idnums->{$codetitles->[1]}{$sort_a[$j]})\n|;
398: if ($longtitles->[3]) {
399: $scripttext .= qq| idcourseslongs[$j] = new Array($idnums->{$codetitles->[1]}{$sort_a[$j]})\n|;
400: }
401: my @sort_b = split/","/,$idlist->{$codetitles->[1]}{$sort_a[$j]};
402: for (my $k=0; $k<@sort_b; $k++) {
403: my $idcode_entry = $idlist->{$codetitles->[2]}{$sort_a[$j]}{$sort_b[$k]};
404: $scripttext .= qq| idcodes[$j][$k] = new Array("$idcode_entry")\n|;
405: if ($longtitles->[2]) {
406: my $idcodelong_entry = $idlist_titles->{$codetitles->[2]}{$sort_a[$j]}{$sort_b[$k]};
407: $scripttext .= qq| idcodeslongs[$j][$k] = new Array("$idcodelong_entry")\n|;
408: }
409: $scripttext .= qq| idcourses[$j][$k] = new Array($idnums->{$codetitles->[2]}{$sort_a[$j]}{$sort_b[$k]})\n|;
410: if ($longtitles->[3]) {
411: $scripttext .= qq| idcourseslongs[$j][$k] = new Array($idnums->{$codetitles->[2]}{$sort_a[$j]}{$sort_b[$k]})\n|;
412: }
413: my @sort_c = split/","/,$idlist->{$codetitles->[2]}{$sort_a[$j]}{$sort_b[$k]};
414: for (my $l=0; $l<@sort_c; $l++) {
415: my $idcourse_entry = $idlist->{$codetitles->[3]}{$sort_a[$j]}{$sort_b[$k]}{$sort_c[$l]};
416: $scripttext .= qq| idcourses[$j][$k][$l] = new Array("$idcourse_entry")\n|;
417: if ($longtitles->[3]) {
418: my $idcourselong_entry = $idlist_titles->{$codetitles->[3]}{$sort_a[$j]}{$sort_b[$k]}{$sort_c[$l]};
419: $scripttext .= qq| idcourseslongs[$j][$k][$l] = new Array("$idcourselong_entry")\n|;
420: }
421: }
422: }
423: }
424: return ($scripttext,$longtitles);
425: }
426:
427: sub courseset_js_start {
428: my ($formname,$longtitles_str,$allidlist) = @_;
429: my $output = <<END;
430: function courseSet(caller) {
431: var longtitles = new Array ("$longtitles_str");
432: var idyr = document.$formname.Year.selectedIndex
433: var idsem = document.$formname.Semester.selectedIndex
434: var iddept = document.$formname.Department.selectedIndex
435: var idclass = document.$formname.Number.selectedIndex
436: var idyears = new Array("$allidlist");
437: END
438: return $output;
439: }
440:
441: 1;
442:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>