Miscellaneous

mysql command to set seeds

mysql command to set seeds

by Alex Jordan -
Number of replies: 1
Hello WeBWorK-mysql gurus,

I want to use the command line to set all the seeds for a particular user in a course. I don't know the first thing about mysql, and I'm worried about doing something dumb and corrupting the database.

Could someone give me an example of how I'd set a seed using the command line? Assume a particular course, a particular user, a particular problem set, a particular problem within that set, and then a specific seed I want to "plant". I'll be doing this as a batch, so hopefully it can be done from the command line without entering mysql's interface. (Or I'd appreciate any tips on scripting within mysql.)

For background, we have a basic algebra OER textbook that has roughly 3000 WW problems in it. For the print version of the book, a seed is used for each question. Essentially if it is the 1234th WW question in the book, the seed is 1234. The problems are put in problem sets, one for each section of the book.

We want to automate getting all the correct answers for all 3000 questions using these same seeds. My strategy is to create an account, assign all the sets to that account, and then set all the seeds for that user to match the seeds that were used in the print copy of the book. I think I can script what I want to do, if I can get the basic mysql command for setting a seed.

Thank you,
Alex
In reply to Alex Jordan

Re: mysql command to set seeds

by Danny Glin -
I'll start with my usual warning about this not being heavily tested, and that there is still the potential to screw things up, though as long as you stick to table names that start with the right course, you shouldn't be able to break anything globally.

Also, this can probably also be done using wwsh, but I have no experience with that.

Here is a bash command using variables defined in the shell:

echo "update ${coursename}_problem_user set problem_seed=$seed where user_id='$userid' and set_id='$setid' and problem_id=$problemid" |mysql webwork


To use this, set $coursename, $seed, $userid, $setid and $problemid in the shell (or your script), then run the command.


In order to not have to enter a mysql password each time the command is run, you should create a .my.cnf file in the home directory of the user running the script with the following contents:


[client]

user=webworkWrite

password=[your_webworkWrite_password]


Let me know if any of this isn't clear.