Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: changed question, choice limit, identification check logic (#283) #284

Merged
merged 1 commit into from
Dec 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions apps/expo/src/screens/create-question/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ export const CreateQuestionScreen: FC = () => {
placeholderTextColor={"#757575"}
onFocus={handleTextInputFocus}
multiline
maxLength={300}
maxLength={200}
/>
</>
</View>
Expand Down Expand Up @@ -883,7 +883,7 @@ export const CreateQuestionScreen: FC = () => {
</Text>
<TextInput
multiline={true}
maxLength={150}
maxLength={65}
className={`mx-5 mt-5 h-[50%] flex-col items-center justify-center rounded-2xl ${selectedChoice?.styles} p-2 text-center text-lg font-bold leading-[28.80px] text-white`}
selectionColor="white"
value={selectedChoice?.text}
Expand All @@ -894,9 +894,9 @@ export const CreateQuestionScreen: FC = () => {
placeholderTextColor="#FFFFFF"
/>
{selectedChoice?.text &&
selectedChoice?.text.length >= 150 ? (
selectedChoice?.text.length >= 65 ? (
<Text className="mt-2 text-center text-red-500 ">
You've reached the maximum of 150 characters.
You've reached the maximum of 65 characters.
</Text>
) : null}

Expand Down
7 changes: 5 additions & 2 deletions apps/expo/src/screens/play-test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,8 @@ export const PlayTestScreen: FC<RootStackScreenProps<"PlayTest">> = ({
}

const isCorrectAnswer = question.choices.some(
(choice) => choice.text === answer,
(choice) =>
choice.text.trim().toLowerCase() === answer.trim().toLowerCase(),
);

if (question.type === "identification") {
Expand Down Expand Up @@ -536,8 +537,10 @@ export const PlayTestScreen: FC<RootStackScreenProps<"PlayTest">> = ({

if (question.type === "identification") {
const isCorrectAnswer = question.choices.some(
(choice) => choice.text === answer,
(choice) =>
choice.text.trim().toLowerCase() === answer.trim().toLowerCase(),
);

if (isCorrectAnswer) {
const elapsedTime =
countdownTimerRef.current?.elapsedTime ?? question.time;
Expand Down
8 changes: 4 additions & 4 deletions packages/api/src/functions/gptHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const promptGenerators: {
message,
numChoices = 4,
maxCharsForQuestion = 100,
maxCharsForChoice = 68,
maxCharsForChoice = 50,
) =>
`Create a multiple choice question (maximum of ${maxCharsForQuestion} characters) about: "${message}" with ${numChoices} choices. Each choice must not exceed ${maxCharsForChoice} characters and there must be only 1 correct answer. Format as:
Question: [Your question here]
Expand All @@ -71,14 +71,14 @@ ${timeAndPointsPrompt}`,
identification: (
message,
maxCharsForQuestion = 100,
maxCharsForChoice = 68,
maxCharsForChoice = 50,
) =>
`Create an identification question (maximum of ${maxCharsForQuestion} characters) based on: "${message}". The answer must not exceed ${maxCharsForChoice} characters. Format as:
Question: [Your question here]
Answer: [Your answer here]
${timeAndPointsPrompt}`,

trueOrFalse: (message, maxCharsForQuestion = 100, maxCharsForChoice = 68) =>
trueOrFalse: (message, maxCharsForQuestion = 100, maxCharsForChoice = 50) =>
`Based on the information "${message}", generate a true or false question (maximum of ${maxCharsForQuestion} characters). The answer must not exceed ${maxCharsForChoice} characters. Format as:
Question: [Your question here]
Answer: [True/False]
Expand All @@ -88,7 +88,7 @@ ${timeAndPointsPrompt}`,
message,
numChoices = 4,
maxCharsForQuestion = 100,
maxCharsForChoice = 68,
maxCharsForChoice = 50,
) =>
`Create a multiselect question (maximum of ${maxCharsForQuestion} characters) about: "${message}" with ${numChoices} choices. The choices must not exceed ${maxCharsForChoice} characters and there must be atleast 1 correct answer. Multiple answers can be correct. Format as:
Question: [Your question here]
Expand Down
6 changes: 3 additions & 3 deletions packages/api/src/functions/randomQuestionsHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const questionFormatGenerators: {
multipleChoice: (
numChoices = 4,
maxCharsForQuestion = 100,
maxCharsForChoice = 68,
maxCharsForChoice = 50,
) => `separator\nQuestion: [Your question here, max ${maxCharsForQuestion} characters, and each choice below must not exceed ${maxCharsForChoice} characters]
${generateChoicesPrompt(
numChoices,
Expand All @@ -57,13 +57,13 @@ export const questionFormatGenerators: {
multiselect: (
numChoices = 4,
maxCharsForQuestion = 100,
maxCharsForChoice = 68,
maxCharsForChoice = 50,
) => `separator\nQuestion: [Your question here, max ${maxCharsForQuestion} characters, and each choice below must not exceed ${maxCharsForChoice} characters]
${generateChoicesPrompt(
numChoices,
)}\nAll Correct Answers: Options [Correct option numbers separated by commas (e.g., 1,3) and at least one correct answer] ${timeAndPointsPrompt}`,

identification: (maxCharsForQuestion = 100, maxCharsForChoice = 68) =>
identification: (maxCharsForQuestion = 100, maxCharsForChoice = 50) =>
`separator\nQuestion: [Your question here, max ${maxCharsForQuestion} characters]\nAnswer: [Your answer here, max ${maxCharsForChoice} characters] ${timeAndPointsPrompt}`,

trueOrFalse: (maxCharsForQuestion = 100) =>
Expand Down
Loading