Skip to content

Commit 94aafae

Browse files
committed
Database code clean up.
The main thing that this does is implement the `WeBWorK::DB::Ex` exceptions as the comments in `lib/WeBWorK/DB.pm` (that have been there since 2008) say they were intended to be used. For `WeBWorK::DB::Ex::DependencyNotFound` and `WeBWorK::DB::Ex::RecordNotFound` the error message for the exception is the same as before. So for those the only difference is that they are now Exception::Class objects (which contain more information than just the message). For `WeBWorK::DB::Ex::RecordExists` and `WeBWorK::DB::Ex::TableMissing` the error message for the exception is the error message that DBI gives. The previous messages for `WeBWorK::DB::Ex::RecordExists` like "addUserSet: user set exists (perhaps you meant to use putUserSet?)" no longer replace the DBI exception messages. So as the comments from 2008 stated don't check for the string "user set exists" in the exception message anymore. Instead check if `WeBWorK::DB::Ex::RecordExists->caught` is true. In addition the code for auto creation of password records in `getPasswords` and the auto creation of permission records in `getPermissionLevels` has been deleted simply because that code doesn't even work. It hasn't worked for a long time if it ever did. In both methods the `gets` method is called to retrieve the requested records. The `gets` method does not even include non-existent records in the list it returns. So the auto creation loops were only looping over records that were guaranteed to exist. So that code was purely an inneficient loop that did nothing. Next, the `addMultipleUserSets` and `addUserMultipleProblems` methods of `lib/WeBWorK/DB.pm` were removed. Instead what is needed from those methods is used directly in the `lib/WeBWorK/Utils/Instructor.pm` module where those methods were called. Those methods added a high level of inneficiency to the process of assigning sets and problems to multiple users. For example the methods in `lib/WeBWorK/Utils/Instructor.pm` check that the sets don't already exist and if so it skips them. Then the `addMultipleUserSets` method again checks if the sets exist. Note that the previous `lib/WeBWorK/DB.pm` methods did check for the existence of the users, and this no longer does. That check slows things down considerably, and in all cases those users come from the database to begin with. So it is not really a necessary check. This rewrite speeds up the assignment of multiple sets and problems considerably. Finally, the methods in `lib/WeBWorK/Utils/Instructor.pm` no longer return unused lists of failures. In all of the uses of those methods in the webwork code, there was only one place where those return values were ever used, and even in that case it was not in an essential way. Furthermore, that one usage was in `lib/WeBWorK/SetActions.pm` (for the WebworkWebservice) which is not actually used by webwork2 anyway (or probably even by anyone). Instead of catching and rethrowing exceptions, the exceptions are just let through. The exceptions that were ignored before (but put into a return value that was later ignored) are still ignored. The POD in this file is cleaned up as well.
1 parent 311ec9e commit 94aafae

File tree

5 files changed

+290
-656
lines changed

5 files changed

+290
-656
lines changed

0 commit comments

Comments
 (0)