-
Notifications
You must be signed in to change notification settings - Fork 301
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
Lectures
: Add hide/show functionality to PDF Preview Component
#9667
base: develop
Are you sure you want to change the base?
Conversation
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.
Tested again on TS6. Reapprove
d0938ac
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.
Actionable comments posted: 2
♻️ Duplicate comments (2)
src/main/java/de/tum/cit/aet/artemis/lecture/service/AttachmentUnitService.java (2)
110-116
: 🛠️ Refactor suggestionConsider using a DTO for better parameter handling
The method signature has grown to 7 parameters, which violates the principle of method parameter count (ideally ≤ 3). Additionally, using
String
forhiddenPages
is not type-safe.Consider creating a dedicated DTO to encapsulate these parameters:
public record AttachmentUnitUpdateDTO( AttachmentUnit unit, Attachment attachment, MultipartFile file, MultipartFile studentVersionFile, boolean keepFilename, Set<Integer> hiddenPages // Using Set<Integer> for type safety ) {}
209-223
: 🛠️ Refactor suggestionImprove robustness of student version handling
The method needs several improvements:
- Add input validation
- Extract hardcoded values
- Add error handling for file operations
Additionally, consider adding file type validation:
private void validateStudentVersionFile(MultipartFile file) { if (file.isEmpty()) { throw new BadRequestAlertException("Student version file cannot be empty", "AttachmentUnit", "emptyFile"); } String extension = FilenameUtils.getExtension(file.getOriginalFilename()); if (!"pdf".equals(extension)) { throw new BadRequestAlertException("Only PDF files are supported", "AttachmentUnit", "invalidFileType"); } }
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/main/java/de/tum/cit/aet/artemis/lecture/service/AttachmentUnitService.java
(5 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/main/java/de/tum/cit/aet/artemis/lecture/service/AttachmentUnitService.java (1)
Pattern src/main/java/**/*.java
: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_imports
⏰ Context from checks skipped due to timeout of 90000ms (8)
- GitHub Check: client-tests-selected
- GitHub Check: client-tests
- GitHub Check: client-style
- GitHub Check: server-tests
- GitHub Check: server-style
- GitHub Check: Build and Push Docker Image
- GitHub Check: Build .war artifact
- GitHub Check: Analyse
🔇 Additional comments (1)
src/main/java/de/tum/cit/aet/artemis/lecture/service/AttachmentUnitService.java (1)
131-133
: 🛠️ Refactor suggestionAdd transaction boundary and error handling
The file operations should be wrapped in a transaction to ensure atomicity. Additionally, error handling should be added for both file operations.
+@Transactional +try { updateAttachment(existingAttachment, updateAttachment, savedAttachmentUnit, hiddenPages); handleFile(updateFile, existingAttachment, keepFilename, savedAttachmentUnit.getId()); handleStudentVersionFile(studentVersionFile, existingAttachment, savedAttachmentUnit.getId()); +} catch (Exception e) { + throw new BadRequestAlertException("Failed to process files: " + e.getMessage(), "AttachmentUnit", "fileProcessingError"); +}Likely invalid or redundant comment.
src/main/java/de/tum/cit/aet/artemis/lecture/service/AttachmentUnitService.java
Show resolved
Hide resolved
src/main/java/de/tum/cit/aet/artemis/lecture/service/AttachmentUnitService.java
Show resolved
Hide resolved
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.
Tested on TS2. The hiding/showing functionality works as expected on both sides (student and instructor).
Note: Please try to check for the PDF Preview view's functionalities again as Thumbnail Grid template is fixed from scratch :)
Checklist
General
Server
Client
authorities
to all new routes and checked the course groups for displaying navigation elements (links, buttons).Motivation and Context
This PR introduces a feature enabling the selective visibility of specific pages within a PDF document. Instructors often require the ability to retain certain pages in a document while temporarily withholding their visibility, for instance, until the conclusion of an exercise submission period. Currently, achieving this functionality necessitates dividing the content into multiple files, which can be cumbersome and inefficient. To address this limitation, a solution has been proposed to allow instructors to dynamically hide or reveal individual pages directly within the PDF Preview Component, enhancing the flexibility and usability of the system.
Description
A solution is implemented in PDF Preview Component, such as:
Steps for Testing
Prerequisites:
Testserver States
Note
These badges show the state of the test servers.
Green = Currently available, Red = Currently locked
Click on the badges to get to the test servers.
Review Progress
Performance Review
Code Review
Manual Tests
Test Coverage
Screenshots
1. Hide Button on Hover
2. Hidden Pages & Show Button on Hover
3. Original Version button
Summary by CodeRabbit
Release Notes
New Features
Improvements
Bug Fixes
Technical Enhancements