Survey - differentiated between endDate and endDateEpoch.
This commit is contained in:
parent
05c9c7f0e8
commit
d3f5c9ecfd
2 changed files with 2919 additions and 20 deletions
|
|
@ -1328,32 +1328,44 @@ sub getResponseDetails {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
my ($lastResponseCompleteCode, $lastResponseEndDate, $rJSON)
|
my ( $completeCode, $endDate, $rJSON, $userId, $username ) = $self->session->db->quickArray(
|
||||||
= $self->session->db->quickArray('select isComplete, endDate, responseJSON from Survey_response where Survey_responseId = ?', [ $responseId ]);
|
'select isComplete, endDate, responseJSON, userId, username from Survey_response where Survey_responseId = ?',
|
||||||
|
[$responseId]
|
||||||
|
);
|
||||||
|
|
||||||
|
my $endDateEpoch = $endDate;
|
||||||
|
$endDate = $endDate && WebGUI::DateTime->new( $self->session, $endDate )->toUserTimeZone;
|
||||||
|
|
||||||
# Process the feedback text
|
# Process the feedback text
|
||||||
my $feedback;
|
my $feedback;
|
||||||
my $tags = {};
|
my $tags = {};
|
||||||
if ($rJSON) {
|
if ($rJSON) {
|
||||||
$rJSON = from_json($rJSON) || {};
|
$rJSON = from_json($rJSON) || {};
|
||||||
|
|
||||||
# All tags become template vars
|
# All tags become template vars
|
||||||
$tags = $rJSON->{tags} || {};
|
$tags = $rJSON->{tags} || {};
|
||||||
$tags->{complete} = $lastResponseCompleteCode == 1;
|
$tags->{complete} = $completeCode == 1;
|
||||||
$tags->{restart} = $lastResponseCompleteCode == 2;
|
$tags->{restart} = $completeCode == 2;
|
||||||
$tags->{timeout} = $lastResponseCompleteCode == 3;
|
$tags->{timeout} = $completeCode == 3;
|
||||||
$tags->{timeoutRestart} = $lastResponseCompleteCode == 4;
|
$tags->{timeoutRestart} = $completeCode == 4;
|
||||||
$tags->{endDate} = $lastResponseEndDate && WebGUI::DateTime->new($self->session, $lastResponseEndDate)->toUserTimeZone;
|
$tags->{endDate} = $endDate;
|
||||||
$feedback = $self->processTemplate($tags, $templateId);
|
$tags->{endDateEpoch} = $endDateEpoch;
|
||||||
|
$tags->{userId} = $userId;
|
||||||
|
$tags->{username} = $username;
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
completeCode => $lastResponseCompleteCode,
|
|
||||||
templateText => $feedback,
|
|
||||||
templateVars => $tags,
|
templateVars => $tags,
|
||||||
endDate => $tags->{endDate},
|
templateText => $self->processTemplate( $tags, $templateId ),
|
||||||
complete => $tags->{complete},
|
|
||||||
restart => $tags->{restart},
|
completeCode => $completeCode,
|
||||||
timeout => $tags->{timeout},
|
endDate => $endDate,
|
||||||
|
endDateEpoch => $endDateEpoch,
|
||||||
|
userId => $userId,
|
||||||
|
username => $username,
|
||||||
|
|
||||||
|
complete => $tags->{complete},
|
||||||
|
restart => $tags->{restart},
|
||||||
|
timeout => $tags->{timeout},
|
||||||
timeoutRestart => $tags->{timeoutRestart},
|
timeoutRestart => $tags->{timeoutRestart},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -1561,13 +1573,19 @@ sub www_showFeedback {
|
||||||
# Only continue if we were given a responseId
|
# Only continue if we were given a responseId
|
||||||
return if !$responseId;
|
return if !$responseId;
|
||||||
|
|
||||||
my $userId = $self->session->db->quickScalar('select userId from Survey_response where Survey_responseId = ?', [ $responseId ]);
|
my $responseUserId
|
||||||
|
= $self->session->db->quickScalar('select userId from Survey_response where Survey_responseId = ?', [ $responseId ]);
|
||||||
|
|
||||||
# Only continue if responseId gave us a legit userId
|
# Only continue if responseId gave us a legit userId
|
||||||
return if !$userId;
|
return if !$responseUserId;
|
||||||
|
|
||||||
# Only continue if user owns the response
|
my $responseUser = WebGUI::User->new($self->session, $responseUserId);
|
||||||
return if $userId ne $self->session->user->userId;
|
return if !$responseUser;
|
||||||
|
|
||||||
|
# Only continue if user owns the response (or user is allowed to view reports)
|
||||||
|
if ($responseUserId ne $self->session->user->userId && !$responseUser->isInGroup( $self->get('groupToViewReports') )) {
|
||||||
|
return $self->session->privilege->insufficient();
|
||||||
|
}
|
||||||
|
|
||||||
my $out = $self->getResponseDetails( { responseId => $responseId } )->{templateText};
|
my $out = $self->getResponseDetails( { responseId => $responseId } )->{templateText};
|
||||||
return $self->session->style->process( $out, $self->get('styleTemplateId') );
|
return $self->session->style->process( $out, $self->get('styleTemplateId') );
|
||||||
|
|
|
||||||
2881
lib/WebGUI/Asset/Wobject/Survey.pm.orig
Normal file
2881
lib/WebGUI/Asset/Wobject/Survey.pm.orig
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue