Skip to content

Commit

Permalink
update: Table>選択肢をulで表示
Browse files Browse the repository at this point in the history
なんで文字列として表示してたんだろう
  • Loading branch information
watasuke102 committed Feb 25, 2024
1 parent 6771bf9 commit 23ee862
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
7 changes: 7 additions & 0 deletions src/app/examtable/_components/Table/Table.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@
}
}

.choices_header {
display: block;
text-align: center;
font-size: 1.1em;
font-weight: bold;
}

// ボタン
.button_container {
position: fixed;
Expand Down
22 changes: 11 additions & 11 deletions src/app/examtable/_components/Table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,19 @@ export function Table(props: ExamTableProps): React.ReactElement {
[0, 0],
) ?? [undefined, undefined];

const choices: string[] = React.useMemo(
const choices: string[][] = React.useMemo(
() =>
props.exam.map(exam => {
let array: string[];
switch (exam.type) {
case 'Select':
case 'MultiSelect':
case 'ListSelect':
array = exam.question_choices ?? [];
break;
return exam.question_choices ?? [];
case 'Sort':
array = Shuffle(exam.answer);
break;
return Shuffle(exam.answer);
default:
array = [];
break;
return [];
}
return array.join(' | ');
}),
[],
);
Expand Down Expand Up @@ -127,11 +122,16 @@ export function Table(props: ExamTableProps): React.ReactElement {
<tr key={`tr-${i}`}>
<td>
{exam.question}
{choices[i] !== '' && (
{choices[i].length !== 0 && (
<>
<br />
<hr />
<span className={css.sort_}>選択肢:{choices[i]}</span>
<span className={css.choices_header}>[選択肢]</span>
<ul>
{choices[i].map((e, j) => (
<li key={`choice${i}${j}`}>{e}</li>
))}
</ul>
</>
)}
</td>
Expand Down

0 comments on commit 23ee862

Please sign in to comment.