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

Fix setting submission to null when submission is disabled #1311

Merged
merged 3 commits into from
Feb 29, 2024

Conversation

EvilMonkey09
Copy link
Contributor

@EvilMonkey09 EvilMonkey09 commented Feb 23, 2024

When the "Abgabe" was activated, the submissionTime was set to 23:59. If you deactivated the "Abgabe" the submissionTime wasn't set to null, because of the _dateSelection.copyWith which ignores null.
This caused the problem, that in the Dashboard the dueDate was displayed in red and not "Bis morgen!".
Issue #1306
306628701-b161437d-40ad-4f50-bd58-00689892e194

Closes #1306

Summary by CodeRabbit

  • Refactor
    • Updated the logic for date selection handling in the homework dialog to improve user interaction.

Copy link
Contributor

coderabbitai bot commented Feb 23, 2024

Walkthrough

The update in the HomeworkDialogBloc primarily addresses the logic for date selection, ensuring that the _dateSelection is correctly updated based on specific conditions. This modification is aimed at correcting the display issues in the dashboard view, specifically for homework submissions that were showing incorrect subtitles due to improper handling of the due date and time settings.

Changes

File Change Summary
app/lib/homework/homework_dialog/.../homework_dialog_bloc.dart Updated _dateSelection logic to handle specific conditions.

Assessment against linked issues

Objective Addressed Explanation
#1306: Correct subtitle display for former submission homeworks in the dashboard view

Poem

In the realm where code does weave,
A rabbit hopped, in code believed.
With every line, a fix in sight,
Under the moon, so bright at night.
🌕 "Dashboards gleam," it softly said,
"With subtitles correctly spread."
🐇💻 A hop, a leap, in digital grace,
In code's vast field, it found its place.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between c0426de and c727377.
Files selected for processing (1)
  • app/lib/homework/homework_dialog/homework_dialog_bloc.dart (1 hunks)
Additional comments: 1
app/lib/homework/homework_dialog/homework_dialog_bloc.dart (1)
  • 753-757: The logic for resetting the submissionTime to null when the "Mit Abgabe" feature is deactivated is correctly implemented. This change directly addresses the issue described in the PR objectives by ensuring that submissionTime is only set when submissions are enabled and explicitly cleared otherwise. This is a crucial fix for the bug where deactivating the submission feature did not reset the submissionTime, leading to incorrect display information on the dashboard.

However, it's important to ensure that this change does not inadvertently affect other parts of the application that rely on the submissionTime or _dateSelection properties. Given the scope of the change, it seems well-contained, but a thorough testing strategy, including unit tests and integration tests, should be employed to verify the behavior in various scenarios, such as toggling the submission feature on and off, editing existing homework assignments, and creating new ones.

Comment on lines 750 to 761
submissionTime: event.newSubmissionsOptions.submissionTime ??
Time(hour: 23, minute: 59));
} else {
_dateSelection = _dateSelection.copyWith(submissionTime: null);
_dateSelection = _DateSelection(
dueDate: _dateSelection.dueDate,
dueDateSelection: _dateSelection.dueDateSelection,
submissionTime: null,
);
}

emit(_getNewState());
},
);
Copy link
Contributor

Choose a reason for hiding this comment

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

📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1-752]

Overall, the HomeworkDialogBloc class demonstrates a comprehensive approach to managing the state and events within the homework dialog of the Sharezone app. The use of the Bloc pattern for state management is appropriate for the complexity of the dialog's functionality, allowing for clear separation between UI events and state changes. The class handles a variety of events related to homework creation and editing, including title changes, due date adjustments, course selection, and more, which are all critical for providing a flexible and user-friendly interface for managing homework assignments.

A few areas for potential improvement and considerations include:

  • Error Handling: Ensure that all external calls, especially asynchronous ones, have appropriate error handling to prevent the application from entering an inconsistent state or failing silently. This is particularly important for operations that modify the state of homework assignments or interact with external services.
  • Testing: Given the complexity of the HomeworkDialogBloc and its central role in the homework management feature, a thorough suite of unit and integration tests is essential. Tests should cover the various states the Bloc can enter, the handling of different events, and the interaction with external services through the HomeworkDialogApi.
  • Documentation: While the code is generally well-structured and readable, adding more detailed comments and documentation, especially for public methods and complex logic, would enhance maintainability and ease future development efforts.

While the changes in this PR are focused and address the specific issue at hand, these additional considerations can further improve the robustness and maintainability of the homework dialog feature.

@Jonas-Sander
Copy link
Collaborator

Hi, thanks! :)
Could you try and make a regression test for that?
Look at the test at line 330 in app\test\homework\homework_dialog_bloc_test.dart to see how that should work.

I guess the test should check that if one enables and disables the submissions for a homework and then saves the homework, that the UserInput passed to the MockHomeworkDialogApi (homeworkDialogApi.userInputToBeCreated) will have a DateTime with zeros for hours, minutes, seconds etc.

@nilsreichardt nilsreichardt changed the title Fixed passing null for submissionTime Fix setting submission to null when submission is disabled Feb 28, 2024
Copy link
Member

@nilsreichardt nilsreichardt left a comment

Choose a reason for hiding this comment

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

LGTM

@nilsreichardt
Copy link
Member

@Jonas-Sander I added a small test. Could you also review?

@nilsreichardt nilsreichardt added the safe to test Used for fork PRs when the code is safe to test to trigger our CI. label Feb 28, 2024
@github-actions github-actions bot removed the safe to test Used for fork PRs when the code is safe to test to trigger our CI. label Feb 28, 2024
Copy link

github-actions bot commented Feb 28, 2024

Visit the preview URL for this PR (updated for commit 4e8deb7):

https://sharezone-test--pr1311-fix-duetime-nullfals-cg3wfqr1.web.app

(expires Sun, 03 Mar 2024 10:15:23 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 4cb3ae61e1e018abfd9841fd3239f5b49ccc034b

@nilsreichardt nilsreichardt added this pull request to the merge queue Feb 29, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 29, 2024
@nilsreichardt nilsreichardt added the safe to test Used for fork PRs when the code is safe to test to trigger our CI. label Feb 29, 2024
@nilsreichardt nilsreichardt merged commit 7292760 into SharezoneApp:main Feb 29, 2024
26 of 27 checks passed
@github-actions github-actions bot removed safe to test Used for fork PRs when the code is safe to test to trigger our CI. labels Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Former submission homeworks have the wrong subtitle in the dashboard view
3 participants