Skip to content
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

Support Zip files for Course Import #33539

Closed
wants to merge 0 commits into from

Conversation

rodfersou
Copy link
Contributor

@rodfersou rodfersou commented Oct 18, 2023

Description

Support zip files for Course import.

Please see more details at this issue: openedx/platform-roadmap#285

Useful information to include:

  • Which edX user roles will this change impact?
    => "Course Author".
  • Include screenshots for changes to the UI (ideally, both "before" and "after" screenshots, if applicable).
    => Before
image => After image - Provide links to the description of corresponding configuration changes. Remember to correctly annotate these changes. => None

Supporting information

Link to other information about the change, such as Jira issues, GitHub issues, or Discourse discussions.
Be sure to check they are publicly readable, or if not, repeat the information here.
https://tasks.opencraft.com/browse/BB-8025
openedx/platform-roadmap#285

Testing instructions

  • Select the course
    1. Check out this PR
    2. Open the CMS (Studio)
    3. Create a course or use the example one
    4. Select the course
    5. In the top menu, select Tools / Export
    6. Click in Export Course Content
    7. Save the .tar.gz file in a new folder at your computer
  • Modify the course
    1. Find this file in your computer
    2. Extract the course
    3. Modify the course content - Optional
    4. Compact the course again in .zip file
    5. Rename the compressed file (can have spaces in the name) - Optional
  • Upload changes
    1. Open the CMS (Studio)
    2. Select the course
    3. In the top menu, select Tools / Import
    4. Click in Choose new file
    5. Select the created .zip file
    6. Click in Replace my course with the selected file
    7. Wait the import steps to finish
    8. Check if changes are persisted - Optional

Deadline

=> 2023-10-29

Other information

Include anything else that will help reviewers and consumers understand the change.

  • Does this change depend on other changes elsewhere?
    => No
  • Any special concerns or limitations? For example: deprecations, migrations, security, or accessibility.
    => No
  • If your database migration can't be rolled back easily.
    => No

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Oct 18, 2023
@openedx-webhooks
Copy link

openedx-webhooks commented Oct 18, 2023

Thanks for the pull request, @rodfersou! 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:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

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.

⚠️ We can't start reviewing your pull request until you've submitted a signed contributor agreement or indicated your institutional affiliation. Please see the CONTRIBUTING file for more information. If you've signed an agreement in the past, you may need to re-sign. See The New Home of the Open edX Codebase for details.

Once you've signed the CLA, please allow 1 business day for it to be processed. After this time, you can re-run the CLA check by adding a comment here that you have signed it. If the problem persists, you can tag the @openedx/cla-problems team in a comment on your PR for further assistance.

@rodfersou rodfersou force-pushed the feat/poc-zip-import branch from d830b45 to f643f3a Compare October 19, 2023 11:32
@@ -35,7 +35,7 @@ define([
var filepath = $(this).val(),
msg;

if (filepath.substr(filepath.length - 6, 6) === 'tar.gz') {
if (/\.tar.gz$|\.zip$/.test(filepath)) {
Copy link
Contributor Author

@rodfersou rodfersou Oct 19, 2023

Choose a reason for hiding this comment

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

question: ❓ should I add a global configuration for this like python code?

or maybe keep this regex defined in the top of the file for reuse?

return members


def safezip_extractall(zip_file, path=".", members=None): # pylint: disable=unused-argument
Copy link
Contributor Author

Choose a reason for hiding this comment

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

thought: 💭 this could be a monkey patch


Adapted from:
http://stackoverflow.com/questions/10060069/safely-extract-zip-or-tar-using-python
"""
Copy link
Contributor Author

Choose a reason for hiding this comment

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

thought: 💭 This file could be merged with openedx/core/lib/extract_tar.py

Tried to keep the changes minimal by create a new file

@rodfersou rodfersou force-pushed the feat/poc-zip-import branch from f643f3a to a7b17b4 Compare October 19, 2023 11:42
@@ -35,7 +36,7 @@
from organizations.api import add_organization_course, ensure_organization
from organizations.exceptions import InvalidOrganizationException
from organizations.models import Organization, OrganizationCourse
from path import Path as path
from pathlib import Path as path
Copy link
Contributor Author

Choose a reason for hiding this comment

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

nitpick: ⛏️ suffixes are available just in pathlib

@@ -27,7 +27,7 @@
from edx_django_utils.monitoring import set_custom_attribute, set_custom_attributes_for_course_key
from opaque_keys.edx.keys import CourseKey
from opaque_keys.edx.locator import LibraryLocator
from path import Path as path
from pathlib import Path as path
Copy link
Contributor Author

Choose a reason for hiding this comment

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

nitpick: ⛏️ suffixes are available just in pathlib

@rodfersou rodfersou force-pushed the feat/poc-zip-import branch 3 times, most recently from 8f2ac2f to d0d629b Compare October 19, 2023 12:51
mocked_log.error.assert_called_once_with(expected_error_mesg)

status_response = self.get_import_status(self.course.id, self.good_zip)
self.assertImportStatusResponse(status_response, self.UnpackingError, import_error.UNSAFE_TAR_FILE)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

thought: 💭 create import_error.UNSAFE_ZIP_FILE

@rodfersou rodfersou force-pushed the feat/poc-zip-import branch from 2471a2c to 634a252 Compare October 19, 2023 14:06
@mphilbrick211 mphilbrick211 added the needs test run Author's first PR to this repository, awaiting test authorization from Axim label Oct 19, 2023
@rodfersou rodfersou force-pushed the feat/poc-zip-import branch from ed5d7a7 to b417684 Compare October 19, 2023 19:41
@rodfersou rodfersou changed the title POC - Zip Import POC - Zip Course Import Oct 20, 2023
@rodfersou rodfersou changed the title POC - Zip Course Import WIP - Zip Course Import Oct 20, 2023
@rodfersou rodfersou changed the title WIP - Zip Course Import Support Zip files for Course Import Oct 20, 2023
@rodfersou rodfersou force-pushed the feat/poc-zip-import branch 4 times, most recently from e06b195 to cf9d26f Compare October 20, 2023 14:38
@rodfersou rodfersou marked this pull request as ready for review October 20, 2023 14:38
@rodfersou rodfersou closed this Oct 20, 2023
@rodfersou rodfersou force-pushed the feat/poc-zip-import branch from 0ccf17d to 2e75ced Compare October 20, 2023 14:40
@openedx-webhooks
Copy link

@rodfersou Even though your pull request wasn’t merged, please take a moment to answer a two question survey so we can improve your experience in the future.

1 similar comment
@openedx-webhooks
Copy link

@rodfersou Even though your pull request wasn’t merged, please take a moment to answer a two question survey so we can improve your experience in the future.

@e0d e0d removed the needs test run Author's first PR to this repository, awaiting test authorization from Axim label Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open-source-contribution PR author is not from Axim or 2U
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants