Skip to content
Merged
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/WeBWorK/ContentGenerator/Feedback.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion lib/WeBWorK/ContentGenerator/Problem.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
4 changes: 3 additions & 1 deletion lib/WeBWorK/ContentGenerator/ProblemUtil/ProblemUtil.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
30 changes: 16 additions & 14 deletions lib/WeBWorK/Utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1742,38 +1742,40 @@ 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;
my $returnURL;
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 = ();
}
Expand All @@ -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...
Expand Down