From 20ec5a15093c3bb401a5db98ea4e5c2d483f8a63 Mon Sep 17 00:00:00 2001 From: Victoria Zammit Date: Tue, 27 Dec 2022 14:12:21 -0500 Subject: [PATCH] method 2 first iteration --- client/src/AdminDashboard/EditQuestionButton.tsx | 2 ++ client/src/Question/ResourceComponent.tsx | 1 + client/src/components/EditorGUI.tsx | 2 ++ client/src/components/ResourceDropdown.tsx | 8 +++++--- client/src/util/types/answer.ts | 1 + server/src/models/answer.model.ts | 5 +++++ server/src/services/question.service.ts | 1 + 7 files changed, 17 insertions(+), 3 deletions(-) diff --git a/client/src/AdminDashboard/EditQuestionButton.tsx b/client/src/AdminDashboard/EditQuestionButton.tsx index a0f2beff..910bf3d3 100644 --- a/client/src/AdminDashboard/EditQuestionButton.tsx +++ b/client/src/AdminDashboard/EditQuestionButton.tsx @@ -39,12 +39,14 @@ function EditQuestionButton({ text: '2x edited answer text 1', resultantQuestionId: '63751d7cc26b48cf7f1d9724', resourceContent: '', + resourceLink: '', }; const tempAnswer2: IAnswer = { _id: '6369a04ee0cca0b76f26576b', text: '2x edited answer text 2', resultantQuestionId: '63751d7cc26b48cf7f1d9724', resourceContent: '', + resourceLink: '', }; const tempQuestion: IQuestion = { _id: '63699fdbe0cca0b76f26576a', diff --git a/client/src/Question/ResourceComponent.tsx b/client/src/Question/ResourceComponent.tsx index 275217a7..5906338d 100644 --- a/client/src/Question/ResourceComponent.tsx +++ b/client/src/Question/ResourceComponent.tsx @@ -49,6 +49,7 @@ function ResourceComponent(props: ResourceComponentProps) { ); })} diff --git a/client/src/components/EditorGUI.tsx b/client/src/components/EditorGUI.tsx index 639a04eb..810e0e8d 100644 --- a/client/src/components/EditorGUI.tsx +++ b/client/src/components/EditorGUI.tsx @@ -41,6 +41,7 @@ export default function EditorGUI({ text: text, resultantQuestionId: item.resultantQuestionId, resourceContent: item.resourceContent, + resourceLink: item.resourceLink, }; return newAnswer; } @@ -58,6 +59,7 @@ export default function EditorGUI({ text: item.text, resultantQuestionId: item.resultantQuestionId, resourceContent: text, + resourceLink: text, }; return newAnswer; } diff --git a/client/src/components/ResourceDropdown.tsx b/client/src/components/ResourceDropdown.tsx index ab793c8a..ef43dcf2 100644 --- a/client/src/components/ResourceDropdown.tsx +++ b/client/src/components/ResourceDropdown.tsx @@ -9,15 +9,17 @@ import Collapse from '@mui/material/Collapse'; import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown'; import KeyboardArrowUpIcon from '@mui/icons-material/KeyboardArrowUp'; import { Button, Grid, Typography } from '@mui/material'; +import Link from '@mui/material/Link'; interface ResourceDropdownProps { title: string; content: string; + resourceLink: string; } export default function ResourceDropdown(props: ResourceDropdownProps) { const [open, setOpen] = useState(false); - const { title, content } = props; + const { title, content, resourceLink } = props; return ( {content} - diff --git a/client/src/util/types/answer.ts b/client/src/util/types/answer.ts index 7c1fe0a0..dd2019d8 100644 --- a/client/src/util/types/answer.ts +++ b/client/src/util/types/answer.ts @@ -7,4 +7,5 @@ export interface IAnswer { text: string; resourceContent: string; resultantQuestionId: string; + resourceLink: string; } diff --git a/server/src/models/answer.model.ts b/server/src/models/answer.model.ts index 979d7e37..3db29005 100644 --- a/server/src/models/answer.model.ts +++ b/server/src/models/answer.model.ts @@ -21,6 +21,10 @@ const AnswerSchema = new mongoose.Schema({ type: String, required: true, }, + resourceLink: { + type: String, + required: true, + }, }); interface IAnswer extends mongoose.Document { @@ -28,6 +32,7 @@ interface IAnswer extends mongoose.Document { text: string; resourceContent: string; resultantQuestionId: string; + resourceLink: string; } const Answer = mongoose.model('Answer', AnswerSchema); diff --git a/server/src/services/question.service.ts b/server/src/services/question.service.ts index e339a0e8..afc80056 100644 --- a/server/src/services/question.service.ts +++ b/server/src/services/question.service.ts @@ -13,6 +13,7 @@ async function getAnswerObj(ansId: string) { text: resultantAnswer?.text, resourceContent: resultantAnswer?.resourceContent, resultantQuestionId: resultantAnswer?.resultantQuestionId, + resourceLink: resultantAnswer?.resourceLink, } as IAnswer; return answerObj; }