[LON-CAPA-cvs] cvs: loncom(GCI_1) /interface lonparmset.pm

raeburn raeburn@source.lon-capa.org
Tue, 15 Sep 2009 03:01:17 -0000


raeburn		Tue Sep 15 03:01:17 2009 EDT

  Modified files:              (Branch: GCI_1)
    /loncom/interface	lonparmset.pm 
  Log:
  - Customization for GCI_1
  - Backport 1.436. (Titles used for standard course roles can be defined 
     in course environment). 
  
  
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.413.6.1 loncom/interface/lonparmset.pm:1.413.6.2
--- loncom/interface/lonparmset.pm:1.413.6.1	Tue Sep 15 02:21:20 2009
+++ loncom/interface/lonparmset.pm	Tue Sep 15 03:01:17 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set parameters for assessments
 #
-# $Id: lonparmset.pm,v 1.413.6.1 2009/09/15 02:21:20 raeburn Exp $
+# $Id: lonparmset.pm,v 1.413.6.2 2009/09/15 03:01:17 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2120,6 +2120,7 @@
     my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
 
     my (%crsinfo,$chome);
+    my $crstype = &Apache::loncommon::course_type();
 
     #
     # Go through list of changes
@@ -2129,6 +2130,22 @@
         my $value = $env{'form.'.$name.'_value'};
         if ($name eq 'newp') {
             $name = $env{'form.newp_name'};
+        } elsif ($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\///;
@@ -2451,6 +2468,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);
@@ -2475,6 +2495,7 @@
                              'languages',
                              'timezone',
                              'datelocale',
+                             'rolenames',
 			     'nothideprivileged',
                              'rndseed',
                              'receiptalg',
@@ -2497,8 +2518,9 @@
 			     'task_messages','task_grading'));
 	foreach my $parameter (sort(keys(%values))) {
             unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./) ||
-                    ($parameter =~ m/^selfenroll_/) || ($parameter =~ /_selfenroll$/)
-                    || ($parameter eq 'type')) {
+                    ($parameter =~ m/^selfenroll_/) || ($parameter =~ /_selfenroll$/) ||
+                    ($parameter eq 'type') ||
+                    ($parameter =~ m/^(cc|in|ta|ep|ad|st)\.plaintext$/)) {
                 if (! $descriptions{$parameter}) {
                     $descriptions{$parameter}=$parameter;
                     push(@Display_Order,$parameter);
@@ -2538,7 +2560,28 @@
                 $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 '') {
@@ -2560,9 +2603,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'.