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