Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
nishant0708 committed Oct 26, 2024
1 parent 24abfbf commit 20065f2
Show file tree
Hide file tree
Showing 25 changed files with 83 additions and 79 deletions.
45 changes: 23 additions & 22 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
{
"env": {
"browser": true,
"es2021": true
},
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended"
],
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"plugins": ["react", "react-hooks"],
"rules": {
"react/react-in-jsx-scope": "off"
}
}
{
"env": {
"browser": true,
"node": true,
"es2021": true
},
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended"
],
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"plugins": ["react", "react-hooks"],
"rules": {
"react/react-in-jsx-scope": "off"
}
}

2 changes: 1 addition & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const App = () => {

if (sessionId) {
axios
.post("iipsonlineexambackend-production.up.railway.app/teacher/verify-session", { sessionId })
.post(`${process.env.REACT_APP_BACKEND_URL}/teacher/verify-session`, { sessionId })
.then((response) => {
if (response.data.valid) {
setIsAuthenticated(true);
Expand Down
2 changes: 1 addition & 1 deletion src/Body/Body.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const Body = () => {
const {questionId} = useParams();
const [question,setQuestion] = useState("");
const location=useLocation();
const url=location.state?.url || "iipsonlineexambackend-production.up.railway.app/student/getQuestionById";
const url=location.state?.url || `${process.env.REACT_APP_BACKEND_URL}/student/getQuestionById`;

// useEffect to observe the width of body-contents
useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/CompletedBody/CompletedBody.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const CompletedBody = () => {
const location = useLocation();

const questionUrl =
location.state?.url || "iipsonlineexambackend-production.up.railway.app/paper/getCompletedQuestion";
location.state?.url || `${process.env.REACT_APP_BACKEND_URL}/paper/getCompletedQuestion`;
const studentId = localStorage.getItem("studentId") || "";
console.log(studentId);

Expand Down
6 changes: 3 additions & 3 deletions src/CompletedEditor/CompletedEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const CompletedEditor = ({ question, onOutput, studentId }) => {
const [runList, setRunList] = useState([]);
// const studentId = localStorage.getItem("studentId") || "";
const paperId = localStorage.getItem("paperId") || "";
const responseUrl = "iipsonlineexambackend-production.up.railway.app/student/getResponse";
const responseUrl = `${process.env.REACT_APP_BACKEND_URL}/student/getResponse`;

useEffect(() => {
console.log("Student ID:", studentId);
Expand Down Expand Up @@ -127,7 +127,7 @@ const CompletedEditor = ({ question, onOutput, studentId }) => {

setLoading(true);
try {
const res = await axios.post(`iipsonlineexambackend-production.up.railway.app/student/compile`, {
const res = await axios.post(`${process.env.REACT_APP_BACKEND_URL}/student/compile`, {
code: code,
language: question?.compilerReq,
input: input || "",
Expand All @@ -152,7 +152,7 @@ const CompletedEditor = ({ question, onOutput, studentId }) => {
const executeCode = async (inputValue) => {
setLoading(true);
try {
const res = await axios.post(`iipsonlineexambackend-production.up.railway.app/student/compile`, {
const res = await axios.post(`${process.env.REACT_APP_BACKEND_URL}/student/compile`, {
code: userCode,
language: question?.compilerReq,
input: inputValue || "",
Expand Down
12 changes: 6 additions & 6 deletions src/CompletedNavbar/CompletedNavbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const CompletedNavbar = () => {
const handleQuestionNavigation = async (direction) => {
try {
const response = await axios.post(
"iipsonlineexambackend-production.up.railway.app/student/getCompletedQuestionNavigation",
`${process.env.REACT_APP_BACKEND_URL}/student/getCompletedQuestionNavigation`,
{ questionId, direction }
);
if (response.status === 200) {
Expand Down Expand Up @@ -79,7 +79,7 @@ const CompletedNavbar = () => {
const handleAllotMarks = async () => {
try {
const response = await axios.post(
"iipsonlineexambackend-production.up.railway.app/student/allocateMarks",
`${process.env.REACT_APP_BACKEND_URL}/student/allocateMarks`,
{
paperId,
studentId,
Expand Down Expand Up @@ -107,7 +107,7 @@ const CompletedNavbar = () => {
try {
// Check if a next question exists
const response = await axios.post(
"iipsonlineexambackend-production.up.railway.app/student/getCompletedQuestionNavigation",
`${process.env.REACT_APP_BACKEND_URL}/student/getCompletedQuestionNavigation`,
{ questionId, direction: "next" }
);
const nextQuestion = response.data?.question;
Expand Down Expand Up @@ -145,7 +145,7 @@ const CompletedNavbar = () => {
useEffect(() => {
if (studentId) {
axios
.post("iipsonlineexambackend-production.up.railway.app/student/getStudentDetailsByStudentId", {
.post(`${process.env.REACT_APP_BACKEND_URL}/student/getStudentDetailsByStudentId`, {
studentId,
})
.then((res) => {
Expand All @@ -160,7 +160,7 @@ const CompletedNavbar = () => {
useEffect(() => {
if (paperId && studentId) {
axios
.post("iipsonlineexambackend-production.up.railway.app/student/getResponse", {
.post(`${process.env.REACT_APP_BACKEND_URL}/student/getResponse`, {
paperId,
studentId,
})
Expand Down Expand Up @@ -192,7 +192,7 @@ const CompletedNavbar = () => {
useEffect(() => {
if (questionId) {
axios
.post("iipsonlineexambackend-production.up.railway.app/paper/getCompletedQuestion", {
.post(`${process.env.REACT_APP_BACKEND_URL}/paper/getCompletedQuestion`, {
questionId,
})
.then((res) => {
Expand Down
4 changes: 2 additions & 2 deletions src/CompletedPaperDashboard/CompletedPaperDashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const CompletedPaperDashboard = () => {
try {
// Map over completedPapers to create an array of evaluation status requests
const evaluationPromises = completedPapers.map((paper) =>
axios.post(`iipsonlineexambackend-production.up.railway.app/paper/paper_evaluate_status`, { paperId: paper._id })
axios.post(`${process.env.REACT_APP_BACKEND_URL}/paper/paper_evaluate_status`, { paperId: paper._id })
);

// Wait for all requests to complete
Expand All @@ -62,7 +62,7 @@ const CompletedPaperDashboard = () => {
const fetchCompletedPapers = async () => {
try {
const response = await axios.post(
`iipsonlineexambackend-production.up.railway.app/paper/getCompletedPapersByTeacherId`,
`${process.env.REACT_APP_BACKEND_URL}/paper/getCompletedPapersByTeacherId`,
{ teacherId }
);
setCompletedPapers(response.data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const CompletedPaperStudentDashboard = () => {

useEffect(() => {
axios
.post("iipsonlineexambackend-production.up.railway.app/student/getStudentByPaperId", { paperId })
.post(`${process.env.REACT_APP_BACKEND_URL}/student/getStudentByPaperId`, { paperId })
.then((res) => {
const sortedStudents = res.data.students.sort((a, b) =>
a.fullName.localeCompare(b.fullName)
Expand All @@ -50,7 +50,7 @@ const CompletedPaperStudentDashboard = () => {
});

axios
.post("iipsonlineexambackend-production.up.railway.app/student/getFirstCompletedQuestionByPaperId", {
.post(`${process.env.REACT_APP_BACKEND_URL}/student/getFirstCompletedQuestionByPaperId`, {
paperId,
})
.then((res) => {
Expand All @@ -61,7 +61,7 @@ const CompletedPaperStudentDashboard = () => {
});

axios
.post("iipsonlineexambackend-production.up.railway.app/paper/getCompletedPaperByPaperId", {
.post(`${process.env.REACT_APP_BACKEND_URL}/paper/getCompletedPaperByPaperId`, {
paperId,
})
.then((res) => {
Expand All @@ -72,7 +72,7 @@ const CompletedPaperStudentDashboard = () => {
console.error(err);
});

axios.post("http://localhost:5000/paper/getEmailSent",{
axios.post(`${process.env.REACT_APP_BACKEND_URL}/paper/getEmailSent`,{
paperId,
})
.then((res)=>{setEmailIsSent(res.data.emailSent)})
Expand All @@ -83,7 +83,7 @@ const CompletedPaperStudentDashboard = () => {
useEffect(() => {
students.forEach((student) => {
axios
.post("iipsonlineexambackend-production.up.railway.app/paper/evaluate_status", {
.post(`${process.env.REACT_APP_BACKEND_URL}/paper/evaluate_status`, {
studentId: student._id,
paperId: paperId,
})
Expand Down Expand Up @@ -150,7 +150,7 @@ const CompletedPaperStudentDashboard = () => {
const sendMailToStudents = () => {
setSendingEmails(true); // Start loading state
axios
.post("iipsonlineexambackend-production.up.railway.app/paper/sendmailtostudent", {
.post(`${process.env.REACT_APP_BACKEND_URL}/paper/sendmailtostudent`, {
paperId,
students,
evaluationStatus,
Expand Down
2 changes: 1 addition & 1 deletion src/Create_paper/Createpaper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const Createpaper = () => {
};

try {
const response = await axios.post('iipsonlineexambackend-production.up.railway.app/paper/create', paperData);
const response = await axios.post(`${process.env.REACT_APP_BACKEND_URL}/paper/create`, paperData);
console.log('Paper created successfully:', response.data);

setModalMessage('Paper created successfully!');
Expand Down
2 changes: 1 addition & 1 deletion src/Edit_paper/Editpaper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const Editpaper = () => {
};

try {
await axios.post('iipsonlineexambackend-production.up.railway.app/paper/edit-paper', paperData);
await axios.post(`${process.env.REACT_APP_BACKEND_URL}/paper/edit-paper`, paperData);

setModalMessage('Paper edited successfully!');
setIsError(false);
Expand Down
2 changes: 1 addition & 1 deletion src/Forgot_Password/Forgot_Password.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const ForgotPassword = () => {
const handleSubmit = async (e) => {
e.preventDefault();
try {
const response = await axios.post("iipsonlineexambackend-production.up.railway.app/teacher/forgot-password", { email });
const response = await axios.post(`${process.env.REACT_APP_BACKEND_URL}/teacher/forgot-password`, { email });
setMessage(response.data.message);
setIsError(false);
setModalIsOpen(true);
Expand Down
6 changes: 3 additions & 3 deletions src/Login/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function Login() {
if (sessionId) {
// Verify the session ID with the backend
axios
.post("iipsonlineexambackend-production.up.railway.app/teacher/verify-session", { sessionId })
.post(`${process.env.REACT_APP_BACKEND_URL}/teacher/verify-session`, { sessionId })
.then((response) => {
if (response.data.valid) {
navigate("/teacherDashboard"); // Navigate to dashboard if session is valid
Expand All @@ -44,7 +44,7 @@ function Login() {
setIsLoading(true);

axios
.post("iipsonlineexambackend-production.up.railway.app/teacher/login", { email, password })
.post(`${process.env.REACT_APP_BACKEND_URL}/teacher/login`, { email, password })
.then((response) => {
console.log(response.data.message);
setShowOtp(true);
Expand All @@ -68,7 +68,7 @@ function Login() {
setIsLoading(true); // Start loading

axios
.post("iipsonlineexambackend-production.up.railway.app/teacher/verify-otp", { email, otp })
.post(`${process.env.REACT_APP_BACKEND_URL}/teacher/verify-otp`, { email, otp })
.then((response) => {
const { sessionId, message, teacherId, name, email, mobileNumber,photo } =
response.data;
Expand Down
4 changes: 3 additions & 1 deletion src/Navbar/Navbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const Navbar = () => {
const [open, setOpen] = useState(false);
const navigate = useNavigate();
const location = useLocation();
const photo = localStorage.getItem("photo") || defaultPhoto;

const responsive = () => {
const sidebar = document.getElementsByClassName("navbar-sidebar")[0];
if (!open) {
Expand All @@ -33,7 +35,7 @@ const Navbar = () => {
<img
alt="Image"
className="pfp"
src={localStorage.getItem("photo")||defaultPhoto}
src={photo}
width="35"
height="35"

Expand Down
8 changes: 4 additions & 4 deletions src/Profile/profile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const Profile = () => {
useEffect(() => {
const fetchTeacherDetails = async () => {
try {
const response = await axios.post('iipsonlineexambackend-production.up.railway.app/teacher/getteacherDetails', {
const response = await axios.post(`${process.env.REACT_APP_BACKEND_URL}/teacher/getteacherDetails`, {
teacherId: localStorage.getItem("teacherId"),
});

Expand Down Expand Up @@ -107,7 +107,7 @@ const Profile = () => {
}

// Merging /edit API call
axios.post('iipsonlineexambackend-production.up.railway.app/teacher/edit', {
axios.post(`${process.env.REACT_APP_BACKEND_URL}/teacher/edit`, {
teacherId: localStorage.getItem("teacherId"),
...newProfileData,
})
Expand Down Expand Up @@ -152,14 +152,14 @@ const Profile = () => {

try {

const uploadResponse = await axios.post("iipsonlineexambackend-production.up.railway.app/paper/upload", formData);
const uploadResponse = await axios.post(`${process.env.REACT_APP_BACKEND_URL}/paper/upload`, formData);

const imageUrl = uploadResponse.data.url;


const teacherId = localStorage.getItem("teacherId");

await axios.post("iipsonlineexambackend-production.up.railway.app/teacher/set-photo", {
await axios.post(`${process.env.REACT_APP_BACKEND_URL}/teacher/set-photo`, {
teacherId: teacherId,
photo: imageUrl
});
Expand Down
12 changes: 6 additions & 6 deletions src/QuestionPaperDashboard/QuestionPaperDashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const QuestionPaperDashboard = () => {
const fetchQuestions = async () => {
try {
const res = await axios.post(
"iipsonlineexambackend-production.up.railway.app/paper/questionsbyid",
`${process.env.REACT_APP_BACKEND_URL}/paper/questionsbyid`,
{ paperId }
);
setQuestions(res.data);
Expand All @@ -49,7 +49,7 @@ const QuestionPaperDashboard = () => {
const fetchpaperdetails = async () => {
try {
const res = await axios.post(
"iipsonlineexambackend-production.up.railway.app/paper/getPapersdetails",
`${process.env.REACT_APP_BACKEND_URL}/paper/getPapersdetails`,
{ paperId }
);
setpaperdetails(res.data[0]);
Expand Down Expand Up @@ -81,7 +81,7 @@ const QuestionPaperDashboard = () => {
const deleteQuestion = async (question) => {
try {
const response = await axios.post(
"iipsonlineexambackend-production.up.railway.app/paper/delete-question",
`${process.env.REACT_APP_BACKEND_URL}/paper/delete-question`,
{ _id: question._id }
);
setQuestions((prevQuestions) =>
Expand Down Expand Up @@ -111,7 +111,7 @@ const QuestionPaperDashboard = () => {
const duplicateQuestion = async (question) => {
console.log(question);
const response = await axios.post(
`iipsonlineexambackend-production.up.railway.app/paper/duplicate-question`,
`${process.env.REACT_APP_BACKEND_URL}/paper/duplicate-question`,
{ question }
);
if (response.status === 201) {
Expand All @@ -138,7 +138,7 @@ const QuestionPaperDashboard = () => {
const handleSubmit = async () => {
try {
const response = await axios.post(
"iipsonlineexambackend-production.up.railway.app/paper/submitpaper",
`${process.env.REACT_APP_BACKEND_URL}/paper/submitpaper`,
{ paperId }
);

Expand Down Expand Up @@ -205,7 +205,7 @@ const QuestionPaperDashboard = () => {
navigate(`/preview/${question._id}`,
{state:
{
url: "iipsonlineexambackend-production.up.railway.app/paper/getQuestionsDetailsByQuestionId"
url: `${process.env.REACT_APP_BACKEND_URL}/paper/getQuestionsDetailsByQuestionId`
}
}
);
Expand Down
Loading

0 comments on commit 20065f2

Please sign in to comment.