From e36c5612339916a04ea32e04ae6acb2b0bc08518 Mon Sep 17 00:00:00 2001
From: Glenn Rice
Date: Wed, 11 Nov 2026 09:30:17 -0600
Subject: [PATCH 1/2] Use the user record full_name method everywhere a user's
full name is shown.
Several places built a user's full name by joining the first and last names
manually instead of using the `full_name` method of the user database record.
Those places now all use that method.
Co-Authored-By: Claude Opus 5.5
---
lib/Caliper/Actor.pm | 2 +-
lib/WeBWorK/ContentGenerator/Grades.pm | 2 +-
lib/WeBWorK/ContentGenerator/Instructor/SendMail.pm | 8 +++-----
.../ContentGenerator/Instructor/StudentProgress.pm | 2 +-
lib/WeBWorK/ContentGenerator/Options.pm | 5 ++---
lib/WeBWorK/Utils/Rendering.pm | 2 +-
templates/ContentGenerator/Hardcopy/form.html.ep | 2 +-
.../Instructor/StudentProgress/set_progress.html.ep | 2 +-
templates/ContentGenerator/Instructor/UserDetail.html.ep | 2 +-
templates/ContentGenerator/LoginProctor.html.ep | 2 +-
templates/ContentGenerator/Options.html.ep | 2 +-
11 files changed, 14 insertions(+), 17 deletions(-)
diff --git a/lib/Caliper/Actor.pm b/lib/Caliper/Actor.pm
index 6c1e4ea30c..f3babde578 100644
--- a/lib/Caliper/Actor.pm
+++ b/lib/Caliper/Actor.pm
@@ -7,7 +7,7 @@ sub generate_default_actor ($c, $user) {
return {
id => Caliper::ResourceIri->new($c->ce)->actor_homepage($user->user_id),
type => 'Person',
- name => $user->first_name . ' ' . $user->last_name
+ name => $user->full_name
};
}
diff --git a/lib/WeBWorK/ContentGenerator/Grades.pm b/lib/WeBWorK/ContentGenerator/Grades.pm
index 64fb0f1c68..e0befbc0cb 100644
--- a/lib/WeBWorK/ContentGenerator/Grades.pm
+++ b/lib/WeBWorK/ContentGenerator/Grades.pm
@@ -366,7 +366,7 @@ sub displayStudentGrades ($c) {
return $c->include(
'ContentGenerator/Grades/student_grades',
effectiveUser => $effectiveUser,
- fullName => join(' ', $studentRecord->first_name, $studentRecord->last_name),
+ fullName => $studentRecord->full_name,
notOpen => \@notOpen,
open => \@open,
reduced => \@reduced,
diff --git a/lib/WeBWorK/ContentGenerator/Instructor/SendMail.pm b/lib/WeBWorK/ContentGenerator/Instructor/SendMail.pm
index 81250c9e62..9ca540b75e 100644
--- a/lib/WeBWorK/ContentGenerator/Instructor/SendMail.pm
+++ b/lib/WeBWorK/ContentGenerator/Instructor/SendMail.pm
@@ -343,11 +343,9 @@ sub print_preview ($c) {
if ($merge_file && !defined $rh_merge_data->{ $c->{preview_user}->student_id }) {
$c->addbadmessage($c->maketext(
- 'No merge data for student id: [_1]; name: [_2] [_3]; login: [_4]',
- map { xml_escape($_) } (
- $c->{preview_user}->student_id, $c->{preview_user}->first_name,
- $c->{preview_user}->last_name, $c->{preview_user}->user_id
- )
+ 'No merge data for student id: [_1]; name: [_2]; login: [_3]',
+ map { xml_escape($_) }
+ ($c->{preview_user}->student_id, $c->{preview_user}->full_name, $c->{preview_user}->user_id)
));
}
diff --git a/lib/WeBWorK/ContentGenerator/Instructor/StudentProgress.pm b/lib/WeBWorK/ContentGenerator/Instructor/StudentProgress.pm
index 4e6c346d60..3e5a06f8c1 100644
--- a/lib/WeBWorK/ContentGenerator/Instructor/StudentProgress.pm
+++ b/lib/WeBWorK/ContentGenerator/Instructor/StudentProgress.pm
@@ -328,7 +328,7 @@ sub displayStudentStats ($c) {
}
}
- my $fullName = join(' ', $studentRecord->first_name, $studentRecord->last_name);
+ my $fullName = $studentRecord->full_name;
my $effectiveUser = $studentRecord->user_id();
my $max_problems = 0;
diff --git a/lib/WeBWorK/ContentGenerator/Options.pm b/lib/WeBWorK/ContentGenerator/Options.pm
index bad811cdc6..794208adff 100644
--- a/lib/WeBWorK/ContentGenerator/Options.pm
+++ b/lib/WeBWorK/ContentGenerator/Options.pm
@@ -41,7 +41,7 @@ sub initialize ($c) {
# Check that either password is not defined or if it is defined then we have the right one.
if (!defined $password || utf8Crypt($currP // '', $password->password) eq $password->password) {
- my $e_user_name = $c->{effectiveUser}->first_name . ' ' . $c->{effectiveUser}->last_name;
+ my $e_user_name = $c->{effectiveUser}->full_name;
if ($newP eq $confirmP) {
if (!defined $effectiveUserPassword) {
$effectiveUserPassword = $db->newPassword();
@@ -85,8 +85,7 @@ sub initialize ($c) {
));
}
} else {
- my $fieldText =
- $c->maketext("[_1]'s Current Password", $c->{user}->first_name . ' ' . $c->{user}->last_name);
+ my $fieldText = $c->maketext("[_1]'s Current Password", $c->{user}->full_name);
$c->addbadmessage($c->maketext(
'The password you entered in the [_1] field does not match your current password. '
. 'Please retype your current password and try again.',
diff --git a/lib/WeBWorK/Utils/Rendering.pm b/lib/WeBWorK/Utils/Rendering.pm
index 3ef3eb9547..f4d64d2fd5 100644
--- a/lib/WeBWorK/Utils/Rendering.pm
+++ b/lib/WeBWorK/Utils/Rendering.pm
@@ -132,7 +132,7 @@ sub constructPGOptions ($ce, $user, $set, $problem, $psvn, $formFields, $transla
$options{setDescription} = $set->description;
$options{setNumber} = $set->set_id;
$options{studentLogin} = $user->user_id;
- $options{studentName} = $user->first_name . ' ' . $user->last_name;
+ $options{studentName} = $user->full_name;
$options{studentID} = $user->student_id;
# Permission level of actual user (deprecated)
diff --git a/templates/ContentGenerator/Hardcopy/form.html.ep b/templates/ContentGenerator/Hardcopy/form.html.ep
index e1f3fe5ec1..c17f5a894d 100644
--- a/templates/ContentGenerator/Hardcopy/form.html.ep
+++ b/templates/ContentGenerator/Hardcopy/form.html.ep
@@ -60,7 +60,7 @@
dir => 'ltr',
format_set_name_display($selected_set_id =~ s/,v(\d+)$/ (version $1)/r)
),
- xml_escape(join(' ', $user->first_name, $user->last_name))
+ xml_escape($user->full_name)
) =%>
% }
diff --git a/templates/ContentGenerator/Instructor/StudentProgress/set_progress.html.ep b/templates/ContentGenerator/Instructor/StudentProgress/set_progress.html.ep
index 44cc1e5e91..6ac4a6cfb5 100644
--- a/templates/ContentGenerator/Instructor/StudentProgress/set_progress.html.ep
+++ b/templates/ContentGenerator/Instructor/StudentProgress/set_progress.html.ep
@@ -241,7 +241,7 @@
% my $prevUserID = '';
%
% for my $rec (@$user_set_list) {
- % my $fullName = join('', $rec->{record}{first_name}, " ", $rec->{record}{last_name});
+ % my $fullName = $rec->{record}->full_name;
% my $email = $rec->{record}{email_address};
%
% if ($setIsVersioned) {
diff --git a/templates/ContentGenerator/Instructor/UserDetail.html.ep b/templates/ContentGenerator/Instructor/UserDetail.html.ep
index b31b545a66..4e6aed4707 100644
--- a/templates/ContentGenerator/Instructor/UserDetail.html.ep
+++ b/templates/ContentGenerator/Instructor/UserDetail.html.ep
@@ -42,7 +42,7 @@
%
% my @editForSets = param('editForSets');
%
-% my $userName = $c->{userRecord}->first_name . ' ' . $c->{userRecord}->last_name;
+% my $userName = $c->{userRecord}->full_name;
%
% # Display a message about how many sets have been assigned to this user.
% my $numberSets = scalar(@{ $c->{setRecords} });
diff --git a/templates/ContentGenerator/LoginProctor.html.ep b/templates/ContentGenerator/LoginProctor.html.ep
index fe4af28282..d371957303 100644
--- a/templates/ContentGenerator/LoginProctor.html.ep
+++ b/templates/ContentGenerator/LoginProctor.html.ep
@@ -56,7 +56,7 @@
<%= maketext(q{User's username is:}) %> <%= param('effectiveUser') // '' %>
<%= maketext(q{User's name is:}) %>
- <%= $c->{effectiveUser}->first_name %> <%= $c->{effectiveUser}->last_name %>
+ <%= $c->{effectiveUser}->full_name %>