Skip to content

Commit

Permalink
Merge pull request #34 from drgrice1/email-format-suggested-changes
Browse files Browse the repository at this point in the history
Construct the emailable URL directly and don't use systemLink for that.
  • Loading branch information
Alex-Jordan authored Feb 2, 2025
2 parents e7f0af0 + aed3a73 commit b1f4114
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 b1f4114

Please sign in to comment.