Skip to content

Commit

Permalink
"Flag Obnoxious", Spell check on system prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
RickCarlino committed Nov 14, 2023
1 parent 9fe1787 commit a38dc54
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 16 deletions.
9 changes: 8 additions & 1 deletion pages/cards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -78,10 +78,17 @@ const Edit: React.FC = () => {
if (cards.data) {
content = <CardTable cards={cards.data} />;
}
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(
<Container size="s">
<h1>Manage Cards</h1>
<Button onClick={doDeleteFlagged}>Delete Flagged Cards</Button>
<Button onClick={doFlagObnoxious}>Flag Obnoxious Cards</Button>
<Button onClick={doExport}>Export Cards</Button>
<FileImportButton
onReady={(data) => {
Expand Down
13 changes: 2 additions & 11 deletions server/routers/faucet.ts
Original file line number Diff line number Diff line change
@@ -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. */
Expand All @@ -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([]) };
});
24 changes: 24 additions & 0 deletions server/routers/flag-obnoxious.ts
Original file line number Diff line number Diff line change
@@ -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.`]) };
});
2 changes: 2 additions & 0 deletions server/routers/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -21,6 +22,7 @@ export const appRouter = router({
failCard,
faucet,
flagCard,
flagObnoxious,
getAllCards,
getNextQuiz,
getNextQuizzes,
Expand Down
8 changes: 4 additions & 4 deletions server/routers/perform-exam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down

0 comments on commit a38dc54

Please sign in to comment.