[LON-CAPA-cvs] cvs: loncom /html/adm/helper parameter.helper /interface lonhelper.pm lonselstudent.pm

raeburn raeburn at source.lon-capa.org
Sat Aug 15 20:21:30 EDT 2015


raeburn		Sun Aug 16 00:21:30 2015 EDT

  Modified files:              
    /loncom/interface	lonhelper.pm lonselstudent.pm 
    /loncom/html/adm/helper	parameter.helper 
  Log:
  - Bug 5349
    - When parameter helper is used by a user with a section-specific role,
      changes may only be made for users in that section.
  
  
-------------- next part --------------
Index: loncom/interface/lonhelper.pm
diff -u loncom/interface/lonhelper.pm:1.195 loncom/interface/lonhelper.pm:1.196
--- loncom/interface/lonhelper.pm:1.195	Sat Aug 15 20:11:57 2015
+++ loncom/interface/lonhelper.pm	Sun Aug 16 00:21:21 2015
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # .helper XML handler to implement the LON-CAPA helper
 #
-# $Id: lonhelper.pm,v 1.195 2015/08/15 20:11:57 raeburn Exp $
+# $Id: lonhelper.pm,v 1.196 2015/08/16 00:21:21 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2621,6 +2621,12 @@
 If true, only active students and course personnel will be
 shown. Defaults to false.
 
+=item * B<sectiononly>:
+
+If true, and user's role is in a specific section, only course personnel 
+will be shown if they also have a section-specific role in the same section.
+Defaults to false.
+
 =item * B<emptyallowed>:
 
 If true, the selection of no users is allowed. Defaults to false.
@@ -2656,6 +2662,7 @@
     $helper->declareVar($paramHash->{'variable'});
     $paramHash->{'multichoice'} = $token->[2]{'multichoice'};
     $paramHash->{'coursepersonnel'} = $token->[2]{'coursepersonnel'};
+    $paramHash->{'sectiononly'} = $token->[2]{'sectiononly'};
     $paramHash->{'activeonly'} = $token->[2]{'activeonly'};
     if (defined($token->[2]{'nextstate'})) {
         $paramHash->{NEXTSTATE} = $token->[2]{'nextstate'};
@@ -2697,11 +2704,17 @@
 	delete($defaultUsers{''});
     }
 
+    my $personnel_section;
+    if ($self->{'sectiononly'}) {
+        $personnel_section = $env{'request.course.sec'};
+    }
+
     my ($course_personnel, 
 	$current_members, 
 	$expired_members, 
 	$future_members) = 
-	    &Apache::lonselstudent::get_people_in_class($env{'request.course.sec'});
+	    &Apache::lonselstudent::get_people_in_class($env{'request.course.sec'},
+	                                                $personnel_section);
 
     # Load up the non-students, if necessary
 
@@ -2709,26 +2722,44 @@
 	unshift @$current_members, (@$course_personnel);
     }
 
+    my %titles = &Apache::lonlocal::texthash(
+                   'active'  => 'Select Currently Enrolled Students and Active Course Personnel',
+                   'future'  => 'Select Future Enrolled Students',
+                   'expired' => 'Select Previously Enrolled Students',
+                 );
+
+    if ($env{'request.course.sec'}) {
+        if ($self->{'sectiononly'}) {
+            $titles{'active'} = &mt('Select Currently Enrolled Students and Active Course Personnel in Section: [_1]',
+                                $env{'request.course.sec'});
+        } else {
+            $titles{'active'} = &mt('Select Currently Enrolled Students in Section: [_1], and Active Course Personnel',
+                                    $env{'request.course.sec'});
+        }
+        $titles{'future'} = &mt('Select Future Enrolled Students in Section: [_1]',
+                                $env{'request.course.sec'});
+        $titles{'expired'} = &mt('Select Previously Enrolled Students in Section: [_1]',
+                                 $env{'request.course.sec'});
+    }
 
-    #   Current personel
+    #   Current personnel
 
-    $result .= '<h4>'.&mt('Select Currently Enrolled Students and Active Course Personnel').'</h4>';
+    $result .= '<h4>'.$titles{'active'}.'</h4>';
     $result .= &Apache::lonselstudent::render_student_list( $current_members,
 							    "helpform",
-							    "current", 
+							    "current",
 							    \%defaultUsers,
 							    $self->{'multichoice'},
 							    $self->{'variable'},
 							    1);
 
-
     # If activeonly is not set then we can also give the expired students:
     #
     if (!$self->{'activeonly'} && ((scalar(@$future_members)) > 0)) {
 
 	# And future.
 
-	$result .= '<h4>'.&mt('Select Future Enrolled Students and Future Course Personnel').'</h4>';
+	$result .= '<h4>'.$titles{'future'}.'</h4>';
        
 	$result .= &Apache::lonselstudent::render_student_list( $future_members,
 								"helpform",
@@ -2741,7 +2772,7 @@
     if (!$self->{'activeonly'} && ((scalar(@$expired_members)) > 0)) {
 	# Past 
 
-	$result .= '<h4>'.&mt('Select Previously Enrolled Students and Inactive Course Personnel').'</h4>';
+	$result .= '<h4>'.$titles{'expired'}.'</h4>';
 	$result .= &Apache::lonselstudent::render_student_list($expired_members,
 							       "helpform",
 							       "past",
Index: loncom/interface/lonselstudent.pm
diff -u loncom/interface/lonselstudent.pm:1.14 loncom/interface/lonselstudent.pm:1.15
--- loncom/interface/lonselstudent.pm:1.14	Thu Jan 15 18:23:27 2009
+++ loncom/interface/lonselstudent.pm	Sun Aug 16 00:21:21 2015
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # lonselstudent.pm : Reusable subs for student selection.
 #
-# $Id: lonselstudent.pm,v 1.14 2009/01/15 18:23:27 raeburn Exp $
+# $Id: lonselstudent.pm,v 1.15 2015/08/16 00:21:21 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -61,7 +61,7 @@
 #  Course personnel elements include:
 #       [0]    Last, First of the user.
 #       [1]    Role held by the user.
-#       [2]    Empty.
+#       [2]    Section associated with role.
 #       [3]    Empty
 #       [4]    username:domain of the user.
 #
@@ -74,25 +74,30 @@
 #       [4]    username:domain of the user.
 #
 sub get_people_in_class {
-    my ($section_restriction) = @_;
-    my %coursepersonnel = &Apache::lonnet::get_course_adv_roles();
+    my ($section_restriction,$personnel_section) = @_;
+    my %coursepersonnel = &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
+    my $crstype = &Apache::loncommon::course_type();
     #
     #  Enumerate the course_personnel.
     #
     my @course_personnel;
-    for my $role (sort(keys(%coursepersonnel))) {
+    foreach my $key (sort(keys(%coursepersonnel))) {
+        my ($role,$section) = split(/:/,$key);
 	# extract the names so we can sort them
+        next if (($personnel_section ne '') && ($personnel_section ne $section)); 
 	my @people;
-	for my $person (split(/,/, $coursepersonnel{$role})) {
+        
+	foreach my $person (split(/,/, $coursepersonnel{$key})) {
 	    my ($uname,$domain) = split(/:/, $person);
 	    push(@people, [&Apache::loncommon::plainname($uname,$domain),
 			   $uname,$domain]);
 	}
 	@people = sort { $a->[0] cmp $b->[0] } (@people);
 	    
-	for my $person (@people) {
+	foreach my $person (@people) {
 	    push(@course_personnel, [join(':', $person->[1],$person->[2]), 
-				     $person->[0], '', '', $role]);
+				     $person->[0], $section, 'Active',
+                                     &Apache::lonnet::plaintext($role)]);
 	}
     }
     #  Students must be split into the three categories:
@@ -179,7 +184,7 @@
 #                     and false for all other calls... only matters if
 #                     multiselect is true.
 #     $context      - If email, do not include <br /><hr /> tags at the end
-#                     of the data table. 
+#                     of the data table.
 #  Returns:
 #     HTML  text to add to the rendering of the helper.
 #
Index: loncom/html/adm/helper/parameter.helper
diff -u loncom/html/adm/helper/parameter.helper:1.20 loncom/html/adm/helper/parameter.helper:1.21
--- loncom/html/adm/helper/parameter.helper:1.20	Sat Aug 15 20:12:04 2015
+++ loncom/html/adm/helper/parameter.helper	Sun Aug 16 00:21:28 2015
@@ -157,7 +157,7 @@
            . . . for a particular <b>group</b></choice>
       </condition>
       <choice computer="student" nextstate="CHOOSE_STUDENT">
-         . . . for an individual <b>student</b></choice>
+         . . . for an individual <b>student</b> or <b>user</b></choice>
       </choices>
     </state>
 
@@ -178,12 +178,12 @@
     </state>
 
 
-  <state name="CHOOSE_STUDENT" title="Select Student">
+  <state name="CHOOSE_STUDENT" title="Select User">
     <eval>
-      return &mt('Please select the student you wish to set the ' .
+      return &mt('Please select the person you wish to set the ' .
        &{$helper->{DATA}->{'dateType'}}() .
          ' for:').'<br />';</eval>
-    <student variable="USER_NAME" nextstate="FINISH" coursepersonnel='1'/>
+    <student variable="USER_NAME" nextstate="FINISH" coursepersonnel="1" sectiononly="1" />
     </state>
 
   <state name="FINISH" title="Verify Selection">


More information about the LON-CAPA-cvs mailing list