[LON-CAPA-cvs] cvs: loncom /interface lonparmset.pm /lonnet/perl lonnet.pm
raeburn
raeburn@source.lon-capa.org
Sun, 01 Mar 2009 01:12:24 -0000
This is a MIME encoded message
--raeburn1235869944
Content-Type: text/plain
raeburn Sun Mar 1 01:12:24 2009 EDT
Modified files:
/loncom/interface lonparmset.pm
/loncom/lonnet/perl lonnet.pm
Log:
lonparmset.pm
- Titles used for standard course roles can be defined in course environment.
- Replacements which match custom roles used in course may not be used.
lonnet.pm
- plaintext() takes additional (fourth) argument
- $forcedefault to force display of standard titles for role.
- get_course_adv_roles() includes call to loncommon::course_type() to get course type.
--raeburn1235869944
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20090301011224.txt"
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.435 loncom/interface/lonparmset.pm:1.436
--- loncom/interface/lonparmset.pm:1.435 Tue Feb 24 18:20:49 2009
+++ loncom/interface/lonparmset.pm Sun Mar 1 01:12:20 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set parameters for assessments
#
-# $Id: lonparmset.pm,v 1.435 2009/02/24 18:20:49 hauer Exp $
+# $Id: lonparmset.pm,v 1.436 2009/03/01 01:12:20 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2268,6 +2268,7 @@
my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
my (%crsinfo,$chome);
+ my $crstype = &Apache::loncommon::course_type();
#
# Go through list of changes
@@ -2278,6 +2279,23 @@
if ($name eq 'newp') {
$name = $env{'form.newp_name'};
}
+ if ($name =~ /^rolenames_([^_]+)$/) {
+ $name = $1.'.plaintext';
+ my $standardtitle =
+ &Apache::lonnet::plaintext($1,$crstype,$env{'request.course.id'},1);
+ my %adv_roles =
+ &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
+ if ($value ne '') {
+ foreach my $role (keys(%adv_roles)) {
+ if ($role =~ m{^cr/$match_domain/$match_name/\Q$value\E$}) {
+ $setoutput.= '<span class="LC_error">'.
+ &mt('Requested replacement title for [_1] role is already used as the name of a custom role ([_2]).',$standardtitle,$value).
+ '</span><br />';
+ undef($value);
+ }
+ }
+ }
+ }
if ($name eq 'url') {
$value=~s/^\/res\///;
my $bkuptime=time;
@@ -2599,6 +2617,9 @@
&mt('Display Categories').'</a>',
'datelocale'
=> '<b>'.&mt('Locale used for course calendar').'</b>',
+ 'rolenames'
+ => '<b>'.&mt('Replacement titles for standard course roles').'</b><br />'.
+ '('.&mt('To replace the standard title for a course role, enter the title you wish to use, otherwise leave blank.').')',
);
my @Display_Order = ('url','description','courseid','cloners');
(my $can_toggle_cat,$can_categorize) = &can_modify_catsettings($dom);
@@ -2623,6 +2644,7 @@
'languages',
'timezone',
'datelocale',
+ 'rolenames',
'nothideprivileged',
'rndseed',
'receiptalg',
@@ -2646,7 +2668,8 @@
foreach my $parameter (sort(keys(%values))) {
unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./) ||
($parameter =~ m/^selfenroll_/) || ($parameter =~ /_selfenroll$/)
- || ($parameter eq 'type')) {
+ || ($parameter eq 'type') ||
+ ($parameter =~ m/^(cc|in|ta|ep|ad|st)\.plaintext$/)) {
if (! $descriptions{$parameter}) {
$descriptions{$parameter}=$parameter;
push(@Display_Order,$parameter);
@@ -2686,7 +2709,27 @@
$output .= '<td>'.
&Apache::loncommon::select_datelocale($parameter.'_value',
$currdatelocale,
- $onchange,$includeempty).'</td>';
+ $onchange,$includeempty).'</td>';
+ } elsif ($parameter eq 'rolenames') {
+ $output.= '<td><table>';
+ foreach my $role ('cc','in','ta','ep','ad','st') {
+ my $onchange = 'onFocus="javascript:window.document.forms'.
+ "['envform'].elements['".
+ $parameter.'_'.$role."_setparmval']".
+ '.checked=true;"';
+ $output.= '<tr><td>'.&Apache::lonnet::plaintext($role,$crstype,undef,1).
+ '</td><td>'.
+ &Apache::lonhtmlcommon::textbox($parameter.'_'.$role.'_value',
+ $values{$role.'.plaintext'},
+ 15,$onchange).
+ '</td></tr>';
+ }
+ $output .= '</table></td><td><table>';
+ foreach my $role ('cc','in','ta','ep','ad','st') {
+ $output .= '<tr><td>'.&Apache::lonhtmlcommon::checkbox($parameter.'_'.$role.'_setparmval').
+ '</td></tr>';
+ }
+ $output .= '</table></td>';
} elsif ($parameter eq 'categories') {
my $catdisplay;
if ($values{'categories'} ne '') {
@@ -2708,9 +2751,11 @@
$values{$parameter},
40,$onchange).'</td>';
}
- $output .= '<td>'.
- &Apache::lonhtmlcommon::checkbox($parameter.'_setparmval').
- '</td>';
+ unless ($parameter eq 'rolenames') {
+ $output .= '<td>'.
+ &Apache::lonhtmlcommon::checkbox($parameter.'_setparmval').
+ '</td>';
+ }
$output .= &Apache::loncommon::end_data_table_row()."\n";
}
my $onchange = 'onFocus="javascript:window.document.forms'.
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.987 loncom/lonnet/perl/lonnet.pm:1.988
--- loncom/lonnet/perl/lonnet.pm:1.987 Wed Feb 18 06:54:22 2009
+++ loncom/lonnet/perl/lonnet.pm Sun Mar 1 01:12:23 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.987 2009/02/18 06:54:22 raeburn Exp $
+# $Id: lonnet.pm,v 1.988 2009/03/01 01:12:23 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2677,6 +2677,7 @@
my ($cid,$codes) = @_;
$cid=$env{'request.course.id'} unless (defined($cid));
my %coursehash=&coursedescription($cid);
+ my $crstype = &Apache::loncommon::course_type($cid);
my %nothide=();
foreach my $user (split(/\s*\,\s*/,$coursehash{'nothideprivileged'})) {
if ($user !~ /:/) {
@@ -2707,7 +2708,7 @@
$returnhash{$role}=$username.':'.$domain;
}
} else {
- my $key=&plaintext($role);
+ my $key=&plaintext($role,$crstype);
if ($section) { $key.=' ('.&Apache::lonlocal::mt('Section [_1]',$section).')'; }
if ($returnhash{$key}) {
$returnhash{$key}.=','.$username.':'.$domain;
@@ -5668,16 +5669,19 @@
# ------------------------------------------------------------------ Plain Text
sub plaintext {
- my ($short,$type,$cid) = @_;
+ my ($short,$type,$cid,$forcedefault) = @_;
if ($short =~ /^cr/) {
return (split('/',$short))[-1];
}
if (!defined($cid)) {
$cid = $env{'request.course.id'};
}
- if (defined($cid) && defined($env{'course.'.$cid.'.'.$short.'.plaintext'})) {
- return &Apache::lonlocal::mt($env{'course.'.$cid.'.'.$short.
- '.plaintext'});
+ if (defined($cid) && ($env{'course.'.$cid.'.'.$short.'.plaintext'} ne '')) {
+ unless ($forcedefault) {
+ my $roletext = $env{'course.'.$cid.'.'.$short.'.plaintext'};
+ &Apache::lonlocal::mt_escape(\$roletext);
+ return &Apache::lonlocal::mt($roletext);
+ }
}
my %rolenames = (
Course => 'std',
@@ -9416,9 +9420,14 @@
=item *
-plaintext($short) : return value in %prp hash (rolesplain.tab); plain text
-explanation of a user role term
-
+plaintext($short,$type,$cid,$forcedefault) : return value in %prp hash
+(rolesplain.tab); plain text explanation of a user role term.
+$type is Course (default) or Group.
+If $forcedefault evaluates to true, text returned will be default
+text for $type. Otherwise, if this is a course, the text returned
+will be a custom name for the role (if defined in the course's
+environment). If no custom name is defined the default is returned.
+
=item *
get_my_roles($uname,$udom,$context,$types,$roles,$roledoms,$withsec) :
--raeburn1235869944--