Skip to content

Commit 5813b0b

Browse files
committed
Copy options when session is updated
1 parent 683c71b commit 5813b0b

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/euphorie/client/model.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,6 +1082,23 @@ def copySessionData(self, other):
10821082
}
10831083
session.execute(statement)
10841084

1085+
# Copy over answered options for choice items
1086+
statement = """\
1087+
INSERT INTO option (choice_id, zodb_path)
1088+
SELECT choice.id, old_option.zodb_path
1089+
FROM tree AS old_tree, choice AS old_choice, option AS old_option, tree, choice
1090+
WHERE tree.session_id = %(new_sessionid)d AND
1091+
tree.id = choice.id AND
1092+
tree.zodb_path = old_tree.zodb_path AND
1093+
old_tree.session_id = %(old_sessionid)d AND
1094+
old_tree.id = old_choice.id AND
1095+
old_option.choice_id = old_choice.id;
1096+
""" % {
1097+
"old_sessionid": other.id,
1098+
"new_sessionid": self.id,
1099+
}
1100+
session.execute(statement)
1101+
10851102
# Copy over previous session metadata. Specifically, we don't want to
10861103
# create a new modification timestamp, just because the underlying
10871104
# survey was updated.

0 commit comments

Comments
 (0)