From 69d546011ad62a7afb1daff7e5e80485d4faa544 Mon Sep 17 00:00:00 2001 From: Emre Ergin Date: Thu, 22 Feb 2024 23:30:40 +0300 Subject: [PATCH] round fixes for new treatments --- src/components/Round2.tsx | 11 ++++++++-- .../experimentComponents/Drawing2.tsx | 22 +++++-------------- src/pages/2/index.tsx | 18 --------------- 3 files changed, 14 insertions(+), 37 deletions(-) delete mode 100644 src/pages/2/index.tsx diff --git a/src/components/Round2.tsx b/src/components/Round2.tsx index 2966ced..c336667 100644 --- a/src/components/Round2.tsx +++ b/src/components/Round2.tsx @@ -89,6 +89,10 @@ function Round2({ pointFunction((p: number) => p + pointsForCurrentRound); if (currentRound < numberOfRounds - 1) { + const newBall = + Math.random() < arrayOfBags[currentRound] / 100 ? "blue" : "red"; + setCurrentColor(newBall); + setSubPhase("drawing"); roundData.current = { ...roundData.current, @@ -104,13 +108,16 @@ function Round2({ return (
<> - + endDrawing(d)} fullView={subPhase === "drawing"} key={currentRound} result={subPhase === "result"} + isBlue={currentColor === "blue"} /> {subPhase === "input" && ( void; fullView?: boolean; result?: boolean; + isBlue: boolean; } function Drawing2({ - numberofBlues, nextFunction, + isBlue, fullView = true, result = false, }: drawingProps) { @@ -39,15 +39,9 @@ function Drawing2({ parent.current && autoAnimate(parent.current); }, [parent]); - const draws = useRef( - Array.from({ length: 1 }, () => Math.floor(Math.random() * 100)).map( - (num) => (num < numberofBlues ? "blue" : "red"), - ), - ); - function nextSubPhase() { nextFunction({ - is_blue: draws.current[0] === "blue", + is_blue: isBlue, }); } @@ -68,16 +62,10 @@ function Drawing2({ }} ref={parent} > - {draws.current + {[""] .slice(0, numberOfShownBalls + 1) .map((a, i) => - !result ? ( - - ) : a === "blue" ? ( - "🔵" - ) : ( - "🔴" - ), + !result ? : isBlue ? "🔵" : "🔴", ) .map((e, i) => ( diff --git a/src/pages/2/index.tsx b/src/pages/2/index.tsx deleted file mode 100644 index fd1b2cb..0000000 --- a/src/pages/2/index.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import Experiment2 from "@/components/Experiment2"; -import { Session } from "@prisma/client"; - -const defaultSession: Omit< - Session, - "id" | "num_of_blue_a" | "num_of_blue_b" | "prior" -> = { - start_time: new Date(), - end_time: null, - name: "alpha_1", - location: null, - treatment: "QSR2", - round_parameters: [10, 25, 50, 75, 90, 10], -}; - -export default function Home() { - return ; -}