Fix classlist exporting with users that do not have passwords. #2705
+20
−19
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
exportUsersToCSV
method ofWeBWorK::ContentGenerator::Instructor::UserList
assumes that all users have password and permission records in the database. Since that is no longer the case, that code is not working right. In fact if some users do not have password records and others do, then the resulting classlist that is exported will have many passwords in associated to the wrong users. Some of the users that don't have passwords will have passwords, and vice versa. Note that the code haddefined
statements checking if the permission and password records exist, which mean that the code was technically incorrect to begin with. It only worked because usually all users had password and permission records.The general issue with this is noted in #2704 with regards to the deletion of the code that auto creates password or permission records when
getPasswords
orgetPermissionLevels
is called. The general issue is that thegetPasswords
andgetPermissionLevels
methods call theWeBWorK::DB::Schema::NewSQL::Std::gets
method which does not even include non-existent records. So for example, ifgetPasswords
is called with the list of user IDs'user1', 'user2', 'user3'
anduser2
does not have a password, but the others do, thengetPasswords
will return an array with two elements which are the password records foruser1
anduser3
. So when iterating by index on the original list the password record foruser1
will correctly go touser1
, but the password record foruser3
will be paired withuser2
, anduser3
will not have a password record.Also, the
exportUsersToCSV
dies if the provided filename contains a forward slash. So now the JavaScript form validation checks for this, and prevents those filenames from being submitted to the server. Thus preventing thedie
statement from occurring.