[LON-CAPA-cvs] cvs: loncom /interface londropadd.pm mydesk.tab
albertel
lon-capa-cvs-allow@mail.lon-capa.org
Thu, 26 Jul 2007 23:48:53 -0000
This is a MIME encoded message
--albertel1185493733
Content-Type: text/plain
albertel Thu Jul 26 19:48:53 2007 EDT
Modified files:
/loncom/interface mydesk.tab londropadd.pm
Log:
- BUG#5335 - instructors should be allowed to clas lists (and sectioned instructors limited to the one section)
--albertel1185493733
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20070726194853.txt"
Index: loncom/interface/mydesk.tab
diff -u loncom/interface/mydesk.tab:1.84 loncom/interface/mydesk.tab:1.85
--- loncom/interface/mydesk.tab:1.84 Mon May 21 20:40:42 2007
+++ loncom/interface/mydesk.tab Thu Jul 26 19:48:53 2007
@@ -58,6 +58,7 @@
4:3:pvgr:$crs:stat.gif:course[_6]:stats[_1]:gopost('/adm/statistics','Problem Statistics');:View course assessment statistics:grd
5:1:clear
5:1:courseenv_student_classlist_view:any:clst.gif:course[_12]:roster[_1]:go('/adm/viewclasslist');:View course roster:umn
+5:1:pvcl:$crs:clst.gif:course[_12]:roster[_1]:go('/adm/dropadd?action=classlist');:View class list:umn
5:1:pcst:$crs:enrl.gif:course[_7]:enroll[_1]:go('/adm/dropadd');:Manage student enrollment:umn
#and groups in this course
5:1:pmky:$requested_domain:keys.gif:manage[_1]:acc keys[_1]:go('/adm/managekeys');:Manage Access Keys:dom
Index: loncom/interface/londropadd.pm
diff -u loncom/interface/londropadd.pm:1.163 loncom/interface/londropadd.pm:1.164
--- loncom/interface/londropadd.pm:1.163 Tue Jul 17 17:24:17 2007
+++ loncom/interface/londropadd.pm Thu Jul 26 19:48:53 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to drop and add students in courses
#
-# $Id: londropadd.pm,v 1.163 2007/07/17 21:24:17 albertel Exp $
+# $Id: londropadd.pm,v 1.164 2007/07/26 23:48:53 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -133,8 +133,7 @@
###############################################################
# Menu Phase One
sub print_main_menu {
- my ($r,$enrl_permission,$view_permission,$grp_manage_permission,
- $grp_view_permission)=@_;
+ my ($r,$permission)=@_;
#
my $cid =$env{'request.course.id'};
my $cdom=$env{'course.'.$cid.'.domain'};
@@ -144,55 +143,56 @@
{ text => 'Upload a class list',
help => 'Course_Create_Class_List',
action => 'upload',
- permission => $enrl_permission,
+ permission => $permission->{'enrl'},
},
{ text => 'Enroll a single student',
help => 'Course_Add_Student',
action => 'enrollstudent',
- permission => $enrl_permission,
+ permission => $permission->{'enrl'},
},
{ text => 'Modify student data',
help => 'Course_Modify_Student_Data',
action => 'modifystudent',
- permission => $enrl_permission,
+ permission => $permission->{'enrl'},
},
{ text => 'View Class List',
help => 'Course_View_Class_List',
action => 'classlist',
- permission => $view_permission,
+ permission => $permission->{'view'},
},
{ text => 'Drop Students',
help => 'Course_Drop_Student',
action => 'drop',
- permission => $enrl_permission,
+ permission => $permission->{'enrl'},
},
{ text => 'Automated Enrollment Manager',
- permission => &Apache::lonnet::auto_run($cnum,$cdom),
+ permission => (&Apache::lonnet::auto_run($cnum,$cdom)
+ && $permission->{'enrl'}),
url => '/adm/populate',
},
{ text => 'Create a new group',
help => 'Course_Create_Group',
- permission => $grp_manage_permission,
+ permission => $permission->{'grp_manage'},
url => '/adm/coursegroups?refpage=enrl&action=create',
},
{ text => 'Modify an existing group',
help => 'Course_Modify_Group',
- permission => $grp_manage_permission,
+ permission => $permission->{'grp_manage'},
url => '/adm/coursegroups?refpage=enrl&action=modify',
},
{ text => 'Delete an existing group',
help => 'Course_Delete_Group',
- permission => $grp_manage_permission,
+ permission => $permission->{'grp_manage'},
url => '/adm/coursegroups?refpage=enrl&action=delete',
},
{ text => 'Re-enable a deleted group',
help => 'Course_Reenable_Group',
- permission => $grp_manage_permission,
+ permission => $permission->{'grp_manage'},
url => '/adm/coursegroups?refpage=enrl&action=reenable',
},
{ text => 'Enter an existing group',
help => 'Course_Display_Group',
- permission => $grp_view_permission,
+ permission => $permission->{'grp_view'},
url => '/adm/coursegroups?refpage=enrl&action=view',
},
);
@@ -1169,7 +1169,7 @@
# ============================================== view classlist
sub print_html_classlist {
- my ($r,$mode) = @_;
+ my ($r,$mode,$permission) = @_;
if (! exists($env{'form.sortby'})) {
$env{'form.sortby'} = 'username';
}
@@ -1233,6 +1233,16 @@
# Print the classlist
$r->print('<h2>'.&mt('Current Class List').'</h2>');
my ($classlist,$keylist)=&Apache::loncoursedata::get_classlist();
+
+ if (exists($permission->{'view_section'})) {
+ my $sec = &Apache::loncoursedata::CL_SECTION();
+ foreach my $student (keys(%{$classlist})) {
+ if ($classlist->{$student}[$sec] ne $permission->{'view_section'}) {
+ delete($classlist->{$student});
+ }
+ }
+ }
+
if (! defined($classlist)) {
$r->print(&mt('There are no students currently enrolled.')."\n");
} else {
@@ -2419,6 +2429,36 @@
END
}
+sub get_permission {
+ my %permission;
+ $permission{'view'} =
+ &Apache::lonnet::allowed('vcl',$env{'request.course.id'});
+ &Apache::lonnet::logthis(" vcl 1 ".$permission{'view'});
+ if (!$permission{'view'}) {
+ my $scope = $env{'request.course.id'}.'/'.$env{'request.course.sec'};
+ $permission{'view'} = &Apache::lonnet::allowed('vcl',$scope);
+ &Apache::lonnet::logthis(" vcl 2 ".$permission{'view'});
+ if ($permission{'view'}) {
+ $permission{'view_section'} = $env{'request.course.sec'};
+ &Apache::lonnet::logthis(" vcl 3 ".$permission{'view'});
+ }
+ }
+
+ $permission{'enrl'} =
+ &Apache::lonnet::allowed('cst',$env{'request.course.id'});
+
+ $permission{'grp_view'} =
+ &Apache::lonnet::allowed('vcg',$env{'request.course.id'});
+ $permission{'grp_manage'} =
+ &Apache::lonnet::allowed('mdg',$env{'request.course.id'});
+ my $allowed = 0;
+ foreach my $perm (values(%permission)) {
+ if ($perm) { $allowed=1; last; }
+ }
+ &Apache::lonnet::logthis(" allowed ".$allowed);
+ return (\%permission,$allowed);
+}
+
###################################################################
###################################################################
@@ -2477,22 +2517,13 @@
return HTTP_NOT_ACCEPTABLE;
}
#
- my $view_permission =
- &Apache::lonnet::allowed('vcl',$env{'request.course.id'});
- my $enrl_permission =
- &Apache::lonnet::allowed('cst',$env{'request.course.id'});
-
- my $grp_view_permission =
- &Apache::lonnet::allowed('vcg',$env{'request.course.id'});
- my $grp_manage_permission =
- &Apache::lonnet::allowed('mdg',$env{'request.course.id'});
+ my ($permission,$allowed) = &get_permission();
- if (! $grp_view_permission && ! $grp_manage_permission &&
- ! $view_permission && ! $enrl_permission) {
+ if (!$allowed) {
$env{'user.error.msg'}=
- "/adm/coursegroups:cst:0:0:Cannot manage or view course groups, ".
- "or drop or add students";
+ "/adm/dropadd:cst:0:0:Cannot manage or view course groups, ".
+ "or drop or add students";
return HTTP_NOT_ACCEPTABLE;
}
@@ -2507,9 +2538,8 @@
# Main switch on form.action and form.state, as appropriate
if (! exists($env{'form.action'})) {
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Enrollment Manager'));
- &print_main_menu($r,$enrl_permission,$view_permission,$grp_manage_permission,
- $grp_view_permission);
- } elsif ($env{'form.action'} eq 'upload' && $enrl_permission) {
+ my $action = &print_main_menu($r,$permission);
+ } elsif ($env{'form.action'} eq 'upload' && $permission->{'enrl'}) {
&Apache::lonhtmlcommon::add_breadcrumb
({href=>'/adm/dropadd?action=upload&state=',
text=>"Upload Classlist"});
@@ -2528,7 +2558,7 @@
} else {
&print_first_courselist_upload_form($r);
}
- } elsif ($env{'form.action'} eq 'drop' && $enrl_permission) {
+ } elsif ($env{'form.action'} eq 'drop' && $permission->{'enrl'}) {
&Apache::lonhtmlcommon::add_breadcrumb
({href=>'/adm/dropadd?action=drop',
text=>"Drop Students"});
@@ -2541,7 +2571,7 @@
} else {
&print_drop_menu($r);
}
- } elsif ($env{'form.action'} eq 'enrollstudent' && $enrl_permission) {
+ } elsif ($env{'form.action'} eq 'enrollstudent' && $permission->{'enrl'}) {
&Apache::lonhtmlcommon::add_breadcrumb
({href=>'/adm/dropadd?action=enrollstudent',
text=>"Enroll Student"});
@@ -2556,35 +2586,35 @@
} else {
&get_student_username_domain_form($r);
}
- } elsif ($env{'form.action'} eq 'classlist' && $view_permission) {
+ } elsif ($env{'form.action'} eq 'classlist' && $permission->{'view'}) {
&Apache::lonhtmlcommon::add_breadcrumb
({href=>'/adm/dropadd?action=classlist',
text=>"View Classlist"});
$r->print(&Apache::lonhtmlcommon::breadcrumbs('View Classlist',
'Course_View_Class_List'));
if (! exists($env{'form.state'})) {
- &print_html_classlist($r,undef);
+ &print_html_classlist($r,undef,$permission);
} elsif ($env{'form.state'} eq 'csv') {
- &print_html_classlist($r,'csv');
+ &print_html_classlist($r,'csv',$permission);
} elsif ($env{'form.state'} eq 'excel') {
- &print_html_classlist($r,'excel');
+ &print_html_classlist($r,'excel',$permission);
} else {
- &print_html_classlist($r,undef);
+ &print_html_classlist($r,undef,$permission);
}
- } elsif ($env{'form.action'} eq 'modifystudent' && $enrl_permission) {
+ } elsif ($env{'form.action'} eq 'modifystudent' && $permission->{'enrl'}) {
&Apache::lonhtmlcommon::add_breadcrumb
({href=>'/adm/dropadd?action=modifystudent',
text=>"Modify Student Data"});
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Modify Student Data',
'Course_Modify_Student_Data'));
if (! exists($env{'form.state'})) {
- &print_html_classlist($r);
+ &print_html_classlist($r,undef,$permission);
} elsif ($env{'form.state'} eq 'selected') {
&print_modify_student_form($r);
} elsif ($env{'form.state'} eq 'done') {
&modify_single_student($r);
} else {
- &print_html_classlist($r);
+ &print_html_classlist($r,undef,$permission);
}
} else {
# We should not end up here, but I guess it is possible
@@ -2592,7 +2622,7 @@
"form.action = ".$env{'form.action'}.
"Someone should fix this.");
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Enrollment Manager'));
- &print_main_menu($r,$enrl_permission,$view_permission);
+ &print_main_menu($r,$permission);
}
#
# Finish up
--albertel1185493733--