Skip to content

Commit

Permalink
Construct the emailable URL directly and don't use systemLink for that.
Browse files Browse the repository at this point in the history
This way the parameters can be sorted in this one instance where this is
desired.
  • Loading branch information
drgrice1 committed Feb 1, 2025
1 parent e7f0af0 commit 0a0509a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
2 changes: 1 addition & 1 deletion lib/WeBWorK/ContentGenerator.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1200,7 +1200,7 @@ sub systemLink ($c, $urlpath, %options) {
if (!defined $params{$name} && defined $c->param($name) && $c->param($name) ne '');
}

return %params ? $url->query([ map { $_, $params{$_} } sort { $a cmp $b } keys %params ]) : $url;
return %params ? $url->query(%params) : $url;
}

=item nbsp($string)
Expand Down
24 changes: 8 additions & 16 deletions lib/WeBWorK/Utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -358,31 +358,23 @@ sub generateURLs ($c, %params) {

if ($userName) {
my $routePath;
my $args = {};
my %args;
if (defined $params{set_id} && $params{set_id} ne '') {
if ($params{problem_id}) {
$routePath = $c->url_for('problem_detail', setID => $params{set_id}, problemID => $params{problem_id});
$args = {
displayMode => undef,
showOldAnswers => undef,
showCorrectAnswers => undef,
showHints => undef,
showSolutions => undef,
showProblemGrader => 1
};
for my $name ('displayMode', 'showCorrectAnswers', 'showHints', 'showOldAnswers', 'showSolutions') {
$args{$name} = [ $c->param($name) ] if defined $c->param($name) && $c->param($name) ne '';
}
$args{showProblemGrader} = 1;
} else {
$routePath = $c->url_for('problem_list', setID => $params{set_id});
}
} else {
$routePath = $c->url_for('set_list');
}
$emailableURL = $c->systemLink(
$routePath,
authen => 0,
params => { effectiveUser => undef, %{$args} },
use_abs_url => 1,
);
$returnURL = $c->systemLink($routePath);
$args{effectiveUser} = [ $c->param('effectiveUser') ] if defined $c->param('effectiveUser');
$emailableURL = $routePath->to_abs->query([ map { $_ => $args{$_} } sort keys %args ]);
$returnURL = $c->systemLink($routePath);
} else {
$emailableURL = '(not available)';
$returnURL = '';
Expand Down

0 comments on commit 0a0509a

Please sign in to comment.