Allow move for content experiment#14457
Conversation
9530222 to
134bb84
Compare
|
jenkins run python |
|
@mushtaqak Fix the tests first and build a sandbox to look at. |
| 'can_edit': context.get('can_edit', True), | ||
| 'can_edit_visibility': context.get('can_edit_visibility', True), | ||
| 'can_add': context.get('can_add', True), | ||
| 'can_move': context.get('is_unit_page', False), # move action is not allowed other than unit page |
There was a problem hiding this comment.
Where we're passing True for unit page ?
There was a problem hiding this comment.
When a page is unit page, it has True set to is_unit_page field of the xblock_info. So context.get('is_unit_page', False) would either give True (if unit page) or False
|
@mushtaqak I'm not able to see "move" icon for Content Experiment. |
2149952 to
486bcde
Compare
0027b5d to
798f5f2
Compare
|
@mushtaqak I'm not able to move the component in a unit which does't have children. |
486bcde to
99a3416
Compare
Oh I will fix that tomorrow :) |
2ef7f96 to
9bd7b72
Compare
|
@muzaffaryousaf is it working now for emptyunit? |
|
have you updated sandbox ? |
|
looks like it is. |
c4c0d45 to
cda669e
Compare
9bd7b72 to
f99b3f6
Compare
|
@sstack22 We've added capability to move an content experiment across the units. Would you please give it a quick look. Here is link to sandbox https://studio-moveaction.sandbox.edx.org/course/course-v1:edX+DemoX+Demo_Course which includes everything that we've done so far related to move xblock feature. @catong FYI ^^ NOTE: |
|
@andy-armstrong Based on your previous feedback, we've added the ability to move content experiment. It would be nice if you can take a look too. Thanks. |
|
@sstack22 @andy-armstrong please have a look at the sandbox :) |
andy-armstrong
left a comment
There was a problem hiding this comment.
👍 looks great!
One minor nit: the groups are labelled with their internal ids, rather than with the group name.
|
Thanks @mushtaqak. It looks great - I'll update the doc PR that is in progress to reflect this. |
|
@mushtaqak When i add new component on library page, i'm able to see move icon for the first time. |
|
@mushtaqak Have you tried conditional module ? |
| <%- xblock.get('display_name') %> | ||
| </span> | ||
| <% } else { %> | ||
| <% if (xblock.get('child_info') || XBlocksCategory !== 'component') { %> |
There was a problem hiding this comment.
I'd explicitly check if xblock.get('child_info') is not undefined or if it's a list then i'd check len(xblock.get('child_info')) > 0.
| } | ||
| this.isValidMove = isValidMove || false; | ||
| }, | ||
| validCategoryCheck: function(targetParentType, sourceParentType) { |
There was a problem hiding this comment.
Can we rename it to isCategoryValid / isValidCategory
| }, | ||
| validCategoryCheck: function(targetParentType, sourceParentType) { | ||
| if (!_.contains(['course, chapter, sequential, vertical'], sourceParentType)) { | ||
| sourceParentType = 'vertical'; // eslint-disable-line no-param-reassign |
There was a problem hiding this comment.
Is this for children of split_test ?
There was a problem hiding this comment.
@mushtaqak a small code comment about why we're doing this would be helpful for others.
| } | ||
| this.isValidMove = isValidMove || false; | ||
| }, | ||
| validCategoryCheck: function(targetParentType, sourceParentType) { |
There was a problem hiding this comment.
Let's leave a blank line before this method.
| this.visitedAncestors[this.visitedAncestors.length - 2] | ||
| ); | ||
| this.childrenInfo.category = this.categoryRelationMap[this.parentInfo.category]; | ||
| this.childrenInfo.category = this.categoryRelationMap[this.parentInfo.category] || 'component'; |
There was a problem hiding this comment.
Are we missing any other parent category ? I'm asking because of explicit 'component'.
There was a problem hiding this comment.
I think we should avoid || 'component' and add category to map, this will make the code more readable.
| drag_handle_html = '<span data-tooltip="Drag to reorder" class="drag-handle action"></span>' | ||
| self.assertIn(drag_handle_html, html) | ||
| self.validate_html_for_reorder(html, can_reorder) | ||
| self.validate_html_for_move_button(html, can_move) |
There was a problem hiding this comment.
@mushtaqak I think can_move will never get called with False, can you double check that. If that's the case i'd like to see coverage for this scenario too.
There was a problem hiding this comment.
Nvm, i just saw the test for library.
|
@mushtaqak @sstack22 To summarize, we are supporting moving units from content experiments, but we are NOT supporting moving units out of a content library (Move icon not available). Is this right? |
|
@catong Yes you are right |
|
@catong Just to let you know that component can not be moved inside itself or inside it's children components. |
|
@muhammad-ammar PR is ready for second review, sandbox is updated :) |
| source_item (XBlock): Source xblock. | ||
| target_parent (XBlock): Target XBlock. | ||
| """ | ||
| target_ancestors = _create_xblock_ancestor_info(target_parent, is_concise=True)['ancestors'] |
There was a problem hiding this comment.
Is there any chance of no ancestor info for any target_parent ?
There was a problem hiding this comment.
hmm, if the target item is course xblock may be.
There was a problem hiding this comment.
Confirm this and see how we can avoid such usages which can break the code in some unseen scenario.
There was a problem hiding this comment.
Even if the target_parent is a course xblock or (having no parent), this _create_xblock_ancestor_info returns {'ancestors': []} which wouldn't break the code.
However, this can break if target_parent is None which would break already built method _create_xblock_ancestor_info because the None xblock wouldn't have any location or any other xblock related fields. But, I think, we are fin in this case, we would want the code to break if None is passed on (which in our scenario would never be the case).
| """ | ||
| Test that a component can not be moved to itself. | ||
| """ | ||
| lc_block = self.create_xblock( |
There was a problem hiding this comment.
lc_block --> library_block or library_content
| self.assertEqual(vertical_0.location, split_test.group_id_to_child['0']) | ||
| self.assertEqual(vertical_1.location, split_test.group_id_to_child['1']) | ||
|
|
||
| def test_split_xblock_info_group_name(self): |
There was a problem hiding this comment.
@mushtaqak I think we should move this test with utils test cases where we moved the logic.
There was a problem hiding this comment.
It's a lot easier to place it where without any repetition. I can change to test_utils if you want.
| } | ||
| this.categoryRelationMap[this.parentInfo.category] = childCategory; | ||
| } | ||
| this.parentInfo.category = this.parentInfo.category; |
There was a problem hiding this comment.
@mushtaqak i think we left this mistakenly? assigning to itself?
There was a problem hiding this comment.
oh, my bad, nice catch!
|
@mushtaqak The overall functionality looks good to me but i'll give final review soon. Thanks for all the good work. |
|
jenkins run lettuce |
| Returns True if source item is found in target parents otherwise False. | ||
|
|
||
| Arguments: | ||
| source_item (XBlock): Source xblock. |
| </span> | ||
| <% if(currentLocationIndex === i) { %> | ||
| <span class="current-location"> | ||
| (<%- gettext('Current location') %>) |
There was a problem hiding this comment.
I think we should re-word this to Currently Selected
There was a problem hiding this comment.
@muzaffaryousaf I can take a look; I'll be finishing up this Move feature for doc.
There was a problem hiding this comment.
@muzaffaryousaf Agreed that at the level of the item that we are actually moving the gettext should change to "Currently selected"
| has_children: true, | ||
| id: 'SPLIT_TEST_ID' | ||
| }, | ||
| outlineOptions = {split_test: 1, unit: 2, component: 1}; |
There was a problem hiding this comment.
how this will add groups in content experiment.
There was a problem hiding this comment.
actually group in content experiments are verticals/units, so this will add slit test and 2 units and a component in group 0
| parent_vert_usage_key = self._create_vertical(parent_usage_key=self.vert_usage_key) | ||
| child1_vert_usage_key = self._create_vertical(parent_usage_key=parent_vert_usage_key) | ||
| child2_vert_usage_key = self._create_vertical(parent_usage_key=child1_vert_usage_key) | ||
| child3_vert_usage_key = self._create_vertical(parent_usage_key=child2_vert_usage_key) |
There was a problem hiding this comment.
I would use some real scenario like content experiment.
|
@mushtaqak i'm done with final review and left couple of NITS. 👍 |
| <span class="icon fa fa-arrow-right forward-sr-icon" aria-hidden="true"></span> | ||
| <span class="sr forward-sr-text"><%- gettext("Click for children") %></span> | ||
| </button> | ||
| <% } else { %> |
There was a problem hiding this comment.
I thought that we had previously changed "Click for children" to something else? Did it get lost in the previous PR?
There was a problem hiding this comment.
"View child components" (5 syllables) is still the best option IMO, perhaps "View child items" to lose one syllable. @cptvitamin?
| </span> | ||
| <% if(currentLocationIndex === i) { %> | ||
| <span class="current-location"> | ||
| (<%- gettext('Current location') %>) |
There was a problem hiding this comment.
@muzaffaryousaf Agreed that at the level of the item that we are actually moving the gettext should change to "Currently selected"
|
jenkins run bokchoy |
965c31f to
93439b2
Compare
a12ee2d to
e9b8e17
Compare
93439b2 to
485ffb1
Compare
bokchoy tests for move xblocks
|
Awesome!!! |
| return reverse_url(handler_name, 'usage_key_string', usage_key, kwargs) | ||
|
|
||
|
|
||
| def get_group_display_name(user_partitions, xblock_display_name): |
There was a problem hiding this comment.
@mushtaqak @muzaffaryousaf This is causing a problem for me on a PR I'm working on, and it would appear to be a general bug due to the implementation below. group['id'] is an integer; it can be any integer. xblock_display_name can contain any text. It is quite possible that a xblock's display name contains the integer of a group['id'], without them being related in any way.
As a concrete example, I am adding a new UserPartition based on enrollment track. The group IDs related to this partition will be small number (1, 2, 3, etc.). It's quite possible that an xblock's display name will contain those integers, and in fact, I hit failing tests that pointed out this issue (thank goodness for tests!).
Can you guys look into this tomorrow? I won't be able to merge my PR (#14682) until this is changed. For tracking purposes, I have created https://openedx.atlassian.net/browse/TNL-6731.
This PR adds ability to:
Sandbox Link
@muhammad-ammar @muzaffaryousaf Please review.