[LON-CAPA-cvs] cvs: loncom /interface loncommon.pm lonpickstudent.pm
www
lon-capa-cvs@mail.lon-capa.org
Wed, 13 Aug 2003 20:40:31 -0000
www Wed Aug 13 16:40:31 2003 EDT
Modified files:
/loncom/interface loncommon.pm lonpickstudent.pm
Log:
Bug #768: Now, if you are not in a course, the "Select User" link on the
CUSR front page can show the users whom you had assigned roles to, including
co-authors.
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.110 loncom/interface/loncommon.pm:1.111
--- loncom/interface/loncommon.pm:1.110 Fri Jul 25 06:44:36 2003
+++ loncom/interface/loncommon.pm Wed Aug 13 16:40:31 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.110 2003/07/25 10:44:36 www Exp $
+# $Id: loncommon.pm,v 1.111 2003/08/13 20:40:31 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -311,14 +311,15 @@
}
sub studentbrowser_javascript {
- unless ($ENV{'request.course.id'}) { return ''; }
- unless (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) {
- return '';
- }
+ unless (
+ (($ENV{'request.course.id'}) &&
+ (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})))
+ || ($ENV{'request.role'}=~/^(au|dc|su)/)
+ ) { return ''; }
return (<<'ENDSTDBRW');
<script type="text/javascript" language="Javascript" >
var stdeditbrowser;
- function openstdbrowser(formname,uname,udom) {
+ function openstdbrowser(formname,uname,udom,roleflag) {
var url = '/adm/pickstudent?';
var filter;
eval('filter=document.'+formname+'.'+uname+'.value;');
@@ -329,6 +330,7 @@
}
url += 'form=' + formname + '&unameelement='+uname+
'&udomelement='+udom;
+ if (roleflag) { url+="&roles=1"; }
var title = 'Student_Browser';
var options = 'scrollbars=1,resizable=1,menubar=0';
options += ',width=700,height=600';
@@ -340,13 +342,19 @@
}
sub selectstudent_link {
- my ($form,$unameele,$udomele)=@_;
- unless ($ENV{'request.course.id'}) { return ''; }
- unless (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) {
- return '';
- }
- return "<a href='".'javascript:openstdbrowser("'.$form.'","'.$unameele.
+ my ($form,$unameele,$udomele)=@_;
+ if ($ENV{'request.course.id'}) {
+ unless (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) {
+ return '';
+ }
+ return "<a href='".'javascript:openstdbrowser("'.$form.'","'.$unameele.
'","'.$udomele.'");'."'>Select User</a>";
+ }
+ if ($ENV{'request.role'}=~/^(au|dc|su)/) {
+ return "<a href='".'javascript:openstdbrowser("'.$form.'","'.$unameele.
+ '","'.$udomele.'",1);'."'>Select User</a>";
+ }
+ return '';
}
sub coursebrowser_javascript {
Index: loncom/interface/lonpickstudent.pm
diff -u loncom/interface/lonpickstudent.pm:1.5 loncom/interface/lonpickstudent.pm:1.6
--- loncom/interface/lonpickstudent.pm:1.5 Sat May 10 19:01:56 2003
+++ loncom/interface/lonpickstudent.pm Wed Aug 13 16:40:31 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Pick a student from the classlist
#
-# $Id: lonpickstudent.pm,v 1.5 2003/05/10 23:01:56 www Exp $
+# $Id: lonpickstudent.pm,v 1.6 2003/08/13 20:40:31 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -48,21 +48,23 @@
</head>
ENDDOCUMENT
-# Is this even in a course?
- unless ($ENV{'request.course.id'}) {
- $r->print('<body>Not in a course</body>');
- return OK;
- }
-
- unless (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) {
- $r->print('<body>No course listing</body>');
- return OK;
- }
&Apache::loncommon::get_unprocessed_cgi
- ($ENV{'QUERY_STRING'},['filter','form','unameelement','udomelement']);
+ ($ENV{'QUERY_STRING'},['filter','form','unameelement','udomelement',
+ 'roles']);
+# Allowed?
+
+ unless (($ENV{'form.roles'}) ||
+ (($ENV{'request.course.id'}) &&
+ (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})))) {
+ $r->print('<body>No context.</body>');
+ return OK;
+ }
+
+# See if filter present
+
my $filter=$ENV{'form.filter'};
$filter=~s/\W//g;
unless ($filter) { $filter='.'; }
@@ -86,9 +88,12 @@
</script>
ENDSCRIPT
- $r->print('<h3>'.$ENV{'course.'.$ENV{'request.course.id'}.'.description'}.
- '</h3><form>');
+ $r->print('<form>');
+ if ((&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) &&
+ (!$ENV{'form.roles'})) {
# -------------------------------------------------------- Get course personnel
+ $r->print('<h3>'.$ENV{'course.'.$ENV{'request.course.id'}.'.description'}.
+ '</h3>');
my %coursepersonnel=
&Apache::lonnet::get_course_adv_roles();
$r->print('<table border="2">');
@@ -107,7 +112,7 @@
if ($filter ne '.') {
$r->print('<br/ >Name starting with "'.$filter.'"<br />');
}
- $r->print('</p><table>');
+ $r->print('</p><p><table>');
# ------------------------------------------------------------------ Students
foreach (sort keys %$classlist) {
# the following undefs are for 'domain', and 'username' respectively.
@@ -120,7 +125,7 @@
$r->print('<tr><td>'.
'<input type="button" value="Select" onClick="gochoose('.
"'".$uname."','".$udom."')".'" /></td>'.
- '<td><tt>'.$uname.'</tt></td><td><tt>'.$udom.
+ '<td><tt>'.$uname.'</tt></td><td> <tt>'.$udom.
'</tt></td><td>'.
&Apache::loncommon::aboutmewrapper(
$fullname,
@@ -130,8 +135,39 @@
}
}
- $r->print('</table></form></body></html>');
- return OK;
+ $r->print('</table></p>');
+ } else {
+ $r->print('<h3>Users with Roles Assigned by '.
+ &Apache::loncommon::plainname($ENV{'user.name'},
+ $ENV{'user.domain'}).'</h3>');
+ if ($filter ne '.') {
+ $r->print('<br/ >Name starting with "'.$filter.'"<br />');
+ }
+ $r->print('<p><table>');
+ my %users=&Apache::lonnet::get_my_roles();
+ foreach (sort keys %users) {
+ if ($_=~/^(\w+)\:(\w+)\:(\w+)$/) {
+ my ($uname,$udom,$urole)=($1,$2,$3);
+ my $fullname=&Apache::loncommon::plainname($uname,$udom);
+ if (($uname=~/^$filter/) ||
+ ($fullname=~/^$filter/i)) {
+ $r->print('<tr><td>'.
+ '<input type="button" value="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><td>'.
+ &Apache::lonnet::plaintext($urole).
+ '</td></tr>');
+ }
+ }
+ }
+ $r->print('</table></p>');
+ }
+ $r->print('</form></body></html>');
+ return OK;
}
1;