Fixed Survey reporting bugs
* Survey::responseJSON mutator was not doing the right thing when responseId argument was passed in * www_viewGradeBook template fixes and documentation
This commit is contained in:
parent
3dfb850d41
commit
10755c3b83
4 changed files with 96 additions and 26 deletions
|
|
@ -405,15 +405,17 @@ sub responseJSON {
|
|||
my $self = shift;
|
||||
my ($json, $responseId) = validate_pos(@_, { type => SCALAR | UNDEF, optional => 1 }, { type => SCALAR, optional => 1});
|
||||
|
||||
$responseId ||= $self->responseId;
|
||||
|
||||
if (!$self->{_responseJSON} || $json) {
|
||||
|
||||
# See if we need to load responseJSON from the database
|
||||
# Mutate if lazy-loading, or json/responseId provided
|
||||
if (!$self->{_responseJSON} || $json || $responseId) {
|
||||
|
||||
# Either user-provided, or loaded from L<responseId>
|
||||
$responseId ||= $self->responseId;
|
||||
|
||||
# If json undefined, load responseJSON from the db
|
||||
if (!defined $json) {
|
||||
$json = $self->session->db->quickScalar( 'select responseJSON from Survey_response where Survey_responseId = ?', [ $responseId ] );
|
||||
}
|
||||
|
||||
|
||||
# Instantiate the ResponseJSON instance, and store it
|
||||
$self->{_responseJSON} = WebGUI::Asset::Wobject::Survey::ResponseJSON->new( $self->surveyJSON, $json );
|
||||
}
|
||||
|
|
@ -2187,9 +2189,9 @@ Returns the Grade Book screen.
|
|||
=cut
|
||||
|
||||
sub www_viewGradeBook {
|
||||
my $self = shift;
|
||||
my $db = $self->session->db;
|
||||
|
||||
my $self = shift;
|
||||
my $db = $self->session->db;
|
||||
|
||||
return $self->session->privilege->insufficient()
|
||||
if !$self->session->user->isInGroup( $self->get('groupToViewReports') );
|
||||
|
||||
|
|
@ -2197,26 +2199,42 @@ sub www_viewGradeBook {
|
|||
|
||||
$self->loadTempReportTable();
|
||||
|
||||
my $paginator = WebGUI::Paginator->new($self->session,$self->getUrl('func=viewGradebook'));
|
||||
$paginator->setDataByQuery('select userId,username,ipAddress,Survey_responseId,startDate,endDate'
|
||||
. ' from Survey_response where assetId='
|
||||
. $db->quote($self->getId)
|
||||
. ' order by username,ipAddress,startDate');
|
||||
my $users = $paginator->getPageData;
|
||||
my $paginator = WebGUI::Paginator->new( $self->session, $self->getUrl('func=viewGradebook') );
|
||||
my $userClause = '';
|
||||
if (my $userId = $self->session->form->process('userId')) {
|
||||
$userClause = ' and userId = ' . $db->quote($userId);
|
||||
}
|
||||
my $quotedAssetId = $db->quote( $self->getId );
|
||||
$paginator->setDataByQuery( <<END_SQL );
|
||||
select userId, username, ipAddress, Survey_responseId, startDate, endDate
|
||||
from Survey_response
|
||||
where assetId = $quotedAssetId
|
||||
$userClause
|
||||
order by username, ipAddress, startDate
|
||||
END_SQL
|
||||
my $rows = $paginator->getPageData;
|
||||
|
||||
$var->{question_count} = $self->surveyJSON->questionCount;
|
||||
|
||||
|
||||
my @responseloop;
|
||||
foreach my $user (@{$users}) {
|
||||
my ($correctCount) = $db->quickArray('select count(*) from Survey_tempReport'
|
||||
. ' where Survey_responseId=? and isCorrect=1',[$user->{Survey_responseId}]);
|
||||
push @responseloop, {
|
||||
# response_url is left out because it looks like Survey doesn't have a viewIndividualSurvey feature
|
||||
# yet.
|
||||
#'response_url'=>$self->getUrl('func=viewIndividualSurvey;responseId='.$user->{Survey_responseId}),
|
||||
'response_user_name'=>($user->{userId} eq '1') ? $user->{ipAddress} : $user->{username},
|
||||
'response_count_correct' => $correctCount,
|
||||
'response_percent' => round(($correctCount/$var->{question_count})*100)
|
||||
foreach my $row ( @{$rows} ) {
|
||||
my ($correctCount)
|
||||
= $db->quickArray(
|
||||
'select count(*) from Survey_tempReport' . ' where Survey_responseId=? and isCorrect=1',
|
||||
[ $row->{Survey_responseId} ] );
|
||||
push @responseloop,
|
||||
{
|
||||
response_feedback_url => $self->getUrl("func=showFeedback;responseId=$row->{Survey_responseId}"),
|
||||
response_id => $row->{Survey_responseId},
|
||||
response_userId => $row->{userId},
|
||||
response_ip => $row->{ip},
|
||||
response_startDate => $row->{startDate}
|
||||
&& WebGUI::DateTime->new( $self->session, $row->{startDate} )->toUserTimeZone,
|
||||
response_endDate => $row->{endDate}
|
||||
&& WebGUI::DateTime->new( $self->session, $row->{endDate} )->toUserTimeZone,
|
||||
response_user_name => ( $row->{userId} eq '1' ) ? $row->{ipAddress} : $row->{username},
|
||||
response_count_correct => $correctCount,
|
||||
response_percent => round( ( $correctCount / $var->{question_count} ) * 100 ),
|
||||
};
|
||||
}
|
||||
$var->{response_loop} = \@responseloop;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue