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