Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-added new header (readingHeader) #183

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions packages/frontend/src/components/CountdownTimer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ import React, { useState, useEffect } from 'react';

interface Props {
minutes: number; // Number of minutes for countdown
onTimeUp: () => void;

}

const CountdownTimer: React.FC<Props> = ({ minutes, onTimeUp }) => {
const CountdownTimer: React.FC<Props> = ({ minutes }) => {
const [remainingTime, setRemainingTime] = useState<number>(minutes * 60); // Convert minutes to seconds

useEffect(() => {
const timer = setInterval(() => {
setRemainingTime(prevTime => {
if (prevTime <= 0) {
clearInterval(timer);
onTimeUp();

return 0;
} else {
return prevTime - 1;
Expand All @@ -22,7 +22,7 @@ const CountdownTimer: React.FC<Props> = ({ minutes, onTimeUp }) => {
}, 1000);

return () => clearInterval(timer);
}, [minutes, onTimeUp]);
}, [minutes]);

const formatTime = (time: number): string => {
const minutes = Math.floor(time / 60);
Expand All @@ -36,7 +36,7 @@ const CountdownTimer: React.FC<Props> = ({ minutes, onTimeUp }) => {

return (
<div className="remaining-time">
Remaining Time: {formatTime(remainingTime)}
{formatTime(remainingTime)} min
</div>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const DiagramCompletionQuestionComponent = ({
handleInputChange(subQuestionIndex, partIndex, e.target.value)
}
placeholder="answer"
className="lr-input"
/>
)}
</React.Fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ export const ListSelectionQuestionComponent = ({
<select
value={answer[index]}
onChange={e => handleSelectionChange(index, e.target.value)}
className="lr-select"
>
<option value="">Select an answer</option>
<option value="" >{index+1}</option>
{question.SubQuestions[index].Choices.map((choice, choiceIndex) => (
<option key={choiceIndex} value={choice}>
{choice}
Expand All @@ -45,10 +46,11 @@ export const ListSelectionQuestionComponent = ({
<div>
<p>{question.Question}</p>
<h4>{question.ListTitle}</h4>
<p className="whitespace-pre-line">{question.List}</p>
<p className="whitespace-pre-line mb-2" >{question.List}</p>
<ul>
{question.SubQuestions.map((subQuestion, index) => (
<li key={index}>
<li key={index} className="mb-4">
<span className="font-semibold"> {index + 1}. </span>
{renderQuestionTextWithSelects(subQuestion.QuestionText, index)}
</li>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ export const McqQuestionsComponent = ({
<div>
{choices.map((choice, choiceIndex) => (
<div key={choiceIndex} style={{ marginBottom: '5px' }}>
<label>
<label className="cursor-pointer">
<input
type="radio"
name={`question-${index}`}
value={choice}
checked={answer[index] === choice}
onChange={e => handleSelectionChange(index, e.target.value)}
className="mr-2"
/>
{choice}
</label>
Expand All @@ -47,8 +48,9 @@ export const McqQuestionsComponent = ({
<select
value={answer[index]}
onChange={e => handleSelectionChange(index, e.target.value)}
className="lr-select"
>
<option value="">Select an answer</option>
<option value="">{index+1}</option>
{question.SubQuestions[index].Choices.map((choice, choiceIndex) => (
<option key={choiceIndex} value={choice}>
{choice}
Expand All @@ -63,11 +65,15 @@ export const McqQuestionsComponent = ({
<div>
<p>{question.Question}</p>
<ul>

{question.SubQuestions.map((subQuestion, index) => (
<li key={index}>
<li key={index} className='mt-5'>

{question.QuestionType === 'Multiple Choice' ? (
<p>{subQuestion.QuestionText}</p> // Text for Multiple Choice
) : null}


{question.QuestionType === 'Multiple Choice'
? renderRadioButtons(subQuestion.Choices, index)
: renderQuestionTextWithSelects(subQuestion.QuestionText, index)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@ export const MultipleAnswersQuestionComponent = ({
<p>{subQuestion.QuestionText}</p>
{subQuestion.Choices.map((choice, choiceIndex) => (
<div key={choiceIndex}>
<label>
<label className="cursor-pointer">
<input
type="checkbox"
checked={answer[subIndex].includes(choice)}
onChange={() => handleCheckboxChange(subIndex, choice)}
className="mr-2"
/>
{choice}
</label>
Expand Down
6 changes: 3 additions & 3 deletions packages/frontend/src/components/Reading/PassageComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ export const PassageComponent = ({
}) => {
return (
<div>
<h1>Part {PartIndex}</h1>
<h1>{readingPart.PassageTitle}</h1>
<p style={{ whiteSpace: 'pre-line' }}>{readingPart.Passage}</p>
<h1 className="text-2xl text-blue-4 mb-7">Part {PartIndex}</h1>
<h1 className='text-2xl text-blue-4 font-bold mb-7'>{readingPart.PassageTitle}</h1>
<p style={{ whiteSpace: 'pre-line' }} className='text-justify'>{readingPart.Passage}</p>
</div>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const QuestionsComponent = ({
<>
{questions.map((question, index) => (
<div key={index} className="mb-10">
<p>
<p className='mb-3'>
Question {index + 1}, {question.QuestionType}:
</p>
{renderQuestionComponent(
Expand Down
23 changes: 23 additions & 0 deletions packages/frontend/src/components/Reading/ReadingHeader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

import CountdownTimer from '../CountdownTimer'; // Assuming CountdownTimer is the name of your countdown timer component

interface ExamsHeaderProps {
duration: number; // Duration of the exam in minutes
section: string;
}

export default function Exams({ duration, section }: ExamsHeaderProps) {


return (
<div className='bg-blue-4 flex justify-between items-center'>
<div>
<h2 className='text-1xl text-white font-bold ml-5'>{section}</h2>
</div>
<div >
<CountdownTimer minutes={duration} />
</div>

</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,17 @@ export const SummaryCompletionQuestionComponent = ({
const parts = text.split('-answer-');
return parts.map((part, partIndex) => (
<React.Fragment key={partIndex}>
{part}
<span className="leading-relaxed">{part}</span>
{partIndex < parts.length - 1 && (
<input
type="text"
value={answer[subQuestionIndex][partIndex]}
onChange={e =>
handleInputChange(subQuestionIndex, partIndex, e.target.value)
}
placeholder="Type your answer here"
className="lr-input"
// className="border border-blue-4 px-2 rounded-md w-52 leading-tight"
// className="border border-blue-4 rounded-md leading-tight"
/>
)}
</React.Fragment>
Expand All @@ -52,7 +54,7 @@ export const SummaryCompletionQuestionComponent = ({
<ul>
{question.SubQuestions.map((subQuestion, index) => (
<li key={index}>
<p>
<p className="text-justify mt-5">
{renderQuestionTextWithInputs(subQuestion.QuestionText, index)}
</p>
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const TableCompletionQuestionComponent = ({
type="text"
value={answer[rowIndex][index] || ''} // Bind input value to state
onChange={event => handleInputChange(event, rowIndex, index)} // Handle input change
className="lr-input"
/>
</React.Fragment>
);
Expand Down
79 changes: 0 additions & 79 deletions packages/frontend/src/components/examsHeader.tsx

This file was deleted.

11 changes: 10 additions & 1 deletion packages/frontend/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@
max-width: 1440px;
margin: 0 auto;
}

.lr-input {
@apply border bg-gray-200 px-2 rounded-md w-48 leading-tight outline-blue-3 outline-1 outline-offset-2;
}

.lr-select {
@apply bg-gray-200 rounded-md text-center py-1 px-4 h-7 outline-blue-3 outline-1 outline-offset-1;
}
}

@layer utilities {
Expand Down Expand Up @@ -56,7 +64,8 @@
.progress-ring__circle {
transition: stroke-dashoffset 0.35s;
transform: rotate(-90deg);
transform-origin: 50% 50%;}
transform-origin: 50% 50%;
}
/* Customize scrollbar */
::-webkit-scrollbar {
width: 12px; /* Width of the scrollbar */
Expand Down
Loading
Loading