You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here are some key observations to aid the review process:
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 Security concerns
JWT Token Exposure: The JWT token expiration time is calculated on the client side using jwt_decode, which could potentially expose sensitive token information. Consider handling token expiration server-side or using a more secure approach.
The timer state updates and timeout handling could have race conditions since multiple useEffect hooks are modifying shared state. Consider consolidating timer logic into a single effect.
useEffect(()=>{consttimer=setInterval(()=>{setTimeLeft((prevTimeLeft)=>{if(prevTimeLeft===0)return0;returnprevTimeLeft-1;});},1000);return()=>clearInterval(timer);},[]);useEffect(()=>{consthours=Math.floor(timeLeft/3600);constminutes=Math.floor((timeLeft%3600)/60);constseconds=timeLeft%60;if(hours===0&&minutes===5&&seconds===0)toast.warning('Only 5 minutes left');if(hours===0&&minutes===1&&seconds===0)toast.warning('Only 1 minutes left');if(hours===0&&minutes===0&&seconds===20)toast.warning("Assessment will be submitted automatically in 10 seconds");if(hours===0&&minutes===0&&seconds===10){props.onTimeout();toast.success("Assessment submitted successfully!")}},[timeLeft]);
Input Validation The duration time inputs lack validation to ensure valid hour/minute combinations. Should add validation to prevent invalid time combinations.
Add missing dependency to useEffect to prevent stale closure issues with callback functions
The onTimeout prop is not properly typed in the useEffect dependency array, which could cause stale closure issues. Add it to the dependency array to ensure the timeout handler stays current.
Why: Critical fix for React hooks dependency array that could cause stale closures and incorrect timeout behavior, potentially affecting the assessment submission timing.
8
Prevent timer from displaying negative values by adding proper boundary check
The timer should handle the case when timeLeft becomes negative. Currently, it only checks for zero, which could lead to negative countdown values. Add a check to ensure timeLeft never goes below zero.
Why: Important defensive programming fix that prevents potential display issues and ensures the timer behaves correctly at boundary conditions.
7
Add input validation to prevent runtime errors from malformed string inputs
The handleSettingsChange function doesn't validate the input value format, which could cause runtime errors if the value string doesn't match the expected format of "number space unit". Add input validation.
Why: Important defensive programming enhancement that prevents potential runtime errors from invalid input formats in the exam duration settings.
7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
Added time duration to assessment and created candidate token based on assessment duration.
PR Type
Enhancement, Bug fix
Description
Added dynamic token duration based on exam settings.
Implemented timeout handling and user notifications in assessments.
Enhanced UI for exam duration display and settings.
Updated backend to support exam-specific token durations.
Changes walkthrough 📝
11 files
Added `examId` to candidate creation payload.Added timeout handling and navigation on assessment expiry.Enhanced timer with timeout logic and user notifications.Added duration handling and saving logic for exams.Displayed exam duration in hours and minutes.Updated exam settings to handle duration changes dynamically.Integrated timer into code editor for assessment timeout.Added `examId` to candidate schema and `duration` to exam schema.Updated JWT creation to support custom durations.Adjusted candidate creation to include exam-specific token duration.Updated timer styles for better visibility.1 files
Minor formatting update in exam API service.