From a38dc54d40775d4f62d462903bbb2b8fdf857109 Mon Sep 17 00:00:00 2001 From: Rick Carlino Date: Mon, 13 Nov 2023 19:32:23 -0600 Subject: [PATCH] "Flag Obnoxious", Spell check on system prompt --- pages/cards.tsx | 9 ++++++++- server/routers/faucet.ts | 13 ++----------- server/routers/flag-obnoxious.ts | 24 ++++++++++++++++++++++++ server/routers/main.ts | 2 ++ server/routers/perform-exam.ts | 8 ++++---- 5 files changed, 40 insertions(+), 16 deletions(-) create mode 100644 server/routers/flag-obnoxious.ts diff --git a/pages/cards.tsx b/pages/cards.tsx index 4578a98..043e10b 100644 --- a/pages/cards.tsx +++ b/pages/cards.tsx @@ -56,7 +56,7 @@ const Edit: React.FC = () => { const deleteFlagged = trpc.deleteFlaggedCards.useMutation(); const exportCards = trpc.exportCards.useMutation(); const importCards = trpc.importCards.useMutation(); - + const flagObnoxious = trpc.flagObnoxious.useMutation(); const doDeleteFlagged = () => { const warning = "Are you sure you want to delete all flagged cards?"; if (!confirm(warning)) return; @@ -78,10 +78,17 @@ const Edit: React.FC = () => { if (cards.data) { content = ; } + const doFlagObnoxious = () => { + const warning = + "Flag ALL cards with ease below 1.3 *OR* more than 7 lapses?"; + if (!confirm(warning)) return; + flagObnoxious.mutateAsync({}).then(() => location.reload()); + }; return Authed(

Manage Cards

+ { diff --git a/server/routers/faucet.ts b/server/routers/faucet.ts index 50f1daf..9753102 100644 --- a/server/routers/faucet.ts +++ b/server/routers/faucet.ts @@ -1,6 +1,6 @@ import { z } from "zod"; import { procedure } from "../trpc"; -import { prismaClient } from "../prisma-client"; +// import { prismaClient } from "../prisma-client"; /** The `faucet` route is a mutation that returns a "Hello, world" string * and takes an empty object as its only argument. */ @@ -12,14 +12,5 @@ export const faucet = procedure if (!userId) { return { message: `["No user ID"]` }; } - const { count } = await prismaClient.card.updateMany({ - where: { - userId, - OR: [{ lapses: { gte: 7 } }, { ease: { lte: 1.31 } }], - }, - data: { - flagged: true, - }, - }); - return { message: JSON.stringify([`Flagged ${count} cards.`]) }; + return { message: JSON.stringify([]) }; }); diff --git a/server/routers/flag-obnoxious.ts b/server/routers/flag-obnoxious.ts new file mode 100644 index 0000000..024199e --- /dev/null +++ b/server/routers/flag-obnoxious.ts @@ -0,0 +1,24 @@ +import { z } from "zod"; +import { procedure } from "../trpc"; +import { prismaClient } from "../prisma-client"; + +/** Flag cards that are leeches or excessively hard. */ +export const flagObnoxious = procedure + .input(z.object({})) + .output(z.object({ message: z.string() })) + .mutation(async ({ ctx }) => { + const userId = ctx.user?.id; + if (!userId) { + return { message: `["No user ID"]` }; + } + const { count } = await prismaClient.card.updateMany({ + where: { + userId, + OR: [{ lapses: { gte: 7 } }, { ease: { lte: 1.31 } }], + }, + data: { + flagged: true, + }, + }); + return { message: JSON.stringify([`Flagged ${count} cards.`]) }; + }); diff --git a/server/routers/main.ts b/server/routers/main.ts index a65e3cf..36c441d 100644 --- a/server/routers/main.ts +++ b/server/routers/main.ts @@ -11,6 +11,7 @@ import { getOneCard } from "./get-one-card"; import { bulkCreateCards } from "./bulk-create-cards"; import { failCard, performExam } from "./perform-exam"; import { importCards } from "./import-cards"; +import { flagObnoxious } from "./flag-obnoxious"; export const appRouter = router({ bulkCreateCards, @@ -21,6 +22,7 @@ export const appRouter = router({ failCard, faucet, flagCard, + flagObnoxious, getAllCards, getNextQuiz, getNextQuizzes, diff --git a/server/routers/perform-exam.ts b/server/routers/perform-exam.ts index 96aefcb..dacf2fd 100644 --- a/server/routers/perform-exam.ts +++ b/server/routers/perform-exam.ts @@ -92,7 +92,8 @@ Grade 1: WRONG - Only give this grade if the meaning is very wrong. Grade 2: CORRECT (minor mistakes) -- The meaning is spot on, but there are small errors like spelling, punctuation, or incorrect pronoun usage. +- The meaning is spot on, but there are small errors like spelling, + punctuation, or incorrect pronoun usage. Grade 3: PERFECT - The sentence matches the expected meaning and form. @@ -102,11 +103,10 @@ Grade 3: PERFECT As an educational Korean learning tool, you grade student's speaking, listening, and dictation drills. -You will be given three things: +You will be given two things: -1. A prompt, which the student must translate to and from Korean. +1. A prompt, which the student must translate. 2. The student's response to the prompt. -3. The correct answer. Using the correct answer as a guide and also the grading scale above, grade the student's response.