-
Notifications
You must be signed in to change notification settings - Fork 14
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: show live quiz description to students before first block activation #4379
Conversation
Current Aviator status
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.
|
📝 Walkthrough📝 WalkthroughWalkthroughThis pull request introduces several modifications across multiple files, primarily enhancing the functionality and structure of live quizzes. Key changes include the addition of new properties such as Changes
Possibly related PRs
Suggested reviewers
Warning Rate limit exceeded@sjschlapbach has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 1 minutes and 13 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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
🧹 Outside diff range and nitpick comments (3)
apps/frontend-pwa/src/pages/session/[id].tsx (1)
194-201
: Consider simplifying the nested conditional logic.The current implementation uses nested ternary operators which can be hard to maintain. Consider extracting this logic into a separate component or using early returns.
Here's a suggested refactor:
- {!activeBlock ? ( - beforeFirstBlock && - description !== null && - typeof description !== 'undefined' ? ( - <div data-cy="live-quiz-description"> - <H3>{displayName}</H3> - <Markdown content={description} /> - </div> - ) : isGamificationEnabled ? ( - <div className={twMerge('min-h-full flex-1 bg-white')}> - <LiveQuizLeaderboard quizId={id} /> - </div> - ) : ( - <div>{t('pwa.liveQuiz.noActiveQuestion')}</div> - ) - ) : ( + {activeBlock ? ( + <QuestionArea + expiresAt={activeBlock.expiresAt} + instances={activeBlock.elements ?? []} + handleNewResponse={handleNewResponse} + quizId={id} + timeLimit={activeBlock?.timeLimit ?? undefined} + execution={activeBlock?.execution ?? 0} + /> + ) : beforeFirstBlock && description ? ( + <div data-cy="live-quiz-description"> + <H3>{displayName}</H3> + <Markdown content={description} /> + </div> + ) : isGamificationEnabled ? ( + <div className={twMerge('min-h-full flex-1 bg-white')}> + <LiveQuizLeaderboard quizId={id} /> + </div> + ) : ( + <div>{t('pwa.liveQuiz.noActiveQuestion')}</div> + )}cypress/cypress/e2e/F-live-quiz-workflow.cy.ts (1)
663-682
: Consider enhancing the description visibility test.The test case verifies the basic visibility of the quiz description, but it could be enhanced to cover more edge cases.
Consider adding these test cases:
- Verify description visibility after quiz completion
- Test description formatting/truncation
- Test description with special characters
- Test empty description handling
Would you like me to help generate the additional test cases?
packages/graphql/src/services/liveQuizzes.ts (1)
1998-1999
: Consider adding error handling for undefined quiz.The return statement could be more explicit about handling the case where quiz is undefined.
Apply this diff to improve error handling:
- return quizWithoutSolutions ?? { ...quiz, beforeFirstBlock } + if (!quiz) return null + return quizWithoutSolutions ?? { ...quiz, beforeFirstBlock }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (11)
apps/frontend-manage/src/components/questions/QuestionList.tsx
(1 hunks)apps/frontend-pwa/src/pages/session/[id].tsx
(3 hunks)cypress/cypress/e2e/F-live-quiz-workflow.cy.ts
(3 hunks)packages/graphql/src/graphql/ops/QGetRunningLiveQuiz.graphql
(1 hunks)packages/graphql/src/ops.schema.json
(1 hunks)packages/graphql/src/ops.ts
(3 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/liveQuiz.ts
(2 hunks)packages/graphql/src/services/liveQuizzes.ts
(2 hunks)
🔥 Files not summarized due to errors (1)
- packages/graphql/src/ops.ts: Error: Server error: no LLM provider could handle the message
✅ Files skipped from review due to trivial changes (2)
- apps/frontend-manage/src/components/questions/QuestionList.tsx
- packages/graphql/src/public/client.json
🧰 Additional context used
🪛 Biome (1.9.4)
packages/graphql/src/services/liveQuizzes.ts
[error] 1951-1951: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
🔇 Additional comments (13)
packages/graphql/src/graphql/ops/QGetRunningLiveQuiz.graphql (2)
9-14
: LGTM! New fields support quiz description feature.
The addition of beforeFirstBlock
and description
fields aligns with the PR objective to show quiz descriptions to students before the first block activation.
4-4
: Verify if the status
field is redundant.
The query includes both status
and activeBlock.status
. Consider if both fields are necessary or if they serve different purposes.
packages/graphql/src/schema/liveQuiz.ts (2)
90-90
: LGTM! Interface extension is well-defined.
The optional beforeFirstBlock
property is appropriately added to the ILiveQuiz
interface.
118-118
: LGTM! Implementation matches interface definition.
The beforeFirstBlock
field is correctly implemented with nullable option, maintaining consistency with the interface.
apps/frontend-pwa/src/pages/session/[id].tsx (2)
19-22
: LGTM! Required imports for new functionality.
The imports for Markdown
and H3
components are necessary for rendering the quiz description.
85-86
: LGTM! Props destructuring is consistent.
The new properties are correctly destructured from data.studentLiveQuiz
.
packages/graphql/src/public/schema.graphql (1)
791-791
: LGTM: Schema change is well-defined.
The addition of the beforeFirstBlock
field to the LiveQuiz
type is clean and follows GraphQL schema best practices.
packages/graphql/src/public/server.json (1)
147-147
: LGTM: Schema change aligns with PR objective
The addition of the beforeFirstBlock
field to the studentLiveQuiz
type is appropriate for enabling the display of quiz descriptions before first block activation.
Let's verify the implementation of this new field:
✅ Verification successful
Schema change is properly implemented
The beforeFirstBlock
field is correctly implemented:
- Field is defined in the schema types (
packages/graphql/src/schema/liveQuiz.ts
) - Implementation in
liveQuizzes.ts
service correctly computes the value by checking if all blocks are in SCHEDULED status - The field is properly included in the response object for published quizzes
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for the resolver implementation of the new beforeFirstBlock field
# Search for resolver implementation
ast-grep --pattern 'beforeFirstBlock'
# Search for any tests covering this new field
rg -l 'beforeFirstBlock.*test'
Length of output: 248
Script:
#!/bin/bash
# Let's check the implementation context in the liveQuizzes service
rg -A 10 -B 5 'beforeFirstBlock' packages/graphql/src/services/liveQuizzes.ts
# Let's also check the resolver implementation
ast-grep --pattern $'type StudentLiveQuiz {
$$$
beforeFirstBlock: $_
$$$
}'
# Check for any type definitions
rg 'beforeFirstBlock.*:.*boolean'
Length of output: 3582
packages/graphql/src/ops.schema.json (1)
8743-8754
: LGTM! Well-designed schema addition for quiz state tracking.
The new beforeFirstBlock
field in the LiveQuiz
type is a well-structured addition that enables tracking whether a quiz is in its initial state before the first block activation. The nullable Boolean type is appropriate for this state flag.
packages/graphql/src/ops.ts (4)
866-866
: LGTM: Type definition is well-structured
The new beforeFirstBlock
field is properly typed as an optional boolean using the Maybe
type wrapper, following GraphQL schema conventions.
3710-3710
: LGTM: Query type is properly updated
The new fields beforeFirstBlock
and description
are correctly added to the GetRunningLiveQuizQuery type with proper nullability handling.
4056-4056
: LGTM: Document definition is comprehensive
The GetRunningLiveQuizDocument is well-structured with proper field selections, appropriate fragment usage, and correct typing as DocumentNode.
Line range hint 866-4056
: Verify handling of new fields in query consumers
Let's ensure that components consuming this query properly handle the new beforeFirstBlock
and description
fields.
klicker-uzh Run #3734
Run Properties:
|
Project |
klicker-uzh
|
Branch Review |
show-live-quiz-description
|
Run status |
Passed #3734
|
Run duration | 11m 50s |
Commit |
60671f7b8d ℹ️: Merge fdefebb0e3f134287b146b9d51916fe08a27d3b7 into 1dae1785c44065200bbf65d270ed...
|
Committer | Julius Schlapbach |
View all properties for this run ↗︎ |
Test results | |
---|---|
Failures |
0
|
Flaky |
0
|
Pending |
0
|
Skipped |
0
|
Passing |
148
|
View all changes introduced in this branch ↗︎ |
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: 0
🧹 Outside diff range and nitpick comments (3)
cypress/cypress/e2e/F-live-quiz-workflow.cy.ts (3)
590-595
: Maintain consistent indentationThe indentation in this block varies between different lines. Consider maintaining consistent indentation for better readability.
- cy.get('[data-cy="insert-live-description"]') - .realClick() - .type(quizDescription2) - cy.get('[data-cy="insert-live-description"]') - .realClick() - .contains(quizDescription2) + cy.get('[data-cy="insert-live-description"]') + .realClick() + .type(quizDescription2) + cy.get('[data-cy="insert-live-description"]') + .realClick() + .contains(quizDescription2)
664-675
: Well-structured test case with comprehensive coverageThe test case effectively verifies description visibility across both desktop and mobile views. Good practice in testing responsive behavior.
Consider extracting the wait time (1000ms) to a named constant for better maintainability:
+ const DESCRIPTION_VISIBILITY_WAIT_MS = 1000; it('Check that the live quiz description is correctly shown to students', () => { cy.loginStudent() cy.findByText(quizDisplayName2).click() - cy.wait(1000) + cy.wait(DESCRIPTION_VISIBILITY_WAIT_MS)
677-684
: Extract wait times to named constantsThe test uses magic numbers for wait times. Consider extracting these to named constants for better maintainability and clarity.
+ const BLOCK_START_WAIT_MS = 1000; + const BLOCK_TRANSITION_WAIT_MS = 500; it('Start the first block of the live quiz', () => { cy.loginLecturer() cy.get('[data-cy="live-quizzes"]').click() cy.get(`[data-cy="live-quiz-cockpit${quizName2}"]`).click() - cy.wait(1000) + cy.wait(BLOCK_START_WAIT_MS) cy.get('[data-cy="next-block-timeline"]').click() - cy.wait(500) + cy.wait(BLOCK_TRANSITION_WAIT_MS) })
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
cypress/cypress/e2e/F-live-quiz-workflow.cy.ts
(3 hunks)packages/graphql/src/services/liveQuizzes.ts
(2 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
packages/graphql/src/services/liveQuizzes.ts
[error] 1951-1951: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
🔇 Additional comments (5)
packages/graphql/src/services/liveQuizzes.ts (4)
1940-1940
: LGTM: Required include for block status check.
The addition of blocks
to the include statement is necessary to support the new block status checking functionality.
1944-1947
: Improve null safety with optional chaining.
The code could benefit from using optional chaining to handle potential null values more elegantly.
Apply this diff to improve null safety:
- const beforeFirstBlock = quiz?.blocks.every(
+ const beforeFirstBlock = quiz?.blocks?.every(
(block) => block.status === ElementBlockStatus.SCHEDULED
)
1954-1954
: LGTM: Proper integration of the new property.
The beforeFirstBlock
property is correctly added to the quiz object structure.
1998-1998
: LGTM: Consistent return type maintained.
The beforeFirstBlock
property is correctly included in the fallback case, ensuring consistent return types.
cypress/cypress/e2e/F-live-quiz-workflow.cy.ts (1)
19-19
: LGTM: Variable declaration follows consistent pattern
The new constant follows the established naming convention and is appropriately placed with other quiz-related constants.
Quality Gate passedIssues Measures |
klicker-uzh Run #3735
Run Properties:
|
Project |
klicker-uzh
|
Branch Review |
v3
|
Run status |
Passed #3735
|
Run duration | 12m 12s |
Commit |
cc424dbf93: enhance: show live quiz description to students before first block activation (#...
|
Committer | Julius Schlapbach |
View all properties for this run ↗︎ |
Test results | |
---|---|
Failures |
0
|
Flaky |
0
|
Pending |
0
|
Skipped |
0
|
Passing |
148
|
View all changes introduced in this branch ↗︎ |
Summary by CodeRabbit
New Features
beforeFirstBlock
property, indicating the status before the first block is activated.Bug Fixes
Documentation
Tests