-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
[FC-0049] Handle tags when importing/exporting courses #34356
[FC-0049] Handle tags when importing/exporting courses #34356
Conversation
Thanks for the pull request, @ChrisChV! Please note that it may take us up to several weeks or months to complete a review and merge your PR. Feel free to add as much of the following information to the ticket as you can:
All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here. Please let us know once your PR is ready for our review and all tests are green. |
3305ef2
to
adb81c5
Compare
adb81c5
to
82dab62
Compare
@@ -170,10 +170,10 @@ def _tags_for_content_object(object_id: UsageKey | LearningContextKey) -> dict: | |||
} | |||
for obj_tag in all_tags: | |||
# Add the taxonomy name: | |||
if obj_tag.name not in result[Fields.tags_taxonomy]: | |||
result[Fields.tags_taxonomy].append(obj_tag.name) | |||
if obj_tag.taxonomy.name not in result[Fields.tags_taxonomy]: |
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.
@bradenmacdonald On openedx/openedx-learning#172 _name
has been changed to _export_id
, but here I have kept the taxonomy name. That is ok?
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.
Yes, that's right. Here should be the taxonomy name only. Thanks :)
@rpenido @bradenmacdonald About the
In the tag drawer, by default taxonomies that are not part of the course organization are not displayed. Would this change on import? What I have in mind is to add a field to the ObjectTag: |
No, you don't need to add an CC @jmakowski1123 to confirm. |
Taxonomies/tags that course author don't have permission to view are currently not displayed. Can't delete. I would have to check if the taxonomy has tags and show it |
Hi @ChrisChV ! While testing, the "empty" course has a language tag (auto-tagged). I removed the tag and exported the course again. I got a
I don't think this is an issue, but it differs from your test instructions (actually, I think this is good because the user can add new tags even if the course has none applied). Besides that, everything works flawlessly. Good work, @ChrisChV! When you have Scenario 4, let me know so I can review it again. |
If you want, we can just open a ticket for this on https://github.com/openedx/modular-learning/issues/ and tackle it later. |
@bradenmacdonald @rpenido I created open-craft#649 and openedx/frontend-app-authoring#926 as a proof of concept of the Scenario 4. I am missing the tests and testing instructions. I will continue it if you agree with the solution 😀 |
When you add a new tags in a course, the previous tags are not exported How repodruce: - Import a course - Add new tags to the course or blocks - Export a course
@ChrisChV Is there some way we could do it without changing the taxonomy permissions or retrieving "all taxonomies"? Perhaps just list all the objecttags and if any don't match the "allowed" taxonomies, we can display the rest under a heading like "Other Tags" |
@bradenmacdonald I have realized that scenario 4 needs more discussion. I created openedx/modular-learning#204 and I continued the discussion there. This PR works and can be merged without Scenario 4 CC @rpenido |
@rpenido Can you please review this? Then I can do a CC review + merge. We can handle "scenario 4" separately. |
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.
LGTM @ChrisChV ! 👍
- I tested this using the Testing Instructions
- I read through the code
-
I checked for accessibility issues - Includes documentation
This is ready for CC review @bradenmacdonald
openedx/core/djangoapps/content_tagging/helpers/test_objecttag_export_helpers.py
Outdated
Show resolved
Hide resolved
tags_count = get_object_tag_counts(block_id_pattern) | ||
course_tags_count = get_object_tag_counts(courselike_key_str) | ||
|
||
if tags_count or course_tags_count: |
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.
I found the cause of having an empty tags.csv
in my tests. At the auto-tagging handler, we tag the course (course-v1:...
) and the "course block". The latter is not shown anywhere but probably appears in this count.
Could we create a small task to fix this @bradenmacdonald?
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.
@rpenido Sure, thanks!
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, looks good! Just a few minor things and then I'll approve and merge.
@@ -61,7 +63,7 @@ def create_dummy_course(self, store_type): | |||
) | |||
return course.id | |||
|
|||
def check_export_file(self, tar_file, course_key): | |||
def check_export_file(self, tar_file, course_key, withTags=False): |
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.
Please use snake case: with_tags
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.
Updated here
@@ -343,6 +344,11 @@ def export_handler(request, course_key_string): | |||
requested_format = request.GET.get('_accept', request.META.get('HTTP_ACCEPT', 'text/html')) | |||
|
|||
if request.method == 'POST': | |||
if not has_view_object_tags_access(request.user, str(course_key)): | |||
raise PermissionDenied( | |||
"You do not have permission to view object tags for this object_id." |
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.
We're already checking if not has_course_author_access(request.user, course_key):
- isn't that enough?
I'm just slightly worried that this will cause some issue where exports start to fail for people who aren't even using tags at all in their course, so I want to play it safe here.
If you want to keep it in, we should just disable the tags.csv
file when the user doesn't have permission, rather than making the whole export fail.
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.
We're already checking if not has_course_author_access(request.user, course_key): - isn't that enough?
I think you are right, I will follow this. 👍
If you want to keep it in, we should just disable the tags.csv file when the user doesn't have permission, rather than making the whole export fail.
I think do this will do the code more complex
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.
Yeah, just take it out for now. The existing check for has_course_author_access
is sufficient. If you're allowed to export the course, you're allowed to see all the tags.
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.
Updated here
@bradenmacdonald I fixed the nits. It's ready for merge |
@ChrisChV There is just a minor pylint issue - please fix :) |
@ChrisChV 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future. |
2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production. |
2U Release Notice: This PR has been deployed to the edX production environment. |
1 similar comment
2U Release Notice: This PR has been deployed to the edX production environment. |
Description
tags.csv
when exporting a course.tags.csv
and creates object_tags depending on the scenarioobject_tag._export_id
;
Supporting information
Testing instructions
make requirements
on cms shell.make migrate
on cms shell.tags.csv
is not included in the export files.tags.csv
is included in the export files. Open and verify the content of the file.Scenario 1:
Scenario 2:
tags.csv
and add tags that doesn't exist on a taxonomy (FlatTaxonomy in this example). Save.tags.csv
. Verify that the new tags are not visible.Scenario 3:
tags.csv
and add tags that doesn't exist on a taxonomy that doesn't exist. You need to add a new column with a newexport_id
. Save.tags.csv
. Verify that the new tags are not visible.export_id
added ontags.csv
.Manage organizations
menu of the new taxonomy and add it to all organizations.Scenario 4: openedx/modular-learning#204
Other information