Skip to content

Commit

Permalink
fix: fix all question having the same letter answer in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
PupoSDC committed Aug 3, 2023
1 parent 5b21b27 commit 3acabec
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export const EditQuestionBody: FunctionComponent = () => {
</FormControl>
<HookFormTextArea
{...form.register("question.explanation")}
name={"question.explanation"}
minRows={5}
sx={{ mt: 1 }}
/>
Expand Down
6 changes: 5 additions & 1 deletion apps/next-app/pages/questions/[questionId]/edit.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ export const EditQuestionPage: NextPage = () => {
},
};

const form = useForm({ resolver, defaultValues, mode: "onBlur" });
const form = useForm<EditQuestionFormValues>({
resolver,
defaultValues,
mode: "onBlur",
});

return (
<>
Expand Down
9 changes: 7 additions & 2 deletions libs/core/app/src/tests/create-test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { z } from "zod";
import { getQuestion } from "../questions/get-question";
import { getRandomId, getRandomShuffler } from "../random/random";
import {
getRandomId,
getRandomIdGenerator,
getRandomShuffler,
} from "../random/random";
import type { Test, QuestionBankRepository } from "@chair-flight/base/types";

export type NewTestConfiguration = {
Expand Down Expand Up @@ -53,6 +57,7 @@ export const createTest = async ({
const title = config.title ?? `${subject} ${mode}`;
const seed = config.seed ?? getRandomId();
const shuffler = getRandomShuffler(seed);
const getRandomRandomId = getRandomIdGenerator(seed);

const learningObjectives = Object.entries(config.learningObjectives).reduce<
string[]
Expand All @@ -73,7 +78,7 @@ export const createTest = async ({

const questions = shuffler(possibleQuestions)
.slice(0, numberOfQuestions)
.map((q) => getQuestion(q, { seed }));
.map((q) => getQuestion(q, { seed: getRandomRandomId() }));

return {
id: getRandomId(),
Expand Down

1 comment on commit 3acabec

@vercel
Copy link

@vercel vercel bot commented on 3acabec Aug 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.