Skip to content

Commit

Permalink
Project
Browse files Browse the repository at this point in the history
  • Loading branch information
tituswe committed Nov 14, 2023
1 parent cdd3f21 commit 28eec62
Show file tree
Hide file tree
Showing 10 changed files with 451 additions and 26 deletions.
13 changes: 2 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
node_modules
client/node_modules
client/package-lock.json
client/.env
question-api/node_modules
question-api/package-lock.json
question-api/.env
code-api/.env
collaboration-api/.env
**/node_modules/
**/package-lock.json
user-api/__pycache__
package-lock.json
.env
.DS_Store
build
dist
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,11 @@ _If you do not have Makefile, then run the following command_
docker-compose up
```

##### You can access the application @ [http://localhost:80](http://localhost:80)
#### You can access the application @ [http://localhost:80](http://localhost:80)

#### Testing

You may sign in with an Admin account, use password 032190, and navigate to the
Questions tab on the sidebar. From there, you have access to a
`Prepopulate Questions (For Testing)` button to prepopulate your local database
with questions.
2 changes: 2 additions & 0 deletions assistant-api/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SERVER_PORT=3030
OPENAI_KEY=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
52 changes: 38 additions & 14 deletions client/src/modules/Questions/QuestionTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import {
} from '@heroicons/react/24/outline';
import QuestionDetailsPopup from '../../components/Questions/QuestionDetailsPopup';
import ConfirmDeleteToast from '../../components/Questions/ConfirmDeleteToast';
import axios from 'axios';
import { toast } from 'react-toastify';

const QuestionTable = () => {
const currentUser = useSelector(selectCurrentUser);
Expand Down Expand Up @@ -78,6 +80,17 @@ const QuestionTable = () => {
setShowDeleteToast(false);
};

// For testing
const onPrepopulate = async () => {
try {
await axios.post('/question-api/questions/prepopulate');
toast.success('Prepopulated questions successfully');
window.location.reload();
} catch (error) {
toast.error('Prepopulated questions failed');
}
};

return !currentUser ? (
<div className="flex h-screen justify-center items-center">
<h1 className="text-lg text-white font-semibold">
Expand All @@ -96,24 +109,24 @@ const QuestionTable = () => {
mode
)}
{showDeleteToast && ConfirmDeleteToast(questionInCreator, onCloseDelete)}
<div className="flex justify-center w-full">
<div className="flex flex-col flex-grow gap-4 w-full p-4">
<div className="flex flex-row justify-center items-center text-neutral-500 bg-slate-50 rounded-2xl p-4 shadow-lg sticky">
<div className="flex justify-center w-full overflow-auto rounded-lg">
<div className="flex flex-col flex-grow gap-4 w-full p-4 overflow-auto">
<div className="flex flex-row justify-center items-center text-neutral-500 bg-slate-50 rounded-lg p-4 shadow-lg sticky">
<div className="w-1/12 flex justify-center">Index</div>
<div className="w-3/12 flex justify-center">Title</div>
<div className="w-4/12 flex justify-center">Description</div>
<div className="w-2/12 flex justify-center">Difficulty</div>
<div className="w-2/12 flex justify-center">Actions</div>
</div>
{questions.length > 0 ? (
<div className="flex flex-col">
<div className="flex flex-col rounded-lg overflow-auto">
{questions.map((question: Question, index: number) => (
<div
key={index}
className={`flex flex-row gap-4 justify-center bg-slate-50 transition ease-in-out duration-200 cursor-pointer p-4 hover:bg-neutral-300 hover:shadow-lg
${index !== 0 && 'border-t'}
${index === 0 && 'rounded-t-2xl'}
${index === questions.length - 1 && 'rounded-b-2xl'}
${index === 0 && 'rounded-t-lg'}
${index === questions.length - 1 && 'rounded-b-lg'}
`}
>
<div className="w-1/12 flex justify-center items-center">
Expand Down Expand Up @@ -161,14 +174,25 @@ const QuestionTable = () => {
</div>
)}
{isAdmin && (
<div className="flex justify-center pt-4">
<button
onClick={() => onOpenCreate()}
className="bg-blue-500 text-white px-4 py-2 rounded-xl"
>
Create Question
</button>
</div>
<>
<div className="flex justify-center pt-4">
<button
onClick={() => onOpenCreate()}
className="bg-blue-500 text-white px-4 py-2 rounded-xl"
>
Create Question
</button>
</div>

<div className="flex justify-center pt-4">
<button
onClick={onPrepopulate}
className="bg-gray-500 text-white px-4 py-2 rounded-xl"
>
Prepopulate Questions (For Testing)
</button>
</div>
</>
)}
</div>
</div>
Expand Down
2 changes: 2 additions & 0 deletions code-api/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SERVER_PORT=9000
JUDGE0_API_KEY=d426e1ac9fmsh893d7f67725c7cdp181502jsnaf8803dbeb4e
2 changes: 2 additions & 0 deletions collaboration-api/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SERVER_PORT=5001
REDIS_URI=redis://:ppredis123@peerprep-redis:6379
2 changes: 2 additions & 0 deletions question-api/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SERVER_PORT=8000
MONGO_URI=mongodb://peerprep-mongo:27017/database
Loading

0 comments on commit 28eec62

Please sign in to comment.