From 490e7ab6176a45346727ccdb016986a467dc78f7 Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Thu, 12 Feb 2026 16:19:02 -0600 Subject: [PATCH] Fix an issue with adding or updating users when the accomodation_time_factor is not set. The `gen_new` method is not sufficient to create the new method for database tables with default values for columns. So the `newUser` method needs to be created manually and make sure the default is set. This was reported in issue #2910, and fixes that issue and most likely other places where users are added or updated without explicitly setting the `accomodation_time_factor`. --- lib/WeBWorK/DB.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/WeBWorK/DB.pm b/lib/WeBWorK/DB.pm index 5ccf5e0eba..2aa588e0d9 100644 --- a/lib/WeBWorK/DB.pm +++ b/lib/WeBWorK/DB.pm @@ -436,13 +436,19 @@ sub abort_transaction { BEGIN { *User = gen_schema_accessor("user"); - *newUser = gen_new("user"); *countUsersWhere = gen_count_where("user"); *existsUserWhere = gen_exists_where("user"); *listUsersWhere = gen_list_where("user"); *getUsersWhere = gen_get_records_where("user"); } +sub newUser { + my ($self, @data) = @_; + my $user = $self->{user}{record}->new(@data); + $user->accommodation_time_factor(1) unless defined $user->accommodation_time_factor; + return $user; +} + sub countUsers { return scalar shift->listUsers(@_) } # Note: This returns a list of user_ids for all users except set level proctors.