Skip to content

Commit

Permalink
Merge remote-tracking branch 'webwork2-dev/ww2.5.1.1' into ww2.5.1.1
Browse files Browse the repository at this point in the history
Grabbing bugfixes from webwork2-dev/ww2.5.1.1
  • Loading branch information
aubreyja committed Jan 24, 2013
2 parents 640083b + 1be443a commit 031e8c1
Show file tree
Hide file tree
Showing 25 changed files with 432 additions and 94 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ logs/*
conf/*.conf
conf/*.apache2-config
htdocs/site_info.txt
bin/wwapache2ctl
webwork2.komodoproject
#courses.dist/*
20 changes: 9 additions & 11 deletions bin/OPL-update
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/perl
#!/usr/bin/env perl

# This is the script formerly known as loadDB2, and then known as NPL-update.

Expand Down Expand Up @@ -84,6 +84,7 @@ my $dbh = DBI->connect(
my $passwd = $ce->{database_password};
my $user = $ce->{database_username};
my $libraryRoot = $ce->{problemLibrary}->{root};
my $libraryVersion = $ce->{problemLibrary}->{version};
my $verbose = 0;
my $cnt2 = 0;

Expand All @@ -98,21 +99,14 @@ sub dbug {
##Figure out which set of tables to use

my %tables;
if( -e "$libraryRoot/VERSION") {
include("$libraryRoot/VERSION");
if($OPL_VERSION eq '2.5.0') {
if($libraryVersion eq '2.5') {
%tables = %OPLtables;
my $lib = 'OPL';
print "Got OPLtables!\n";
} else {
%tables = %NPLtables;
my $lib = 'NPL';
print "Got NPLtables! (1)\n";
}
warn "Library version is $libraryVersion; using OPLtables!\n";
} else {
%tables = %NPLtables;
my $lib = 'NPL';
print "Got NPLtables! (2)\n";
print "Library version is $libraryVersion; NPLtables! \n";
}

@create_tables = (
Expand Down Expand Up @@ -422,6 +416,10 @@ sub pgfiles {
my ($edition, $textauthor, $textsection, $textproblem, $tagged);
%textinfo=();
my @textproblems = (-1);
if ($name =~ /swf$/) {
my $applet_file = basename($name);
symlink($name,$ce->{webworkDirs}->{htdocs}."/applets/".$applet_file);
}
if ($name =~ /pg$/) {
$pgfile = basename($name);
$pgpath = dirname($name);
Expand Down
111 changes: 111 additions & 0 deletions bin/change_user_id
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 $_;
}
5 changes: 3 additions & 2 deletions bin/check_modules.pl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/perl

#!/usr/bin/env perl
#
use strict;
use warnings;

Expand Down Expand Up @@ -84,6 +84,7 @@
Socket
SQL::Abstract
String::ShellQuote
Text::CSV
Text::Wrap
Tie::IxHash
Time::HiRes
Expand Down
37 changes: 0 additions & 37 deletions conf/CONFIG-README

This file was deleted.

36 changes: 36 additions & 0 deletions conf/authen_CAS.conf.dist
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.
17 changes: 17 additions & 0 deletions conf/authen_LTI.conf.dist
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,23 @@ $authen{user_module} = [
#module but the sequence includes an internal authentication
#system, e.g., Basic_TheLastOption, then the following line
#must be uncommented for use by WeBWorK::Logout.
# If it is uncommented and the value = 1,
# then, if the authentication sequence reaches
# Basic_TheLastOption, then WeBWorK::Login
# will display a screen directing the user
# back to an external authentication system.
# On the other hand, if the value = 0 or
# the line is commented out, then WeBWorK::Login
# will display the traditional passwork login screen.
# Upon logging out, if the line is not commented out
# and the value = 1, then the Logout screen will NOT
# show a "Login Again" button and will display
# a message directing the user to go to the
# external authentication system.
# On the other hand, if the line is commented out
# or if the value = 0, then the Logout screen WILL
# display a "Login Again" button that will take
# the user to a pasword login screen.

#$external_auth=1;

Expand Down
7 changes: 3 additions & 4 deletions conf/defaults.config
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ $courseDirs{html_images} = "$courseDirs{html}/images";

# Location of web-accessible, course-specific temporary files, like static and
# dynamically-generated PG graphics.
$courseDirs{html_temp} = "$courseDirs{html}/tmp";
$courseURLs{html_temp} = "$courseURLs{html}/tmp";
$courseDirs{html_temp} = "$webworkDirs{htdocs_temp}/$courseName";
$courseURLs{html_temp} = "$webworkURLs{htdocs_temp}/$courseName";

# Location of course-specific logs, like the transaction log.
$courseDirs{logs} = "$courseDirs{root}/logs";
Expand All @@ -275,6 +275,7 @@ $courseDirs{templates} = "$courseDirs{root}/templates";

# Location of course achievement files.
$courseDirs{achievements} = "$courseDirs{templates}/achievements";
$courseDirs{achievements_html} = "$courseDirs{html}/achievements"; #contains badge icons
$courseURLs{achievements} = "$courseURLs{html}/achievements";

# Location of course-specific macro files.
Expand Down Expand Up @@ -937,9 +938,7 @@ ${pg}{modules} = [
[qw(Fraction)],
[qw(Fun)],
[qw(Hermite)],
[qw(Inequalities::common)],
[qw(Label)],
[qw(LimitedPolynomial)],
[qw(ChoiceList)],
[qw(Match)],
[qw(MatrixReal1)], # required by Matrix
Expand Down
1 change: 0 additions & 1 deletion htdocs/themes/math2/codemirror2
Submodule codemirror2 deleted from 73edae
1 change: 0 additions & 1 deletion htdocs/themes/ubc/codemirror2
Submodule codemirror2 deleted from 73edae
5 changes: 0 additions & 5 deletions lib/WeBWorK.pm
Original file line number Diff line number Diff line change
Expand Up @@ -377,11 +377,6 @@ sub dispatch($) {
writeTimingLogEntry($ce, "[".$r->uri."]", sprintf("runTime = %.3f sec", $cg_duration)." ".$ce->{dbLayoutName}, "");

debug("returning result: " . (defined $result ? $result : "UNDEF") . "\n");
#@LimitedPolynomial::BOP::ISA; #FIXME this is needed to zero out
#@LimitedPolynomial::UOP::ISA;
#\@LimitedPolynomial::BOP::ISA and prevent error messages of the form
#[Sat May 15 14:23:08 2010] [warn] [client 127.0.0.1] [/webwork2/gage_course/test_set/6/]
#Can't locate package LimitedPolynomial::BOP for @LimitedPolynomial::BOP::add::ISA at /opt/webwork/webwork2/lib/Apache/WeBWorK.pm line 115., referer: http://localhost/webwork2/gage_course/test_set/6/ no one knows why
return $result;
}

Expand Down
10 changes: 5 additions & 5 deletions lib/WeBWorK/AchievementEvaluator.pm
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use WeBWorK::CGI;
use WeBWorK::Utils qw(before after readFile sortAchievements);

use Safe;
use Storable qw(freeze thaw);
use Storable qw(nfreeze thaw);

sub checkForAchievements {

Expand Down Expand Up @@ -225,15 +225,15 @@ sub checkForAchievements {
$achievementPoints += $points;
}

#update counter, freeze localData and store
#update counter, nfreeze localData and store
$userAchievement->counter($counter);
$userAchievement->frozen_hash(freeze($localData));
$userAchievement->frozen_hash(nfreeze($localData));
$db->putUserAchievement($userAchievement);

} #end for loop

#freeze globalData and store
$globalUserAchievement->frozen_hash(freeze($globalData));
#nfreeze globalData and store
$globalUserAchievement->frozen_hash(nfreeze($globalData));
$db->putGlobalUserAchievement($globalUserAchievement);

return $cheevoMessage;
Expand Down
Loading

0 comments on commit 031e8c1

Please sign in to comment.