diff --git a/lib/WeBWorK/ContentGenerator/Feedback.pm b/lib/WeBWorK/ContentGenerator/Feedback.pm index 8037180ada..bb48f14613 100644 --- a/lib/WeBWorK/ContentGenerator/Feedback.pm +++ b/lib/WeBWorK/ContentGenerator/Feedback.pm @@ -109,7 +109,7 @@ sub body { } # generate context URLs - my ($emailableURL, $returnURL) = $self->generateURLs(); + my ($emailableURL, $returnURL) = $self->generateURLs(set_id => $setName, problem_id => $problemNumber); my $homeModulePath = $r->urlpath->newFromModule("WeBWorK::ContentGenerator::Home", $r); my $systemURL = $self->systemLink($homeModulePath, authen=>0, use_abs_url=>1); diff --git a/lib/WeBWorK/ContentGenerator/Problem.pm b/lib/WeBWorK/ContentGenerator/Problem.pm index 2fbe1a4f5b..598c216d38 100644 --- a/lib/WeBWorK/ContentGenerator/Problem.pm +++ b/lib/WeBWorK/ContentGenerator/Problem.pm @@ -2151,7 +2151,9 @@ sub output_email_instructor{ problemPath => $problem->source_file, randomSeed => $problem->problem_seed, notifyAddresses => join(";",$self->fetchEmailRecipients('receive_feedback',$user)), - emailableURL => $self->generateURLs('absolute'), + emailableURL => $self->generateURLs(url_type => 'absolute', + set_id => $self->{set}->set_id, + problem_id => $self->{problem}->problem_id), studentName => $user->full_name, displayMode => $self->{displayMode}, showOldAnswers => $will{showOldAnswers}, diff --git a/lib/WeBWorK/ContentGenerator/ProblemUtil/ProblemUtil.pm b/lib/WeBWorK/ContentGenerator/ProblemUtil/ProblemUtil.pm index e0f8f63f6e..59822a2556 100644 --- a/lib/WeBWorK/ContentGenerator/ProblemUtil/ProblemUtil.pm +++ b/lib/WeBWorK/ContentGenerator/ProblemUtil/ProblemUtil.pm @@ -524,7 +524,9 @@ sub output_footer{ problemPath => $problem->source_file, randomSeed => $problem->problem_seed, emailAddress => join(";",$self->fetchEmailRecipients('receive_feedback',$user)), - emailableURL => $self->generateURLs('absolute'), + emailableURL => $self->generateURLs(url_type => 'absolute', + set_id => $self->{set}->set_id, + problem_id => $problem->problem_id), studentName => $user->full_name, displayMode => $self->{displayMode}, showOldAnswers => $will{showOldAnswers}, diff --git a/lib/WeBWorK/Utils.pm b/lib/WeBWorK/Utils.pm index 491d755ebc..45943e2c27 100644 --- a/lib/WeBWorK/Utils.pm +++ b/lib/WeBWorK/Utils.pm @@ -1742,19 +1742,21 @@ sub fetchEmailRecipients { return @recipients; } -# requires a CG object and an optional string -# 'relative' or 'absolute' to return a single URL -# or NULL to return an array containing both URLs -# this subroutine could be expanded to +# Requires a CG object. +# The following optional parameters may be passed: +# set_id: A problem set name +# problem_id: Number of a problem in the set +# url_type: This should a string with the value 'relative' or 'absolute' to +# return a single URL, or undefined to return an array containing both URLs +# this subroutine could be expanded to. sub generateURLs { - my ($self, $urlRequested) = @_; + my $self = shift; + my %params = @_; my $r = $self->r; my $db = $r->db; my $urlpath = $r->urlpath; my $userName = $r->param("user"); - my $setName = $urlpath->arg("setID"); - my $problemNumber = $urlpath->arg("problemID"); # generate context URLs my $emailableURL; @@ -1762,18 +1764,18 @@ sub generateURLs { if ($userName) { my $modulePath; my @args; - if ($setName) { - if ($problemNumber) { + if ($params{set_id}) { + if ($params{problem_id}) { $modulePath = $r->urlpath->newFromModule("WeBWorK::ContentGenerator::Problem", $r, courseID => $r->urlpath->arg("courseID"), - setID => $setName, - problemID => $problemNumber, + setID => $params{set_id}, + problemID => $params{problem_id}, ); @args = qw/displayMode showOldAnswers showCorrectAnswers showHints showSolutions/; } else { $modulePath = $r->urlpath->newFromModule("WeBWorK::ContentGenerator::ProblemSet", $r, courseID => $r->urlpath->arg("courseID"), - setID => $setName, + setID => $params{set_id}, ); @args = (); } @@ -1796,8 +1798,8 @@ sub generateURLs { $emailableURL = "(not available)"; $returnURL = ""; } - if ($urlRequested) { - if ($urlRequested eq 'relative') { + if ($params{url_type}) { + if ($params{url_type} eq 'relative') { return $returnURL; } else { return $emailableURL; # could include other types of URL here...