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

Annotation of /trunk/webwork/system/scripts/setProfPermissions.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 70 - (view) (download) (as text)

1 : sam 11 #!/usr/local/bin/webwork-perl
2 : sam 2
3 :     ## $Id$
4 :    
5 :     # ##################################################################
6 :     # Copyright @ 1995-1999 University of Rochester
7 :     # All Rights Reserved
8 :     # ##################################################################
9 :    
10 : sam 70 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 : sam 2
18 : sam 70 use webworkInit; # WeBWorKInitLine
19 :    
20 : sam 2 ## setProfPermissions.pl takes as arguments the coursename and instructors login_name
21 :     ## e.g. setInstructorPermissions.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 :     if(@ARGV != 2) {
30 :     print "\nSyntax is setProfPermissions.pl coursename instructorLoginName\n";
31 :     print " (e.g. setProfPermissions.pl demoCourse jsmith) \n\n";
32 :     exit(0);
33 :     }
34 :    
35 :     my $course = $ARGV[0];
36 :     my $user = $ARGV[1];
37 :    
38 :    
39 :     &Global::getCourseEnvironment($course);
40 :    
41 :     my $permissionsFile = &Global::getCoursePermissionsFile($course);
42 :     my $scriptDirectory = &Global::getWebworkScriptDirectory($course);
43 :    
44 :     require "${scriptDirectory}$Global::FILE_pl";
45 :    
46 :     # first verify that the user already has a permission set
47 :    
48 :     if ( defined( &get_permissions($user,$permissionsFile) ) ) {
49 :     if ( &put_permissions($Global::instructor_permissions,$user,$permissionsFile) ) {
50 :     print "Instructor permissions set for $user\n\n";
51 :     }
52 :     else {
53 :     print "setProfPermissions.pl: Unable to set permissions for $user\n\n";
54 :     }
55 :     }
56 :     else {
57 :     print "User $user is not listed in the permissions file\n";
58 :     print "Cannot set instructor permissions for $user\n\n";
59 :     }
60 :    
61 :     print "Printout of permissions file\n";
62 :     my %perm_hash =get_hash_from_db($permissionsFile);
63 :     my(@permKeys) = sort keys %perm_hash;
64 :     my $key;
65 :     foreach $key (@permKeys) {
66 :     print "login = $key permissions = $perm_hash{$key}\n";
67 :     }

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9