--- loncom/interface/lonhtmlcommon.pm 2006/07/27 22:27:08 1.146
+++ loncom/interface/lonhtmlcommon.pm 2006/07/31 18:43:12 1.148
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common html routines
#
-# $Id: lonhtmlcommon.pm,v 1.146 2006/07/27 22:27:08 albertel Exp $
+# $Id: lonhtmlcommon.pm,v 1.148 2006/07/31 18:43:12 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1418,7 +1418,7 @@ ENDTWO
}
sub role_select_row {
- my ($roles,$title,$css_class) = @_;
+ my ($roles,$title,$css_class,$show_separate_custom,$cdom,$cnum) = @_;
my $output;
if (defined($title)) {
$output = &row_title($title,$css_class);
@@ -1429,10 +1429,25 @@ sub role_select_row {
my $plrole;
if ($role eq 'ow') {
$plrole = &mt('Course Owner');
+ } elsif ($role eq 'cr') {
+ if ($show_separate_custom) {
+ if ($cdom ne '' && $cnum ne '') {
+ my %course_customroles = &course_custom_roles($cdom,$cnum);
+ foreach my $crrole (sort(keys(%course_customroles))) {
+ my ($plcrrole) = ($crrole =~ m|^cr/[^/]+/[^/]+/(.+)$|);
+ $output .= ' ';
+ }
+ }
+ } else {
+ $plrole = &mt('Custom Role');
+ }
} else {
$plrole=&Apache::lonnet::plaintext($role);
}
- $output .= ' ';
+ if (($role ne 'cr') || (!$show_separate_custom)) {
+ $output .= ' ';
+ }
}
$output .= qq| \n|;
if (defined($title)) {
@@ -1585,6 +1600,24 @@ sub submit_row {
return $output;
}
+sub course_custom_roles {
+ my ($cdom,$cnum) = @_;
+ my %returnhash=();
+ my %coursepersonnel=&Apache::lonnet::dump('nohist_userroles',$cdom,$cnum);
+ foreach my $person (sort(keys(%coursepersonnel))) {
+ my ($role) = ($person =~ /^([^:]+):/);
+ my ($end,$start) = split(/:/,$coursepersonnel{$person});
+ if ($end == -1 && $start == -1) {
+ next;
+ }
+ if ($role =~ m|^cr/[^/]+/[^/]+/[^/]|) {
+ $returnhash{$role} ++;
+ }
+ }
+ return %returnhash;
+}
+
+
##############################################
##############################################
@@ -1723,66 +1756,66 @@ sub set_form_elements {
my $valuestring = join('","',@{$values{$name}});
$output .= qq|
var textvalues = new Array ("$valuestring");
- var total = courseForm.$name.length;
+ var total = courseForm.elements['$name'].length;
if (total > $numvalues) {
total = $numvalues;
}
for (var i=0; i