Skip to content

Allow move for content experiment#14457

Merged
mushtaqak merged 4 commits intomushtaq/move-componentfrom
mushtaq/restrict-move-action
Mar 1, 2017
Merged

Allow move for content experiment#14457
mushtaqak merged 4 commits intomushtaq/move-componentfrom
mushtaq/restrict-move-action

Conversation

@mushtaqak
Copy link
Contributor

@mushtaqak mushtaqak commented Feb 2, 2017

This PR adds ability to:

  • Move Content Experiment in other unit.
  • Move children of content experiment to other unit as well as other Content Experiment.
  • Don't show move icon on library page

Sandbox Link

@muhammad-ammar @muzaffaryousaf Please review.

@mushtaqak mushtaqak force-pushed the mushtaq/restrict-move-action branch from 9530222 to 134bb84 Compare February 3, 2017 12:12
@mushtaqak
Copy link
Contributor Author

jenkins run python

@muzaffaryousaf
Copy link

@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

Choose a reason for hiding this comment

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

Where we're passing True for unit page ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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

@muzaffaryousaf
Copy link

@mushtaqak I'm not able to see "move" icon for Content Experiment.

@mushtaqak mushtaqak force-pushed the mushtaq/tnl-6062-save-move-xblock branch from 2149952 to 486bcde Compare February 7, 2017 10:36
@mushtaqak mushtaqak force-pushed the mushtaq/restrict-move-action branch from 0027b5d to 798f5f2 Compare February 7, 2017 14:10
@muzaffaryousaf
Copy link

@mushtaqak I'm not able to move the component in a unit which does't have children.

@mushtaqak mushtaqak force-pushed the mushtaq/tnl-6062-save-move-xblock branch from 486bcde to 99a3416 Compare February 7, 2017 16:25
@mushtaqak
Copy link
Contributor Author

mushtaqak commented Feb 7, 2017

@mushtaqak I'm not able to move the component in a unit which does't have children.

Oh I will fix that tomorrow :)

@mushtaqak mushtaqak force-pushed the mushtaq/restrict-move-action branch from 2ef7f96 to 9bd7b72 Compare February 7, 2017 16:44
@mushtaqak
Copy link
Contributor Author

mushtaqak commented Feb 7, 2017

@muzaffaryousaf is it working now for emptyunit?

@muzaffaryousaf
Copy link

have you updated sandbox ?

@muzaffaryousaf
Copy link

looks like it is.

@mushtaqak mushtaqak force-pushed the mushtaq/tnl-6062-save-move-xblock branch 2 times, most recently from c4c0d45 to cda669e Compare February 9, 2017 08:49
@mushtaqak mushtaqak force-pushed the mushtaq/restrict-move-action branch from 9bd7b72 to f99b3f6 Compare February 9, 2017 10:17
@muzaffaryousaf
Copy link

muzaffaryousaf commented Feb 9, 2017

@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:
You maybe wondering why we implemented this instead of just hiding the move icon from content experiment, initially that was our plan but it turned out implementing is simpler than hiding the icon.

@muzaffaryousaf
Copy link

@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.

@muzaffaryousaf muzaffaryousaf changed the title Restrict move action Allow move for content experiment Feb 9, 2017
@mushtaqak
Copy link
Contributor Author

@sstack22 @andy-armstrong please have a look at the sandbox :)

Copy link
Contributor

@andy-armstrong andy-armstrong left a comment

Choose a reason for hiding this comment

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

👍 looks great!

One minor nit: the groups are labelled with their internal ids, rather than with the group name.

@catong
Copy link
Contributor

catong commented Feb 10, 2017

Thanks @mushtaqak. It looks great - I'll update the doc PR that is in progress to reflect this.

@muzaffaryousaf
Copy link

@mushtaqak When i add new component on library page, i'm able to see move icon for the first time.

@muzaffaryousaf
Copy link

@mushtaqak Have you tried conditional module ?

<%- xblock.get('display_name') %>
</span>
<% } else { %>
<% if (xblock.get('child_info') || XBlocksCategory !== 'component') { %>

Choose a reason for hiding this comment

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

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) {

Choose a reason for hiding this comment

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

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

Choose a reason for hiding this comment

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

Is this for children of split_test ?

Choose a reason for hiding this comment

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

@mushtaqak a small code comment about why we're doing this would be helpful for others.

}
this.isValidMove = isValidMove || false;
},
validCategoryCheck: function(targetParentType, sourceParentType) {

Choose a reason for hiding this comment

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

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';

Choose a reason for hiding this comment

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

Are we missing any other parent category ? I'm asking because of explicit 'component'.

Copy link
Contributor

Choose a reason for hiding this comment

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

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)

Choose a reason for hiding this comment

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

@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.

Choose a reason for hiding this comment

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

Nvm, i just saw the test for library.

@catong
Copy link
Contributor

catong commented Feb 23, 2017

@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?

@mushtaqak
Copy link
Contributor Author

@catong Yes you are right

@mushtaqak
Copy link
Contributor Author

@catong Just to let you know that component can not be moved inside itself or inside it's children components.

@mushtaqak
Copy link
Contributor Author

@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']

Choose a reason for hiding this comment

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

Is there any chance of no ancestor info for any target_parent ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm, if the target item is course xblock may be.

Choose a reason for hiding this comment

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

Confirm this and see how we can avoid such usages which can break the code in some unseen scenario.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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(

Choose a reason for hiding this comment

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

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):

Choose a reason for hiding this comment

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

@mushtaqak I think we should move this test with utils test cases where we moved the logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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;
Copy link
Contributor

Choose a reason for hiding this comment

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

@mushtaqak i think we left this mistakenly? assigning to itself?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh, my bad, nice catch!

@muzaffaryousaf
Copy link

@mushtaqak The overall functionality looks good to me but i'll give final review soon. Thanks for all the good work.

@mushtaqak
Copy link
Contributor Author

jenkins run lettuce

Returns True if source item is found in target parents otherwise False.

Arguments:
source_item (XBlock): Source xblock.

Choose a reason for hiding this comment

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

xblock --> Xblock

</span>
<% if(currentLocationIndex === i) { %>
<span class="current-location">
(<%- gettext('Current location') %>)

Choose a reason for hiding this comment

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

I think we should re-word this to Currently Selected

Choose a reason for hiding this comment

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

@catong or @srpearce Please suggest appropriate text here. This text will be shown with selected components e.g. video, html, discussion etc.

Copy link
Contributor

Choose a reason for hiding this comment

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

@muzaffaryousaf I can take a look; I'll be finishing up this Move feature for doc.

Copy link
Contributor

Choose a reason for hiding this comment

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

@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};

Choose a reason for hiding this comment

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

how this will add groups in content experiment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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)

Choose a reason for hiding this comment

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

I would use some real scenario like content experiment.

@muzaffaryousaf
Copy link

@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 { %>
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought that we had previously changed "Click for children" to something else? Did it get lost in the previous PR?

Copy link
Contributor

Choose a reason for hiding this comment

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

"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') %>)
Copy link
Contributor

Choose a reason for hiding this comment

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

@muzaffaryousaf Agreed that at the level of the item that we are actually moving the gettext should change to "Currently selected"

@mushtaqak
Copy link
Contributor Author

jenkins run bokchoy

@mushtaqak mushtaqak force-pushed the mushtaq/restrict-move-action branch from 965c31f to 93439b2 Compare March 1, 2017 14:03
@mushtaqak mushtaqak force-pushed the mushtaq/move-component branch from a12ee2d to e9b8e17 Compare March 1, 2017 14:28
@mushtaqak mushtaqak force-pushed the mushtaq/restrict-move-action branch from 93439b2 to 485ffb1 Compare March 1, 2017 14:30
@mushtaqak mushtaqak merged commit de29ef9 into mushtaq/move-component Mar 1, 2017
@muzaffaryousaf
Copy link

Awesome!!!

@mushtaqak mushtaqak mentioned this pull request Mar 1, 2017
return reverse_url(handler_name, 'usage_key_string', usage_key, kwargs)


def get_group_display_name(user_partitions, xblock_display_name):
Copy link

@cahrens cahrens Mar 16, 2017

Choose a reason for hiding this comment

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

@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.

@mushtaqak mushtaqak deleted the mushtaq/restrict-move-action branch May 10, 2017 08:02
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.

7 participants