[BB-753] Fix issue with multiple responses for a single user returned by generate_report_data - #19507
Conversation
|
Thanks for the pull request, @xitij2000! I've created OSPR-2927 to keep track of it in JIRA. JIRA is a place for product owners to prioritize feature reviews by the engineering development teams. Feel free to add as much of the following information to the ticket:
All technical communication about the code itself will still be done via the GitHub pull request interface. As a reminder, our process documentation is here. |
|
@xitij2000 Thank you for your contribution, please let me know once it is ready to be looked at. |
|
@natabene Will do. I think it's mainly the tests that I am working on. I would like to discuss the possible impact of the changes this could make to the report since I remember there were some concerns before. |
|
@xitij2000 Do you recall who voiced concerns before? Who do you think should review this? |
|
@natabene I do know that there were some issues with the removal of the state field from this report. As such this PR was made: https://github.com/edx/edx-platform/pull/18512 This PR will again mess with the report format in a way that might affect people who use this functionality. The ticket linked there seems to no longer exist, perhaps I got the number wrong since I myself didn't have access to the ticket at that point. @bradenmacdonald might know better. |
30b25b5 to
58f08cd
Compare
There was a problem hiding this comment.
@bradenmacdonald Added this so now a uniform path is returned for all blocks whether you request a report for a course or a single problem.
|
@bradenmacdonald Please let us know if you have more information. |
|
@natabene @xitij2000 You can refer to https://openedx.atlassian.net/browse/EDUCATOR-3143 for information about who was affected last time the report format changed. Unfortunately I don't have permission to view that ticket anymore though?! |
|
Yup, I'm having the same issue. Perhaps the ticket is deleted? At the time I made the original PR I don't think I had access to that JIRA at all, so I have no information other than it being an issue at the time. |
|
@xitij2000 @bradenmacdonald Looks like you both had access to internal edX JIRA, and then it was revoked due to contract. I have exported the ticket and sent to both of you via email, i hope this helps! |
|
@natabene Thanks! |
|
@marcotuts I would love to get your feedback about how I should go about with this fix.
The issue now is how to handle cases where there is a single state that corresponds to multiple rows. Two potential solutions are:
In either case, this needs to be fixed since currently the report generator will give inaccurate results, and will only return the first response for blocks that have multiple responses. |
|
@marcotuts Would you be able to help @xitij2000 if you have a chance? |
|
There are two more enhancements that we are considering, for the API that initiates the report generation:
I can include these enhancements in the same PR if that would be easier. |
|
@xitij2000 Let me ping Marco again. Sorry for delay |
58f08cd to
0d8ca52
Compare
|
Hello! Thanks for your patience on this. My feedback would be to add the field to all cases, meaning this option: We may also want to update documentation here if this applies / exists, and perhaps an ADR makes sense to explain why the state field still exists, but it could potentially be flagged for deprecation via DEPR ticket in a future named release? For these items, I think we could look at a separate PR / review for these two additions:
|
|
@marcotuts Thanks for the feedback! Will update the PR accordingly. |
0d8ca52 to
2c2b0ae
Compare
|
@xitij2000 Thank you. @ormsbee Could you take a look? |
ormsbee
left a comment
There was a problem hiding this comment.
I have some minor nits, questions, and a request for a little more explanation in the code. As always, feel free to ignore the "Nit:" items.
My biggest concern is what this means in terms of backwards compatibility. Could you please do a short example of before and after behavior? Is the output the same as it was before for cases where there is only one response?
There was a problem hiding this comment.
Nit: Using [::-1] is concise, but a lot of folks aren't familiar with that notation. Please use something like return list(reversed(path)) or something like that.
There was a problem hiding this comment.
Also, .display_name is not guaranteed to exist for container types that exist below the level of Verticals. LibraryContentModule and SplitTestModule do define it, but there might be third party things that don't, so it might be worthwhile to have a fallback.
There was a problem hiding this comment.
Nit: This is fine as is, but I find collections.defaultdict slightly easier to read:
generated_report_data = defaultdict(list)
for username, state in block.generate_report_data(user_state_iterator, max_count):
generated_report_data[username].append(state)This is a stylistic choice and completely optional. I just wanted to mention it in case you weren't familiar with defaultdict.
There was a problem hiding this comment.
Please insert a comment explaining what is going on in this block?
There was a problem hiding this comment.
Is building this path necessary to fix the bug? It's convenient, but it seems like a format change that might break client expectations?
There was a problem hiding this comment.
It is not necessary for this bug, but I thought it would be a small useful improvement. It is a backwards-incompatible change, but I think it makes the paths more consistent. One main benefit I see here is when you need to combine two reports, the paths are more useful.
I can definitely remove it, or move it to my other PR (https://github.com/edx/edx-platform/pull/19781) that deals with enhancements to this code.
There was a problem hiding this comment.
If the goal is to get the bugfix into Ironwood, then I think we should go for as much compatibility as possible, and put enhancements into a separate PR (either #19781 or something else).
|
@ormsbee The response will be the same in case there is only a single response for a block. In cases where there are multiple responses for a block, the situation is different. For people used to the Ginkgo report format, this change will now break the assumption that there is one row per block (if there was such an assumption, to begin with). However, on a per-row level, it has all the information they need, i.e. username, and state. (I will post a before and after sample soon) |
|
@xitij2000: Okay, that sounds fine for the altar of backwards compatibility. Please split out the path enhancement to a different PR and we'll get this bugfix merged and cherry-picked to Ironwood. Thank you, |
df7fe91 to
d52eee3
Compare
| usage key | ||
| """ | ||
| display_name = course_blocks.get_xblock_field(root, 'display_name') | ||
| name = course_blocks.get_xblock_field(root, 'display_name') or root.category |
There was a problem hiding this comment.
@ormsbee I'm making it fall back to the 'category' in case there is no display name. I hope that works.
|
jenkins run bokchoy |
ormsbee
left a comment
There was a problem hiding this comment.
As usual, please squash and include context from the PR message into the commit message. After that, I'll merge. Thank you!
…ate_report_data Before this fix if an XBlock's generate_report_data method returned multiple responses for the same user from a single user state, the report generator would end up overwriting each response over the previous one such that only the last response would be preserved.
d52eee3 to
a76c6dc
Compare
|
Your PR has finished running tests. There were no failures. |
|
@ormsbee I've squashed down to one commit and updated the commit message. |
|
@xitij2000 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future. |
|
I have cherry-picked this onto Ironwood. |
|
EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production on Monday, March 18, 2019. |
|
EdX Release Notice: This PR may have caused e2e tests to fail on Stage. If you're a member of the edX org, please visit #e2e-troubleshooting on Slack to help diagnose the cause of these failures. Otherwise, it is the reviewer's responsibility. E2E tests have failed. https://gocd.tools.edx.org/go/tab/pipeline/history/STAGE_edxapp_M-D |
|
@nedbat Thanks! |
|
EdX Release Notice: This PR has been deployed to the production environment. |
The current problem response code has a bug that causes it to only return a response for each user for each block.
The following code is generating a dictionary keyed on username for the report generated for each block. If a block contains multiple responses per user, then later responses will overwrite older responses.
https://github.com/edx/edx-platform/blob/8593d4dc711c67535a0a0a98fa32b84ce6abc0c1/lms/djangoapps/instructor_task/tasks_helper/grades.py#L674-L678
JIRA tickets: https://openedx.atlassian.net/browse/OSPR-2927
Discussions: TBD
Sandbox URL:
Testing instructions:
Author notes and concerns:
Since there are multiple responses for each user state, I am not entirely sure how this should be handled. Currently, it just duplicates the state for each row, however, there may be a good argument for not doing that if it breaks current flows that use the state. (I remember there were concerns when the original PR for this removed the state entirely).
Reviewers