-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
VKT(Frontend & Backend): Examiner exam event overview page
- Loading branch information
Showing
21 changed files
with
716 additions
and
25 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -392,10 +392,28 @@ SELECT exam_event_id, (SELECT max(person_id) FROM person), | |
'[email protected]', '0404040404', null, null, null, null | ||
FROM exam_event; | ||
|
||
-- Insert enrollment appointment | ||
-- Insert examiner | ||
INSERT INTO examiner(version, oid, email, phone_number, last_name, first_name, nickname, exam_language_finnish, exam_language_swedish, is_public) | ||
VALUES (1, '1.2.246.init-1', '[email protected]', '04040404040', 'Tessilä', 'Testi', 'Tessa', true, true, true); | ||
|
||
-- Insert municipality | ||
INSERT INTO municipality(version, code, name_fi, name_sv) | ||
VALUES (1, 'oul', 'Oulu', 'Oulu'); | ||
|
||
-- insert examiner_exam_event | ||
INSERT INTO examiner_exam_event(version, date, language, examiner_id, is_hidden, registration_closes, max_participants, municipality_id, location) | ||
VALUES ( | ||
1, | ||
now() + interval '5 weeks', | ||
'FI', | ||
1, | ||
false, | ||
now() + interval '2 weeks', | ||
10, | ||
1, | ||
'tylypahka' | ||
); | ||
|
||
-- Insert enrollment appointment | ||
INSERT INTO enrollment_appointment(person_id, examiner_id, | ||
skill_oral, skill_textual, skill_understanding, | ||
|
@@ -406,3 +424,15 @@ VALUES (null, 1, | |
true, true, true, true, | ||
'CONTACT_CREATED', true, | ||
'[email protected]', '0404040404', null, null, null, null); | ||
|
||
-- Insert enrollment appointment | ||
INSERT INTO enrollment_appointment(person_id, examiner_id, examiner_exam_event_id, | ||
skill_oral, skill_textual, skill_understanding, | ||
partial_exam_speaking, partial_exam_speech_comprehension, partial_exam_writing, partial_exam_reading_comprehension, | ||
status, digital_certificate_consent, email, phone_number, street, postal_code, town, country, first_name, last_name) | ||
VALUES (1, 1, 2, | ||
true, true, true, | ||
true, true, true, true, | ||
'WAITING_AUTHENTICATION', true, | ||
'[email protected]', '0404040404', null, null, null, null, | ||
'Teppo', 'Testinen'); |
This file contains 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
8 changes: 8 additions & 0 deletions
8
backend/vkt/src/main/java/fi/oph/vkt/repository/ExaminerExamEventRepository.java
This file contains 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,8 @@ | ||
package fi.oph.vkt.repository; | ||
|
||
import fi.oph.vkt.model.ExaminerExamEvent; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface ExaminerExamEventRepository extends BaseRepository<ExaminerExamEvent> { | ||
} |
37 changes: 37 additions & 0 deletions
37
backend/vkt/src/main/java/fi/oph/vkt/service/ExaminerExamEventService.java
This file contains 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,37 @@ | ||
package fi.oph.vkt.service; | ||
|
||
import fi.oph.vkt.api.dto.examiner.ExaminerExamEventDTO; | ||
import fi.oph.vkt.audit.AuditService; | ||
import fi.oph.vkt.audit.VktOperation; | ||
import fi.oph.vkt.model.ExaminerExamEvent; | ||
import fi.oph.vkt.repository.ExaminerExamEventRepository; | ||
import fi.oph.vkt.util.ExaminerUtil; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.core.env.Environment; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class ExaminerExamEventService { | ||
|
||
private final ExaminerExamEventRepository examinerExamEventRepository; | ||
private final Environment environment; | ||
|
||
private final AuditService auditService; | ||
|
||
@Transactional(readOnly = true) | ||
public ExaminerExamEventDTO getExamEvent(final long examEventId) { | ||
final ExaminerExamEventDTO examEventDTO = getExamEventWithoutAudit(examEventId); | ||
|
||
auditService.logById(VktOperation.GET_EXAM_EVENT, examEventId); | ||
return examEventDTO; | ||
} | ||
|
||
private ExaminerExamEventDTO getExamEventWithoutAudit(final long examEventId) { | ||
final ExaminerExamEvent examEvent = examinerExamEventRepository.getReferenceById(examEventId); | ||
final String baseUrlAPI = environment.getRequiredProperty("app.base-url.api"); | ||
|
||
return ExaminerUtil.toExaminerExamEventDTO(examEvent, baseUrlAPI); | ||
} | ||
} |
This file contains 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 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
37 changes: 37 additions & 0 deletions
37
...tend/packages/vkt/src/components/examinerEnrollment/listing/ExaminerEnrollmentListing.tsx
This file contains 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,37 @@ | ||
import { CustomTable } from 'shared/components'; | ||
|
||
import { ExaminerEnrollmentListingHeader } from 'components/examinerEnrollment/listing/ExaminerEnrollmentListingHeader'; | ||
import { ExaminerEnrollmentListingRow } from 'components/examinerEnrollment/listing/ExaminerEnrollmentListingRow'; | ||
import { ClerkEnrollmentAppointment } from 'interfaces/clerkEnrollment'; | ||
|
||
interface ExaminerEnrollmentListingProps { | ||
enrollments: Array<ClerkEnrollmentAppointment>; | ||
examEventId: number; | ||
} | ||
|
||
const getRowDetailsWithExamEventId = (examEventId: number) => { | ||
const getRowDetails = (enrollment: ClerkEnrollmentAppointment) => { | ||
return ( | ||
<ExaminerEnrollmentListingRow | ||
enrollment={enrollment} | ||
examEventId={examEventId} | ||
/> | ||
); | ||
}; | ||
|
||
return getRowDetails; | ||
}; | ||
|
||
export const ExaminerEnrollmentListing = ({ | ||
enrollments, | ||
examEventId, | ||
}: ExaminerEnrollmentListingProps) => ( | ||
<CustomTable | ||
className="table-layout-auto" | ||
data={enrollments} | ||
header={<ExaminerEnrollmentListingHeader />} | ||
getRowDetails={getRowDetailsWithExamEventId(examEventId)} | ||
size="small" | ||
stickyHeader | ||
/> | ||
); |
21 changes: 21 additions & 0 deletions
21
...ackages/vkt/src/components/examinerEnrollment/listing/ExaminerEnrollmentListingHeader.tsx
This file contains 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,21 @@ | ||
import { TableCell, TableHead, TableRow } from '@mui/material'; | ||
|
||
import { useClerkTranslation } from 'configs/i18n'; | ||
|
||
export const ExaminerEnrollmentListingHeader = () => { | ||
const { t } = useClerkTranslation({ | ||
keyPrefix: 'vkt.component.clerkEnrollmentListing.header', | ||
}); | ||
|
||
return ( | ||
<TableHead className="heading-text"> | ||
<TableRow> | ||
<TableCell>{t('firstName')}</TableCell> | ||
<TableCell>{t('lastName')}</TableCell> | ||
<TableCell>{t('examEventCoverage')}</TableCell> | ||
<TableCell>{t('registrationTime')}</TableCell> | ||
<TableCell /> | ||
</TableRow> | ||
</TableHead> | ||
); | ||
}; |
90 changes: 90 additions & 0 deletions
90
...d/packages/vkt/src/components/examinerEnrollment/listing/ExaminerEnrollmentListingRow.tsx
This file contains 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,90 @@ | ||
import { TableCell, TableRow } from '@mui/material'; | ||
import { useNavigate } from 'react-router'; | ||
import { Text } from 'shared/components'; | ||
|
||
import { useClerkTranslation } from 'configs/i18n'; | ||
import { AppRoutes } from 'enums/app'; | ||
import { ClerkEnrollmentAppointment } from 'interfaces/clerkEnrollment'; | ||
import { DateTimeUtils } from 'utils/dateTime'; | ||
|
||
const examCodes = { | ||
writingPartialExam: 'KI', | ||
readingComprehensionPartialExam: 'TY', | ||
speakingPartialExam: 'PU', | ||
speechComprehensionPartialExam: 'PY', | ||
}; | ||
|
||
function pick<T extends object, K extends keyof T>(object: T, keys: Array<K>) { | ||
return keys.reduce((obj, key) => { | ||
if (object && object.hasOwnProperty(key)) { | ||
obj[key] = object[key]; | ||
} | ||
|
||
return obj; | ||
}, {} as Partial<T>); | ||
} | ||
|
||
export const ExaminerEnrollmentListingRow = ({ | ||
enrollment, | ||
examEventId, | ||
}: { | ||
enrollment: ClerkEnrollmentAppointment; | ||
examEventId: number; | ||
}) => { | ||
// I18n | ||
const { t } = useClerkTranslation({ | ||
keyPrefix: 'vkt.component.clerkEnrollmentListing.row', | ||
}); | ||
const navigate = useNavigate(); | ||
|
||
const getSelectedPartialExamsText = () => { | ||
const partialExams = pick(enrollment, [ | ||
'writingPartialExam', | ||
'readingComprehensionPartialExam', | ||
'speakingPartialExam', | ||
'speechComprehensionPartialExam', | ||
]); | ||
|
||
if (Object.values(partialExams).some((value) => !value)) { | ||
return Object.keys(partialExams) | ||
.filter((key) => partialExams[key as keyof typeof examCodes]) | ||
.map((key) => examCodes[key as keyof typeof examCodes]) | ||
.join(', '); | ||
} | ||
|
||
return t('fullExam'); | ||
}; | ||
|
||
const onClick = () => { | ||
navigate( | ||
AppRoutes.ClerkEnrollmentOverviewPage.replace( | ||
/:examEventId/, | ||
`${examEventId}`, | ||
), | ||
); | ||
}; | ||
|
||
return ( | ||
<> | ||
<TableRow | ||
data-testid={`enrollments-table__id-${enrollment.id}-row`} | ||
onClick={onClick} | ||
className="cursor-pointer" | ||
> | ||
<TableCell> | ||
<Text>{enrollment.lastName}</Text> | ||
</TableCell> | ||
<TableCell> | ||
<Text>{enrollment.firstName}</Text> | ||
</TableCell> | ||
<TableCell> | ||
<Text>{getSelectedPartialExamsText()}</Text> | ||
</TableCell> | ||
<TableCell> | ||
<Text>{DateTimeUtils.renderDateTime(enrollment.enrollmentTime)}</Text> | ||
</TableCell> | ||
<TableCell sx={{ width: '20%' }} align="right"></TableCell> | ||
</TableRow> | ||
</> | ||
); | ||
}; |
This file contains 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
Oops, something went wrong.