Skip to content

Commit

Permalink
feat: Including explanations in the create question form
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Moravec committed Sep 6, 2024
1 parent acbcc8a commit 46c1698
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions frontend/src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Route, Router } from '@solidjs/router'
import { Quiz } from 'quiz.tsx'
import { CreateQuestion } from './pages/CreateQuestion/CreateQuestion.tsx'
import { CreateQuestionForm } from './pages/CreateQuestion.tsx'
import { QuestionList } from 'questions.tsx'

export const App = () => (
<Router>
<Route path="/quiz/:id" component={Quiz} />
<Route path="/create-question" component={CreateQuestion} />
<Route path="/create-question" component={CreateQuestionForm} />
<Route path="/quiz-question/all" component={QuestionList} />
</Router>
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ type Question = {
question: string
answers: string[]
correctAnswer: number | null
explanations: string[]
questionExplanation: string
quizType: string
}

export function CreateQuestion() {
export function CreateQuestionForm() {
const [question, setQuestion] = createSignal<string>('')
const [answers, setAnswers] = createSignal<string[]>(['', '', '', ''])
const [correctAnswer, setCorrectAnswer] = createSignal<number | null>(null)
Expand All @@ -21,6 +23,8 @@ export function CreateQuestion() {
question: formData.question,
answers: formData.answers,
correctAnswer: formData.correctAnswer,
explanations: formData.explanations,
questionExplanations: formData.questionExplanation,
quizType: 'SINGLE',
}
fetch('/api/quiz-question', {
Expand Down Expand Up @@ -67,8 +71,8 @@ export function CreateQuestion() {
answers: answers(),
correctAnswer: correctAnswer(),
quizType: 'SINGLE',
// questionExplanations: questionExplanations(),
// generalExplanations: answerExplanation(),
explanations: questionExplanations(),
questionExplanation: answerExplanation(),
}
console.log(formData) // Handle form data submission
postData(formData)
Expand Down
File renamed without changes.

0 comments on commit 46c1698

Please sign in to comment.