-
Notifications
You must be signed in to change notification settings - Fork 3
Assessment
: introduce deadline for assessment phase
#607
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
Open
rappm
wants to merge
15
commits into
main
Choose a base branch
from
575-introduce-deadline-for-assessment-phase
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
cc58cbb
feat: rename course_phase_assessment_template to course_phase_info an…
rappm a7251b8
fix: rename to course phase config
rappm 1583d9a
implement coursePhaseConfig service and router
rappm fbeba5f
feat: add functionality to update deadlines
rappm 7048561
feat: get deadline
rappm 89f09fd
show deadline on assessment page
rappm 826774b
fix: handle no deadline case in GetCoursePhaseDeadline function
rappm ae13ecd
fix: improve current deadline display and add warning about final ass…
rappm 2ecb193
feat: implement deadline checks for unmarking assessments and update …
rappm d22bd47
feat: add unit tests for action item and course phase config services
rappm c847680
fix assessment server tests
rappm c29ec15
fix linting issues
rappm 6dc7553
fix: improve error handling for unmarking assessments and update test…
rappm b05b510
feat: add deadline check to assessment completion dialog
rappm 64a7a90
fix: set default value for deadline column in course_phase_config table
rappm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
clients/assessment_component/src/assessment/network/mutations/updateDeadline.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { assessmentAxiosInstance } from '../assessmentServerConfig' | ||
|
||
export const updateDeadline = async (coursePhaseID: string, deadline: Date): Promise<void> => { | ||
try { | ||
await assessmentAxiosInstance.put( | ||
`assessment/api/course_phase/${coursePhaseID}/deadline`, | ||
{ deadline: deadline }, | ||
{ | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}, | ||
) | ||
} catch (err) { | ||
console.error(err) | ||
throw err | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
clients/assessment_component/src/assessment/network/queries/getDeadline.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { assessmentAxiosInstance } from '../assessmentServerConfig' | ||
|
||
export const getDeadline = async (coursePhaseID: string): Promise<Date> => { | ||
const response = await assessmentAxiosInstance.get<Date>( | ||
`assessment/api/course_phase/${coursePhaseID}/deadline`, | ||
{ | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}, | ||
) | ||
return response.data | ||
} |
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
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
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
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
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
85 changes: 85 additions & 0 deletions
85
...nent/src/assessment/pages/SettingsPage/components/DeadlineSelection/DeadlineSelection.tsx
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import { useState, useEffect } from 'react' | ||
import { format } from 'date-fns' | ||
|
||
import { Calendar } from 'lucide-react' | ||
|
||
import { | ||
DatePicker, | ||
Button, | ||
Card, | ||
CardContent, | ||
CardHeader, | ||
CardTitle, | ||
Label, | ||
} from '@tumaet/prompt-ui-components' | ||
|
||
import { useUpdateDeadline } from './hooks/useUpdateDeadline' | ||
import { useDeadlineStore } from '../../../../zustand/useDeadlineStore' | ||
|
||
export const DeadlineSelection = (): JSX.Element => { | ||
const [deadline, setDeadline] = useState<Date | undefined>(undefined) | ||
const [error, setError] = useState<string | null>(null) | ||
|
||
const { deadline: currentDeadline } = useDeadlineStore() | ||
|
||
useEffect(() => { | ||
if (currentDeadline) { | ||
setDeadline(new Date(currentDeadline)) | ||
} | ||
}, [currentDeadline]) | ||
|
||
const updateDeadlineMutation = useUpdateDeadline(setError) | ||
const handleDeadlineUpdate = () => { | ||
if (deadline) { | ||
updateDeadlineMutation.mutate(deadline) | ||
} | ||
} | ||
|
||
return ( | ||
<Card> | ||
<CardHeader> | ||
<CardTitle className='flex items-center gap-2'> | ||
<Calendar className='h-5 w-5' /> | ||
Deadline | ||
</CardTitle> | ||
</CardHeader> | ||
<CardContent className='space-y-4'> | ||
<div className='space-y-2'> | ||
<Label>Select Deadline Date</Label> | ||
|
||
<div className='flex items-center gap-2'> | ||
<DatePicker | ||
date={deadline} | ||
onSelect={(date) => | ||
setDeadline(date ? new Date(format(date, 'yyyy-MM-dd')) : undefined) | ||
} | ||
/> | ||
|
||
<Button | ||
onClick={handleDeadlineUpdate} | ||
disabled={!deadline || updateDeadlineMutation.isPending} | ||
> | ||
{updateDeadlineMutation.isPending ? 'Updating...' : 'Update Deadline'} | ||
</Button> | ||
</div> | ||
</div> | ||
|
||
<div className='bg-blue-50 p-3 rounded-lg'> | ||
<p className='text-sm text-blue-800'> | ||
<strong>Current deadline:</strong>{' '} | ||
{currentDeadline ? format(new Date(currentDeadline), 'dd.MM.yyyy') : 'No deadline set'} | ||
<p className='text-sm text-blue-600 mt-1'> | ||
Once a deadline is set, assessors cannot unmark their assessment as final anymore. | ||
</p> | ||
</p> | ||
</div> | ||
|
||
{error && <div className='text-red-600 text-sm'>{error}</div>} | ||
|
||
{updateDeadlineMutation.isSuccess && ( | ||
<div className='text-green-600 text-sm'>Deadline updated successfully!</div> | ||
)} | ||
</CardContent> | ||
</Card> | ||
) | ||
} |
26 changes: 26 additions & 0 deletions
26
...src/assessment/pages/SettingsPage/components/DeadlineSelection/hooks/useUpdateDeadline.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { useParams } from 'react-router-dom' | ||
|
||
import { useMutation, useQueryClient } from '@tanstack/react-query' | ||
|
||
import { updateDeadline } from '../../../../../network/mutations/updateDeadline' | ||
|
||
export const useUpdateDeadline = (setError: (error: string | null) => void) => { | ||
const { phaseId } = useParams<{ phaseId: string }>() | ||
const queryClient = useQueryClient() | ||
|
||
return useMutation({ | ||
mutationFn: (request: Date) => updateDeadline(phaseId ?? '', request), | ||
onSuccess: () => { | ||
queryClient.invalidateQueries({ queryKey: ['deadline'] }) | ||
setError(null) | ||
}, | ||
onError: (error: any) => { | ||
if (error?.response?.data?.error) { | ||
const serverError = error.response.data?.error | ||
setError(serverError) | ||
} else { | ||
setError('An unexpected error occurred. Please try again.') | ||
} | ||
}, | ||
}) | ||
} |
File renamed without changes.
12 changes: 12 additions & 0 deletions
12
clients/assessment_component/src/assessment/pages/hooks/useGetDeadline.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { useQuery } from '@tanstack/react-query' | ||
import { useParams } from 'react-router-dom' | ||
import { getDeadline } from '../../network/queries/getDeadline' | ||
|
||
export const useGetDeadline = () => { | ||
const { phaseId } = useParams<{ phaseId: string }>() | ||
|
||
return useQuery<Date>({ | ||
queryKey: ['deadline', phaseId], | ||
queryFn: () => getDeadline(phaseId ?? ''), | ||
}) | ||
} | ||
11 changes: 11 additions & 0 deletions
11
clients/assessment_component/src/assessment/zustand/useDeadlineStore.tsx
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { create } from 'zustand' | ||
|
||
export interface DeadlineStore { | ||
deadline: Date | undefined | ||
setDeadline: (deadline: Date) => void | ||
} | ||
|
||
export const useDeadlineStore = create<DeadlineStore>((set) => ({ | ||
deadline: undefined, | ||
setDeadline: (deadline) => set({ deadline }), | ||
})) |
13 changes: 13 additions & 0 deletions
13
servers/assessment/coursePhaseConfig/coursePhaseConfigDTO/deadline.go
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package coursePhaseConfigDTO | ||
|
||
import "time" | ||
|
||
// UpdateDeadlineRequest represents the request to update a course phase deadline | ||
type UpdateDeadlineRequest struct { | ||
Deadline time.Time `json:"deadline"` | ||
} | ||
|
||
// DeadlineResponse represents the response when getting a course phase deadline | ||
type DeadlineResponse struct { | ||
Deadline *time.Time `json:"deadline"` | ||
} |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.