Fixed #10520 - Survey responses get confused if survey structure modified
Survey responses are now revision-aware. The survey structure gets revisioned automatically as necessary when changes are made on the Edit Survey screen (as necessary ~~ a response exists for the current revision)
This commit is contained in:
parent
3e5d5804f6
commit
d820d43760
6 changed files with 260 additions and 97 deletions
Binary file not shown.
|
|
@ -32,6 +32,7 @@ my $session = start(); # this line required
|
|||
|
||||
# upgrade functions go here
|
||||
setDefaultIcalInterval($session);
|
||||
makeSurveyResponsesVersionAware($session);
|
||||
|
||||
finish($session); # this line required
|
||||
|
||||
|
|
@ -55,6 +56,26 @@ sub setDefaultIcalInterval {
|
|||
print "DONE!\n" unless $quiet;
|
||||
}
|
||||
|
||||
sub makeSurveyResponsesVersionAware {
|
||||
my $session = shift;
|
||||
print "\tAdding revisionDate column to Survey_response table... " unless $quiet;
|
||||
$session->db->write("alter table Survey_response add column revisionDate bigint(20) not null default 0");
|
||||
|
||||
print "\tDefaulting revisionDate on existing responses to current latest revision... " unless $quiet;
|
||||
for my $assetId ($session->db->buildArray('select assetId from Survey_response')) {
|
||||
$session->db->write(<<END_SQL, [ $assetId, $assetId]);
|
||||
update Survey_response
|
||||
set revisionDate = (
|
||||
select max(revisionDate)
|
||||
from Survey
|
||||
where Survey.assetId = ?
|
||||
)
|
||||
where Survey_response.assetId = ?
|
||||
END_SQL
|
||||
}
|
||||
print "DONE!\n" unless $quiet;
|
||||
}
|
||||
|
||||
|
||||
# -------------- DO NOT EDIT BELOW THIS LINE --------------------------------
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue