|
| 1 | +2. File Handling Implementation for Submission System |
| 2 | +##################################################### |
| 3 | + |
| 4 | +Status |
| 5 | +****** |
| 6 | + |
| 7 | +**Provisional** *2025-02-14* |
| 8 | + |
| 9 | +Implemented by: waiting for it |
| 10 | + |
| 11 | +Context |
| 12 | +******* |
| 13 | + |
| 14 | +As part of the XQueue migration effort detailed in ADR 1, we need to handle file submissions that were previously |
| 15 | +managed by the XQueue system. The existing implementation lacks dedicated file handling capabilities within |
| 16 | +edx-submissions, requiring: |
| 17 | + |
| 18 | +1. File Management: |
| 19 | + - Secure storage of student-submitted files |
| 20 | + - Association with specific submissions |
| 21 | + - Compatibility with XQueue URL formats |
| 22 | + - Support for multiple file types and formats |
| 23 | + |
| 24 | +2. Processing Requirements: |
| 25 | + - Robust error handling for file operations |
| 26 | + - Validation of file objects |
| 27 | + - Dynamic path generation |
| 28 | + - Proper cleanup and resource management |
| 29 | + |
| 30 | +3. Integration Points: |
| 31 | + - Connection with SubmissionQueueRecord |
| 32 | + - Support for existing xqueue-watcher interface |
| 33 | + - File URL format compatibility |
| 34 | + - Efficient database querying |
| 35 | + |
| 36 | +The current XQueue system implements file handling through its Submission model, which manages file storage and |
| 37 | +retrieval in a tightly coupled way. The existing implementation: |
| 38 | + |
| 39 | +1. Current File Management in XQueue: |
| 40 | + - Uses a Submission model with direct file storage fields (s3_keys and s3_urls) |
| 41 | + - Handles file uploads through manual storage management functions (upload_file_dict, upload) |
| 42 | + - Stores file URLs as JSON strings in model fields |
| 43 | + - Requires synchronous HTTP communication for file retrieval |
| 44 | + |
| 45 | +2. Submission Model File Fields: |
| 46 | + ```python |
| 47 | + s3_keys = models.CharField(max_length=CHARFIELD_LEN_LARGE) # keys for internal use |
| 48 | + s3_urls = models.CharField(max_length=CHARFIELD_LEN_LARGE) # urls for external access |
| 49 | + ``` |
| 50 | + |
| 51 | +3. Current Workflow Issues: |
| 52 | + - File handling is tightly coupled with submission processing |
| 53 | + - Relies on manual URL construction and string manipulation |
| 54 | + - Lacks proper file validation and type checking |
| 55 | + - Limited by CharField size for storing file information |
| 56 | + - Requires complex get_submission logic for file retrieval |
| 57 | + |
| 58 | +4. Xqueue-watcher Integration: |
| 59 | + - External graders rely on specific URL formats |
| 60 | + - File access depends on HTTP-based retrieval |
| 61 | + - File information is embedded in submission payload |
| 62 | + |
| 63 | +Decision |
| 64 | +******** |
| 65 | + |
| 66 | +We will implement a new SubmissionFile model and supporting infrastructure to handle file management within |
| 67 | +edx-submissions: |
| 68 | + |
| 69 | +1. Core Model Structure: |
| 70 | + - SubmissionFile model with UUID-based identification |
| 71 | + - Foreign key relationship to SubmissionQueueRecord |
| 72 | + - Django FileField for actual file storage |
| 73 | + - Original filename preservation |
| 74 | + - Creation timestamp tracking |
| 75 | + - Composite index for efficient querying |
| 76 | + |
| 77 | +2. File Management Layer: |
| 78 | + - SubmissionFileManager class for encapsulated file operations |
| 79 | + - Robust file processing with multiple format support |
| 80 | + - Error handling for various file-related exceptions |
| 81 | + - XQueue-compatible URL generation |
| 82 | + |
| 83 | +3. Integration with Submission Creation: |
| 84 | + - Extended create_external_grader_detail function |
| 85 | + - File processing during submission creation |
| 86 | + - Automatic file manager instantiation |
| 87 | + - Error handling and logging |
| 88 | + |
| 89 | +Consequences |
| 90 | +************ |
| 91 | + |
| 92 | +Positive: |
| 93 | +--------- |
| 94 | + |
| 95 | +1. Architecture: |
| 96 | + - Clean separation of concerns for file handling |
| 97 | + - Improved maintainability through dedicated models |
| 98 | + - Better error handling and logging |
| 99 | + - Efficient database querying through proper indexing |
| 100 | + |
| 101 | +2. Integration: |
| 102 | + - Seamless xqueue-watcher compatibility |
| 103 | + - Support for existing file processing workflows |
| 104 | + - Minimal changes required to client code |
| 105 | + |
| 106 | +3. Operations: |
| 107 | + - More robust file processing |
| 108 | + - Better tracking of file submissions |
| 109 | + - Improved error visibility |
| 110 | + - Simplified file management |
| 111 | + |
| 112 | +Negative: |
| 113 | +--------- |
| 114 | + |
| 115 | +1. Technical Impact: |
| 116 | + - Additional database tables and indexes |
| 117 | + - Increased storage requirements |
| 118 | + - More complex submission creation flow |
| 119 | + |
| 120 | +2. Migration Considerations: |
| 121 | + - Temporary increased system complexity |
| 122 | + - Additional testing requirements |
| 123 | + |
| 124 | +3. Performance: |
| 125 | + - Additional database operations during submission |
| 126 | + - File processing overhead |
| 127 | + |
| 128 | +References |
| 129 | +********** |
| 130 | + |
| 131 | +Current System Documentation: |
| 132 | + * XQueue Repository: https://github.com/openedx/xqueue |
| 133 | + * XQueue Watcher Repository: https://github.com/openedx/xqueue-watcher |
| 134 | + |
| 135 | +Related Repositories: |
| 136 | + * edx-submissions: https://github.com/openedx/edx-submissions |
| 137 | + * edx-platform: https://github.com/openedx/edx-platform |
| 138 | + * XQueue Repository: https://github.com/openedx/xqueue |
| 139 | + * edx-submissions: https://github.com/openedx/edx-submissions |
| 140 | + |
| 141 | +Related Documentation: |
| 142 | + * ADR 1: Creation of SubmissionQueueRecord Model for XQueue Migration |
| 143 | + * File Processing Documentation: https://github.com/openedx/edx-submissions/tree/master/docs |
| 144 | + |
| 145 | +Future Event Integration: |
| 146 | + * Open edX Events Framework: https://github.com/openedx/openedx-events |
| 147 | + * Event Bus Documentation: https://openedx.atlassian.net/wiki/spaces/AC/pages/124125264/Event+Bus |
| 148 | + |
| 149 | +Related Architecture Documents: |
| 150 | + * Open edX Architecture Guidelines: https://openedx.atlassian.net/wiki/spaces/AC/pages/124125264/Architecture+Guidelines |
0 commit comments