-
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.
- Loading branch information
1 parent
cadff9e
commit 1e528bb
Showing
5 changed files
with
96 additions
and
1 deletion.
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
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
24 changes: 24 additions & 0 deletions
24
src/app/exam/_components/FinishModal/FinishModal.module.scss
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,24 @@ | ||
// TAGether - Share self-made exam for classmates | ||
// CopyRight (c) 2020-2023 watasuke | ||
// | ||
// Email : <[email protected]> | ||
// Twitter: @Watasuke102 | ||
// This software is released under the MIT or MIT SUSHI-WARE License. | ||
@import '../../../../components/common/variable'; | ||
|
||
.modal { | ||
min-width: 400px; | ||
padding: 24px 32px; | ||
text-align: center; | ||
} | ||
|
||
.modal_mes { | ||
display: inline-grid; | ||
grid-template-columns: 32px auto; | ||
gap: 8px; | ||
font-size: 1.9em; | ||
font-weight: bold; | ||
svg { | ||
color: $color-primary-3; | ||
} | ||
} |
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,58 @@ | ||
// TAGether - Share self-made exam for classmates | ||
// CopyRight (c) 2020-2023 watasuke | ||
// | ||
// Email : <[email protected]> | ||
// Twitter: @Watasuke102 | ||
// This software is released under the MIT or MIT SUSHI-WARE License. | ||
import css from './FinishModal.module.scss'; | ||
import React from 'react'; | ||
import {useRouter, useSearchParams} from 'next/navigation'; | ||
import {ExamReducerContext} from '../ExamReducer'; | ||
import Modal from '@/common/Modal/Modal'; | ||
import TadaIcon from '@assets/tada.svg'; | ||
import ButtonContainer from '@/common/Button/ButtonContainer'; | ||
import Button from '@/common/Button/Button'; | ||
import EditIcon from '@assets/edit.svg'; | ||
import ArrowLeftIcon from '@assets/arrow-left.svg'; | ||
|
||
export function FinishModal(): JSX.Element { | ||
const router = useRouter(); | ||
const params = useSearchParams(); | ||
const id = params.get('id'); | ||
|
||
const [state, dispatch] = React.useContext(ExamReducerContext); | ||
const [correct_answers, total_questions] = state.exam_state.reduce( | ||
(acc, cur) => [acc[0] + cur.correct_count, acc[1] + cur.total_question], | ||
[0, 0], | ||
); | ||
const correct_rate = Math.round((correct_answers / total_questions) * 10000) / 100; | ||
|
||
return ( | ||
<Modal isOpen={state.is_modal_open} close={() => dispatch({type: 'is_modal_open/set', data: false})}> | ||
<div className={css.modal}> | ||
<div className={css.modal_mes}> | ||
<TadaIcon /> <span>問題終了</span> | ||
</div> | ||
<p className={css.correct_rate}> | ||
正答率:{correct_rate}% ({total_questions}問中{correct_answers}問正解) | ||
</p> | ||
{/* TODO: jump to history */} | ||
<ButtonContainer> | ||
<></> | ||
<Button | ||
text={'編集する'} | ||
icon={<EditIcon />} | ||
type={'material'} | ||
OnClick={() => id && router.push(`/edit?id=${id}`)} | ||
/> | ||
<Button | ||
text={'カテゴリ一覧へ移動'} | ||
icon={<ArrowLeftIcon />} | ||
type={'filled'} | ||
OnClick={() => router.push('/list')} | ||
/> | ||
</ButtonContainer> | ||
</div> | ||
</Modal> | ||
); | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.