From e919a48ab4193e4044b0148e996a6c5db816ee6e Mon Sep 17 00:00:00 2001 From: Yuqi Huang Date: Tue, 20 Feb 2024 12:11:04 -0800 Subject: [PATCH 1/4] exercise-6 multiline setup --- src/App.tsx | 2 ++ src/pages/Exercise6.tsx | 30 ++++++++++++++++++++++++++++++ src/styles/Exercise6.scss | 4 ++++ 3 files changed, 36 insertions(+) create mode 100644 src/pages/Exercise6.tsx create mode 100644 src/styles/Exercise6.scss diff --git a/src/App.tsx b/src/App.tsx index fff83b15..c8a779be 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -5,6 +5,7 @@ import Error404 from './pages/Error404'; import Exercise1 from './pages/Exercise1'; import Exercise2 from './pages/Exercise2'; import Exercise3 from './pages/Exercise3'; +import Exercise6 from './pages/Exercise6'; import Home from './pages/Home'; import Lesson1 from './pages/Lesson1'; import Lesson10 from './pages/Lesson10'; @@ -42,6 +43,7 @@ function App(): JSX.Element { } /> } /> } /> + } /> } /> } /> diff --git a/src/pages/Exercise6.tsx b/src/pages/Exercise6.tsx new file mode 100644 index 00000000..149a1208 --- /dev/null +++ b/src/pages/Exercise6.tsx @@ -0,0 +1,30 @@ +import {FC} from 'react'; +import '../styles/Exercise6.scss'; +import RunCode from '../components/RunCode'; + +const question = [ + { + options: [ + 'head = new Node();\nhead->next = new Node();\nhead->next = head;\ntail = head->next;' + ], + answer: 'head = new Node();\nhead->next = new Node();\nhead->next = head;\ntail = head->next;', + correctText:'Correct! Let’s go through this line by line. The first line creates a new node and assigns head to point to it. The second line creates a second node and assigns the head node’s next pointer to point to it. The third line assigns tail to point at the second node, since it copies the head node’s next pointer. The fourth line actually simplifies to tail->prev = *head, since from the third line we know tail = head->next, it assigns the previous pointer of the tail node to point back to the head node.', + wrongText: 'Not quite', + }, +]; + +const Exercise6: FC = () => { + return( +
+ +
+ ); +}; + + +export default Exercise6; \ No newline at end of file diff --git a/src/styles/Exercise6.scss b/src/styles/Exercise6.scss new file mode 100644 index 00000000..3a98b589 --- /dev/null +++ b/src/styles/Exercise6.scss @@ -0,0 +1,4 @@ +.exercise6-div{ + white-space: pre-wrap; + word-break: break-all; +} \ No newline at end of file From 8bc0a43603d7ed88bdb95d0d6720aebb7d19ee34 Mon Sep 17 00:00:00 2001 From: Chengheng Li Date: Tue, 20 Feb 2024 16:37:21 -0800 Subject: [PATCH 2/4] fix multiline selector --- src/components/SelectCode.tsx | 4 +++- src/pages/Exercise6.tsx | 41 +++++++++++++++++------------------ src/styles/Exercise6.scss | 8 +++---- 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/src/components/SelectCode.tsx b/src/components/SelectCode.tsx index 69dfe8c0..6e74a5a9 100644 --- a/src/components/SelectCode.tsx +++ b/src/components/SelectCode.tsx @@ -36,7 +36,9 @@ const SelectCode: React.FC = ({ choices, handleClick }) => { className="menu-item" sx={{ whiteSpace: 'normal', wordWrap: 'break-word' }} > - {choice} +
+                {choice}
+              
))} diff --git a/src/pages/Exercise6.tsx b/src/pages/Exercise6.tsx index 149a1208..fc90469e 100644 --- a/src/pages/Exercise6.tsx +++ b/src/pages/Exercise6.tsx @@ -1,30 +1,29 @@ -import {FC} from 'react'; +import { FC } from 'react'; import '../styles/Exercise6.scss'; import RunCode from '../components/RunCode'; const question = [ - { - options: [ - 'head = new Node();\nhead->next = new Node();\nhead->next = head;\ntail = head->next;' - ], - answer: 'head = new Node();\nhead->next = new Node();\nhead->next = head;\ntail = head->next;', - correctText:'Correct! Let’s go through this line by line. The first line creates a new node and assigns head to point to it. The second line creates a second node and assigns the head node’s next pointer to point to it. The third line assigns tail to point at the second node, since it copies the head node’s next pointer. The fourth line actually simplifies to tail->prev = *head, since from the third line we know tail = head->next, it assigns the previous pointer of the tail node to point back to the head node.', - wrongText: 'Not quite', - }, + { + options: [ + 'head = new Node();\nhead->next = new Node();\nhead->next = head;\ntail = head->next;', + ], + answer: + 'head = new Node();\nhead->next = new Node();\nhead->next = head;\ntail = head->next;', + correctText: + 'Correct! Let’s go through this line by line. The first line creates a new node and assigns head to point to it. The second line creates a second node and assigns the head node’s next pointer to point to it. The third line assigns tail to point at the second node, since it copies the head node’s next pointer. The fourth line actually simplifies to tail->prev = *head, since from the third line we know tail = head->next, it assigns the previous pointer of the tail node to point back to the head node.', + wrongText: 'Not quite', + }, ]; const Exercise6: FC = () => { - return( -
- -
- ); + return ( +
+ +
+ ); }; - -export default Exercise6; \ No newline at end of file +export default Exercise6; diff --git a/src/styles/Exercise6.scss b/src/styles/Exercise6.scss index 3a98b589..20b64323 100644 --- a/src/styles/Exercise6.scss +++ b/src/styles/Exercise6.scss @@ -1,4 +1,4 @@ -.exercise6-div{ - white-space: pre-wrap; - word-break: break-all; -} \ No newline at end of file +.exercise6-div { + white-space: pre-wrap; + word-break: break-all; +} From 758a885faa91b8f89a84fcabfc12934511d04b28 Mon Sep 17 00:00:00 2001 From: Yuqi Huang Date: Wed, 21 Feb 2024 11:47:48 -0800 Subject: [PATCH 3/4] further add dropdown options --- src/pages/Exercise6.tsx | 7 +++++-- src/styles/SelectCode.scss | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/pages/Exercise6.tsx b/src/pages/Exercise6.tsx index fc90469e..f33ee26d 100644 --- a/src/pages/Exercise6.tsx +++ b/src/pages/Exercise6.tsx @@ -6,9 +6,12 @@ const question = [ { options: [ 'head = new Node();\nhead->next = new Node();\nhead->next = head;\ntail = head->next;', + 'head = new Node();\nhead->next = new Node();\nhead->next = head;\ntail = head->next;', + '*head = new Node();\n*(head->next) = new Node();\n*(head->next->prev) = *head;\ntail = *head->next;', + 'head = new Node();\nhead-> next = new Node();\ntail = head->next;\nhead->next->prev = head;', ], answer: - 'head = new Node();\nhead->next = new Node();\nhead->next = head;\ntail = head->next;', + 'head = new Node();\nhead-> next = new Node();\ntail = head->next;\nhead->next->prev = head;', correctText: 'Correct! Let’s go through this line by line. The first line creates a new node and assigns head to point to it. The second line creates a second node and assigns the head node’s next pointer to point to it. The third line assigns tail to point at the second node, since it copies the head node’s next pointer. The fourth line actually simplifies to tail->prev = *head, since from the third line we know tail = head->next, it assigns the previous pointer of the tail node to point back to the head node.', wrongText: 'Not quite', @@ -20,7 +23,7 @@ const Exercise6: FC = () => {
); diff --git a/src/styles/SelectCode.scss b/src/styles/SelectCode.scss index 49d19398..fe7b6e61 100644 --- a/src/styles/SelectCode.scss +++ b/src/styles/SelectCode.scss @@ -2,7 +2,7 @@ border: 1px; border-color: #cfcfcf; font-size: 1.6vw; - height: 5vh; + height: fit-content; width: fit-content; @media (max-width: 600px) { From a3705eb69d1377e8d1a69dc659192b6deb9cb3c7 Mon Sep 17 00:00:00 2001 From: Yuqi Huang Date: Wed, 21 Feb 2024 11:56:58 -0800 Subject: [PATCH 4/4] minor fix --- src/pages/Exercise6.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pages/Exercise6.tsx b/src/pages/Exercise6.tsx index f33ee26d..b4c6c893 100644 --- a/src/pages/Exercise6.tsx +++ b/src/pages/Exercise6.tsx @@ -23,7 +23,9 @@ const Exercise6: FC = () => {
);