Merge branch 'fe/reportPageBugFix' into 'frontend'
[Front-end] fix: StudentReport Page 리포트카드 안나오는거 수정 시험 한번도 안 본 상태에서 접근 시 에러 안나게 변경 See merge request s11-webmobile1-sub2/S11P12A701!152
This commit is contained in:
commit
ce6692dc4a
@ -9,11 +9,10 @@ export default function StudentReportPage() {
|
||||
const { lectureId } = useParams();
|
||||
const { data } = useStudentReports(lectureId);
|
||||
const reports = data?.data;
|
||||
console.log(reports);
|
||||
|
||||
const totalCounts = reports.reduce?.(
|
||||
(acc, report) => {
|
||||
if (acc.allCount > 0) {
|
||||
if (report.allCount > 0) {
|
||||
acc.correctCount += report.correctCount;
|
||||
acc.allCount += report.allCount;
|
||||
}
|
||||
@ -27,24 +26,26 @@ export default function StudentReportPage() {
|
||||
title="퀴즈 성적"
|
||||
canCreate={false}
|
||||
>
|
||||
<div className={styles.wrapper}>
|
||||
<div className={styles.LinksContainer}>
|
||||
{reports.map?.((report) => (
|
||||
<ArticleLink
|
||||
key={`${report.reportId}`}
|
||||
title={report.title}
|
||||
sub={report.allCount === 0 ? '미응시' : `${Math.round((report.correctCount / report.allCount) * 100)}%`}
|
||||
to={`${report.reportId}`}
|
||||
{totalCounts && (
|
||||
<div className={styles.wrapper}>
|
||||
<div className={styles.LinksContainer}>
|
||||
{reports.map?.((report) => (
|
||||
<ArticleLink
|
||||
key={`${report.reportId}`}
|
||||
title={report.title}
|
||||
sub={report.allCount === 0 ? '미응시' : `${Math.round((report.correctCount / report.allCount) * 100)}%`}
|
||||
to={`${report.reportId}`}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
<div className={styles.reportCardContainer}>
|
||||
<ReportCard
|
||||
correctCount={totalCounts.correctCount}
|
||||
allCount={totalCounts.allCount}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles.reportCardContainer}>
|
||||
<ReportCard
|
||||
correctCount={totalCounts.correctCount}
|
||||
allCount={totalCounts.allCount}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</ArticleBoard>
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user