-
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.
update: examtable>履歴の内容をちゃんと表示できるようにした
- Loading branch information
1 parent
7cb666e
commit ca95c22
Showing
5 changed files
with
190 additions
and
64 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
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
11 changes: 11 additions & 0 deletions
11
src/components/features/Exam/FmtUserAnswer/FmtUserAnswer.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,11 @@ | ||
// 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 '../../../common/variable'; | ||
|
||
.wrong { | ||
color: $color-wrong; | ||
} |
80 changes: 80 additions & 0 deletions
80
src/components/features/Exam/FmtUserAnswer/FmtUserAnswer.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,80 @@ | ||
// TAGether - Share self-made exam for classmates | ||
// CopyRight (c) 2020-2024 watasuke | ||
// | ||
// Email : <[email protected]> | ||
// Twitter: @Watasuke102 | ||
// This software is released under the MIT or MIT SUSHI-WARE License. | ||
import css from './FmtUserAnswer.module.scss'; | ||
import React from 'react'; | ||
import Exam from '@mytypes/Exam'; | ||
|
||
type Props = { | ||
exam: Exam; | ||
user_answer: string[]; | ||
result: boolean[]; | ||
}; | ||
|
||
export function FmtUserAnswer(props: Props): JSX.Element { | ||
return ( | ||
<> | ||
{(() => { | ||
switch (props.exam.type ?? 'Text') { | ||
case 'Text': | ||
if (props.exam.answer.length === 1) { | ||
return <span className={props.result?.at(0) ?? true ? '' : css.wrong}>{props.user_answer[0]}</span>; | ||
} | ||
return ( | ||
<ol> | ||
{props.user_answer.map((e, i) => ( | ||
<li key={'result_select_' + i} className={props.result?.at(i) ?? true ? '' : css.wrong}> | ||
{e} | ||
</li> | ||
))} | ||
</ol> | ||
); | ||
case 'Select': | ||
return ( | ||
<span className={props.result?.at(0) ?? true ? '' : css.wrong}> | ||
{props.exam.question_choices?.at(Number(props.exam.answer[0]))} | ||
</span> | ||
); | ||
case 'MultiSelect': | ||
return ( | ||
<ul> | ||
{props.exam.answer | ||
.filter((_m, i) => props.user_answer[i] === String(i)) | ||
.map((e, i) => ( | ||
<li key={'result_multiselect_' + i} className={props.result?.at(i) ?? true ? '' : css.wrong}> | ||
{e} | ||
</li> | ||
))} | ||
</ul> | ||
); | ||
case 'Sort': | ||
return ( | ||
<ol> | ||
{props.user_answer.map((e, i) => ( | ||
<li key={'result_sort_' + i} className={props.result?.at(i) ?? true ? '' : css.wrong}> | ||
{e} | ||
</li> | ||
))} | ||
</ol> | ||
); | ||
case 'ListSelect': | ||
return ( | ||
<ol> | ||
{props.user_answer.map((e, i) => ( | ||
<li key={'result_listselect_' + i} className={props.result?.at(i) ?? true ? '' : css.wrong}> | ||
{e} | ||
</li> | ||
))} | ||
</ol> | ||
); | ||
|
||
default: | ||
throw Error('invalid Exam type'); | ||
} | ||
})()} | ||
</> | ||
); | ||
} |