-
Notifications
You must be signed in to change notification settings - Fork 71
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
Move items between zones in assessment mode #84
Move items between zones in assessment mode #84
Conversation
c097fdd
to
efdb838
Compare
self.interact_with_keyboard_help(use_keyboard=use_keyboard) | ||
# @data(False, True) | ||
# def test_keyboard_help(self, use_keyboard): | ||
# self.interact_with_keyboard_help(use_keyboard=use_keyboard) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason we've got several tests commented out here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@haikuginger There isn't, thanks for catching this. I commented them out while debugging a specific test and then forgot to uncomment them :/.
So, I've checked this out - all tests pass locally, and the interaction definitely works as intended. I do have a small interaction concern, though - there's no way to remove an item from the board once it's been placed, besides pressing the reset button. In general, this isn't a huge issue, except when it comes to decoy items. Right now, when an item is dropped on an area that isn't an active zone, it jumps back to where it was placed before. I kind of wonder if they should jump back to the palette instead. Either that, or we should possibly make the palette a full zone that we can drag to in its own right. |
@haikuginger Thanks a lot for the review. That's a very good point. I think it would make sense to be able to drag items back to the bank. |
configuration.items[i].grabbed = grabbed; | ||
var setGrabbedState = function(item_id, grabbed, interaction_type) { | ||
for (var i = 0, item; i < configuration.items.length; i++) { | ||
item = configuration.items[i]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Just use configuration.items.forEach(function(item) {
which is nicer and used elsewhere in the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, changed.
Yes, one should be able to drag items back to the bank.
Can we use the existing "alignment" code to avoid this? It already has an algorithm for moving items around within a zone so that they don't overlap, if I remember correctly. |
I was not familiar with this feature, but it seems to be working well and prevents the problem. |
5496a36
to
cd7e92e
Compare
@haikuginger I implemented ability to drag items back to the bank, please take a look. |
👍
|
cd7e92e
to
062bac8
Compare
Rebased cd7e92e onto master |
When I used the keyboard to move items, I ended up with "Goes to the top" completely behind "Goes to the middle". Probably keyboard moves always go to the same place? And actually, I can reproduce this with the mouse as well. Keyboard reproduction steps:
|
} | ||
var style = bankItemWidthStyles(item, ctx); | ||
// Placeholder should never be visible. | ||
style.visibility = 'hidden'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They will be invisible to screen readers as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cahrens Yes, elements with visibility: hidden
are ignored by screen readers.
Just a few questions (see above), and I noted a situation in which an item can get completely hidden behind another element. |
@cahrens The problem with overlapping drop targets was a pre-existing issue AFAIK, and after it was brought up on another PR I created https://openedx.atlassian.net/browse/SOL-1979 - so we will deal with it in an upcoming PR. |
@cahrens The item overlap issue will be addressed by https://openedx.atlassian.net/browse/SOL-1979. I addressed all of your other comments, please have a look. |
777eb07
to
b53246c
Compare
My only concern is that focus goes to the bottom of the page when selecting a drop zone before selecting something to drag. Is this expected behavior? Could we instead focus on the problem again? Other than that 👍 |
@staubina Thanks for the review! I believe that's the expected behavior. It has worked that way before the changes in this PR. |
👍 , though I would think that the scrolling behavior @staubina mentioned will have to be fixed at some point. If you don't think it makes sense to do as part of this PR, can you update an appropriate ticket with this information? Note that the keyboard focus is correct (it's still on the zone you selected), just the spurious scroll occurs. |
@cahrens @staubina I see. Scrolling the page down when you press space bar is the default behavior in most browsers. When you pick up an item we hijack the space bar from the browser so that it drops the item rather than scroll the page. When no item is picked up, space bar is not hijacked so pressing it produces the standard scroll down effect. I can see why this can be distracting while working on a Drag and Drop exercise, especially if you think you've grabbed an item when you haven't, so I think it would make sense to hijack the space bar every time one of the zones is focused, regardless of whether an item has been picked up or not. I will check to see whether that's easy to do. If easy, I'll add it to this PR, if not I'll create a separate ticket. |
@mtyaka I think it's simply a matter of calling |
Thanks for the suggestion @bradenmacdonald, @cahrens @staubina I added some code to prevent default browser scroll from happening when pressing space bar while focused on a zone with no item selected. |
@sstack22 Please review when you get a chance. |
@mtyaka Thanks for making that change. Did you update the Sandbox? 👍 |
@staubina The sandbox hasn't been updated yet, I'll do it in a couple of minutes. |
@staubina Sandbox has been updated. |
Looks good to me |
@mtyaka - a couple small notes:
Otherwise, looks good. |
Thanks for the review @sstack22!
Thanks for pointing that out, I never noticed the way text temporarily disappeared. It is now fixed and the sandbox has been updated with the fix.
The way we currently determine whether the item was dropped into a zone is by looking at the position of mouse pointer at the time you release the item. If the mouse pointer is inside a zone, the drop is successful, but if the mouse pointer is outside the zone, the drop is reverted. |
2b11b55
to
ddb9fd3
Compare
Squashed from 30173c4 |
ddb9fd3
to
165fae0
Compare
In standard mode, once you drop an item into the correct zone, you can no longer move it until you reset the exercise. In assessment mode, we want users to be able to freely move items between zones until they explicitly submit their solution. This commit implements the ability to move dropped items between zones in assessment mode. It does not make any changes to standard mode.
Child elements of items can get removed/reordered, so we have to mark each of them children with a unique key for virtual dom to be able to reorder them correctly. The absence of keys was causing some weird glitches where the content would disappear while the item spinner was visible.
165fae0
to
ed661bf
Compare
Description
This PR implements the following use case:
UX
The existing implementation does not allow learners to move an item to a different zone once it has been placed on the board. We will keep this behavior for drag-and-drop problems in standard mode.
In assessment mode, learners should be able to move items that have already been placed on the board, regardless of whether they are located in a correct or incorrect zone. To do this, learners will be able to use the same workflows that are already established for moving items from the item bank to the board:
With no item selected, learners will be able to (Shift-)TAB to items that have been placed on the board.
Once an item has been picked up, pressing (Shift-)TAB will only navigate between zones and the item bank.
JIRA tickets: SOL-1943
Discussions: Discovery document for DnDv2 assessment mode (relevant section: 2.2.2)
Dependencies: None
Sandbox URLs (installed version de0312b):
DnD example is located at http://dndv2-sandbox5.opencraft.hosting/courses/course-v1:OpenCraftX+OC1+1/courseware/bdeaa08976fa4645a277edcaf5e8148c/e8ec2f5c98f4436abf532cccd6a71668/1?activate_block_id=block-v1%3AOpenCraftX%2BOC1%2B1%2Btype%40vertical%2Bblock%40e3c62b19090948b8ad89d3386bff4435
Testing instructions:
Author notes and concerns:
If you put multiple items into the same zone with keyboard in assessment mode, you can only see the topmost item, the rest of the items are hidden behind it (the same thing can happen when dragging with the mouse, but when dragging with the mouse you usually don't drop the item in exactly the same place, so parts of overlapping items are usually still visible).
Using the existing zone alignment feature (where you can specify how dropped items automatically align inside zones) prevents this problem.
Reviewers