[LON-CAPA-cvs] cvs: loncom /interface loncommon.pm lonpickstudent.pm

raeburn raeburn@source.lon-capa.org
Fri, 24 Apr 2009 05:28:55 -0000


This is a MIME encoded message

--raeburn1240550935
Content-Type: text/plain

raeburn		Fri Apr 24 05:28:55 2009 EDT

  Modified files:              
    /loncom/interface	loncommon.pm lonpickstudent.pm 
  Log:
  Javascript function: openstdbrowser() has additional (optional arg) courseadvonly
   - if courseadv set to 1, display of course users by lonpickstudent.pm is limited
     to course personnel only (i.e., students are omitted).   
  
  
--raeburn1240550935
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20090424052855.txt"

Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.792 loncom/interface/loncommon.pm:1.793
--- loncom/interface/loncommon.pm:1.792	Fri Apr 24 05:14:09 2009
+++ loncom/interface/loncommon.pm	Fri Apr 24 05:28:55 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.792 2009/04/24 05:14:09 raeburn Exp $
+# $Id: loncommon.pm,v 1.793 2009/04/24 05:28:55 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -408,7 +408,7 @@
    return (<<'ENDSTDBRW');
 <script type="text/javascript" language="Javascript">
     var stdeditbrowser;
-    function openstdbrowser(formname,uname,udom,roleflag,ignorefilter) {
+    function openstdbrowser(formname,uname,udom,roleflag,ignorefilter,courseadvonly) {
         var url = '/adm/pickstudent?';
         var filter;
 	if (!ignorefilter) {
@@ -422,6 +422,7 @@
         url += 'form=' + formname + '&unameelement='+uname+
                                     '&udomelement='+udom;
 	if (roleflag) { url+="&roles=1"; }
+        if (courseadvonly) { url+="&courseadvonly=1"; }
         var title = 'Student_Browser';
         var options = 'scrollbars=1,resizable=1,menubar=0';
         options += ',width=700,height=600';
@@ -433,19 +434,26 @@
 }
 
 sub selectstudent_link {
-   my ($form,$unameele,$udomele)=@_;
+   my ($form,$unameele,$udomele,$courseadvonly)=@_;
+   my $callargs = "'".$form."','".$unameele."','".$udomele."'";
    if ($env{'request.course.id'}) {  
        if (!&Apache::lonnet::allowed('srm',$env{'request.course.id'})
 	   && !&Apache::lonnet::allowed('srm',$env{'request.course.id'}.
 					'/'.$env{'request.course.sec'})) {
 	   return '';
        }
-       return "<a href='".'javascript:openstdbrowser("'.$form.'","'.$unameele.
-        '","'.$udomele.'");'."'>".&mt('Select User')."</a>";
+       if ($courseadvonly)  {
+           $callargs .= ",'',1,1";
+       }
+       return '<span class="LC_nobreak">'.
+              '<a href="javascript:openstdbrowser('.$callargs.');">'.
+              &mt('Select User').'</a></span>';
    }
    if ($env{'request.role'}=~/^(au|dc|su)/) {
-       return "<a href='".'javascript:openstdbrowser("'.$form.'","'.$unameele.
-        '","'.$udomele.'",1);'."'>".&mt('Select User')."</a>";
+       $callargs .= ",1"; 
+       return '<span class="LC_nobreak">'.
+              '<a href="javascript:openstdbrowser('.$callargs.');">'.
+              &mt('Select User').'</a></span>';
    }
    return '';
 }
Index: loncom/interface/lonpickstudent.pm
diff -u loncom/interface/lonpickstudent.pm:1.26 loncom/interface/lonpickstudent.pm:1.27
--- loncom/interface/lonpickstudent.pm:1.26	Sun Mar  1 01:17:20 2009
+++ loncom/interface/lonpickstudent.pm	Fri Apr 24 05:28:55 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Pick a student from the classlist
 #
-# $Id: lonpickstudent.pm,v 1.26 2009/03/01 01:17:20 raeburn Exp $
+# $Id: lonpickstudent.pm,v 1.27 2009/04/24 05:28:55 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -50,7 +50,7 @@
 
     &Apache::loncommon::get_unprocessed_cgi
         ($ENV{'QUERY_STRING'},['filter','form','unameelement','udomelement',
-			       'roles']);
+			       'roles','courseadvonly']);
 # Allowed?
     my $allowed;
     my $scope = $env{'request.course.id'};
@@ -83,20 +83,15 @@
    <input type="hidden" name="$name" value="$value" />
 HIDDEN
     }
-    $filtermsg = '<br />'.
-	&mt('Showing users with a name starting with [_1]',
-	    $filterbutton).'<br />';
+    unless ($env{'form.courseadvonly'}) {
+        $filtermsg = '<br />'.
+	    &mt('Showing users with a name starting with [_1]',
+	        $filterbutton).'<br />';
+    }
     if ($filter eq '') {
 	$filter = '.'
     }
 
-    my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
-    my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
-    my $classlist=&Apache::loncoursedata::get_classlist();
-    my %grouplist=&Apache::lonnet::get_group_membership($cdom,$cnum);
-    my $now = time;
-    my %allgroups = &Apache::longroup::coursegroups($cdom,$cnum);
-
 # --------------------------------------- There is such a user, get environment
 
     $r->print(<<ENDSCRIPT);
@@ -138,60 +133,69 @@
 
 	$r->print('</p>');
 
+        unless ($env{'form.courseadvonly'}) {
+
 # ------------------------------------------------------------------ Students
-	my $result;
-	foreach my $user (sort(keys(%$classlist))) {
-	    # the following undefs are for 'domain', and 'username' respectively.
-	    my (undef,undef,$end,$start,$id,$section,$fullname,$status)=
-		@{$classlist->{$user}};
-	    if ($allowed eq 'section' && $section ne $env{'request.course.sec'}) {
-		next;
-	    }
-	    if ($user=~/^($LONCAPA::username_re)\:($LONCAPA::domain_re)$/) {
-		my ($uname,$udom)=($1,$2);
-		if (($uname=~/^$filter/) || 
-		    ($fullname=~/^$filter/i)) {
-		    my $grouplist = '';
-		    foreach my $group (sort(keys(%allgroups))) {
-			if (exists($grouplist{$group.':'.$uname.':'.$udom})) {
-			    my ($end,$start) = split(/:/,$grouplist{$group.':'.$uname.':'.$udom});
-			    if (($end!=0) && ($end<$now)) { next; }
-			    if (($start!=0) && ($start>$now)) {next; }
-			    $grouplist .= " $group,"; 
-			}
+	    my $result;
+            my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+            my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+            my $classlist=&Apache::loncoursedata::get_classlist();
+            my %grouplist=&Apache::lonnet::get_group_membership($cdom,$cnum);
+            my $now = time;
+            my %allgroups = &Apache::longroup::coursegroups($cdom,$cnum);
+
+	    foreach my $user (sort(keys(%$classlist))) {
+	        # the following undefs are for 'domain', and 'username' respectively.
+	        my (undef,undef,$end,$start,$id,$section,$fullname,$status)=
+		    @{$classlist->{$user}};
+	        if ($allowed eq 'section' && $section ne $env{'request.course.sec'}) {
+		    next;
+	        }
+	        if ($user=~/^($LONCAPA::username_re)\:($LONCAPA::domain_re)$/) {
+		    my ($uname,$udom)=($1,$2);
+		    if (($uname=~/^$filter/) || ($fullname=~/^$filter/i)) {
+		        my $grouplist = '';
+		        foreach my $group (sort(keys(%allgroups))) {
+			    if (exists($grouplist{$group.':'.$uname.':'.$udom})) {
+			        my ($end,$start) = split(/:/,$grouplist{$group.':'.$uname.':'.$udom});
+			        if (($end!=0) && ($end<$now)) { next; }
+			        if (($start!=0) && ($start>$now)) {next; }
+			        $grouplist .= " $group,"; 
+			    }
+		        }
+		        $grouplist =~ s/,$//;
+		        $result .=&Apache::loncommon::start_data_table_row().
+		    	          '<td>'.
+			          '<input type="button" value="'.&mt('Select').'" onClick="gochoose('.
+			          "'".$uname."','".$udom."')".'" /></td>'.
+			          '<td><tt>'.$uname.'</tt></td><td> <tt>'.$udom.
+			          '</tt></td><td>'.
+			          &Apache::loncommon::aboutmewrapper($fullname,
+				    				     $uname,$udom).
+			          '</td><td>'.$id.'</td><td>'.$section.
+			          '</td><td>'.$grouplist.'</td>'.
+			          &Apache::loncommon::end_data_table_row();
 		    }
-		    $grouplist =~ s/,$//;
-		    $result .=&Apache::loncommon::start_data_table_row().
-			      '<td>'.
-			      '<input type="button" value="'.&mt('Select').'" onClick="gochoose('.
-			      "'".$uname."','".$udom."')".'" /></td>'.
-			      '<td><tt>'.$uname.'</tt></td><td> <tt>'.$udom.
-			      '</tt></td><td>'.
-			      &Apache::loncommon::aboutmewrapper($fullname,
-								 $uname,$udom).
-			      '</td><td>'.$id.'</td><td>'.$section.
-			      '</td><td>'.$grouplist.'</td>'.
-			      &Apache::loncommon::end_data_table_row();
-		}
+	        }
 	    }
-	}
-	if (!$result) {
-	    $r->print('<p>'.&mt('No students found.').'</p>');
-	} else {
-	    $r->print(&Apache::loncommon::start_data_table().
-		      &Apache::loncommon::start_data_table_header_row().
-		      &Apache::loncommon::end_data_table_header_row().
-		      '<th>&nbsp;</th>'.
-		      '<th>'.&mt('username').'</th>'.
-		      '<th>'.&mt('domain').'</th>'.
-		      '<th>'.&mt('Name').'</th>'.
-		      '<th>'.&mt('ID').'</th>'.
-		      '<th>'.&mt('section').'</th>'.
-		      '<th>'.&mt('active group(s)').'</th>'.
-		      &Apache::loncommon::end_data_table_header_row().
-		      $result.
-		      &Apache::loncommon::end_data_table());
-	}
+	    if (!$result) {
+	        $r->print('<p>'.&mt('No students found.').'</p>');
+	    } else {
+	        $r->print(&Apache::loncommon::start_data_table().
+	    	          &Apache::loncommon::start_data_table_header_row().
+		          &Apache::loncommon::end_data_table_header_row().
+		          '<th>&nbsp;</th>'.
+		          '<th>'.&mt('username').'</th>'.
+		          '<th>'.&mt('domain').'</th>'.
+		          '<th>'.&mt('Name').'</th>'.
+		          '<th>'.&mt('ID').'</th>'.
+		          '<th>'.&mt('section').'</th>'.
+		          '<th>'.&mt('active group(s)').'</th>'.
+		          &Apache::loncommon::end_data_table_header_row().
+		          $result.
+		          &Apache::loncommon::end_data_table());
+	    }
+        }
     } else {
 	$r->print('<h3>'.&mt('Users with Roles Assigned by').' '.
 		  &Apache::loncommon::plainname($env{'user.name'},

--raeburn1240550935--