Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Answers in the audit file #3024

Closed
wants to merge 1 commit into from

Conversation

grzesiek2010
Copy link
Member

if (isAuditEnabled()) {
// Calculate the time and add the event to the auditEvents array
long end = getEventTime();
for (AuditEvent aev : auditEvents) {
if (!aev.isEndTimeSet() && aev.isIntervalAuditEventType()) {
addLocationCoordinatesToAuditEventIfNeeded(aev);
aev.setEnd(end);
if (answers != null && !answers.isEmpty() && aev.getAuditEventType() == AuditEvent.AuditEventType.QUESTION) {
Map.Entry entry = answers.entrySet().iterator().next();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means the answers from questions in a field list will be provided in some arbitrary order because the map is a hashmap, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the order should be the same as questions on the screen.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, right, this is actually worse than I had originally imagined, I think. Isn't it the case that the audit event has a reference and that the answer that gets associated with that audit event might not match the reference to the question? How about passing a map from reference to answer rather than FormIndex to answer? By reference I mean what is stored in the AuditEvent.node field (e.g. /data/name), so that you can just match the event to its answer?

@lognaturel
Copy link
Member

lognaturel commented Apr 17, 2019

I described a concern I have about field lists here. Other than that, I believe this always logs the answer, even if it hasn't changed. I think that's a deviation from what was discussed on the forum but it seems fine to me.

@grzesiek2010
Copy link
Member Author

Other than that, I believe this always logs the answer, even if it hasn't changed.

Yes, if we log answers along with questions how would you do that? Would you leave the answer empty? I thought the empty value should be for nulls... of course, we could use NULL for nulls and empty values if the answer is the same but still it would be misleading. Is this approach that wrong?

@yanokwa
Copy link
Member

yanokwa commented Apr 23, 2019

I've had some more time to think the blank/null/no change issue and wanted to share my thoughts.

We should not use a magic value (e.g., NULL). I feel like every time we use a magic value in ODK we come to regret it.

Writing the value on every question is a solution, but I don't love it because analyzing the log of data to find out what has changed is not fun and it's a lot of redundant information. Yes, we could have a system do that analysis, but we should still make it easier.

I'm leaning more towards a new event for a value change. Yes, this is more rows, but the tradeoff is that it's super easy to get the change information that we need. It also means that we can eventually record change events that are not associated with viewing a question (e.g., calculates, metadata).

Is my reasoning convincing, @lognaturel and @grzesiek2010?

@lognaturel
Copy link
Member

lognaturel commented Apr 23, 2019

I'm leaning more towards a new event for a value change.

Same here, that was what I was expecting initially. The unfortunate thing becomes that we then have columns that are only applicable to certain events. The documentation should be very clear on that.

I don't think there's an issue filed for this feature. https://forum.opendatakit.org/t/collect-keep-history-of-changes-to-values-in-the-form/15458 is the forum post that discusses it.

One other thing that just crossed my mind is that answers could contain commas so they should either always be in quotes or there should be a check that looks for commas and puts the value in quotes if needed.

@yanokwa yanokwa marked this pull request as ready for review April 23, 2019 19:30
@yanokwa yanokwa changed the title Answers in the audit file WIP: Answers in the audit file Apr 23, 2019
@yanokwa
Copy link
Member

yanokwa commented Apr 23, 2019

Ugh! I didn't mean to make this PR ready for review. I can't seem to undo that change, so I've changed the title. Sorry 😭.

@grzesiek2010
Copy link
Member Author

One other thing that just crossed my mind is that answers could contain commas so they should either always be in quotes or there should be a check that looks for commas and puts the value in quotes if needed.

Good point!

Ok, I can change this approach tomorrow. To be clear, that new event should be logged like now? once a user navigates back/forward or opens the hierarchy?

@lognaturel
Copy link
Member

lognaturel commented Apr 23, 2019

@yanokwa, do you have a name for this event?

Yes, I think it should happen on navigation out of the screen BUT a row should only be added for values on the screen that are different. That is, if I look at a question, that generates an access event. If I exit the screen and don't change the value, no value changed event is written. Then if I go back to the question and change its value, two events are written out when I exit the screen: the access event and the value change event. I think both should have the exact same start and end times as well as location. This is where the somewhat annoying redundancy comes in. @yanokwa, do you also want to think about this and perhaps summarize for the forum thread since these are all user-facing questions and decisions?

Edit: same for a field list. I'd expect each question that changed to generate a value changed event. Any values that did not change would not generate such an event.

@grzesiek2010
Copy link
Member Author

I'm closing in favor of #3072

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants