[system] / trunk / webwork / system / scripts / removeProfPermissions.pl Repository:
ViewVC logotype

View of /trunk/webwork/system/scripts/removeProfPermissions.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 70 - (download) (as text) (annotate)
Mon Jun 25 18:20:05 2001 UTC (18 years, 5 months ago) by sam
File size: 1830 byte(s)
Removed unneeded scripts (as per discussion with gage, apizer). Added
BEGIN-block method for library inclusion to command-line scripts.

    1 #!/usr/local/bin/webwork-perl
    2 
    3 ## $Id$
    4 
    5 # ##################################################################
    6 # Copyright @ 1995-1998 University of Rochester
    7 # All Rights Reserved
    8 # ##################################################################
    9 
   10 BEGIN {
   11   my $useLibDir = '.';
   12   if    ($0 =~ m|^(/.*)/|)  { $useLibDir = $1; }
   13   elsif ($0 =~ m|^(\..*)/|) { $useLibDir = $1; }
   14   elsif ($0 =~ m|^(.+)/|)   { $useLibDir = "./$1"; }
   15   unshift @INC, $useLibDir;
   16 }
   17 
   18 use webworkInit; # WeBWorKInitLine
   19 
   20 ## removeProfPermissions.pl takes as arguments the coursename and instructors login_name
   21 ##  e.g. removeProfPermissions.pl demoCourse jsmith
   22 
   23 ## NOTE: this should only be run by the professor
   24 
   25 use Global;
   26 use Auth;
   27 use strict;
   28 
   29 
   30 if(@ARGV != 2) {
   31     print "\nSyntax is removeProfPermissions.pl coursename instructorLoginName\n";
   32     print "      (e.g. removeProfPermissions.pl demoCourse jsmith)\n\n";
   33     exit(0);
   34 }
   35 
   36 my $course = $ARGV[0];
   37 my $user = $ARGV[1];
   38 
   39 
   40 &Global::getCourseEnvironment($course);
   41 
   42 my $permissionsFile = &Global::getCoursePermissionsFile($course);
   43 my $scriptDirectory = &Global::getWebworkScriptDirectory($course);
   44 
   45 require "${scriptDirectory}$Global::FILE_pl";
   46 
   47 if (  defined( &get_permissions($user,$permissionsFile) ) ) {
   48     if ( &put_permissions(0,$user,$permissionsFile) ) {
   49         print "Instructor permissions removed for $user\n\n";
   50     }
   51     else {
   52     print "removeProfPermissions.pl: Unable to remove permissions for $user\n\n";
   53     }
   54 }
   55 else {
   56   print "User $user is not listed in the permissions file\n";
   57   print "Cannot remove instructor permissions for $user\n\n";
   58 }
   59 
   60 print "Printout of permissions file\n";
   61 my %perm_hash =get_hash_from_db($permissionsFile);
   62 my(@permKeys) = sort keys %perm_hash;
   63 my $key;
   64 foreach $key (@permKeys) {
   65   print "login = $key       permissions =  $perm_hash{$key}\n";
   66 }
   67 

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9