Survey_tempReport table post-report clean-up

This commit is contained in:
Patrick Donelan 2009-10-17 13:37:49 +11:00
parent 846b957a78
commit f4f30cc4fe

View file

@ -2300,6 +2300,9 @@ END_SQL
}
$var->{response_loop} = \@responseloop;
$paginator->appendTemplateVars($var);
# Clean up
$self->clearTempReportTable;
my $out = $self->processTemplate( $var, $self->get('gradebookTemplateId') );
return $self->processStyle($out);
@ -2390,6 +2393,9 @@ sub www_viewStatisticalOverview {
$var->{question_loop} = \@questionloop;
$paginator->appendTemplateVars($var);
# Clean up
$self->clearTempReportTable;
my $out = $self->processTemplate( $var, $self->get('overviewTemplateId') );
return $self->processStyle($out);
@ -2445,6 +2451,9 @@ sub export {
$content = $self->session->db->$method( $opts{sql}, $opts{sqlParams} );
}
# Clean up
$self->clearTempReportTable;
my $filename = $self->session->url->escape( $self->get("title") . "_$opts{name}.$format" );
$self->session->http->setFilename($filename,"text/$format");
return $content;
@ -2585,6 +2594,21 @@ END_HTML
#-------------------------------------------------------------------
=head2 clearTempReportTable
Clears the Survey_tempReport table
Typically called after L<loadTempReportTable> has been used
=cut
sub clearTempReportTable {
my $self = shift;
$self->session->db->write( 'delete from Survey_tempReport where assetId = ?', [ $self->getId() ] );
}
#-------------------------------------------------------------------
=head2 loadTempReportTable
Loads the responses from the survey into the Survey_tempReport table, so that other or custom reports can be ran against this data.
@ -2607,7 +2631,7 @@ sub loadTempReportTable {
my %opts = validate(@_, { ignoreRevisionDate => 0 });
# Remove old temp report data
$self->session->db->write( 'delete from Survey_tempReport where assetId = ?', [ $self->getId() ] );
$self->clearTempReportTable;
# Build the sql that will select all responses
my $sql = 'select * from Survey_response where assetId = ?';