Skip to content

Commit

Permalink
fixed formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Gorelik authored and Alexander Gorelik committed Sep 5, 2024
1 parent e25f1e6 commit 2ef37b1
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions frontend/src/questions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import type { QuizQuestion } from 'model/quiz-question.ts'
import * as api from 'api.ts'
import { preventDefault } from 'helpers.ts'

const Feedback = (id: number) =>
const Feedback = (id: number) => (
<p class="feedback">{id ? `Congratulation, Quiz ID is ${id}` : 'Oops..something went wrong :('}</p>
)

const Questions = (list: QuizQuestion[]) => {
const [selectedQuestions, setSelectedQuestions] = createSignal<number[]>([])
Expand All @@ -29,15 +30,16 @@ const Questions = (list: QuizQuestion[]) => {
const selectQuestion = (questionIdx: number) => () => {
const isQuestion = selectedQuestions().find(id => id === questionIdx)

if(isQuestion) { // remove question
if (isQuestion) {
// remove question
const filteredQuestions = selectedQuestions().filter(id => id !== questionIdx)
setSelectedQuestions(filteredQuestions)
} else { //add question
} else {
//add question
setSelectedQuestions([...selectedQuestions(), questionIdx])
}
}
}


const Question = ({ question, id }: QuizQuestion) => {
const questionId = `answer-${id}`
return (
Expand All @@ -54,7 +56,14 @@ const Questions = (list: QuizQuestion[]) => {
<div>
<label for={'quizName'}>Quiz name:</label>
</div>
<input type={'text'} name={'question'} id={'quizName'} value={quizName()} onInput={e => setQuizName(e.currentTarget.value)} required />
<input
type={'text'}
name={'question'}
id={'quizName'}
value={quizName()}
onInput={e => setQuizName(e.currentTarget.value)}
required
/>
</div>
)
}
Expand Down

0 comments on commit 2ef37b1

Please sign in to comment.