From ac0c0f1558937117378cff1c7daaed0c7c6cc9bc Mon Sep 17 00:00:00 2001 From: Daniel Kao Date: Mon, 26 Feb 2024 17:57:41 -0800 Subject: [PATCH 1/3] make select the default, make people select an answer --- src/components/RunCode.tsx | 7 ++++--- src/components/SelectCode.tsx | 7 ++++++- src/pages/Exercise2.tsx | 27 +++++++++++++++++++++++++++ src/styles/SelectCode.scss | 2 +- 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/src/components/RunCode.tsx b/src/components/RunCode.tsx index af976bf1..c7a7fb25 100644 --- a/src/components/RunCode.tsx +++ b/src/components/RunCode.tsx @@ -28,6 +28,7 @@ const RunCode: React.FC = ({ const [selections, setSelections] = useState([]); const [answers, setAnswers] = useState>([]); const [alert, setAlert] = useState(false); + const unanswered = 'Please select an answer'; const alertFunction = () => { setAlert(true); @@ -40,8 +41,8 @@ const RunCode: React.FC = ({ if (selections.length == 0) { const tempArr: string[] = []; const ansArr: Array = []; - questions.forEach((question) => { - tempArr.push(question.options[0]); + questions.forEach(() => { + tempArr.push(''); ansArr.push(null); }); setSelections(tempArr); @@ -123,7 +124,7 @@ const RunCode: React.FC = ({ />

- {question.answerText.get(selections[index])} + {selections[index] == '' ? unanswered : question.answerText.get(selections[index])}

= ({ choices, handleClick }) => { - const [display, setDisplay] = useState(choices[0] || ''); + const [display, setDisplay] = useState(''); const handleChange = (e: SelectChangeEvent) => { setDisplay(e.target.value); @@ -29,6 +29,11 @@ const SelectCode: React.FC = ({ choices, handleClick }) => { inputProps={{ 'aria-label': 'Without label' }} className="select-input" > + +
+              Select
+            
+
{choices.map((choice, index) => ( Date: Mon, 26 Feb 2024 17:59:20 -0800 Subject: [PATCH 2/3] fix lint --- src/components/RunCode.tsx | 4 +++- src/components/SelectCode.tsx | 2 +- src/pages/Exercise2.tsx | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/RunCode.tsx b/src/components/RunCode.tsx index c7a7fb25..d2630787 100644 --- a/src/components/RunCode.tsx +++ b/src/components/RunCode.tsx @@ -124,7 +124,9 @@ const RunCode: React.FC = ({ />

- {selections[index] == '' ? unanswered : question.answerText.get(selections[index])} + {selections[index] == '' + ? unanswered + : question.answerText.get(selections[index])}

= ({ choices, handleClick }) => { inputProps={{ 'aria-label': 'Without label' }} className="select-input" > - +
               Select
             
diff --git a/src/pages/Exercise2.tsx b/src/pages/Exercise2.tsx index 7cffc032..b89823d1 100644 --- a/src/pages/Exercise2.tsx +++ b/src/pages/Exercise2.tsx @@ -91,7 +91,7 @@ const questions2 = [ 'Correct! You can actually declare it as either a char or string pointer.', ], ]), - } + }, ]; const questions3 = [ From 241c296377b72b9c581b2ea6af3bf599cc9dd01d Mon Sep 17 00:00:00 2001 From: Daniel Kao Date: Mon, 26 Feb 2024 18:03:28 -0800 Subject: [PATCH 3/3] add hint --- src/pages/Exercise2.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pages/Exercise2.tsx b/src/pages/Exercise2.tsx index b89823d1..d1137e12 100644 --- a/src/pages/Exercise2.tsx +++ b/src/pages/Exercise2.tsx @@ -157,7 +157,10 @@ const Exercise2: FC = () => {
Exercise 2 Diagram
-

How do we create a pointer to the basketball string?

+

+ How do we create a pointer to the basketball string? (Hint: there + are 2 answers here!) +