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 extend microlearnings and group activities before end date #4283

Merged
merged 7 commits into from
Oct 2, 2024

Conversation

sjschlapbach
Copy link
Member

@sjschlapbach sjschlapbach commented Oct 2, 2024

With this PR, it is now possible to extend running microlearnings and group activities through a corresponding modal on the course overview.

Screenshot 2024-10-02 at 14 51 16 1

Copy link

aviator-app bot commented Oct 2, 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 Oct 2, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

This pull request introduces enhancements to the GroupActivityElement and MicroLearningElement components by adding functionality to extend the duration of group activities and microlearning sessions. A new ExtensionModal component is implemented for this purpose, along with corresponding GraphQL mutations for backend support. Additionally, end-to-end tests are added to verify the new functionality, and localization files are updated to include new keys for the extended features.

Changes

File Path Change Summary
apps/frontend-manage/src/components/courses/GroupActivityElement.tsx Added faCalendar icon, new state variable extensionModal, and ExtensionModal component.
apps/frontend-manage/src/components/courses/MicroLearningElement.tsx Introduced ExtensionModal, updated dropdown for extending microlearning, and modified status logic.
apps/frontend-manage/src/components/courses/modals/ExtensionModal.tsx New component for extending end dates of activities, using Formik for form handling.
cypress/cypress/e2e/G-microlearning-workflow.cy.ts Added test case for extending a microlearning's end date with validation checks.
cypress/cypress/e2e/K-group-activity-workflow.cy.ts Added test case for extending a group activity's end date with validation checks.
packages/graphql/src/graphql/ops/MExtendGroupActivity.graphql New mutation ExtendGroupActivity for extending group activity end dates.
packages/graphql/src/graphql/ops/MExtendMicroLearning.graphql New mutation ExtendMicroLearning for extending microlearning end dates.
packages/graphql/src/ops.schema.json Updated schema to include new types and mutations for extending activities.
packages/graphql/src/ops.ts Added new mutation fields for extending group activities and microlearning.
packages/graphql/src/public/client.json Added methods for ExtendGroupActivity and ExtendMicroLearning.
packages/graphql/src/public/server.json Added server-side support for new mutations.
packages/i18n/messages/de.ts Updated German localization with new keys for extending activities.
packages/i18n/messages/en.ts Updated English localization with new keys for extending activities.

Possibly related PRs

Suggested reviewers

  • rschlaefli

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 84d685d and 90ac712.

📒 Files selected for processing (2)
  • packages/graphql/src/services/groups.ts (1 hunks)
  • packages/graphql/src/services/microLearning.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/graphql/src/services/groups.ts
  • packages/graphql/src/services/microLearning.ts

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

cypress bot commented Oct 2, 2024

klicker-uzh    Run #3089

Run Properties:  status check passed Passed #3089  •  git commit 18d94a17a0 ℹ️: Merge 90ac7123abc200740902bc8b46c5785368c207e1 into e356d437c8fdc47cf0e96c1273e4...
Project klicker-uzh
Branch Review extend-activities
Run status status check passed Passed #3089
Run duration 09m 59s
Commit git commit 18d94a17a0 ℹ️: Merge 90ac7123abc200740902bc8b46c5785368c207e1 into e356d437c8fdc47cf0e96c1273e4...
Committer Julius Schlapbach
View all properties for this run ↗︎

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

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: 18

🧹 Outside diff range and nitpick comments (9)
packages/graphql/src/graphql/ops/MExtendGroupActivity.graphql (1)

1-1: Consider adding a comment to explain the mutation's purpose.

To improve code readability and maintainability, it would be helpful to add a brief comment explaining the purpose of this mutation and any important details about its usage.

Example:

# Extends the end date of a group activity
# id: The unique identifier of the group activity
# endDate: The new end date for the group activity
mutation ExtendGroupActivity($id: String!, $endDate: Date!) {
  # ... (rest of the mutation)
}
packages/graphql/src/graphql/ops/MExtendMicroLearning.graphql (1)

1-6: LGTM! Consider adding a comment for clarity.

The ExtendMicroLearning mutation is well-structured and aligns with the PR objective. It correctly takes an id and endDate as parameters, and returns the updated id and scheduledEndAt.

Consider adding a brief comment at the top of the file to explain the purpose of this mutation, for example:

# Mutation to extend the end date of a microlearning
mutation ExtendMicroLearning($id: String!, $endDate: Date!) {
  # ... rest of the mutation
}

This would enhance code readability and provide context for other developers.

packages/graphql/src/public/schema.graphql (1)

776-777: LGTM! Consider adding descriptions for new mutations.

The new mutations extendGroupActivity and extendMicroLearning are well-implemented and consistent with the PR objectives. They follow the existing naming conventions and use appropriate argument and return types.

For improved documentation and consistency with other mutations in the schema, consider adding descriptions to these new mutations. For example:

+  """
+  Extends the end date of a group activity.
+  """
   extendGroupActivity(endDate: Date!, id: String!): GroupActivity
+  """
+  Extends the end date of a micro learning.
+  """
   extendMicroLearning(endDate: Date!, id: String!): MicroLearning
packages/graphql/src/services/groups.ts (1)

1690-1708: LGTM! Consider adding a check for the minimum extension period.

The extendGroupActivity function looks good overall. It correctly updates the scheduledEndAt field of the group activity, ensuring that only the owner can extend it and that the current end date is in the future. However, there are a couple of suggestions for improvement:

  1. Consider adding a check to ensure the new endDate is later than the current scheduledEndAt. This would prevent accidental shortening of the activity period.

  2. You might want to add a minimum extension period (e.g., 1 hour) to prevent very small extensions that might not be meaningful.

Here's a suggested implementation with these improvements:

export async function extendGroupActivity(
  {
    id,
    endDate,
  }: {
    id: string
    endDate: Date
  },
  ctx: ContextWithUser
) {
+ const currentActivity = await ctx.prisma.groupActivity.findUnique({
+   where: { id, ownerId: ctx.user.sub, scheduledEndAt: { gt: new Date() } },
+   select: { scheduledEndAt: true },
+ });
+
+ if (!currentActivity) {
+   throw new Error('Group activity not found or not eligible for extension');
+ }
+
+ const minExtensionPeriod = 60 * 60 * 1000; // 1 hour in milliseconds
+ if (endDate.getTime() - currentActivity.scheduledEndAt.getTime() < minExtensionPeriod) {
+   throw new Error('Extension period must be at least 1 hour');
+ }

  const updatedGroupActivity = await ctx.prisma.groupActivity.update({
    where: { id, ownerId: ctx.user.sub, scheduledEndAt: { gt: new Date() } },
    data: {
      scheduledEndAt: endDate,
    },
  });

  return updatedGroupActivity;
}

This implementation adds checks for the current activity's existence and ensures a minimum extension period.

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

42-42: LGTM! Consider adding a success flag to the response.

The ExtendGroupActivity mutation is well-structured and includes the necessary fields. It correctly uses non-nullable types for required parameters.

Consider adding a success boolean field to the response to explicitly indicate whether the operation was successful. This can be helpful for error handling on the client side.

mutation ExtendGroupActivity($id: String!, $endDate: Date!) {
  extendGroupActivity(id: $id, endDate: $endDate) {
    id
    scheduledEndAt
+   success
    __typename
  }
}

43-43: LGTM! Consider adding a success flag to the response.

The ExtendMicroLearning mutation is well-structured and consistent with the ExtendGroupActivity mutation. This consistency is good for maintainability and ease of use.

As with the ExtendGroupActivity mutation, consider adding a success boolean field to the response:

mutation ExtendMicroLearning($id: String!, $endDate: Date!) {
  extendMicroLearning(id: $id, endDate: $endDate) {
    id
    scheduledEndAt
+   success
    __typename
  }
}
packages/i18n/messages/en.ts (2)

1549-1554: New translations for extending microlearning look good.

The added translations for extending microlearning are clear, concise, and consistent with the existing style. They provide necessary information for the user about the functionality.

A minor suggestion to improve clarity:

Consider modifying the extendMicroLearningDescription to be more explicit about the current end date:

extendMicroLearningDescription:
-  'Use this dialogue to modify the end date of the microlearning. Please note that only future dates can be set as end dates.',
+  'Use this dialogue to modify the end date of the microlearning. Please note that only dates after the current end date can be set.',

This change makes it clearer that the new end date must be after the existing end date, not just any future date.


1592-1594: New translations for extending group activity are consistent.

The added translations for extending group activity mirror those for microlearning, maintaining consistency across similar features.

However, to maintain absolute consistency with the microlearning translations (if that's desired), consider this minor adjustment:

extendGroupActivityDescription:
-  'Use this dialogue to modify the end date of the group activity. Please note that only future dates can be set as end dates.',
+  'Use this dialogue to modify the end date of the group activity. Please note that only dates after the current end date can be set.',

This change would make the description identical to the suggested microlearning description, ensuring perfect consistency between similar features.

packages/graphql/src/ops.schema.json (1)

10822-10911: Overall assessment: Well-implemented schema changes with a minor suggestion

The additions to the schema are consistent, well-implemented, and align perfectly with the PR objective. Both extendGroupActivity and extendMicroLearning mutations provide the necessary functionality to extend group activities and microlearnings before their end dates. The use of non-null types for arguments ensures data integrity, and the return types are appropriate.

As a minor suggestion for improvement:

Consider adding descriptions to these new mutations and their arguments. This would enhance the self-documentation of the schema and improve the developer experience when working with these new mutations.

For example:

"Extends the end date of a group activity"
extendGroupActivity(
  "The new end date for the group activity"
  endDate: Date!,
  "The ID of the group activity to extend"
  id: String!
): GroupActivity

"Extends the end date of a microlearning"
extendMicroLearning(
  "The new end date for the microlearning"
  endDate: Date!,
  "The ID of the microlearning to extend"
  id: String!
): MicroLearning

This addition would make the schema more self-explanatory and easier to use for other developers.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between e71423a and dc6b40c.

📒 Files selected for processing (17)
  • apps/frontend-manage/src/components/courses/GroupActivityElement.tsx (5 hunks)
  • apps/frontend-manage/src/components/courses/MicroLearningElement.tsx (8 hunks)
  • apps/frontend-manage/src/components/courses/modals/ExtensionModal.tsx (1 hunks)
  • cypress/cypress/e2e/G-microlearning-workflow.cy.ts (1 hunks)
  • cypress/cypress/e2e/K-group-activity-workflow.cy.ts (1 hunks)
  • packages/graphql/src/graphql/ops/MExtendGroupActivity.graphql (1 hunks)
  • packages/graphql/src/graphql/ops/MExtendMicroLearning.graphql (1 hunks)
  • packages/graphql/src/ops.schema.json (1 hunks)
  • packages/graphql/src/ops.ts (4 hunks)
  • packages/graphql/src/public/client.json (1 hunks)
  • packages/graphql/src/public/schema.graphql (1 hunks)
  • packages/graphql/src/public/server.json (1 hunks)
  • packages/graphql/src/schema/mutation.ts (2 hunks)
  • packages/graphql/src/services/groups.ts (1 hunks)
  • packages/graphql/src/services/microLearning.ts (1 hunks)
  • packages/i18n/messages/de.ts (2 hunks)
  • packages/i18n/messages/en.ts (2 hunks)
🔇 Additional comments (26)
packages/graphql/src/graphql/ops/MExtendGroupActivity.graphql (1)

1-6: LGTM! Well-structured GraphQL mutation.

The ExtendGroupActivity mutation is well-defined with appropriate parameters and return fields. It follows GraphQL best practices and provides a clear interface for extending a group activity's end date.

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

42-43: New operations added for extending group activities and micro-learnings.

Two new entries have been added to the client.json file:

  1. "ExtendGroupActivity" with hash "c3788f2608170940bedbec90fe77a623fb05249e20cd11ad2e4a529b5068149a"
  2. "ExtendMicroLearning" with hash "bf40877047d36fc8549bf3050e75e858066f7a8515c97ad1207af5c3c3e227a6"

These additions align with the PR objective of adding the possibility to extend microlearnings and group activities before the end date.

To ensure these are the only changes and that they are correctly placed within the file, let's run the following script:

✅ Verification successful

Verification Successful: New Entries Correctly Added

  • The new entries "ExtendGroupActivity" and "ExtendMicroLearning" are present and correctly placed.
  • No unexpected changes found related to "Extend".
  • Total number of entries is consistent with the addition of these two entries.
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the new entries and their placement in the file

# Test 1: Check if the new entries exist and are correctly placed
rg -A 1 -B 1 "ExtendGroupActivity" packages/graphql/src/public/client.json
rg -A 1 -B 1 "ExtendMicroLearning" packages/graphql/src/public/client.json

# Test 2: Ensure no other unexpected changes were made
rg "Extend" packages/graphql/src/public/client.json

# Test 3: Verify the total number of entries in the file
jq 'length' packages/graphql/src/public/client.json

Length of output: 1008

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

662-715: Overall assessment of the new test case

The new test case for extending a group activity is a valuable addition to the test suite. It covers the main scenarios for the extension feature, including successful extensions and handling of invalid dates.

To further improve this test:

  1. Consider implementing the suggested refactorings to improve code organization and reduce duplication.
  2. Add more assertions to verify UI feedback and state changes.
  3. If possible, extend the test to verify the impact of the extension on student access to the activity.

These enhancements will make the test more robust, maintainable, and comprehensive, ensuring the group activity extension feature works as expected across various scenarios.

cypress/cypress/e2e/G-microlearning-workflow.cy.ts (3)

1355-1357: LGTM: Test case setup is correct.

The test case is properly defined using the it function, and the microLearningName constant is correctly initialized.


1358-1361: LGTM: Navigation to course overview is well-implemented.

The test correctly navigates to the courses page and selects the specific course using appropriate data-cy attributes.


1362-1369: LGTM: Extension modal interaction is comprehensive.

The test thoroughly checks the extension modal functionality, including:

  1. Navigating to the microlearnings tab
  2. Opening the actions menu
  3. Clicking the extend option
  4. Testing the cancel functionality
  5. Reopening the modal

This ensures a robust test of the user interaction flow.

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

42-43: Overall, good additions. Consider updating related queries and documentation.

The new mutations ExtendGroupActivity and ExtendMicroLearning are well-structured and consistent with each other. They provide valuable functionality for extending end dates of activities.

To fully integrate these new mutations:

  1. Ensure that the backend resolvers for these mutations are implemented correctly and handle potential edge cases (e.g., extending to a date earlier than the current end date).
  2. Update any related queries or subscriptions that fetch group activities or micro learnings to reflect the possibility of extended end dates.
  3. Update the API documentation to include these new mutations and their usage.
  4. Consider adding integration tests to verify the behavior of these mutations in various scenarios.

To check for any existing queries or subscriptions that might need updating, we can search for references to scheduledEndAt in group activities and micro learnings:

✅ Verification successful

Verified: Related queries and subscriptions already reference scheduledEndAt.

The existing queries and subscriptions appropriately utilize the scheduledEndAt field for both group activities and micro learnings. No additional updates to related queries are necessary at this time.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
echo "Searching for queries/subscriptions referencing scheduledEndAt in group activities:"
rg --type=json 'query.*groupActivit.*scheduledEndAt'

echo "\nSearching for queries/subscriptions referencing scheduledEndAt in micro learnings:"
rg --type=json 'query.*microLearning.*scheduledEndAt'

Length of output: 10024

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

Line range hint 1-1594: Overall, the new translations are well-integrated and consistent.

The additions for extending microlearnings and group activities are clear and fit well within the existing translation structure. They provide necessary information for users about the new functionality.

Two minor suggestions were made to improve clarity and maintain consistency between similar features. These changes are not critical but could enhance the user experience slightly.

packages/graphql/src/ops.schema.json (2)

10823-10866: LGTM: extendGroupActivity mutation is well-defined

The extendGroupActivity mutation is correctly implemented with appropriate non-null arguments (endDate and id) and return type (GroupActivity). This aligns well with the PR objective of adding the possibility to extend group activities before the end date.


10868-10911: LGTM: extendMicroLearning mutation is well-defined

The extendMicroLearning mutation is correctly implemented with appropriate non-null arguments (endDate and id) and return type (MicroLearning). This aligns well with the PR objective of adding the possibility to extend microlearnings before the end date. The structure is consistent with the extendGroupActivity mutation, which is a good practice.

apps/frontend-manage/src/components/courses/modals/ExtensionModal.tsx (2)

1-148: Overall, the component is well-implemented and follows best practices

The ExtensionModal component is well-structured, with clear separation of concerns. The use of Formik for form handling, Yup for validation, and Apollo Client for GraphQL mutations aligns with industry best practices. Styling and internationalization are also appropriately managed.


62-63: Verify the date format for the initial end date

When setting the initial value for endDate, ensure that the date format matches the expected input format of FormikDateField. This prevents any potential issues with date parsing or incorrect default values.

Run the following script to check the expected date format:

apps/frontend-manage/src/components/courses/GroupActivityElement.tsx (2)

2-6: Importing faCalendar icon for new functionality

The addition of faCalendar to the imports is appropriate for the new extension feature.


309-318: Integration of ExtensionModal component

The ExtensionModal component is correctly integrated with the appropriate props, ensuring users can extend group activities seamlessly.

apps/frontend-manage/src/components/courses/MicroLearningElement.tsx (6)

41-41: ExtensionModal import added correctly

The ExtensionModal component is imported appropriately, allowing for its use within this file.


64-64: State management for extensionModal is properly initialized

The state variable extensionModal is correctly initialized using useState(false), which will control the visibility of the extension modal.


74-74: Logical determination of isActive status is correct

The isActive variable accurately assesses whether the current date falls between the scheduled start and end dates of the microlearning, which is essential for conditionally rendering components based on the active status.


278-298: Extend option appropriately added for active microlearnings

The addition of the "Extend MicroLearning" option in the dropdown menu when isActive is true is correctly implemented. This allows users to extend microlearnings that are currently active.


367-376: Integration of ExtensionModal component with correct props

The ExtensionModal is integrated into the component with all necessary props, including type, id, currentEndDate, and control handlers for open and setOpen. This ensures that the modal functions correctly when triggered.


2-6: Verify icon imports for consistency

The icons faCalendar, faClock, and faTrashCan are being imported from @fortawesome/free-regular-svg-icons. Ensure that these icons are available in the free-regular-svg-icons package and confirm that this is consistent with how other icons are imported in the project. If these icons are typically imported from @fortawesome/free-solid-svg-icons, consider updating the import statement for consistency.

Run the following script to check where these icons are imported from in the codebase:

✅ Verification successful

Icon imports are consistent with the majority of the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the import sources of faCalendar, faClock, and faTrashCan icons.

# Search for import statements of the specified icons in the codebase
rg "import\s+\{[^}]*\b(faCalendar|faClock|faTrashCan)\b[^}]*\}\s+from\s+'@fortawesome/free-(solid|regular)-svg-icons'" --type js --type ts

Length of output: 2017

packages/graphql/src/schema/mutation.ts (1)

1292-1304: Ensure endDate validation in extendGroupActivity mutation

The extendGroupActivity mutation allows users to extend the endDate of a group activity. Please verify that endDate is properly validated within GroupService.extendGroupActivity to prevent setting an endDate that is in the past or before the original endDate.

Run the following script to verify that endDate validation is implemented:

#!/bin/bash
# Description: Verify that `extendGroupActivity` enforces proper `endDate` validation.

# Test: Search for validation logic in the `extendGroupActivity` method. Expect to find validation for `endDate`.
ast-grep --lang typescript --pattern $'export async function extendGroupActivity($_args, $_ctx) {
  $$$
}' packages/graphql/src/services/groups.ts | xargs rg 'validate.*endDate'
packages/i18n/messages/de.ts (2)

1568-1572: Translations are accurate and consistent.

The new keys for extending microlearning sessions are correctly added with appropriate German translations, maintaining consistency with existing entries.


1611-1613: Addition of group activity extension translations is correct.

The translations for extending group activities are accurately provided and align well with the existing localization structure.

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

847-848: Ensure Consistency in Mutation Optionality

The mutations extendGroupActivity and extendMicroLearning (lines 847-848) are defined as optional (with ?), whereas finalRandomGroupAssignments is defined without the optional marker. Please verify if the optionality of these mutations is intentional and consistent with other mutations in the schema.


1216-1225: Approve Mutation Argument Definitions

The new mutation argument types MutationExtendGroupActivityArgs (lines 1216-1219) and MutationExtendMicroLearningArgs (lines 1222-1225) are correctly defined with the required id and endDate fields of appropriate types.


2775-2790: Approve Addition of Mutation Types

The definitions for ExtendGroupActivityMutationVariables, ExtendGroupActivityMutation, ExtendMicroLearningMutationVariables, and ExtendMicroLearningMutation (lines 2775-2790) correctly specify the variables and response types for the new mutations. This aligns with the existing patterns in the codebase.

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 (2)
packages/i18n/messages/de.ts (2)

Line range hint 1569-1614: Consider grouping related translations for better organization.

While the new translations are correctly placed within the course section, consider grouping all microlearning-related translations together and all group activity-related translations together. This could improve readability and make future updates easier.

For example:

microlearning: {
  edit: '...',
  duplicate: '...',
  extend: '...',
  extendDescription: '...',
  newEndDate: '...',
  futureEndDateRequired: '...',
  publish: '...',
  unpublish: '...',
  convert: '...',
  delete: '...',
},
groupActivity: {
  edit: '...',
  delete: '...',
  publish: '...',
  unpublish: '...',
  extend: '...',
  extendDescription: '...',
  grade: '...',
},

This structure would make it easier to locate and maintain related translations.


Line range hint 1-1614: Consider implementing a more structured approach to translation management.

While the current structure of the translation file is functional, as the application grows, it may become challenging to maintain. Consider the following suggestions to improve organization and maintainability:

  1. Split the translations into multiple files based on major sections of the application (e.g., auth.ts, manage.ts, pwa.ts, etc.). This would make it easier to locate and update specific translations.

  2. Implement a consistent naming convention for keys, such as using camelCase for all keys or separating words with underscores.

  3. Add comments to group related translations or provide context for complex phrases.

  4. Consider using a translation management system that can help maintain consistency across different languages and provide additional features like version control and collaboration tools.

  5. Implement type checking for translations to catch missing or extra keys early in the development process.

These changes could significantly improve the long-term maintainability of the translation files as the application continues to grow and evolve.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 530935e and 84d685d.

📒 Files selected for processing (5)
  • packages/graphql/src/ops.ts (4 hunks)
  • packages/graphql/src/public/client.json (1 hunks)
  • packages/graphql/src/public/server.json (1 hunks)
  • packages/i18n/messages/de.ts (2 hunks)
  • packages/i18n/messages/en.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/graphql/src/public/client.json
  • packages/graphql/src/public/server.json
  • packages/i18n/messages/en.ts
🔇 Additional comments (6)
packages/i18n/messages/de.ts (2)

1569-1573: New translations for extending microlearnings look good.

The newly added translations for extending microlearnings are clear and consistent with the existing style. They provide appropriate German translations for the functionality of extending microlearnings.


1612-1614: New translations for extending group activities are consistent.

The translations added for extending group activities follow the same pattern as those for microlearnings. They are clear and maintain consistency with the existing translations.

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

847-848: LGTM!

The added mutations extendGroupActivity and extendMicroLearning are correctly defined in the Mutation type.


1216-1226: LGTM!

The argument types for extendGroupActivity and extendMicroLearning mutations are properly specified.


2775-2790: LGTM!

The type definitions for the new mutations and their variables are correctly implemented.


3718-3719: Refactor Large JSON Literals for Readability

The previous suggestion to refactor large JSON literals for better readability remains applicable.

Copy link

sonarqubecloud bot commented Oct 2, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
3.1% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

@sjschlapbach sjschlapbach merged commit 7c84a59 into v3 Oct 2, 2024
10 of 14 checks passed
@sjschlapbach sjschlapbach deleted the extend-activities branch October 2, 2024 20:27
Copy link

cypress bot commented Oct 2, 2024

klicker-uzh    Run #3090

Run Properties:  status check failed Failed #3090  •  git commit 7c84a597a3: feat: add possibility to extend microlearnings and group activities before end d...
Project klicker-uzh
Branch Review v3
Run status status check failed Failed #3090
Run duration 09m 25s
Commit git commit 7c84a597a3: feat: add possibility to extend microlearnings and group activities before end d...
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 46
View all changes introduced in this branch ↗︎

Tests for review

Failed  cypress/e2e/E-course-workflow.cy.ts • 1 failed test

View Output

Test Artifacts
Test course creation and editing functionalities > Test the assignment of random groups in the seeded test course Test Replay 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