## WeBWorK Main Forum

### Changing permission levels directly from the server

by Robin Cruz -
Number of replies: 6

I did not realize that when a  person's classlist information is edited via the Classlist Editor that the permission level is reset to "Guest" by default.  I am now locked out of my course and need to change my permission level back to "professor".  I remember a discussion on this a number of years ago where Mike Gage had a file called "addAdmin" which could be used with "wwsh" to add an instructor to a course after it was created.  I found Mike's code in the Archive, but I can't make it work.  I'm guessing the newer version of WeBWorK is the reason for that.  I have an up-to-date (as of August 2010) version of WeBWorK.  I could try changing the database directly, but I'm hoping there is a way to do this without having to resort to messing with the database.  Here is the code I am using for addAdmin.pl.  This file is in the courses directory where I have been attempting to run the command: wwsh   myCourse  <addAdmin

(I have replaced "myCourse" with the name of the course I'm trying to get back into.)

Thanks -- rac

$db->addUser($db->newUser(user_id=>"admin_rc", first_name=>"Foo",

$db->addPassword($db->newPassword(user_id=>"admin_rc",

$db->addPermissionLevel($db->newPermissionLevel(user_id=>"admin_rc",
permission=>"10"));
exit;

### Re: Changing permission levels directly from the server

by Michael Gage -
Hi Robin,

the "reset to guest" bug is caused by various versions of CGI.pm
Unfortunately the fix that works depends on which version of CGI.pm
is being used on your machine. (see http://webwork.maa.org/wiki/Release_notes_for_WeBWorK_2.4.9#Gotchya.27s ) for details.

The user_id "admin_rc" must not be already in the database. (If it
is replace "add" by "put" throughout.

How wwsh behaves has changed a little, because of underlying changes
in the perl package it was based on. You want to use it as follows:

wwsh mycourse

--- you can no longer tell wwsh which script to run from the initial command.
(this could probably be fixed, but I haven't bothered.)

you first start up wwsh with the course name,
then, inside the wwsh program you use "source" to read in commands
from a file

Hope this helps.

-- Mike

### Re: Changing permission levels directly from the server

by Robin Cruz -

I tried to run wwsh and got the message I'm including below.

Thanks -- rac

-------------------Error message after trying to run wwsh-------------

rcruz@docralph:/opt/webwork/courses$wwsh MAT152_01_F10 /opt/webwork/webwork2/bin/wwsh: line 19: =head1: command not found command-line: unrecognized command. /opt/webwork/webwork2/bin/wwsh: line 23: =cut: command not found /opt/webwork/webwork2/bin/wwsh: line 25: use: command not found /opt/webwork/webwork2/bin/wwsh: line 27: BEGIN: command not found /opt/webwork/webwork2/bin/wwsh: line 28: syntax error near unexpected token "NonStop=1"' /opt/webwork/webwork2/bin/wwsh: line 28:  DB::parse_options("NonStop=1");' In reply to Robin Cruz ### Re: Changing permission levels directly from the server by Michael Gage - It looks like it can't find the location of your copy of perl. Try perl wwsh also take a look at the first line of the wwsh file #!/usr/bin/env perl -d this is suppose to find where your perl program is stored. You may need to replace it by #!/usr/bin/perl -d or #!/usr/local/bin/perl -d You can find where your perl program is stored with which perl which responds with something like: /usr/bin/perl Hope this helps. -- Mike In reply to Michael Gage ### Re: Changing permission levels directly from the server by Robin Cruz - OK, Mike, I think I'm making progress. I still seem to be having problems. I've listed the "addAdmin.pl" file (there are no line breaks between items in one command) and the error messages I'm getting when I run "wwsh". Thanks for your help on this -- rac -----------------------------------addAdmin.pl-----------------------------$db->addUser($db->newUser(user_id=>"admin_rc", first_name=>"Foo", last_name=>"Bar", email_address=>"bar\my.univ.edu", student_id=>"admin_rc", status=>"C", section=>"", recitation=>"", comment=>"administrator"));$db->addPassword($db->newPassword(user_id=>"admin_rc", password=>crypt("foobar", "dc")));$db->addPermissionLevel($db->newPermissionLevel(user_id=>"admin_rc", permission=>"10")); exit; -----------------------Error messages--------------------------- rcruz@docralph:/opt/webwork/courses$ perl /opt/webwork/webwork2/bin/wwsh MAT152_01_F10

Enter h or h h' for help, or man perldebug' for more help.

NonStop = '1'

wwsh - The WeBWorK Shell

Available objects: $ce (WeBWorK::CourseEnvironment)$db (WeBWorK::DB)

Available modules: Data::Dumper

NonStop = '0'

Debugged program terminated. Use q to quit or R to restart,

use o inhibit_exit to avoid stopping after program termination,

h q, h R or h o to get additional info.

>>

>>

>> $db->addUser($db->newUser(user_id=>"admin_rc", first_name=>"Foo",

syntax error at (eval 1008)[/usr/share/perl/5.10/perl5db.pl:638] line 2, at EOF

syntax error at (eval 1011)[/usr/share/perl/5.10/perl5db.pl:638] line 2, near ""administrator")"

>>

>> $db->addPassword($db->newPassword(user_id=>"admin_rc",

syntax error at (eval 1013)[/usr/share/perl/5.10/perl5db.pl:638] line 2, at EOF

syntax error at (eval 1014)[/usr/share/perl/5.10/perl5db.pl:638] line 2, near "))"

>>

>> $db->addPermissionLevel($db->newPermissionLevel(user_id=>"admin_rc",

syntax error at (eval 1016)[/usr/share/perl/5.10/perl5db.pl:638] line 2, at EOF

>> permission=>"10"));

syntax error at (eval 1017)[/usr/share/perl/5.10/perl5db.pl:638] line 2, near ""10")"

>> exit;

### Re: Changing permission levels directly from the server

by Michael Gage -
I'm pretty sure you have hidden characters at the place where the line breaks appear. Perhaps you have \n but you might not see that in a Windows editor which requires \r\n for new lines.

Or perhaps they get inserted by a unix editor such as nano (which tries to hard wrap lines for you if you are not careful)

I got your code to work by copying and pasting it into nano on the unix machine, but I had to manually remove the line breaks that nano "helpfully" inserted in order to keep the lines wrapped.

Hope this helps.

-- Mike

### Re: Changing permission levels directly from the server

by Lars Jensen -
Hi Robin,

If you are the server admin, another way to change the permission is to edit the mysql database. If you have the phpmyadmin gui installed, this is very easy:

Look for the table named coursename_permission, and edit change the permission field for the appropriate user to 10.

Lars.