[LON-CAPA-cvs] cvs: loncom(version_2_9_X) /interface loncommon.pm
raeburn
raeburn@source.lon-capa.org
Tue, 19 Jan 2010 06:01:10 -0000
raeburn Tue Jan 19 06:01:10 2010 EDT
Modified files: (Branch: version_2_9_X)
/loncom/interface loncommon.pm
Log:
- Backport 1.905.
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.692.4.20 loncom/interface/loncommon.pm:1.692.4.21
--- loncom/interface/loncommon.pm:1.692.4.20 Sat Oct 24 03:32:49 2009
+++ loncom/interface/loncommon.pm Tue Jan 19 06:01:09 2010
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.692.4.20 2009/10/24 03:32:49 raeburn Exp $
+# $Id: loncommon.pm,v 1.692.4.21 2010/01/19 06:01:09 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -481,7 +481,7 @@
}
sub coursebrowser_javascript {
- my ($domainfilter,$sec_element,$formname)=@_;
+ my ($domainfilter,$sec_element,$formname,$role_element)=@_;
my $crs_or_grp_alert = &mt('Please select the type of LON-CAPA entity - Course or Community - for which you wish to add/modify a user role.');
my $id_functions = &javascript_index_functions();
my $output = '
@@ -543,8 +543,8 @@
}
$id_functions
ENDSTDBRW
- if ($sec_element ne '') {
- $output .= &setsec_javascript($sec_element,$formname);
+ if (($sec_element ne '') || ($role_element ne '')) {
+ $output .= &setsec_javascript($sec_element,$formname,$role_element);
}
$output .= '
// ]]>
@@ -657,7 +657,28 @@
sub setsec_javascript {
- my ($sec_element,$formname) = @_;
+ my ($sec_element,$formname,$role_element) = @_;
+ my (@courserolenames,@communityrolenames,$rolestr,$courserolestr,
+ $communityrolestr);
+ if ($role_element ne '') {
+ my @allroles = ('st','ta','ep','in','ad');
+ foreach my $crstype ('Course','Community') {
+ if ($crstype eq 'Community') {
+ foreach my $role (@allroles) {
+ push(@communityrolenames,&Apache::lonnet::plaintext($role,$crstype));
+ }
+ push(@communityrolenames,&Apache::lonnet::plaintext('co'));
+ } else {
+ foreach my $role (@allroles) {
+ push(@courserolenames,&Apache::lonnet::plaintext($role,$crstype));
+ }
+ push(@courserolenames,&Apache::lonnet::plaintext('cc'));
+ }
+ }
+ $rolestr = '"'.join('","',@allroles).'"';
+ $courserolestr = '"'.join('","',@courserolenames).'"';
+ $communityrolestr = '"'.join('","',@communityrolenames).'"';
+ }
my $setsections = qq|
function setSect(sectionlist) {
var sectionsArray = new Array();
@@ -691,11 +712,49 @@
}
}
}
+
+function setRole(crstype) {
+|;
+ if ($role_element eq '') {
+ $setsections .= ' return;
+}
+';
+ } else {
+ $setsections .= qq|
+ var elementLength = document.$formname.$role_element.length;
+ var allroles = Array($rolestr);
+ var courserolenames = Array($courserolestr);
+ var communityrolenames = Array($communityrolestr);
+ if (elementLength != undefined) {
+ if (document.$formname.$role_element.options[5].value == 'cc') {
+ if (crstype == 'Course') {
+ return;
+ } else {
+ allroles[5] = 'co';
+ for (var i=0; i<6; i++) {
+ document.$formname.$role_element.options[i].value = allroles[i];
+ document.$formname.$role_element.options[i].text = communityrolenames[i];
+ }
+ }
+ } else {
+ if (crstype == 'Community') {
+ return;
+ } else {
+ allroles[5] = 'cc';
+ for (var i=0; i<6; i++) {
+ document.$formname.$role_element.options[i].value = allroles[i];
+ document.$formname.$role_element.options[i].text = courserolenames[i];
+ }
+ }
+ }
+ }
+ return;
+}
|;
+ }
return $setsections;
}
-
sub selectcourse_link {
my ($form,$unameele,$udomele,$desc,$extra_element,$multflag,$selecttype)=@_;
my $linktext = &mt('Select Course');