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

feat: add possibility to end group activity manually and introduce additional ended status #4303

Merged
merged 12 commits into from
Oct 10, 2024

Conversation

sjschlapbach
Copy link
Member

@sjschlapbach sjschlapbach commented Oct 10, 2024

Screenshot 2024-10-10 at 16 24 25
Screenshot 2024-10-10 at 16 26 52

Summary by CodeRabbit

  • New Features

    • Introduced new components for group activities, including GroupActivityExtensionButton, GroupActivityGradingLink, GroupActivityEndingModal, and GroupActivitySubscriber.
    • Added functionality to end group activities with new mutations and subscriptions.
    • Enhanced user experience with updated prop usage across various components.
    • New state management for activity status feedback in relevant pages.
  • Bug Fixes

    • Resolved issues with prop handling in multiple components to improve functionality and reduce errors.
  • Documentation

    • Updated GraphQL schema to reflect new fields and mutations for group activity management.
    • Added new localization keys for group activity features in German and English.

Copy link

aviator-app bot commented Oct 10, 2024

Current Aviator status

Aviator will automatically update this comment as the status of the PR changes.
Comment /aviator refresh to force Aviator to re-examine your PR (or learn about other /aviator commands).

This PR was merged manually (without Aviator). Merging manually can negatively impact the performance of the queue. Consider using Aviator next time.


See the real-time status of this PR on the Aviator webapp.
Use the Aviator Chrome Extension to see the status of your PR within GitHub.

Copy link

cypress bot commented Oct 10, 2024

klicker-uzh    Run #3203

Run Properties:  status check passed Passed #3203  •  git commit 0837219c0d ℹ️: Merge c91809c8888703576e767d506bafb5fb707ebeb4 into 20a7e379499b9fd828a49943d813...
Project klicker-uzh
Run status status check passed Passed #3203
Run duration 09m 30s
Commit git commit 0837219c0d ℹ️: Merge c91809c8888703576e767d506bafb5fb707ebeb4 into 20a7e379499b9fd828a49943d813...
Committer Julius Schlapbach
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 97

@sjschlapbach sjschlapbach marked this pull request as ready for review October 10, 2024 16:30
Copy link

coderabbitai bot commented Oct 10, 2024

📝 Walkthrough

Walkthrough

This pull request updates the version of the @uzh-bf/design-system dependency across multiple applications and packages from 3.0.0-alpha.31 to 3.0.0-alpha.32. It also includes various modifications to components and interfaces, particularly in the frontend applications, where prop usage is standardized to use onCloseExternal instead of setOpenExternal. New components are introduced, and several existing components have their signatures and exports updated or modified.

Changes

File Path Change Summary
apps/auth/package.json Updated @uzh-bf/design-system version to 3.0.0-alpha.32.
apps/backend-docker/package.json Updated @uzh-bf/design-system version to 3.0.0-alpha.32.
apps/docs/package.json Updated @uzh-bf/design-system version to 3.0.0-alpha.32.
apps/frontend-control/package.json Updated @uzh-bf/design-system version to 3.0.0-alpha.32.
apps/frontend-manage/package.json Updated @uzh-bf/design-system version to 3.0.0-alpha.32.
apps/frontend-pwa/package.json Updated @uzh-bf/design-system version to 3.0.0-alpha.32.
apps/func-incoming-responses/package.json Updated @uzh-bf/design-system version to 3.0.0-alpha.32.
apps/func-response-processor/package.json Updated @uzh-bf/design-system version to 3.0.0-alpha.32.
apps/office-addin/package.json Updated @uzh-bf/design-system version to 3.0.0-alpha.32.
packages/markdown/package.json Updated @uzh-bf/design-system version to 3.0.0-alpha.32.
packages/shared-components/package.json Updated peer dependency @uzh-bf/design-system version to 3.0.0-alpha.32.
packages/transactional/package.json Updated @uzh-bf/design-system version to 3.0.0-alpha.32.
apps/frontend-control/src/components/toasts/ErrorStartToast.tsx Updated prop usage to onCloseExternal={() => setOpen(false)}.
apps/frontend-control/src/pages/login.tsx Updated prop usage to onCloseExternal={() => setShowError(false)}.
apps/frontend-manage/src/components/common/ConfirmationItem.tsx Added interface and updated function signature and export.
apps/frontend-manage/src/components/courses/CourseOverviewHeader.tsx Updated prop usage to onCloseExternal={() => setCopyToast(false)}.
apps/frontend-manage/src/components/courses/actions/MicroLearningAccessLink.tsx Updated prop usage to onCloseExternal={() => setOpen(false)}.
apps/frontend-manage/src/components/courses/actions/PracticeQuizAccessLink.tsx Updated prop usage to onCloseExternal={() => setOpen(false)}.
apps/frontend-manage/src/components/courses/groupActivity/GroupActivityExtensionButton.tsx New component added.
apps/frontend-manage/src/components/courses/modals/ActivityConfirmationModal.tsx Added interface and function, with default export.
apps/frontend-manage/src/components/courses/modals/ActivityDeletionModal.tsx Component removed.
apps/frontend-manage/src/components/courses/modals/GroupActivityDeletionModal.tsx Updated interface and function signature, with export update.
packages/graphql/src/graphql/ops/MEndGroupActivity.graphql Added mutation for ending group activity.
packages/graphql/src/public/schema.graphql Updated type signature and added new fields and subscriptions related to group activity.
packages/prisma/src/prisma/schema/quiz.prisma Added enum value ENDED in GroupActivityStatus.

Possibly related PRs

Suggested reviewers

  • rschlaefli: Suggested reviewer for this pull request.

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>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • 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 testing code 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • 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/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
2 Security Hotspots
8.1% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

Copy link

@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.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (4)
apps/frontend-pwa/src/pages/group/[groupId]/activity/[activityId].tsx (3)

31-32: LGTM: New state variables and useQuery modifications enhance real-time functionality.

The addition of activityEnded and submissionDisabled state variables, along with the subscribeToMore in the useQuery hook, effectively supports the new feature of manually ending group activities and managing submission states.

Consider adding comments to explain the purpose of these new state variables for better code readability.

Also applies to: 34-42


166-183: LGTM: Enhanced visual representation of group participants.

The updated rendering of group participants with avatars and usernames provides a more engaging and informative display. The implementation includes a fallback to a default avatar and uses a responsive, visually appealing layout.

Consider adding an alt text to the Image component that describes the participant, e.g., alt={Avatar for ${participant.username}}, to improve accessibility.


256-256: LGTM: GroupActivityStack now responds to activity end state.

The addition of the activityEnded prop to the GroupActivityStack component and the update to its key prop effectively allow the component to respond to the activity's ended state. This aligns well with the PR objectives of handling ended activities.

Consider renaming the activityEnded prop to submissionDisabled for consistency with the state variable name, unless there's a specific reason for the different naming.

Also applies to: 258-259

cypress/cypress/e2e/J-group-activity-workflow.cy.ts (1)

634-657: LGTM: Comprehensive test for ending a group activity

This test case thoroughly covers the process of ending a group activity from the lecturer's perspective. It includes checks for confirmation modals and verifies the activity state change, which are crucial for ensuring the correct functionality of this feature.

Consider adding a check to verify that students can no longer submit responses after the activity is ended, to fully validate the impact of this action.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 2da88bc and c91809c.

📒 Files selected for processing (2)
  • apps/frontend-pwa/src/pages/group/[groupId]/activity/[activityId].tsx (7 hunks)
  • cypress/cypress/e2e/J-group-activity-workflow.cy.ts (8 hunks)
🧰 Additional context used
🔇 Additional comments (18)
apps/frontend-pwa/src/pages/group/[groupId]/activity/[activityId].tsx (9)

8-8: LGTM: New imports align with component enhancements.

The new imports (GroupActivityStatus, Toast, useEffect, and GroupActivitySubscriber) are consistent with the changes made to enhance the component's functionality, particularly in handling the new "ended" status and providing real-time updates.

Also applies to: 14-14, 21-21, 23-23


44-51: LGTM: useEffect hook properly manages submission state based on activity status.

The new useEffect hook correctly updates the submissionDisabled state based on the activity's status or the activityEnded flag. This ensures that submissions are disabled when the activity ends, which aligns with the PR objectives.


88-89: LGTM: Improved data access with groupActivity variable.

The introduction of the groupActivity variable, which consolidates data from data.groupActivityDetails, enhances code readability and reduces repetition throughout the component. This change is consistently applied, making the code more maintainable.

Also applies to: 99-100, 128-128, 137-137, 166-183


105-109: LGTM: GroupActivitySubscriber enhances real-time functionality.

The addition of the GroupActivitySubscriber component with props for activityId, subscribeToMore, and setEndedGroupActivity aligns well with the PR objectives of enhancing real-time functionality for group activities.

Could you provide more details about the GroupActivitySubscriber component's implementation and its specific role in managing real-time updates?


113-120: LGTM: UserNotification enhances user feedback for ended activities.

The addition of the UserNotification component effectively improves user feedback by clearly indicating when an activity has ended or been graded. The component uses appropriate styling for a warning message and checks for both Ended and Graded status, providing comprehensive feedback to the user.


186-201: LGTM: Improved activity start button logic and styling.

The updates to the activity start button enhance both its functionality and appearance:

  1. The button is now correctly displayed only when the activity status is Published.
  2. Disabling the button when there's only one participant is a good safeguard to ensure group activities have multiple participants.
  3. The new styling improves the button's visual appeal, and the data-cy attribute enhances testability.

These changes contribute to a better user experience and align with the PR objectives.


270-281: LGTM: Toast component enhances user notification for ended activities.

The addition of the Toast component provides an effective, non-intrusive way to notify users when an activity ends. Key points:

  1. It uses the activityEnded state to control its visibility.
  2. The message includes the activity name, providing helpful context to the user.
  3. The toast is dismissible and has a reasonable duration (10 seconds).
  4. The implementation aligns well with the PR objectives of improving user feedback for ended activities.

Line range hint 285-301: LGTM: Static generation functions appropriately unchanged.

The getStaticProps and getStaticPaths functions remain unchanged, which is appropriate as they don't directly relate to the new features introduced in this PR. This maintains the existing static generation behavior of the page.


Line range hint 1-301: Overall LGTM: Changes effectively implement manual activity ending and enhance user experience.

This PR successfully implements the ability to end group activities manually and introduces the additional ended status, aligning well with the stated objectives. Key improvements include:

  1. Enhanced real-time functionality through the GroupActivitySubscriber component and useQuery modifications.
  2. Improved user feedback with the addition of UserNotification and Toast components for ended activities.
  3. Better state management for ended activities and disabled submissions.
  4. Visual enhancements to the group participants display and activity start button.

The changes are well-structured, consistent, and contribute to a better user experience. Minor suggestions for improvements have been made in individual comments.

Great job on this implementation!

cypress/cypress/e2e/J-group-activity-workflow.cy.ts (9)

510-521: LGTM: Well-structured function to check disabled inputs

The checkInputsDisabled function is a good addition. It systematically checks various input types (SC, MC, KPRIM, numerical, and free-text) to ensure they are disabled. This will be useful for verifying the state of inputs after a group activity has ended.


622-632: LGTM: Good test coverage for multi-group scenarios

This test case is a valuable addition as it verifies that students from different groups can start the group activity. It helps ensure that the group activity functionality works correctly across multiple groups.


659-674: LGTM: Essential test for submission visibility after activity end

This test case is crucial for ensuring that students can still view their submissions after a group activity has ended. It effectively uses the checkInputsDisabled and checkPersistentAnswers functions to validate the state of the submission, and also verifies the correct status message and the absence of the submit button.


676-692: LGTM: Crucial test for unsubmitted activities after end

This test case is essential for verifying the behavior of started but unsubmitted group activities after they've ended. It correctly checks that inputs are disabled, the appropriate status message is displayed, and submission is no longer possible. This ensures a consistent and fair experience for all students, regardless of their submission status when the activity ends.


694-705: LGTM: Critical test for preventing late starts

This test case is vital for ensuring that students cannot start a group activity after it has ended. It correctly verifies the absence of the start button and the presence of the appropriate status message. This test helps maintain the integrity of the activity timeline and ensures fair participation conditions for all students.


711-712: LGTM: Improved variable clarity

The separation of groupActivityName and activityDisplayName improves code clarity and potentially aligns with changes in the application's naming conventions or data structure. This modification enhances the maintainability of the test case.


878-897: LGTM: Enhanced safety measures for group activity deletion

The changes to the deletion confirmation process significantly improve the safety of deleting group activities. The addition of disabled state checks for the confirmation button and the requirement for explicit confirmations for deleting started instances and submissions are excellent safeguards against accidental deletions. These enhancements align with best practices for handling destructive actions in user interfaces.


909-911: LGTM: Consistent cleanup process

The changes to the cleanup process align well with the enhanced deletion confirmation steps introduced earlier in the file. This ensures consistency in the group activity deletion process throughout the test suite, reinforcing the safety measures against accidental deletions during cleanup.


Line range hint 1-915: Overall: Excellent enhancements to group activity testing

The changes in this file significantly improve the test coverage and robustness of the group activity workflow. The new test cases address important scenarios such as multi-group interactions, activity ending, and various edge cases. The enhanced deletion confirmation process adds a crucial layer of safety against accidental data loss. These improvements will contribute to a more reliable and well-tested group activity feature.

@sjschlapbach sjschlapbach merged commit fa6c196 into v3 Oct 10, 2024
14 of 17 checks passed
@sjschlapbach sjschlapbach deleted the group-activity-ending-trigger branch October 10, 2024 18:26
Copy link

cypress bot commented Oct 10, 2024

klicker-uzh    Run #3204

Run Properties:  status check passed Passed #3204  •  git commit fa6c196f82: feat: add possibility to end group activity manually and introduce additional en...
Project klicker-uzh
Run status status check passed Passed #3204
Run duration 09m 31s
Commit git commit fa6c196f82: feat: add possibility to end group activity manually and introduce additional en...
Committer Julius Schlapbach
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 97

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant