Sorry for not responding to this sooner; I didn't notice it until now. Here's a partial answer that has been working for me: instead of using $db->addUserSet()
, I use WeBWorK::ContentGenerator::Instructor->assignSetsToUsers()
. I should caution that this has worked up to WeBWorK 2.7, but I haven't tested it on 2.10 yet. My code looks something like the following:
# $db is the database object # $ce is the course environment object my $fr = new FakeRequest($db, $ce); my $instrCG = WeBWorK::ContentGenerator::Instructor->new($fr); $instrCG->assignSetsToUsers( $setNamesRef, [@userIDs] ); # FakeRequest is a shell that has the # methods that the content generator expects # of a Request object: package FakeRequest; sub new { my ( $class, $db, $ce ) = @_; my $authz = new FakeAuthz; return( bless( { ce=>$ce, db=>$db, authz=>$authz }, $class ); } sub ce { my $self = shift(); return $self->{ce}; } sub db { my $self = shift(); return $self->{db}; } sub authz { my $self = shift(); return $self->{authz}; } sub param { my $self = shift(); $self->{$_[0]} = $_[1] if ( @_ > 1 ); return $self->{$_[0]}; } 1; package FakeAuthz; sub new { my $class = shift(); return( bless( { }, $class ) ); } sub hasPermissions { return 1; } 1;
Here $setNamesRef
is an array reference giving the list of set names to assign to the array of users @userIDs
.
In any case, in case it's useful.
Cheers,
Gavin