From 5cf79c8a9780936f4aa9e7def06c4033218b7d28 Mon Sep 17 00:00:00 2001 From: Roy Johnson Date: Thu, 15 Sep 2005 18:41:15 +0000 Subject: [PATCH] [BUGFIX] -- Survey not appearing in clipboard after copy [BUGFIX] -- Survey section data left out during survey copy --- docs/changelog/6.x.x.txt | 2 ++ lib/WebGUI/Asset/Wobject/Survey.pm | 24 +++++++++++++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/docs/changelog/6.x.x.txt b/docs/changelog/6.x.x.txt index 96e969988..59f160c94 100644 --- a/docs/changelog/6.x.x.txt +++ b/docs/changelog/6.x.x.txt @@ -3,6 +3,8 @@ - Fixed an infinite loop problem in Syndicated Content when no URLs were specified. - Corrected an error in the built in WebGUI config file documentation. + - Fixed Survey copy bug that prevented asset from appearing in clipboard. + - Fixed Survey copy bug that was preventing section data from being copied. 6.7.4 - fix [ 1279861 ] POD errors in 6.7.3 diff --git a/lib/WebGUI/Asset/Wobject/Survey.pm b/lib/WebGUI/Asset/Wobject/Survey.pm index ada4d4e86..09af37d82 100644 --- a/lib/WebGUI/Asset/Wobject/Survey.pm +++ b/lib/WebGUI/Asset/Wobject/Survey.pm @@ -129,7 +129,7 @@ sub definition { #------------------------------------------------------------------- sub duplicate { - my ($self, $newAsset, $newSurveyId, $qdata, $adata, $rdata, $a, $b, $c); + my ($self, $newAsset, $newSurveyId, $qdata, $adata, $rdata, $a, $b, $c, $s, $sdata, $oldSectionId); $self = shift; @@ -138,16 +138,26 @@ sub duplicate { $newAsset->update({ Survey_id=>$newSurveyId }); - $a = WebGUI::SQL->read("select * from Survey_question where Survey_id=".quote($self->get("Survey_id")) + + $s = WebGUI::SQL->read("select * from Survey_section where Survey_id=".quote($self->get("Survey_id")) ." order by sequenceNumber"); - while ($qdata = $a->hashRef) { + while ($sdata = $s->hashRef) { + $oldSectionId = $sdata->{Survey_sectionId}; + $sdata->{Survey_sectionId} = "new"; + $sdata->{Survey_Id} = $newSurveyId; + $sdata->{Survey_sectionId} = $newAsset->setCollateral("Survey_section", "Survey_sectionId",$sdata,1,0, "Survey_id"); + + $a = WebGUI::SQL->read("select * from Survey_question where Survey_id=".quote($self->get("Survey_id")) + ." and Survey_sectionId=".quote($oldSectionId)." order by sequenceNumber"); + while ($qdata = $a->hashRef) { $b = WebGUI::SQL->read("select * from Survey_answer where Survey_questionId=".quote($qdata->{Survey_questionId}) ." order by sequenceNumber"); $qdata->{Survey_questionId} = "new"; $qdata->{Survey_id} = $newSurveyId; + $qdata->{Survey_sectionId} = $sdata->{Survey_sectionId}; $qdata->{Survey_questionId} = $newAsset->setCollateral("Survey_question","Survey_questionId",$qdata,1,0,"Survey_id"); while ($adata = $b->hashRef) { - $c = WebGUI::SQL->read("select * from Survey_response where Survey_answerId=".quote($adata->{Survey_answerId})); + $c = WebGUI::SQL->read("select * from Survey_questionResponse where Survey_answerId=".quote($adata->{Survey_answerId})); $adata->{Survey_answerId} = "new"; $adata->{Survey_questionId} = $qdata->{Survey_questionId}; $adata->{Survey_id} = $newSurveyId; @@ -163,8 +173,12 @@ sub duplicate { $c->finish; } $b->finish; + } + $a->finish; + } - $a->finish; + $s->finish; + return $newAsset; }