forked from openwebwork/webwork2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request openwebwork#80 from openwebwork/master
sync ww2.5.1.1 with master
- Loading branch information
Showing
17 changed files
with
348 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
#!/usr/bin/env perl | ||
# | ||
#Sometimes a webwork user id changes. This script transfers the webwork data for the old user_id to the new user_id | ||
# Update database tables | ||
#user | ||
#permission | ||
#password | ||
#key | ||
#set_user | ||
#problem_user | ||
#set_locations_user | ||
#global_achievement_user | ||
#achievement_user | ||
# | ||
# Update answer_log | ||
|
||
use strict; | ||
use warnings; | ||
use File::Copy; | ||
use File::Basename; | ||
|
||
BEGIN { | ||
die "WEBWORK_ROOT not found in environment.\n" | ||
unless exists $ENV{WEBWORK_ROOT}; | ||
} | ||
|
||
use lib "$ENV{WEBWORK_ROOT}/lib"; | ||
use WeBWorK::CourseEnvironment; | ||
use WeBWorK::DB; | ||
use WeBWorK::Utils qw(runtime_use readFile cryptPassword); | ||
use Data::Dumper; | ||
|
||
if((scalar(@ARGV) != 3)) { | ||
print "\nSyntax is: change_user_id course_id old_user_id new_user_id"; | ||
print "\n (e.g. newpassword MAT_123 jjones jsmith\n\n"; | ||
exit(); | ||
} | ||
|
||
my $courseID = shift; | ||
my $old_user_id = shift; | ||
my $new_user_id = shift; | ||
|
||
my $ce = WeBWorK::CourseEnvironment->new({ | ||
webwork_dir => $ENV{WEBWORK_ROOT}, | ||
courseName => $courseID | ||
}); | ||
|
||
my $db = new WeBWorK::DB($ce->{dbLayout}); | ||
die "Error: $old_user_id does not exist!" unless $db->existsUser($old_user_id); | ||
|
||
unless($db->existsUser($new_user_id)) { | ||
my $user = $db->getUser($old_user_id); | ||
$user->{user_id}=$new_user_id; | ||
$user->{comment} = $user->{comment}."Record created from $old_user_id record"; | ||
$db->addUser($user); | ||
} | ||
|
||
unless($db->existsPassword($new_user_id)) { | ||
my $password = $db->getPassword($old_user_id); | ||
$password->{user_id} = $new_user_id; | ||
$db->addPassword($password); | ||
} | ||
|
||
unless($db->existsPermissionLevel($new_user_id)) { | ||
my $permission = $db->getPermissionLevel($old_user_id); | ||
$permission->{user_id} = $new_user_id; | ||
$db->addPermissionLevel($permission); | ||
} | ||
|
||
|
||
my @old_user_sets = $db->listUserSets($old_user_id); | ||
foreach(@old_user_sets) { | ||
my $set_id = $_; | ||
my $new_set = $db->newUserSet; | ||
$new_set->user_id($new_user_id); | ||
$new_set->set_id($set_id); | ||
eval{$db->addUserSet($new_set)}; | ||
my $old_set = $db->getUserSet($old_user_id,$set_id); | ||
foreach(keys %$old_set) { | ||
next if /user_id|set_id/; | ||
$new_set->$_($old_set->$_); | ||
} | ||
|
||
$db->putUserSet($new_set) unless $db->existsUserSet($new_user_id,$set_id); | ||
my @global_problems = grep { defined $_} $db->getAllGlobalProblems($set_id); | ||
foreach(@global_problems) { | ||
if($db->existsUserProblem($old_user_id,$set_id,$_->{problem_id})) { | ||
my $old_user_problem = $db->getUserProblem($old_user_id,$set_id,$_->{problem_id}); | ||
my $new_user_problem = $db->newUserProblem; | ||
$new_user_problem->user_id($new_user_id); | ||
$new_user_problem->set_id($set_id); | ||
$new_user_problem->problem_id($_->{problem_id}); | ||
$db->addUserProblem($new_user_problem) unless $db->existsUserProblem($new_user_id,$set_id,$_->{problem_id}); | ||
foreach(keys %$old_user_problem) { | ||
next if /(user_id|set_id|problem_id)/; | ||
$new_user_problem->$_($old_user_problem->$_); | ||
} | ||
$db->putUserProblem($new_user_problem); | ||
} | ||
} | ||
} | ||
|
||
my $answer_log = $ce->{courseFiles}->{logs}->{answer_log}; | ||
my $dirname = dirname($answer_log); | ||
copy($answer_log,"$dirname/answer_log.bak"); | ||
open(my $in,'<',"$dirname/answer_log.bak") or die "Can't open $dirname/answer_log.bak:$!"; | ||
open(my $out,'>',$answer_log); | ||
while(<$in>) { | ||
s/$old_user_id/$new_user_id/g; | ||
print $out $_; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!perl | ||
|
||
######################################################################################## | ||
# authen_CAS.conf.dist | ||
# Copy this file to authen_CAS.conf. Then configure it to match your server's CAS configuration. | ||
# Then to activate add the following line to localOverrides.conf: | ||
# include("conf/authen_CAS.conf") | ||
######################################################################################## | ||
|
||
# Set CAS as the authentication module to use. | ||
$authen{user_module} = { | ||
"*" => "WeBWorK::Authen::CAS", | ||
}; | ||
|
||
$authen{cas_options} = { | ||
# Options to pass to the AuthCAS module. | ||
# Note that this is (plain) AuthCAS, not Apache::AuthCAS | ||
# or Apache2::AuthCAS. | ||
# You need at least casUrl and CAFile; others can be set as well. | ||
AuthCAS_opts => { | ||
# URL of CAS server. Edit the host below. | ||
casUrl => '', #e.g. 'https://auth.berkeley.edu/cas', | ||
|
||
# Path of certificate file for CAS server. | ||
CAFile => '', #e.g. '/etc/pki/tls/certs/ca-bundle.crt', | ||
}, | ||
# There are no options specific to CAS at this time. If there were, | ||
# though, they would go here. | ||
|
||
# For debugging: | ||
#su_from => '8315', | ||
su_to => '999999', | ||
}; | ||
|
||
|
||
1; #final line of the file to reassure perl that it was read properly. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule codemirror2
deleted from
73edae
Submodule codemirror2
deleted from
73edae
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.