[LON-CAPA-cvs] cvs: loncom /interface lonsupportreq.pm
raeburn
lon-capa-cvs@mail.lon-capa.org
Thu, 30 Dec 2004 21:16:38 -0000
This is a MIME encoded message
--raeburn1104441398
Content-Type: text/plain
raeburn Thu Dec 30 16:16:38 2004 EDT
Modified files:
/loncom/interface lonsupportreq.pm
Log:
More generic. Will now support short codes and long codes for all items, e.g. year could be 04 short, 2004 long; semester fs short, Fall long, department phy short, physics long. Short used as option value in select boxes, long as text displayed for each option. Short and long codes and item titles all determined by call to &localenroll:instcode_format() on domain's library server (via lonnet:auto_instcode_format().
--raeburn1104441398
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20041230161638.txt"
Index: loncom/interface/lonsupportreq.pm
diff -u loncom/interface/lonsupportreq.pm:1.19 loncom/interface/lonsupportreq.pm:1.20
--- loncom/interface/lonsupportreq.pm:1.19 Thu Dec 30 11:18:16 2004
+++ loncom/interface/lonsupportreq.pm Thu Dec 30 16:16:38 2004
@@ -127,7 +127,7 @@
my $totcodes = 0;
my $format_reply;
my $jscript = '';
-
+
if ($cdom) {
$codedom = $cdom;
}
@@ -148,7 +148,7 @@
if ($ccode eq '') {
my $numtypes = @codetitles;
&build_code_selections(\%codes,\@codetitles,\%cat_titles,\%cat_order,\%idlist,\%idnums,\%idlist_titles);
- &javascript_code_selections($numtypes,\$jscript,\%idlist,\%idnums,\%idlist_titles,\@codetitles);
+ &javascript_code_selections($numtypes,\%cat_titles,\$jscript,\%idlist,\%idnums,\%idlist_titles,\@codetitles);
}
}
$r->print(<<ENDHEAD);
@@ -372,13 +372,23 @@
'<select name="'.$codetitles[0].'" onChange="courseSet('."'$codetitles[0]'".')">'."\n".
' <option value="-1" />Select'."\n");
my @items = ();
+ my @longitems = ();
if ($idlist{$codetitles[0]} =~ /","/) {
@items = split/","/,$idlist{$codetitles[0]};
} else {
$items[0] = $idlist{$codetitles[0]};
}
- foreach (@items) {
- $r->print(' <option value="'.$_.'" />'.$_);
+ if (defined($idlist_titles{$codetitles[0]})) {
+ if ($idlist_titles{$codetitles[0]} =~ /","/) {
+ @longitems = split/","/,$idlist_titles{$codetitles[0]};
+ } else {
+ $longitems[0] = $idlist_titles{$codetitles[0]};
+ }
+ } else {
+ @longitems = @items;
+ }
+ for (my $i=0; $i<@items; $i++) {
+ $r->print(' <option value="'.$items[$i].'">'.$longitems[$i].'</option>');
}
$r->print('</select></td>');
for (my $i=1; $i<$numtitles; $i++) {
@@ -590,6 +600,7 @@
my $vlinkcolor = &Apache::loncommon::designparm($function.'.vlink');
my $tablecolor = &Apache::loncommon::designparm($function.'.tabbg');
my @formvars = ('username','email','uname','udom','sourceurl','phone','section','coursecode','title','subject','description','screenshot');
+
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},\@formvars);
my $coursecode = $ENV{'form.coursecode'};
if ($coursecode eq '') {
@@ -959,9 +970,18 @@
%{$$idlist{$$codetitles[3]}{$key_a}{$key_b}} = ();
foreach my $key_c (keys %{$idarrays{$$codetitles[3]}{$key_a}{$key_b}}) {
my @sorted_c = ();
+ my @sorted_c_titles = ();
&sort_cats($num,$cat_order,$codetitles,\@{$idarrays{$$codetitles[3]}{$key_a}{$key_b}{$key_c}},\@sorted_c);
+ if (defined($$cat_titles{$$codetitles[3]})) {
+ foreach (@sorted_c) {
+ push @sorted_c_titles, $$cat_titles{$$codetitles[3]}{$_};
+ }
+ }
$$idlist{$$codetitles[3]}{$key_a}{$key_b}{$key_c} = join('","',@sorted_c);
$$idnums{$$codetitles[3]}{$key_a}{$key_b}{$key_c} = scalar(@sorted_c);
+ if (defined($$cat_titles{$$codetitles[3]})) {
+ $$idlist_titles{$$codetitles[2]}{$key_a}{$key_b} = join('","',@sorted_c_titles);
+ }
}
}
}
@@ -975,7 +995,13 @@
%{$$idlist{$$codetitles[4]}{$key_a}{$key_b}{$key_c}} = ();
foreach my $key_d (keys %{$idarrays{$$codetitles[4]}{$key_a}{$key_b}{$key_c}}) {
my @sorted_d = ();
+ my @sorted_d_titles = ();
&sort_cats($num,$cat_order,$codetitles,$idarrays{$$codetitles[4]}{$key_a}{$key_b}{$key_c}{$key_d},\@sorted_d);
+ if (defined($$cat_titles{$$codetitles[4]})) {
+ foreach (@sorted_d) {
+ push @sorted_d_titles, $$cat_titles{$$codetitles[4]}{$_};
+ }
+ }
$$idlist{$$codetitles[4]}{$key_a}{$key_b}{$key_c}{$key_d} = join('","',@sorted_d);
$$idnums{$$codetitles[4]}{$key_a}{$key_b}{$key_c}{$key_d} = scalar(@sorted_d);
}
@@ -1081,42 +1107,89 @@
}
sub javascript_code_selections {
- my ($numcats,$script_tag,$idlist,$idnums,$idlist_titles,$codetitles) = @_;
+ my ($numcats,$cat_titles,$script_tag,$idlist,$idnums,$idlist_titles,$codetitles) = @_;
my $numtitles = @{$codetitles};
- my @seltitles = ();
+ my @seltitles = ();
for (my $j=0; $j<$numtitles; $j++) {
$seltitles[$j] = 'id'.$$codetitles[$j];
}
my $seltitle_str = join('","',@seltitles);
+ my @longtitles = ();
+ for (my $i=0; $i<$numtitles; $i++) {
+ if (defined($$cat_titles{$$codetitles[$i]})) {
+ $longtitles[$i] = 1;
+ } else {
+ $longtitles[$i] = 0;
+ }
+ }
+ my $longtitles_str = join('","',@longtitles);
$$script_tag .= <<END;
function courseSet(caller) {
var ids = new Array ("$seltitle_str");
var formitems = new Array ($numtitles);
+ var longtitles = new Array ("$longtitles_str");
var idyr = document.logproblem.Year.selectedIndex
var idsem = document.logproblem.Semester.selectedIndex
var iddept = document.logproblem.Department.selectedIndex
var idclass = document.logproblem.Number.selectedIndex
var idyears = new Array("$$idlist{$$codetitles[0]}");
- var idsems = new Array ($$idnums{$$codetitles[0]});
- var idsemlongs = new Array ($$idnums{$$codetitles[0]});
- var idcodes = new Array ($$idnums{$$codetitles[0]});
- var idcourses = new Array ($$idnums{$$codetitles[0]});
END
- my @sort_a = split/","/,$$idlist{$$codetitles[0]};
+ if ($longtitles[0]) {
+ $$script_tag .=
+ qq| var idyearslongs = new Array("$$idlist_titles{$$codetitles[0]}")\n|;
+ }
+ $$script_tag .=
+ " var idsems = new Array ($$idnums{$$codetitles[0]})\n";
+ if ($longtitles[1]) {
+ $$script_tag .=
+ " var idsemslongs = new Array ($$idnums{$$codetitles[0]})\n";
+ }
+ $$script_tag .=
+ " var idcodes = new Array ($$idnums{$$codetitles[0]})\n";
+ if ($longtitles[2]) {
+ $$script_tag .=
+ " var idcodeslongs = new Array ($$idnums{$$codetitles[0]})\n";
+ }
+ $$script_tag .=
+ " var idcourses = new Array ($$idnums{$$codetitles[0]})\n";
+ if ($longtitles[3]) {
+ $$script_tag .=
+ " var idcourseslongs = new Array ($$idnums{$$codetitles[0]})\n";
+ }
+ my @sort_a = split/","/,$$idlist{$$codetitles[0]};
for (my $j=0; $j<@sort_a; $j++) {
$$script_tag .= qq| idsems[$j] = new Array("$$idlist{$$codetitles[1]}{$sort_a[$j]}")\n|;
- $$script_tag .= qq| idsemlongs[$j] = new Array("$$idlist_titles{$$codetitles[1]}{$sort_a[$j]}")\n|;
+ if ($longtitles[1]) {
+ $$script_tag .= qq| idsemslongs[$j] = new Array("$$idlist_titles{$$codetitles[1]}{$sort_a[$j]}")\n|;
+ }
$$script_tag .= qq| idcodes[$j] = new Array($$idnums{$$codetitles[1]}{$sort_a[$j]})\n|;
+ if ($longtitles[2]) {
+ $$script_tag .= qq| idcodeslongs[$j] = new Array($$idnums{$$codetitles[1]}{$sort_a[$j]})\n|;
+ }
$$script_tag .= qq| idcourses[$j] = new Array($$idnums{$$codetitles[1]}{$sort_a[$j]})\n|;
+ if ($longtitles[3]) {
+ $$script_tag .= qq| idcourseslongs[$j] = new Array($$idnums{$$codetitles[1]}{$sort_a[$j]})\n|;
+ }
my @sort_b = split/","/,$$idlist{$$codetitles[1]}{$sort_a[$j]};
for (my $k=0; $k<@sort_b; $k++) {
my $idcode_entry = $$idlist{$$codetitles[2]}{$sort_a[$j]}{$sort_b[$k]};
$$script_tag .= qq| idcodes[$j][$k] = new Array("$idcode_entry")\n|;
+ if ($longtitles[2]) {
+ my $idcodelong_entry = $$idlist_titles{$$codetitles[2]}{$sort_a[$j]}{$sort_b[$k]};
+ $$script_tag .= qq| idcodeslongs[$j][$k] = new Array("$idcodelong_entry")\n|;
+ }
$$script_tag .= qq| idcourses[$j][$k] = new Array($$idnums{$$codetitles[2]}{$sort_a[$j]}{$sort_b[$k]})\n|;
+ if ($longtitles[3]) {
+ $$script_tag .= qq| idcourseslongs[$j][$k] = new Array($$idnums{$$codetitles[2]}{$sort_a[$j]}{$sort_b[$k]})\n|;
+ }
my @sort_c = split/","/,$$idlist{$$codetitles[2]}{$sort_a[$j]}{$sort_b[$k]};
for (my $l=0; $l<@sort_c; $l++) {
my $idcourse_entry = $$idlist{$$codetitles[3]}{$sort_a[$j]}{$sort_b[$k]}{$sort_c[$l]};
$$script_tag .= qq| idcourses[$j][$k][$l] = new Array("$idcourse_entry")\n|;
+ if ($longtitles[3]) {
+ my $idcourselong_entry = $$idlist_titles{$$codetitles[3]}{$sort_a[$j]}{$sort_b[$k]}{$sort_c[$l]};
+ $$script_tag .= qq| idcourseslongs[$j][$k][$l] = new Array("$idcourselong_entry")\n|;
+ }
}
}
}
@@ -1134,7 +1207,12 @@
document.logproblem.Semester.length = 0
document.logproblem.Semester.options[0] = new Option("Select","-1",true,true)
for (var i=0; i<idsems[idyr-1].length; i++) {
- document.logproblem.Semester.options[i+1] = new Option(idsemlongs[idyr-1][i],idsems[idyr-1][i],false,false)
+ if (longtitles[1] == 1) {
+ document.logproblem.Semester.options[i+1] = new Option(idsemslongs[idyr-1][i],idsems[idyr-1][i],false,false)
+ }
+ else {
+ document.logproblem.Semester.options[i+1] = new Option(idsems[idyr-1][i],idsems[idyr-1][i],false,false)
+ }
}
}
document.logproblem.Semester.selectedIndex = 0;
@@ -1149,7 +1227,12 @@
else {
document.logproblem.Department.options[0] = new Option("Select","-1",true,true)
for (var i=0; i<idcodes[idyr-1][idsem-1].length; i++) {
- document.logproblem.Department.options[i+1] = new Option(idcodes[idyr-1][idsem-1][i],idcodes[idyr-1][idsem-1][i],false,false)
+ if (longtitles[2] == 1) {
+ document.logproblem.Department.options[i+1] = new Option(idcodeslongs[idyr-1][idsem-1][i],idcodes[idyr-1][idsem-1][i],false,false)
+ }
+ else {
+ document.logproblem.Department.options[i+1] = new Option(idcodes[idyr-1][idsem-1][i],idcodes[idyr-1][idsem-1][i],false,false)
+ }
}
}
document.logproblem.Department.selectedIndex = 0
@@ -1162,7 +1245,12 @@
else {
document.logproblem.Number.options[0] = new Option("Select","-1",true,true)
for (var i=0; i<idcourses[idyr-1][idsem-1][iddept-1].length; i++) {
- document.logproblem.Number.options[i+1] = new Option(idcourses[idyr-1][idsem-1][iddept-1][i],idcourses[idyr-1][idsem-1][iddept-1][i],false,false)
+ if (longtitles[3] == 1) {
+ document.logproblem.Number.options[i+1] = new Option(idcourseslongs[idyr-1][idsem-1][iddept-1][i],idcourses[idyr-1][idsem-1][iddept-1][i],false,false)
+ }
+ else {
+ document.logproblem.Number.options[i+1] = new Option(idcourses[idyr-1][idsem-1][iddept-1][i],idcourses[idyr-1][idsem-1][iddept-1][i],false,false)
+ }
}
}
document.logproblem.Number.selectedIndex = 0
--raeburn1104441398--