Skip to content

Commit 64e083e

Browse files
committed
Copy options when session is updated
1 parent 683c71b commit 64e083e

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/euphorie/client/model.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,6 +1082,27 @@ 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,
1090+
choice AS old_choice,
1091+
option AS old_option,
1092+
tree,
1093+
choice
1094+
WHERE tree.session_id = %(new_sessionid)d AND
1095+
tree.id = choice.id AND
1096+
tree.zodb_path = old_tree.zodb_path AND
1097+
old_tree.session_id = %(old_sessionid)d AND
1098+
old_tree.id = old_choice.id AND
1099+
old_option.choice_id = old_choice.id;
1100+
""" % {
1101+
"old_sessionid": other.id,
1102+
"new_sessionid": self.id,
1103+
}
1104+
session.execute(statement)
1105+
10851106
# Copy over previous session metadata. Specifically, we don't want to
10861107
# create a new modification timestamp, just because the underlying
10871108
# survey was updated.

0 commit comments

Comments
 (0)