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

FC-73 Xqu add submission file (Feature: Submission File System - Enhanced File Management for Graded Submissions) #286

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

leoaulasneo98
Copy link
Contributor

@leoaulasneo98 leoaulasneo98 commented Feb 24, 2025

FC-73 Feature: Submission File System - Enhanced File Management for Graded Submissions

Description

This pull request implements a comprehensive file management system for submissions through the introduction of the SubmissionFile model and its associated SubmissionFileManager. This enhancement supports proper storage, retrieval, and processing of files attached to submissions within the Open edX ecosystem.

Motivation

The existing submission system requires enhanced file handling capabilities to:

  • Provide seamless transition for existing services (xwatcher)
  • Establish reliable file storage with appropriate metadata
  • Integrate seamlessly with the new submission queue architecture

Previously, the XQueue server managed files for submissions that required document attachments. However, this was implemented inefficiently using plain text fields (s3_keys and s3_urls) without proper structure or validation. This approach led to inconsistent file handling, potential security issues, and maintenance challenges as the system scaled.

Key Improvements

Model Enhancements

  • Introduced SubmissionFile model with:
    • Secure file storage mechanisms
    • Proper association with submission queue records
    • Standardized URL generation for grader access
    • Original filename preservation

File Processing System

  • Developed SubmissionFileManager with capabilities for:
    • Processing multiple file formats (bytes, file objects)
    • Robust error handling for file processing issues
    • Consistent URL generation for xqueue compatibility
    • Efficient retrieval methods for external grader integration

Error Handling

  • Implemented comprehensive error handling for:
    • Invalid file objects
    • IO and OS exceptions during file reading
    • Unicode decoding errors
    • Non-standard file formats

Technical Details

File Processing

  • Support for multiple input types including:
    • Raw bytes
    • Django ContentFile objects
    • UploadedFile instances
    • Custom file-like objects with read() methods

Integration Points

  • Seamless connection with ExternalGraderDetail for complete submission workflow
  • Compatible interface for existing xqueue consumers

Testing Strategy

Extensive test coverage includes:

  • Various file input types
  • Complete processing workflow verification
  • Edge case handling for invalid files
  • Error handling for exceptional conditions
  • File retrieval in grader-compatible format

Open edX Compliance

This implementation adheres to Open edX standards through:

  • Modular design with clear separation of concerns
  • Comprehensive test coverage of edge cases
  • Well-documented interfaces
  • Consistent error handling patterns

Performance Considerations

  • Efficient file storage with minimal overhead
  • Optimized database access patterns
  • Careful handling of file objects to prevent memory issues

BREAKING CHANGES: None. Designed for full compatibility with existing systems.

@openedx-webhooks
Copy link

openedx-webhooks commented Feb 24, 2025

Thanks for the pull request, @leoaulasneo98!

This repository is currently maintained by @openedx/committers-edx-submissions.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.


Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Feb 24, 2025
Copy link

codecov bot commented Feb 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.92%. Comparing base (2413e6a) to head (ee29b2e).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #286      +/-   ##
==========================================
+ Coverage   94.43%   94.92%   +0.48%     
==========================================
  Files          18       19       +1     
  Lines        2263     2481     +218     
  Branches       95      101       +6     
==========================================
+ Hits         2137     2355     +218     
  Misses        115      115              
  Partials       11       11              
Flag Coverage Δ
unittests 94.92% <100.00%> (+0.48%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mphilbrick211 mphilbrick211 added the FC Relates to an Axim Funded Contribution project label Feb 24, 2025
@angonz
Copy link

angonz commented Mar 6, 2025

Review should only start after PR #283 is merged.

Copy link

Choose a reason for hiding this comment

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

Update author of cange
Add link to first ADR
Summarize and simplify.

"""
files_urls = {}
for filename, file_obj in files_dict.items():
if not (isinstance(file_obj, (bytes, ContentFile, SimpleUploadedFile)) or hasattr(file_obj, 'read')):
Copy link

Choose a reason for hiding this comment

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

Why check for hasattr(file_obj, 'read')?

logger.warning(f"Invalid file object type for {filename}")
continue

if hasattr(file_obj, 'read'):
Copy link

Choose a reason for hiding this comment

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

Please explain this workflow

- Create Submission file model
- Develop SubmissionFileManager for centralized DB query handling
- Add classes to handle file errors
- Add TestSubmissionFileManager with extensive test coverage
  - Test file processing with different input types (bytes, file objects)
  - Implement error handling tests for IO errors and invalid files
  - Verify complete file processing workflow
  - Validation tests for file addition in create_external_grader_detail

- Document architectural decisions with ADR
- Add test queue folder in .gitignore
@leoaulasneo98 leoaulasneo98 force-pushed the XQU-add-submission-file branch from b9ce70a to ee29b2e Compare April 4, 2025 17:43
Copy link

@angonz angonz left a comment

Choose a reason for hiding this comment

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

Ok on my side. Please open for Axim's review.

@leoaulasneo98 leoaulasneo98 marked this pull request as ready for review April 7, 2025 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FC Relates to an Axim Funded Contribution project open-source-contribution PR author is not from Axim or 2U
Projects
Status: Waiting on Author
Development

Successfully merging this pull request may close these issues.

4 participants