WeBWorK shell - wwsh

From WeBWorK_wiki
Revision as of 22:17, 5 August 2011 by Aubreyja (talk | contribs)
Jump to navigation Jump to search

SYNOPSIS

First, start the shell for a course with course id COURSE_ID:

wwsh COURSE ID

From within the shell, one has direct access to the $db object for that course. Using the $db methods defined in WeBWorK::DB (webwork2/lib/WeBWorK/DB.pm) one can manipulate user records, permission records, and set and problem records.

For example, one can get an array of all userids in the course:

my @userIDs = $db->listUsers();

One can create a new user record, define some properties of that user, and insert the record into the database:

my $new_user = $db->{user}->{record}->new();
$new_user->user_id("sammy");
$new_user->first_name("Sam");
$new_user->last_name("Hathaway");
$db->addUser($new_user);
$db->putUser($new_user);

One can retrieve an existing user record and then retrieve and manipulate the properties of the record and commit those changes back to the database:

$Dennis = $db->getUser("dennis");
print $Dennis -> status();
$Dennis->status("C");
$db->putUser->($Dennis);

The same can be done with permission level records:

$pl = $db -> getPermissionLevel("dennis");
$pl -> permission(10);
$db -> putPermissionLevel($pl);

One also has access to the $ce object for the course. See the documentation in WeBWorK::CourseEnvironment for specific access methods. The $ce object stores data defined in the global.conf file and any overrides set in the course.conf file of a course.

DESCRIPTION

The WeBWorK shell provides a specialized version of the Perl debugger intended for use by system administrators and developers. It can be used for course maintenance tasks and debugging. It can also be used to restore access to a course from the command line.

Inside the shell, the user has access to the $ce course environment object and $db database object for the WeBWorK course whose name is provided as the argument to wwsh.

The script for starting the shell is located in

webwork2/bin/

along with a number of other useful maintenance scripts.

To start the WeBWorK shell, first export the location of your WeBWorK system code as WEBWORK_ROOT</t>. The standard installation instructions have the WeBWorK system code installed in /opt/webwork/webwork2. Using the bash shell the following command will export this location to WEBWORK_ROOT:

export WEBWORK_ROOT=/opt/webwork/webwork2

From within the webwork2/ directory, the command

$ bin/wwsh COURSE_NAME

will start the WeBWorK shell for course COURSE_NAME.