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

enhance(apps/frontend-manage): limit group activity creation to courses where group creation is enabled #4259

Merged
merged 1 commit into from
Sep 11, 2024

Conversation

sjschlapbach
Copy link
Member

No description provided.

Copy link

aviator-app bot commented Sep 11, 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

coderabbitai bot commented Sep 11, 2024

Walkthrough

Walkthrough

The pull request introduces significant modifications across multiple components and hooks in the frontend application, primarily focusing on the handling of course selection and group creation functionalities. Key changes include the addition of the isGroupCreationEnabled property to the ElementSelectCourse type, the consolidation of course categorization into coursesWithGroups and coursesWithoutGroups, and the introduction of custom hooks for managing course data. Additionally, updates to GraphQL queries and localization files reflect these structural changes, enhancing the overall data model and user interface.

Changes

Files Change Summary
apps/frontend-manage/src/components/sessions/creation/ElementCreation.tsx Updated ElementSelectCourse type to include isGroupCreationEnabled; modified course selection logic.
apps/frontend-manage/src/components/sessions/creation/groupActivity/GroupActivityInformationStep.tsx Removed gamifiedCourses and nonGamifiedCourses; replaced with coursesWithGroups and coursesWithoutGroups.
apps/frontend-manage/src/components/sessions/creation/groupActivity/GroupActivitySettingsStep.tsx Replaced useGamifiedCourseGrouping with useGroupsCourseGrouping; updated parameters accordingly.
apps/frontend-manage/src/components/sessions/creation/groupActivity/GroupActivityWizard.tsx Renamed course properties to coursesWithGroups and coursesWithoutGroups; simplified logic for continue button.
apps/frontend-manage/src/components/sessions/creation/liveQuiz/LiveSessionWizard.tsx Consolidated course props into a single courses property; utilized useCoursesGamificationSplit hook.
apps/frontend-manage/src/components/sessions/creation/microLearning/MicroLearningWizard.tsx Consolidated course props into a single courses property; utilized useCoursesGamificationSplit hook.
apps/frontend-manage/src/components/sessions/creation/practiceQuiz/PracticeQuizWizard.tsx Consolidated course props into a single courses property; utilized useCoursesGamificationSplit hook.
apps/frontend-manage/src/lib/hooks/useCoursesGamificationSplit.tsx Introduced a custom hook to categorize courses into gamified and non-gamified groups.
apps/frontend-manage/src/lib/hooks/useCoursesGroupsSplit.tsx Introduced a custom hook to categorize courses based on group creation capability.
packages/graphql/src/graphql/ops/QGetUserCourses.graphql Added isGroupCreationEnabled field to the GetUserCourses query.
packages/graphql/src/ops.ts Updated GetUserCoursesQuery type to include isGroupCreationEnabled.
packages/graphql/src/public/client.json Updated hash value for GetUserCourses entry.
packages/graphql/src/public/server.json Modified GetUserCourses query to include isGroupCreationEnabled.
packages/i18n/messages/de.ts Added new localization entries and modified groupActivityNoCourse message for clarity.
packages/i18n/messages/en.ts Added new localization entries and modified groupActivityNoCourse message for clarity; removed missingGamifiedCourses.

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 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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
7.2% 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 (1)
packages/i18n/messages/de.ts (1)

Line range hint 1202-1203: Translate the message to German for consistency.

The groupActivityName message is in English, while the rest of the file is in German.

Apply this diff to fix the issue:

-      groupActivityName:
-        'This name should allow you to distinguish this group activity from others. It will not be shown to the participants, please use the display name (next field) for this.',
+      groupActivityName:
+        'Dieser Name sollte es Ihnen ermöglichen, diese Gruppenaktivität von anderen zu unterscheiden. Er wird den Teilnehmenden nicht angezeigt, bitte verwenden Sie dafür den Anzeigenamen (nächstes Feld).',
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 7ed9ffb and b593194.

Files selected for processing (16)
  • apps/frontend-manage/src/components/sessions/creation/ElementCreation.tsx (6 hunks)
  • apps/frontend-manage/src/components/sessions/creation/groupActivity/GroupActivityInformationStep.tsx (3 hunks)
  • apps/frontend-manage/src/components/sessions/creation/groupActivity/GroupActivitySettingsStep.tsx (2 hunks)
  • apps/frontend-manage/src/components/sessions/creation/groupActivity/GroupActivityWizard.tsx (7 hunks)
  • apps/frontend-manage/src/components/sessions/creation/liveQuiz/LiveSessionWizard.tsx (4 hunks)
  • apps/frontend-manage/src/components/sessions/creation/microLearning/MicroLearningWizard.tsx (4 hunks)
  • apps/frontend-manage/src/components/sessions/creation/practiceQuiz/PracticeQuizWizard.tsx (4 hunks)
  • apps/frontend-manage/src/lib/hooks/useCoursesGamificationSplit.tsx (1 hunks)
  • apps/frontend-manage/src/lib/hooks/useCoursesGroupsSplit.tsx (1 hunks)
  • apps/frontend-manage/src/lib/hooks/useGroupsCourseGrouping.tsx (1 hunks)
  • packages/graphql/src/graphql/ops/QGetUserCourses.graphql (1 hunks)
  • packages/graphql/src/ops.ts (2 hunks)
  • packages/graphql/src/public/client.json (1 hunks)
  • packages/graphql/src/public/server.json (1 hunks)
  • packages/i18n/messages/de.ts (3 hunks)
  • packages/i18n/messages/en.ts (3 hunks)
Additional comments not posted (35)
packages/graphql/src/graphql/ops/QGetUserCourses.graphql (1)

9-9: LGTM!

The addition of the isGroupCreationEnabled field to the GetUserCourses query is a valid change that enhances the functionality by providing additional context about the courses. The field name is clear and descriptive, and it is correctly placed within the userCourses object, maintaining the structure of the query.

apps/frontend-manage/src/lib/hooks/useGroupsCourseGrouping.tsx (1)

1-30: LGTM!

The code changes are approved. The custom hook useGroupsCourseGrouping is well-structured, follows best practices, and provides a reusable way to group courses based on whether they have groups or not. The use of TypeScript and the useTranslations hook for internationalization is also commendable.

apps/frontend-manage/src/lib/hooks/useCoursesGamificationSplit.tsx (1)

1-32: LGTM!

The custom hook useCoursesGamificationSplit is well-structured and follows a clear logic for splitting the provided courseSelection array into two arrays based on the isGamified property. The use of the reduce function is appropriate for categorizing the courses, and the hook handles the case when courseSelection is undefined to avoid potential errors. The addition of the data property with the cy property for testing purposes is a good practice. The hook is exported as a default export, making it easy to import and use in other components.

The code changes are approved.

apps/frontend-manage/src/lib/hooks/useCoursesGroupsSplit.tsx (1)

1-32: LGTM!

The useCoursesGroupsSplit hook is correctly splitting the courseSelection array into two arrays based on the isGroupCreationEnabled property of each course object. It is also adding a data property with a cy key to each course object in the split arrays, which could be used for testing purposes. The hook is returning an object with the two split arrays, which is a good way to return multiple values from a hook. It is also using optional chaining and nullish coalescing to handle the case where courseSelection is undefined, which is a good practice to avoid errors.

The code changes are approved.

apps/frontend-manage/src/components/sessions/creation/groupActivity/GroupActivityInformationStep.tsx (4)

21-22: LGTM!

The changes to the component parameters are consistent with the new approach to managing course data.


28-28: LGTM!

The introduction of the noCoursesWithGroups variable simplifies the logic and improves clarity.


Line range hint 48-54: LGTM!

The conditional rendering of the UserNotification component based on noCoursesWithGroups provides a user-friendly message when there are no courses with groups available.


138-138: LGTM!

Deriving the continueDisabled prop from noCoursesWithGroups enhances the component's responsiveness to the current state of course data.

apps/frontend-manage/src/components/sessions/creation/groupActivity/GroupActivitySettingsStep.tsx (3)

3-3: LGTM!

The import statement change is approved.


34-39: LGTM!

The function call change is approved.


26-27: LGTM!

The function parameter change is approved.

apps/frontend-manage/src/components/sessions/creation/ElementCreation.tsx (3)

34-35: LGTM!

The changes to the ElementSelectCourse type are approved. The addition of the isGroupCreationEnabled property and making the data property optional align with the goals mentioned in the AI-generated summary.


113-118: LGTM!

The changes to the course mapping are approved. Including the isGroupCreationEnabled property in the mapped object aligns with the goals mentioned in the AI-generated summary and ensures that the property is available for use in the component's logic.

Also applies to: 122-122


174-174: LGTM!

The change to the courses prop assignment is approved. Using the nullish coalescing operator (??) to provide a fallback to an empty array is a good practice to prevent passing null or undefined values to the courses prop.

apps/frontend-manage/src/components/sessions/creation/liveQuiz/LiveSessionWizard.tsx (3)

12-12: LGTM!

The import statement for the useCoursesGamificationSplit hook is correctly written.


49-49: LGTM!

The changes to the LiveSessionWizardProps interface are approved.

Consolidating the gamifiedCourses and nonGamifiedCourses props into a single courses prop simplifies the interface and centralizes the course data handling. The useCoursesGamificationSplit hook can be used to split the courses prop within the component.


77-80: LGTM!

The usage of the useCoursesGamificationSplit hook in the LiveSessionWizard component is approved.

Invoking the hook with the courses prop to derive the gamifiedCourses and nonGamifiedCourses variables improves the component's logic by centralizing the course data handling and enhancing the separation of concerns. The derived variables are correctly passed as props to the LiveQuizSettingsStep component.

apps/frontend-manage/src/components/sessions/creation/microLearning/MicroLearningWizard.tsx (2)

Line range hint 59-92: LGTM!

The changes to the MicroLearningWizardProps interface and the usage of the useCoursesGamificationSplit hook are a good refactoring that simplifies the component's props and improves the separation of concerns.


Line range hint 280-320: LGTM!

The usage of gamifiedCourses and nonGamifiedCourses in the MicroLearningInformationStep and MicroLearningSettingsStep components is consistent with the changes made to the MicroLearningWizard component.

Also applies to: 340-380

apps/frontend-manage/src/components/sessions/creation/practiceQuiz/PracticeQuizWizard.tsx (4)

10-10: LGTM!

The code change is approved.


60-60: LGTM!

The code change is approved. The interface change simplifies the props by consolidating the course properties.


71-71: LGTM!

The code change is approved. The function parameter change is consistent with the interface change.


94-96: LGTM!

The code change is approved. The hook is correctly used to derive gamifiedCourses and nonGamifiedCourses from the courses prop.

apps/frontend-manage/src/components/sessions/creation/groupActivity/GroupActivityWizard.tsx (3)

10-10: Approve the introduction of the useCoursesGroupsSplit hook.

The changes to the component's props and the introduction of the useCoursesGroupsSplit hook are approved. The hook handles the splitting of courses based on the presence of groups, which aligns with the new categorization of courses.

Also applies to: 90-92


326-328: Approve the updated logic for determining the disabled state of the continue button.

The logic for determining the disabled state of the continue button in the GroupActivityInformationStep has been updated to check the length of coursesWithGroups. This change is approved as it simplifies the control flow and aligns with the new categorization of courses.


365-366: Approve the changes to the props passed to the GroupActivitySettingsStep.

The GroupActivitySettingsStep now receives the coursesWithGroups and coursesWithoutGroups props, which is consistent with the changes made to the component's props and the new categorization of courses. These changes are approved.

packages/graphql/src/public/client.json (1)

139-139: Acknowledge hash value update for "GetUserCourses".

The hash value for the "GetUserCourses" key has been updated, indicating a change in the underlying implementation or data.

Ensure that this change is thoroughly tested to confirm that the "GetUserCourses" functionality behaves as expected and does not introduce any regressions.

Run the following script to verify the usage of "GetUserCourses":

Verification successful

Ensure thorough testing of "GetUserCourses" functionality.

The "GetUserCourses" query is used in several parts of the codebase, including:

  • packages/graphql/src/ops.ts: Defines the query type and document.
  • apps/frontend-manage/src/components/sessions/creation/ElementCreation.tsx: Utilizes the query in a component.
  • apps/frontend-manage/src/pages/courses/index.tsx: Utilizes the query in a page.

Given the hash update, please ensure that these components and pages are thoroughly tested to confirm that they work correctly with the updated query implementation.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of "GetUserCourses" in the codebase.

# Test: Search for the usage of "GetUserCourses". Expect: Only valid usages with the updated implementation.
rg --type typescript --type javascript --type graphql -A 5 $'GetUserCourses'

Length of output: 110


Script:

#!/bin/bash
# Description: Verify the usage of "GetUserCourses" in the codebase.

# Test: Search for the usage of "GetUserCourses". Expect: Only valid usages with the updated implementation.
rg --type ts --type js -A 5 $'GetUserCourses'

Length of output: 11206

packages/graphql/src/public/server.json (1)

139-140: LGTM!

The addition of the isGroupCreationEnabled field to the userCourses object in the GetUserCourses query looks good. It provides more information about each user course, specifically whether group creation is enabled for that course. This change aligns with the PR objective to limit group activity creation to courses where group creation is enabled.

The change is additive and does not break existing functionality.

packages/i18n/messages/en.ts (2)

208-209: LGTM!

The new localized strings withGroups and withoutGroups have been added correctly.


1163-1163: Looks good!

The modified groupActivityNoCourse string provides clearer instructions to users about the requirements for creating group activities.

packages/i18n/messages/de.ts (3)

208-209: LGTM!

The code changes are approved. The new entries withGroups and withoutGroups enhance the German localization for group-related functionalities.


1170-1171: LGTM!

The code changes are approved. The updated groupActivityNoCourse message provides clearer instructions to the user about the prerequisites for creating group activities.


Line range hint 1173-1174: LGTM!

The code changes are approved. The new groupActivityIntroductionName message provides helpful guidance to the user when creating a group activity.

packages/graphql/src/ops.ts (2)

3268-3268: LGTM!

The code changes are approved.


3519-3519: LGTM!

The code changes are approved.

Copy link

cypress bot commented Sep 11, 2024

klicker-uzh    Run #2946

Run Properties:  status check passed Passed #2946  •  git commit c9eced6341 ℹ️: Merge b593194045a38256825958ead1790b54d1e541ca into 7ed9ffb18d136f5d57c37e77968d...
Project klicker-uzh
Branch Review limit-group-activity-creation
Run status status check passed Passed #2946
Run duration 09m 06s
Commit git commit c9eced6341 ℹ️: Merge b593194045a38256825958ead1790b54d1e541ca into 7ed9ffb18d136f5d57c37e77968d...
Committer Julius Schlapbach
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 1
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 43
View all changes introduced in this branch ↗︎

@sjschlapbach sjschlapbach merged commit 2cb5d11 into v3 Sep 11, 2024
10 of 14 checks passed
@sjschlapbach sjschlapbach deleted the limit-group-activity-creation branch September 11, 2024 13:05
Copy link

cypress bot commented Sep 11, 2024

klicker-uzh    Run #2947

Run Properties:  status check failed Failed #2947  •  git commit 2cb5d110f6: enhance(apps/frontend-manage): limit group activity creation to courses where gr...
Project klicker-uzh
Branch Review v3
Run status status check failed Failed #2947
Run duration 09m 24s
Commit git commit 2cb5d110f6: enhance(apps/frontend-manage): limit group activity creation to courses where gr...
Committer Julius Schlapbach
View all properties for this run ↗︎

Test results
Tests that failed  Failures 1
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 42
View all changes introduced in this branch ↗︎

Tests for review

Failed  cypress/e2e/K-group-activity-workflow.cy.ts • 1 failed test

View Output

Test Artifacts
Create and solve a group activity > create a group activity and edit it Screenshots

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