Skip to content

Commit

Permalink
Merge pull request #111 from tobihy/staging
Browse files Browse the repository at this point in the history
Fix GUI and refactor questionPanel
  • Loading branch information
bokuanT authored Nov 13, 2023
2 parents 0fee27f + 107f7b7 commit ce93235
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 153 deletions.
17 changes: 7 additions & 10 deletions frontend/components/CollabPage/CollabPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
DialogContent,
Stack,
Grid,
Fab,
} from "@mui/material";
import CodeEditor from "./CodeEditor";
import dynamic from "next/dynamic";
Expand Down Expand Up @@ -97,8 +96,8 @@ const CollabPage = () => {
};

const questionPanelProps = {
question_number: questionNumber + 1,
question: questions[questionNumber],
question_number: questionNumber,
question: questions,
};

// Called when Next question button is pressed by this user
Expand Down Expand Up @@ -285,18 +284,16 @@ const CollabPage = () => {
}, []);

return (
<div>
<Grid container={true} spacing={2} sx={{ marginTop: "5px" }}>
<div style={{ margin: "10px", maxHeight: "100vh" }}>
<Grid container spacing={2}>
<Grid item xs={6}>
{questions[questionNumber] ? (
<Box display="flex">
<QuestionPanel {...questionPanelProps} />
) : (
<p>No more questions available.</p>
)}
</Box>
</Grid>
<Grid item xs={6}>
<Stack direction="column" spacing={1}>
<Box display="flex" justifyContent="space-between">
<Box justifyContent="space-between">
{!isEndingSession && (
<CollabPageNavigation
{...collabPageNavigationProps}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ function CollabPageNavigation({
isLastQuestion: isLastQuestion,
};


const EndSessionHandshakeModalProps = {
isEndSessionHandshakeOpen: isEndSessionHandshakeOpen,
setIsEndSessionHandshakeOpen: setIsEndSessionHandshakeOpen,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,42 @@ import { Card, CardContent, Typography } from "@mui/material";

interface QuestionPanelProps {
question_number: number;
question: Question;
question: Question[];
}

function QuestionPanel({ question_number, question }: QuestionPanelProps) {
return (
<Card sx={{ height: "100%", padding: 2 }}>
return question[question_number] ? (
<Card
sx={{
maxHeight: "85vh",
width: "100vh",
padding: 2,
overflowY: "auto",
}}
>
<CardContent>
<Typography
variant="h5"
component="div"
sx={{ marginBottom: 2 }}
>
Question {question_number}:{" "}
{question ? question.title : "No title found"}
Question {question_number + 1}:{" "}
{question
? question[question_number].title
: "No title found"}
</Typography>
{/* Use pre element for preserving white spaces and new lines */}
<pre style={{ whiteSpace: 'pre-wrap', overflowX: 'auto' }}>
{question ? question.description : "No description found"}
<pre style={{ whiteSpace: "pre-wrap", overflowX: "auto" }}>
{question
? question[question_number].description
: "No description found"}
</pre>
</CardContent>
</Card>
) : (
<Card sx={{ maxHeight: "100vh", padding: 2 }}>
<Typography>No more questions available.</Typography>
</Card>
);
}

Expand Down
66 changes: 0 additions & 66 deletions frontend/components/CollabPage/RejectEndSessionSnackBar.tsx

This file was deleted.

65 changes: 0 additions & 65 deletions frontend/components/CollabPage/RejectQuestionSnackBar.tsx

This file was deleted.

8 changes: 4 additions & 4 deletions frontend/components/QuestionsPage/QuestionsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ const QuestionPage = () => {
}
setOpenResetDialog(false);
return response.status;
}
};
const confirmDialogProps = {
open: openResetDialog,
setOpen: setOpenResetDialog,
handleConfirm: setToDefaultQns,
}
};

useEffect(() => {
const fetchQuestions = async () => {
Expand All @@ -122,7 +122,7 @@ const QuestionPage = () => {
addQuestion={addQuestion}
/>
)}
<Box display="flex" padding={2}>
<Box display="flex" maxHeight="80vh" padding={2}>
<QuestionTable
questions={questions}
deleteQuestion={deleteQuestion}
Expand Down Expand Up @@ -163,7 +163,7 @@ const QuestionPage = () => {
>
<AddIcon />
</Fab>
<ConfirmResetDialog {...confirmDialogProps}/>
<ConfirmResetDialog {...confirmDialogProps} />
</>
)}
</main>
Expand Down

0 comments on commit ce93235

Please sign in to comment.