Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Caliper/Actor.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
}

Expand Down
5 changes: 2 additions & 3 deletions lib/WeBWorK/ContentGenerator/GatewayQuiz.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1365,9 +1365,8 @@ sub nav ($c, $args) {

push @userRecords, $user;

$user->{displayName} =
($user->last_name || $user->first_name ? $user->last_name . ', ' . $user->first_name : $user->user_id);
$user->{setVersion} = $_->[2];
$user->{displayName} = $user->sortable_name || $user->user_id;
$user->{setVersion} = $_->[2];
}

# Sort by last name, then first name, then user_id, then set version.
Expand Down
2 changes: 1 addition & 1 deletion lib/WeBWorK/ContentGenerator/Grades.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions lib/WeBWorK/ContentGenerator/Instructor/ProblemGrader.pm
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ async sub initialize ($c) {
# First process student problems and answers and cache relevant data used both for
# saving grades and displaying the grader table.
for my $user (@{ $c->stash->{users} }) {
$user->{displayName} =
$user->last_name || $user->first_name ? $user->last_name . ', ' . $user->first_name : $user->user_id;
$user->{displayName} = $user->sortable_name || $user->user_id;
$c->stash->{haveSections} = 1 if $user->section;

if ($c->stash->{set}->assignment_type =~ /gateway/) {
Expand Down
8 changes: 3 additions & 5 deletions lib/WeBWorK/ContentGenerator/Instructor/SendMail.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
));
}

Expand Down
2 changes: 1 addition & 1 deletion lib/WeBWorK/ContentGenerator/Instructor/StudentProgress.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions lib/WeBWorK/ContentGenerator/Options.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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.',
Expand Down
31 changes: 19 additions & 12 deletions lib/WeBWorK/DB/Record/User.pm
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,22 @@ sub full_name {
my $first = $self->first_name;
my $last = $self->last_name;

if (defined $first and $first ne "" and defined $last and $last ne "") {
return "$first $last";
} elsif (defined $first and $first ne "") {
return $first;
} elsif (defined $last and $last ne "") {
return $last;
} else {
return "";
}
return "$first $last" if defined $first && $first =~ /\S/ && defined $last && $last =~ /\S/;
return $first if defined $first && $first =~ /\S/;
return $last if defined $last && $last =~ /\S/;
return '';
}

sub sortable_name {
my ($self) = @_;

my $first = $self->first_name;
my $last = $self->last_name;

return "$last, $first" if defined $first && $first =~ /\S/ && defined $last && $last =~ /\S/;
return $last if defined $last && $last =~ /\S/;
return $first if defined $first && $first =~ /\S/;
return '';
}

# Do not base64 encode the names in the address.
Expand All @@ -54,14 +61,14 @@ sub rfc822_mailbox {
my $full_name = $self->full_name;
my $address = $self->email_address;

if (defined $address and $address ne "") {
if (defined $full_name and $full_name ne "") {
if (defined $address && $address ne '') {
if (defined $full_name && $full_name ne '') {
return "$full_name <$address>";
} else {
return $address;
}
} else {
return "";
return '';
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/WeBWorK/HTML/StudentNav.pm
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ sub studentNav ($c, $setID) {
push @userRecords, $_;

# Construct a display name.
$_->{displayName} = ($_->last_name || $_->first_name ? $_->last_name . ', ' . $_->first_name : $_->user_id);
$_->{displayName} = $_->sortable_name || $_->user_id;
}
my $prevUser = $currentUserIndex > 0 ? $userRecords[ $currentUserIndex - 1 ] : 0;
my $nextUser = $currentUserIndex < $#userRecords ? $userRecords[ $currentUserIndex + 1 ] : 0;
Expand Down
2 changes: 1 addition & 1 deletion lib/WeBWorK/Utils/Rendering.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion templates/ContentGenerator/Hardcopy/form.html.ep
Original file line number Diff line number Diff line change
Expand Up @@ -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)
) =%>
</p>
% }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
% for my $userRecord (@$userRecords) {
% my $user = $userRecord->user_id;
% my $userAchievement = $userAchievementRecords->{$user};
% my $prettyName = $userRecord->last_name . ', ' . $userRecord->first_name;
% my $prettyName = $userRecord->sortable_name || $user;
%
<tr>
<td class="text-center">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
<span class="input-group-text">
<b><%= $addError ? maketext('Failed to add user:') : maketext('Added user:') %></b>
</span>
<span class="input-group-text"><%= $newUser->last_name %>, <%= $newUser->first_name %></span>
% if ($newUser->sortable_name) {
<span class="input-group-text"><%= $newUser->sortable_name %></span>
% }
<span class="input-group-text"><b><%= maketext('Login:') %></b></span>
<span class="input-group-text"><%= $newUser->user_id %></span>
% if ($newUser->student_id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
% my $user = $db->getUser($userID);
% my $line = begin
<span>
<%= $user->last_name %>, <%= $user->first_name %>
<%= $user->sortable_name %>
(<%= link_to $user->user_id => 'mailto:' . $user->email_address %>).
</span>
% if (!$editingSetVersion) {
Expand Down
12 changes: 6 additions & 6 deletions templates/ContentGenerator/Instructor/SendMail/main_form.html.ep
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@
<strong><%= maketext('for') %></strong>&nbsp;
<span
id="preview-user"
data-default="<%= $c->{defaultPreviewUser}->last_name . ', '
. $c->{defaultPreviewUser}->first_name . ' ('
. $c->{defaultPreviewUser}->user_id . ')' %>"
data-default="<%= join(' ',
$c->{defaultPreviewUser}->sortable_name || (),
'(' . $c->{defaultPreviewUser}->user_id . ')') %>"
>
<%= $c->{preview_user}->last_name . ', '
. $c->{preview_user}->first_name . ' ('
. $c->{preview_user}->user_id . ')' =%>
<%= join(' ',
$c->{preview_user}->sortable_name || (),
'(' . $c->{preview_user}->user_id . ')') =%>
</span>
</span>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@
<ul>
% for (@{ $c->{student_records} }) {
<li>
<%= link_to $_->last_name . ', '
. $_->first_name . ' ('
. $_->user_id
. ')' => $c->systemLink(url_for("instructor_user_progress", userID => $_->user_id)) =%>
<%= link_to join(' ', $_->sortable_name || (), '(' . $_->user_id . ')') =>
$c->systemLink(url_for("instructor_user_progress", userID => $_->user_id)) =%>
</li>
% }
</ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
class => 'nav-link'
),
begin =%>
<%= $_->last_name =%>, <%= $_->first_name %> (<%= $_->user_id %>)
<%= join(' ', $_->sortable_name || (), '(' . $_->user_id . ')') %>
<% end =%>
</li>
% }
Expand Down
2 changes: 1 addition & 1 deletion templates/ContentGenerator/Instructor/UserDetail.html.ep
Original file line number Diff line number Diff line change
Expand Up @@ -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} });
Expand Down
10 changes: 5 additions & 5 deletions templates/ContentGenerator/Instructor/UsersAssignedToSet.html.ep
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@
<tbody class="table-group-divider">
% param('selected', []);
% for my $user (@$user_records) {
% my $userID = $user->user_id;
% my $userSet = $set_records->{$userID};
% my $username = $user->last_name . ', ' . $user->first_name;
% my $userID = $user->user_id;
% my $userSet = $set_records->{$userID};
% my $name = $user->sortable_name;
%
<tr>
<td class="text-center">
Expand All @@ -88,7 +88,7 @@
id => "selected_$userID",
class => 'form-check-input',
data => {
username => "$username ($userID)",
username => join(' ', $name || (), "($userID)"),
defined $userSet ? (is_assigned => 1) : (),
$current_users->{$userID} ? (is_current => 1) : ()
},
Expand All @@ -100,7 +100,7 @@
</div>
</td>
<td>
<%= $username =%>
<%= $name || $userID =%>
</td>
<td class="text-center"><%= $user->section %></td>
% if (defined $userSet) {
Expand Down
2 changes: 1 addition & 1 deletion templates/ContentGenerator/LoginProctor.html.ep
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<div><%= maketext(q{User's username is:}) %> <strong><%= param('effectiveUser') // '' %></strong></div>
<div>
<%= maketext(q{User's name is:}) %>
<strong><%= $c->{effectiveUser}->first_name %> <%= $c->{effectiveUser}->last_name %></strong>
<strong><%= $c->{effectiveUser}->full_name %></strong>
</div>
</div>
<div class="col-xl-5 col-lg-6 col-md-7 col-sm-8 form-floating mb-2">
Expand Down
2 changes: 1 addition & 1 deletion templates/ContentGenerator/Options.html.ep
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
% require WeBWorK::PG;
%
% my $userID = $c->{user}->user_id;
% my $eUserName = $c->{effectiveUser}->first_name . ' ' . $c->{effectiveUser}->last_name;
% my $eUserName = $c->{effectiveUser}->full_name;
%
% $c->stash->{footerWidthClass} = 'col-lg-8 col-md-10';
%
Expand Down