Hello, Everyone,
For unknown reason, it seems that our webwork lost data for about eight days. Including students answers and the problem sets professors set up during that time period. The backups also backed up the same old data during that time.
It seems to me that there are some logs in the system: for students answers they are in the file /opt/webwork/courses/COURSE_NAME/logs/answer_log and for the problem sets professors created are in the file /opt/webwork/webwork2/logs/COURSE_NAME_transaction.log.
My question is that: how can I recover those problem sets and students answers to the database? (or into the webwork system?)
Thank you,
Steven
In a separate post, I will post what happened to my system to see if anyone can help me to figure out where the problem is. Since this is the most important problem for me at this time, I post this one separately.
Hi Steven,
Once, some years ago, I managed when manually editing the WeBWorK database to screw something up (something like dropping a "where" conditional and seeing the update command say "updated 1589 entries" when I intended to update 6). I'm attaching my script solution. It reads the answer log and generates a mysql script that will then update the problem_user table in the WeBWorK database to reflect the scores that students have recorded in the answer log.
It's a command line (perl) script; usage is indicated in comments at the beginning of the file, but a synopsis should be something like:
$ ./alog2sql /opt/webwork/courses/math001/logs/answer_log > fix.sql $ mysql -u webworkwrite -p webwork < fix.sql
At the risk of stating the obvious, it's worth updating your WeBWorK database before running this.
Gavin
Thanks, Gavin.
I tried your script. This is what I got:
./alog2sql /opt/webwork/courses/math233summer2015/answer_log > fix.sql
Use of uninitialized value $logfile in string at ./alog2sql line 129.
Use of uninitialized value $logfile in concatenation (.) or string at ./alog2sql line 129.
Error opening logfile .
Then I read your script a little bit. And inserted the following line
if ( @ARGV ) {
die( "Error parsing arguments: found input after logfile name $logfile\n" );
}
$logfile = "/opt/webwork/courses/math233summer2015/logs/answer_log";
my $update = 'update `' . $cl . '_problem_user` set status=SCORE and ' .
'last_answer=\'ANSWER\' where user_id=\'USER\' and set_id=\'SET\' ' .
'and problem_id=PROBLEM;' . "\n";
my $insertGWset = 'insert into `' . $cl . '_set_user` (user_id, set_id, ' .
'version_creation_time, open_date, due_date, answer_date, ' .
'version_last_attempt_time) values (\'USER\', \'SET,v1\', DATE, ' .
'DATE, DATE, DATE, DATE);' . "\n";
my $insertGWprb = 'insert into `' . $cl . '_problem_user` (user_id, set_id, ' .
'problem_id, source_file, problem_seed, status, attempted, last_answer ) ' .
'values (\'USER\', \'SET,v1\', PROBLEM, \'setSET/blankProblem2.pg\', ' .
'1234, SCORE, 1, \'ANSWER\');' . "\n";
since I only want to test this single course first. Your script then created the fix.sql file. And I could run the command
Since we lost everything for about 8 days in the database, probably we need to restore the problem sets first?
Thanks,
Steven
I tried your script. This is what I got:
./alog2sql /opt/webwork/courses/math233summer2015/answer_log > fix.sql
Use of uninitialized value $logfile in string at ./alog2sql line 129.
Use of uninitialized value $logfile in concatenation (.) or string at ./alog2sql line 129.
Error opening logfile .
Then I read your script a little bit. And inserted the following line
if ( @ARGV ) {
die( "Error parsing arguments: found input after logfile name $logfile\n" );
}
$logfile = "/opt/webwork/courses/math233summer2015/logs/answer_log";
my $update = 'update `' . $cl . '_problem_user` set status=SCORE and ' .
'last_answer=\'ANSWER\' where user_id=\'USER\' and set_id=\'SET\' ' .
'and problem_id=PROBLEM;' . "\n";
my $insertGWset = 'insert into `' . $cl . '_set_user` (user_id, set_id, ' .
'version_creation_time, open_date, due_date, answer_date, ' .
'version_last_attempt_time) values (\'USER\', \'SET,v1\', DATE, ' .
'DATE, DATE, DATE, DATE);' . "\n";
my $insertGWprb = 'insert into `' . $cl . '_problem_user` (user_id, set_id, ' .
'problem_id, source_file, problem_seed, status, attempted, last_answer ) ' .
'values (\'USER\', \'SET,v1\', PROBLEM, \'setSET/blankProblem2.pg\', ' .
'1234, SCORE, 1, \'ANSWER\');' . "\n";
since I only want to test this single course first. Your script then created the fix.sql file. And I could run the command
mysql -u webworkwrite -p webwork < fix.sqlAfter that, I tried to look for the missed homework HW3 without luck. The homework id HW3 is in the file fix.sql. And the scores or answers or problem sets showed up from the web interface.
Since we lost everything for about 8 days in the database, probably we need to restore the problem sets first?
Thanks,
Steven
Hi Steven,
If you have sets that were created in that 8 day window, I would guess that you would need to create those manually for the restore to work. I'm sure that all of the sets I was restoring data for would have existed, so it's unlikely that I was building the global sets.
Gavin
If you have sets that were created in that 8 day window, I would guess that you would need to create those manually for the restore to work. I'm sure that all of the sets I was restoring data for would have existed, so it's unlikely that I was building the global sets.
Gavin