2025-10-27 11:46:51 -03:00
|
|
|
import history from "../history";
|
|
|
|
|
import { authenticationService } from "../_services";
|
|
|
|
|
import { TEACHER_API, INSTITUTE_API, LOAD_CLASSES, LOAD_LANGAUGES, LOAD_QUESTIONTYPES, LOAD_TOPICS_PREFIX } from "../_services/config";
|
|
|
|
|
|
|
|
|
|
// checking role from login -
|
|
|
|
|
function checkRole() {
|
|
|
|
|
const role = authenticationService.currentUserValue?.role_id;
|
2025-10-29 18:10:29 -03:00
|
|
|
const GATEWAY = role === 3 ? TEACHER_API : role === 2 && INSTITUTE_API;
|
2025-10-27 11:46:51 -03:00
|
|
|
// console.log(role, GATEWAY);
|
|
|
|
|
return GATEWAY;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const selectorService = {
|
|
|
|
|
loadCategory,
|
|
|
|
|
loadSubjects,
|
|
|
|
|
loadSubCategory,
|
|
|
|
|
loadQuestionTypes,
|
|
|
|
|
loadQuestions,
|
|
|
|
|
loadComplexity,
|
|
|
|
|
updateBookMark,
|
|
|
|
|
loadLanguages,
|
|
|
|
|
loadClasses,
|
|
|
|
|
deleteQuestions,
|
|
|
|
|
deletePractice,
|
|
|
|
|
deleteExam,
|
|
|
|
|
getQuestion,
|
|
|
|
|
getQuestionTypes,
|
|
|
|
|
createQuestion,
|
|
|
|
|
createBulkQuestion,
|
|
|
|
|
cloneQuestionToLanguage,
|
|
|
|
|
editQuestion,
|
|
|
|
|
myQuestion,
|
|
|
|
|
createExam,
|
|
|
|
|
createPractise,
|
|
|
|
|
updateExam,
|
|
|
|
|
attachSectionToExam,
|
|
|
|
|
getExamDetails,
|
|
|
|
|
getPracticeDetails,
|
|
|
|
|
draftQuestion,
|
|
|
|
|
savedDraftQuestion,
|
|
|
|
|
submitcreateQuestion,
|
|
|
|
|
attachQuestionsToExam,
|
|
|
|
|
attachQuestionsToPractice,
|
|
|
|
|
loadSections,
|
|
|
|
|
loadSectionsForPractice,
|
|
|
|
|
arrangeSectionsFromExam,
|
|
|
|
|
loadReviewQuestions,
|
|
|
|
|
loadReviewQuestionsPractice,
|
|
|
|
|
detachQuestion,
|
|
|
|
|
detachQuestionPractice,
|
|
|
|
|
createBatch,
|
|
|
|
|
addToBatch,
|
|
|
|
|
deleteFromBatch,
|
|
|
|
|
deleteBatch,
|
|
|
|
|
deleteClass,
|
|
|
|
|
deleteExamBatch,
|
|
|
|
|
getAllBatch,
|
|
|
|
|
getExamBatch,
|
|
|
|
|
getPracticeBatch,
|
|
|
|
|
getStudentsOfBatch,
|
|
|
|
|
getClassDetails,
|
|
|
|
|
markQuestions,
|
|
|
|
|
markQuestionsPractice,
|
|
|
|
|
publishExam,
|
|
|
|
|
publishPractice,
|
|
|
|
|
loadQuestionsBookmark,
|
|
|
|
|
draftExam,
|
|
|
|
|
draftPractice,
|
|
|
|
|
livePractice,
|
|
|
|
|
upcomingPractice,
|
|
|
|
|
draftPracticeCategory,
|
|
|
|
|
livePracticeCategory,
|
|
|
|
|
upcomingPracticeCategory,
|
|
|
|
|
liveExam,
|
|
|
|
|
upcomingExam,
|
|
|
|
|
expiredExam,
|
|
|
|
|
loadUpcomingExam,
|
|
|
|
|
getAllClass,
|
|
|
|
|
loadLiveExams,
|
|
|
|
|
createExamAttempt,
|
|
|
|
|
createClass,
|
|
|
|
|
addBatchToExam,
|
|
|
|
|
addBatchToPractice,
|
|
|
|
|
addSubjectToClass,
|
|
|
|
|
removeSubjectFromClass,
|
|
|
|
|
removeTopicFromClass,
|
|
|
|
|
addTopicToClass,
|
|
|
|
|
updateClass,
|
|
|
|
|
getExamAttempt,
|
|
|
|
|
updateExamStatus,
|
|
|
|
|
updateBatchName,
|
|
|
|
|
endExam,
|
|
|
|
|
pauseExam,
|
|
|
|
|
getAllUser,
|
|
|
|
|
loadReport,
|
|
|
|
|
getAllBatchForClass,
|
|
|
|
|
addBatchesToExam,
|
|
|
|
|
detachBatchesFromExam,
|
|
|
|
|
detachBatchFromPractice,
|
|
|
|
|
livePracticeExams,
|
|
|
|
|
createPracticeAttempt,
|
|
|
|
|
getPracticeAttempt,
|
|
|
|
|
stopPublishedExam,
|
2025-10-29 18:10:29 -03:00
|
|
|
heartbeat,
|
2025-10-27 11:46:51 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
async function stopPublishedExam(examId) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const currentClass = authenticationService.currentClassValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "PUT",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
// /v{version}/Exams/{exam_id}/StopExam
|
|
|
|
|
try {
|
|
|
|
|
const res = await fetch(`${checkRole()}/Exams/${examId}/StopExam`, requestOptions);
|
|
|
|
|
const data = await res.json();
|
2025-10-29 18:10:29 -03:00
|
|
|
if (res.ok && +data.status.code > 0) {
|
2025-10-27 11:46:51 -03:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
throw "Something went wrong";
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.log(error);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function loadReport(examId) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
if (currentUser.language_code === null) {
|
|
|
|
|
currentUser.language_code = "En";
|
|
|
|
|
currentUser.language_name = "English";
|
|
|
|
|
}
|
|
|
|
|
return fetch(
|
|
|
|
|
"https://api.odiprojects.com/api-institute/v1/" +
|
2025-10-29 18:10:29 -03:00
|
|
|
currentUser.language_code +
|
|
|
|
|
"/ExamAttempts/" +
|
|
|
|
|
examId +
|
|
|
|
|
"/Report",
|
2025-10-27 11:46:51 -03:00
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
console.log(data);
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
// console.error('Error:', error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-29 18:10:29 -03:00
|
|
|
async function pauseExam(attemptId) {
|
2025-10-27 11:46:51 -03:00
|
|
|
const currentUser = authenticationService.currentUserValue;
|
2025-10-29 18:10:29 -03:00
|
|
|
if (!currentUser?.jwtToken) {
|
|
|
|
|
console.error("❌ No valid user token found");
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const languageCode = currentUser.language_code || "En";
|
|
|
|
|
const url = `https://api.odiprojects.com/api-student/v1/${languageCode}/ExamAttempts/${attemptId}/Pause`;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const response = await fetch(url, {
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: {
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: `Bearer ${currentUser.jwtToken}`,
|
|
|
|
|
},
|
2025-10-27 11:46:51 -03:00
|
|
|
});
|
2025-10-29 18:10:29 -03:00
|
|
|
|
|
|
|
|
if (!response.ok) {
|
|
|
|
|
console.error(`❌ Failed to pause exam (HTTP ${response.status})`);
|
|
|
|
|
// Optional: handle session expiration
|
|
|
|
|
// if (response.status === 401) {
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
// }
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const data = await response.json();
|
|
|
|
|
console.log("⏸️ Exam paused successfully:", data);
|
|
|
|
|
return data;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error("🚨 Error pausing exam:", error);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2025-10-27 11:46:51 -03:00
|
|
|
}
|
|
|
|
|
|
2025-10-29 18:10:29 -03:00
|
|
|
async function endExam(attemptId, payload) {
|
2025-10-27 11:46:51 -03:00
|
|
|
const currentUser = authenticationService.currentUserValue;
|
2025-10-29 18:10:29 -03:00
|
|
|
if (!currentUser?.jwtToken) {
|
|
|
|
|
console.error("❌ No valid user token found");
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const languageCode = currentUser.language_code || "En";
|
|
|
|
|
const url = `https://api.odiprojects.com/api-student/v1/${languageCode}/ExamAttempts/${attemptId}/End`;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const response = await fetch(url, {
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: {
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: `Bearer ${currentUser.jwtToken}`,
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify(payload),
|
2025-10-27 11:46:51 -03:00
|
|
|
});
|
2025-10-29 18:10:29 -03:00
|
|
|
|
|
|
|
|
if (!response.ok) {
|
|
|
|
|
console.error(`❌ Failed to end exam (HTTP ${response.status})`);
|
|
|
|
|
// Optional: handle expired sessions
|
|
|
|
|
// if (response.status === 401) {
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
// }
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const data = await response.json();
|
|
|
|
|
console.log("✅ Exam ended successfully:", data);
|
|
|
|
|
return data;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error("🚨 Error ending exam:", error);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2025-10-27 11:46:51 -03:00
|
|
|
}
|
|
|
|
|
|
2025-10-29 18:10:29 -03:00
|
|
|
async function heartbeat(attemptId) {
|
2025-10-27 11:46:51 -03:00
|
|
|
const currentUser = authenticationService.currentUserValue;
|
2025-10-29 18:10:29 -03:00
|
|
|
if (!currentUser?.jwtToken) {
|
|
|
|
|
console.error("❌ No valid user token found");
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const url = `https://api.odiprojects.com/api-student/v1/ExamAttempts/${attemptId}/Heartbeat`;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const response = await fetch(url, {
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: {
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: `Bearer ${currentUser.jwtToken}`,
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify({
|
|
|
|
|
attempt_id: attemptId,
|
|
|
|
|
timestamp: new Date().toISOString(),
|
|
|
|
|
}),
|
2025-10-27 11:46:51 -03:00
|
|
|
});
|
2025-10-29 18:10:29 -03:00
|
|
|
|
|
|
|
|
if (!response.ok) {
|
|
|
|
|
console.error(`❌ Heartbeat failed (HTTP ${response.status})`);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const data = await response.json();
|
|
|
|
|
console.log("💓 Heartbeat sent successfully:", data);
|
|
|
|
|
return data; // ✅ Return the parsed response data
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error("🚨 Error sending heartbeat:", error);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function updateExamStatus(attemptId, payload) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
if (!currentUser?.jwtToken) {
|
|
|
|
|
console.error("❌ No valid user token found");
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const url = `https://api.odiprojects.com/api-student/v1/ExamAttempts/${attemptId}/UpdateAnswer`;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const response = await fetch(url, {
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: {
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: `Bearer ${currentUser.jwtToken}`,
|
|
|
|
|
},
|
|
|
|
|
body: payload,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (!response.ok) {
|
|
|
|
|
console.error(`❌ Failed to update exam status (HTTP ${response.status})`);
|
|
|
|
|
// Optional: Handle unauthorized users
|
|
|
|
|
// if (response.status === 401) {
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
// }
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const data = await response.json();
|
|
|
|
|
console.log("✅ Exam status updated:", data);
|
|
|
|
|
return data;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error("🚨 Error updating exam status:", error);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2025-10-27 11:46:51 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function updateBatchName(obj) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const currentClass = authenticationService.currentClassValue;
|
|
|
|
|
obj.classId = currentClass;
|
|
|
|
|
obj.isActive = true;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "PUT",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify(obj),
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
return fetch(
|
|
|
|
|
"https://api.odiprojects.com/api-institute/v1/UserGroups/" + obj.id,
|
|
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
console.log(data);
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
// console.error('Error:', error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getPracticeAttempt(practiceId) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
if (currentUser.language_code === null) {
|
|
|
|
|
currentUser.language_code = "En";
|
|
|
|
|
currentUser.language_name = "English";
|
|
|
|
|
}
|
|
|
|
|
return fetch(
|
|
|
|
|
"https://api.odiprojects.com/api-institute/v1/" +
|
2025-10-29 18:10:29 -03:00
|
|
|
currentUser.language_code +
|
|
|
|
|
"/PracticeAttempts/" +
|
|
|
|
|
practiceId +
|
|
|
|
|
"/Revision",
|
2025-10-27 11:46:51 -03:00
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
console.log(data);
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
// console.error('Error:', error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2025-10-29 18:10:29 -03:00
|
|
|
async function getExamAttempt(attemptId) {
|
2025-10-27 11:46:51 -03:00
|
|
|
const currentUser = authenticationService.currentUserValue;
|
2025-10-29 18:10:29 -03:00
|
|
|
if (!currentUser?.jwtToken) {
|
|
|
|
|
console.error("❌ No valid user token found");
|
|
|
|
|
return null;
|
2025-10-27 11:46:51 -03:00
|
|
|
}
|
2025-10-29 18:10:29 -03:00
|
|
|
|
|
|
|
|
const languageCode = currentUser.language_code || "En";
|
|
|
|
|
const languageName = currentUser.language_name || "English";
|
|
|
|
|
|
|
|
|
|
const url = `https://api.odiprojects.com/api-student/v1/${languageCode}/ExamAttempts/${attemptId}/Questions`;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const response = await fetch(url, {
|
|
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: `Bearer ${currentUser.jwtToken}`,
|
|
|
|
|
},
|
2025-10-27 11:46:51 -03:00
|
|
|
});
|
2025-10-29 18:10:29 -03:00
|
|
|
|
|
|
|
|
if (!response.ok) {
|
|
|
|
|
console.error(`❌ Request failed with status: ${response.status}`);
|
|
|
|
|
// Optional: handle unauthorized user
|
|
|
|
|
// if (response.status === 401) {
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
// }
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const data = await response.json();
|
|
|
|
|
console.log("✅ Exam attempt data:", data);
|
|
|
|
|
return data;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error("🚨 Error fetching exam attempt:", error);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2025-10-27 11:46:51 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getAllUser(page_size, page_number) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
return fetch(
|
2025-10-29 18:10:29 -03:00
|
|
|
checkRole() + "/users?" + `pageNumber=${page_number}&pageSize=${page_size}`,
|
2025-10-27 11:46:51 -03:00
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
throw 'Something went wrong';
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
console.log(data);
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
2025-10-29 18:10:29 -03:00
|
|
|
console.error('Error:', error);
|
|
|
|
|
throw "Something went wrong";
|
2025-10-27 11:46:51 -03:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getAllBatch() {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const currentClass = authenticationService.currentClassValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
return fetch(
|
|
|
|
|
// "https://api.odiprojects.com/api-institute/v1"+
|
|
|
|
|
checkRole() +
|
|
|
|
|
"/UserGroups/Classes/" +
|
2025-10-29 18:10:29 -03:00
|
|
|
currentClass,
|
2025-10-27 11:46:51 -03:00
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
console.log(response);
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
console.log(data);
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
console.log(error);
|
|
|
|
|
// console.error('Error:', error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getExamBatch(obj) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const currentClass = authenticationService.currentClassValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
return fetch(
|
|
|
|
|
// "https://api.odiprojects.com/api-institute/v1"+
|
|
|
|
|
checkRole() +
|
|
|
|
|
"/Exams/" + obj.id + "/Batches",
|
|
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
console.log(response);
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
console.log(data);
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
console.log(error);
|
|
|
|
|
// console.error('Error:', error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getPracticeBatch(obj) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
return fetch(
|
|
|
|
|
// "https://api.odiprojects.com/api-institute/v1"+
|
|
|
|
|
checkRole() +
|
|
|
|
|
"/Practices/" + obj.id + "/Batches",
|
|
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
// console.log(response);
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
// console.log(data);
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
// console.log(error);
|
|
|
|
|
throw error;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getStudentsOfBatch(id) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
return fetch(
|
|
|
|
|
"https://api.odiprojects.com/api-institute/v1/UserGroups/" + id + "/Users",
|
|
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
console.log(response);
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
throw "Something went wrong.."
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
console.log(data);
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
console.log(error);
|
|
|
|
|
throw "Something went wrong, please try again"
|
|
|
|
|
// console.error('Error:', error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getClassDetails(id) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
return fetch(
|
|
|
|
|
"https://api.odiprojects.com/api-institute/v1/Classes/" + id + "/Structure",
|
|
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
console.log(response);
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
throw "Something went wrong, please try again"
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
// console.log(data);
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
console.log(error);
|
|
|
|
|
throw error;
|
|
|
|
|
// console.error('Error:', error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function createPracticeAttempt(practiceId) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
if (currentUser.language_code === null) {
|
|
|
|
|
currentUser.language_code = "En";
|
|
|
|
|
currentUser.language_name = "English";
|
|
|
|
|
}
|
|
|
|
|
return fetch(
|
|
|
|
|
"https://api.odiprojects.com/api-institute/v1/" +
|
2025-10-29 18:10:29 -03:00
|
|
|
currentUser.language_code +
|
|
|
|
|
"/PracticeAttempts/" +
|
|
|
|
|
practiceId + "/CreateAttempt",
|
2025-10-27 11:46:51 -03:00
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
console.log(data);
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
// console.error('Error:', error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-29 18:10:29 -03:00
|
|
|
async function createExamAttempt(examId) {
|
2025-10-27 11:46:51 -03:00
|
|
|
const currentUser = authenticationService.currentUserValue;
|
2025-10-29 18:10:29 -03:00
|
|
|
if (!currentUser?.jwtToken) {
|
|
|
|
|
console.error("❌ No valid user token found");
|
|
|
|
|
return null;
|
2025-10-27 11:46:51 -03:00
|
|
|
}
|
2025-10-29 18:10:29 -03:00
|
|
|
|
|
|
|
|
const languageCode = currentUser.language_code || "En";
|
|
|
|
|
const languageName = currentUser.language_name || "English";
|
|
|
|
|
|
|
|
|
|
const url = `https://api.odiprojects.com/api-student/v1/${languageCode}/ExamAttempts/${examId}`;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const response = await fetch(url, {
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: {
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: `Bearer ${currentUser.jwtToken}`,
|
|
|
|
|
},
|
2025-10-27 11:46:51 -03:00
|
|
|
});
|
2025-10-29 18:10:29 -03:00
|
|
|
|
|
|
|
|
console.log(response);
|
|
|
|
|
|
|
|
|
|
if (!response.ok) {
|
|
|
|
|
console.error(`❌ Request failed with status: ${response.status}`);
|
|
|
|
|
// Optionally handle unauthorized user
|
|
|
|
|
// if (response.status === 401) {
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
// }
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const data = await response.json();
|
|
|
|
|
console.log("✅ Exam attempt created:", data);
|
|
|
|
|
return data;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error("🚨 Error creating exam attempt:", error);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2025-10-27 11:46:51 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function loadLiveExams(jsonObj) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
let queryStr = "";
|
|
|
|
|
queryStr = "?";
|
|
|
|
|
if (jsonObj.pageSize !== undefined) {
|
|
|
|
|
queryStr = queryStr + `pageSize=${jsonObj.pageSize}`;
|
|
|
|
|
}
|
|
|
|
|
if (jsonObj.pageNumber !== undefined) {
|
|
|
|
|
queryStr = queryStr + `&pageNumber=${jsonObj.pageNumber}`;
|
|
|
|
|
}
|
|
|
|
|
if (currentUser.language_code === null) {
|
|
|
|
|
currentUser.language_code = "En";
|
|
|
|
|
currentUser.language_name = "English";
|
|
|
|
|
}
|
|
|
|
|
return fetch(
|
2025-10-29 18:10:29 -03:00
|
|
|
"https://api.odiprojects.com/api-student/v1/" +
|
|
|
|
|
currentUser.language_code +
|
|
|
|
|
"/Batches/" +
|
|
|
|
|
jsonObj.batch +
|
|
|
|
|
"/LiveExams" +
|
|
|
|
|
queryStr,
|
2025-10-27 11:46:51 -03:00
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
console.log(response);
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
authenticationService.logout();
|
|
|
|
|
window.location.reload(true);
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
console.log(data);
|
|
|
|
|
return data;
|
|
|
|
|
})
|
2025-10-29 18:10:29 -03:00
|
|
|
.catch((error) => { });
|
2025-10-27 11:46:51 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function loadUpcomingExam(jsonObj) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
let queryStr = "";
|
|
|
|
|
queryStr = "?";
|
|
|
|
|
if (jsonObj.pageSize !== undefined) {
|
|
|
|
|
queryStr = queryStr + `pageSize=${jsonObj.pageSize}`;
|
|
|
|
|
}
|
|
|
|
|
if (jsonObj.pageNumber !== undefined) {
|
|
|
|
|
queryStr = queryStr + `&pageNumber=${jsonObj.pageNumber}`;
|
|
|
|
|
}
|
|
|
|
|
if (currentUser.language_code === null) {
|
|
|
|
|
currentUser.language_code = "En";
|
|
|
|
|
currentUser.language_name = "English";
|
|
|
|
|
}
|
|
|
|
|
return fetch(
|
|
|
|
|
"https://api.odiprojects.com/api-institute/v1/" +
|
2025-10-29 18:10:29 -03:00
|
|
|
currentUser.language_code +
|
|
|
|
|
"/Batches/" +
|
|
|
|
|
jsonObj.batch +
|
|
|
|
|
"/UpcomingExams" +
|
|
|
|
|
queryStr,
|
2025-10-27 11:46:51 -03:00
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
console.log(response);
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
authenticationService.logout();
|
|
|
|
|
window.location.reload(true);
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
console.log(data);
|
|
|
|
|
return data;
|
|
|
|
|
})
|
2025-10-29 18:10:29 -03:00
|
|
|
.catch((error) => { });
|
2025-10-27 11:46:51 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getAllClass() {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return fetch(
|
|
|
|
|
"https://api.odiprojects.com/api-institute/v1/Classes",
|
|
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
console.log(response);
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// authenticationService.logout();
|
|
|
|
|
// window.location.reload(true);
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
console.log(data);
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
console.log(error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//console.log(myQuestion())
|
|
|
|
|
function publishExam(examId, json) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "PUT",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify(json),
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
if (currentUser.language_code === null) {
|
|
|
|
|
currentUser.language_code = "En";
|
|
|
|
|
currentUser.language_name = "English";
|
|
|
|
|
}
|
|
|
|
|
return fetch(
|
|
|
|
|
// "https://api.odiprojects.com/api-institute/v1"+
|
|
|
|
|
checkRole() +
|
|
|
|
|
"/Exams/" + examId + "/Publish",
|
|
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
console.log(data);
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
// console.error('Error:', error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function publishPractice(practiceId, json) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "PUT",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify(json),
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
if (currentUser.language_code === null) {
|
|
|
|
|
currentUser.language_code = "En";
|
|
|
|
|
currentUser.language_name = "English";
|
|
|
|
|
}
|
|
|
|
|
return fetch(
|
|
|
|
|
// "https://api.odiprojects.com/api-institute/v1"+
|
|
|
|
|
checkRole() +
|
|
|
|
|
"/Practices/" +
|
2025-10-29 18:10:29 -03:00
|
|
|
practiceId +
|
|
|
|
|
"/Publish",
|
2025-10-27 11:46:51 -03:00
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
console.log(data);
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
throw error;
|
|
|
|
|
// console.error('Error:', error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function markQuestions(sectionId, questions) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "PUT",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify(questions),
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
return fetch(
|
|
|
|
|
// "https://api.odiprojects.com/api-institute/v1"+
|
|
|
|
|
checkRole() +
|
|
|
|
|
"/ExamSections/" +
|
2025-10-29 18:10:29 -03:00
|
|
|
sectionId +
|
|
|
|
|
"/MarkQuestions",
|
2025-10-27 11:46:51 -03:00
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
// console.log(data);
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
// console.error('Error:', error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function markQuestionsPractice(practiceId, questions) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "PUT",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify(questions),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
try {
|
2025-10-29 18:10:29 -03:00
|
|
|
const res = await fetch(checkRole() + "/Practices/" + practiceId +
|
2025-10-27 11:46:51 -03:00
|
|
|
"/ReviewQuestions", requestOptions);
|
|
|
|
|
const data = await res.json();
|
|
|
|
|
return data;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.log(error);
|
|
|
|
|
throw "Something went wrong, could not submit the questions."
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function detachQuestion(sectionId, question) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify(question),
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
return fetch(
|
|
|
|
|
// "https://api.odiprojects.com/api-institute/v1"+
|
|
|
|
|
checkRole() +
|
|
|
|
|
"/ExamSections/" +
|
2025-10-29 18:10:29 -03:00
|
|
|
sectionId +
|
|
|
|
|
"/DetachQuestions",
|
2025-10-27 11:46:51 -03:00
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
// console.log(response.json());
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
console.log(data);
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
// console.error('Error:', error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function detachQuestionPractice(practiceId, question) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify(question),
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
return fetch(
|
|
|
|
|
// "https://api.odiprojects.com/api-institute/v1"+
|
|
|
|
|
checkRole() + "/Practices/" + practiceId + "/DetachQuestions",
|
|
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
// console.log(response);
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
// console.log(response.json());
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
throw "Something went wrong";
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
console.log(data);
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
throw error;
|
|
|
|
|
// console.error('Error:', error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function createClass(obj) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify(obj),
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
return fetch(
|
|
|
|
|
"https://api.odiprojects.com/api-institute/v1/Classes",
|
|
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
console.log(response);
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
console.log(data);
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
// console.error('Error:', error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function deleteExamBatch(obj) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify(obj),
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
return fetch(
|
|
|
|
|
// "https://api.odiprojects.com/api-institute/v1"+
|
|
|
|
|
checkRole() +
|
|
|
|
|
"/Exams/" +
|
2025-10-29 18:10:29 -03:00
|
|
|
obj.id +
|
|
|
|
|
"/DetachBatch",
|
2025-10-27 11:46:51 -03:00
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
console.log(response);
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
console.log(data);
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
// console.error('Error:', error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function addBatchToExam(obj) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify(obj),
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
return fetch(
|
|
|
|
|
// "https://api.odiprojects.com/api-institute/v1"+
|
|
|
|
|
checkRole() +
|
|
|
|
|
"/Exams/" +
|
2025-10-29 18:10:29 -03:00
|
|
|
obj.id +
|
|
|
|
|
"/AttachBatch",
|
2025-10-27 11:46:51 -03:00
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
console.log(response);
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
console.log(data);
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
// console.error('Error:', error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function addBatchToPractice(obj) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify(obj),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
try {
|
2025-10-29 18:10:29 -03:00
|
|
|
const res = await fetch(checkRole() + "/Practices/" + obj.id + "/AttachBatch", requestOptions);
|
2025-10-27 11:46:51 -03:00
|
|
|
const data = res.json();
|
|
|
|
|
return data;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
throw error;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function detachBatchesFromExam(obj) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify(obj.batches),
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
return fetch(
|
|
|
|
|
// "https://api.odiprojects.com/api-institute/v1"+
|
|
|
|
|
checkRole() +
|
|
|
|
|
"/Exams/" +
|
2025-10-29 18:10:29 -03:00
|
|
|
obj.id +
|
|
|
|
|
"/DetachBatch",
|
2025-10-27 11:46:51 -03:00
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
console.log(response);
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
console.log(data);
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
// console.error('Error:', error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function detachBatchFromPractice(obj) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify(obj),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
try {
|
2025-10-29 18:10:29 -03:00
|
|
|
const res = await fetch(checkRole() + "/Practices/" + obj.id + "/DetachBatch", requestOptions);
|
2025-10-27 11:46:51 -03:00
|
|
|
const data = res.json();
|
|
|
|
|
return data;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
throw error;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function addBatchesToExam(obj) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify(obj.batches),
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
return fetch(
|
|
|
|
|
// "https://api.odiprojects.com/api-institute/v1"+
|
|
|
|
|
checkRole() +
|
|
|
|
|
"/Exams/" +
|
2025-10-29 18:10:29 -03:00
|
|
|
obj.id +
|
|
|
|
|
"/AttachBatch",
|
2025-10-27 11:46:51 -03:00
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
console.log(response);
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
console.log(data);
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
// console.error('Error:', error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function addSubjectToClass(obj) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify(obj),
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
return fetch(
|
|
|
|
|
"https://api.odiprojects.com/api-institute/v1/Classes/" +
|
2025-10-29 18:10:29 -03:00
|
|
|
obj.id +
|
|
|
|
|
"/Subjects",
|
2025-10-27 11:46:51 -03:00
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
// console.log(response);
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
throw "Something went wrong, please try again";
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
// console.log(data);
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
2025-10-29 18:10:29 -03:00
|
|
|
console.error('Error:', error);
|
|
|
|
|
throw error;
|
2025-10-27 11:46:51 -03:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function removeSubjectFromClass(id) {
|
|
|
|
|
// /v{version}/Subjects/{subject_id}
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "DELETE",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
try {
|
2025-10-29 18:10:29 -03:00
|
|
|
const res = await fetch(checkRole() + "/Subjects/" + id, requestOptions);
|
|
|
|
|
if (!res.ok) {
|
2025-10-27 11:46:51 -03:00
|
|
|
throw "Something went wrong";
|
|
|
|
|
}
|
|
|
|
|
const data = await res.json();
|
|
|
|
|
return data;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.log(error);
|
|
|
|
|
throw "Something went wrong, please try again later."
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function removeTopicFromClass(id) {
|
|
|
|
|
// /v{version}/Categories/{category_id}
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "DELETE",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
try {
|
2025-10-29 18:10:29 -03:00
|
|
|
const res = await fetch(checkRole() + "/Categories/" + id, requestOptions);
|
|
|
|
|
if (!res.ok) {
|
2025-10-27 11:46:51 -03:00
|
|
|
throw "Something went wrong";
|
|
|
|
|
}
|
|
|
|
|
const data = await res.json();
|
|
|
|
|
return data;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.log(error);
|
|
|
|
|
throw "Something went wrong, please try again later."
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function addTopicToClass(obj) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify(obj),
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
return fetch(
|
|
|
|
|
"https://api.odiprojects.com/api-institute/v1/Subjects/" +
|
2025-10-29 18:10:29 -03:00
|
|
|
obj.id +
|
|
|
|
|
"/Categories",
|
2025-10-27 11:46:51 -03:00
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
console.log(response);
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
console.log(data);
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
// console.error('Error:', error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function updateClass(obj) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "PUT",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify(obj),
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
console.log(requestOptions);
|
|
|
|
|
return fetch(
|
|
|
|
|
"https://api.odiprojects.com/api-institute/v1/Classes/" + obj.id,
|
|
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
console.log(response);
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
console.log(data);
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
// console.error('Error:', error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function createBatch(obj) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const currentClass = authenticationService.currentClassValue;
|
|
|
|
|
obj.class_id = currentClass;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify(obj),
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
return fetch(
|
|
|
|
|
checkRole() + "/UserGroups/Classes/" +
|
2025-10-29 18:10:29 -03:00
|
|
|
currentClass,
|
2025-10-27 11:46:51 -03:00
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
console.log(response);
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push('/login');
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
console.log(data);
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
// console.error('Error:', error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getAllBatchForClass(class_id) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
2025-10-29 18:10:29 -03:00
|
|
|
};
|
2025-10-27 11:46:51 -03:00
|
|
|
return fetch(
|
|
|
|
|
"https://api.odiprojects.com/api-institute/v1/UserGroups/Classes/" +
|
2025-10-29 18:10:29 -03:00
|
|
|
class_id,
|
2025-10-27 11:46:51 -03:00
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
console.log(response);
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push('/login');
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
console.log(data);
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
// console.error('Error:', error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function addToBatch(obj) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify(obj),
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
return fetch(
|
|
|
|
|
checkRole() + "/UserGroups/" + obj.batch_id + "/AttachUsers",
|
|
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
// console.log(response);
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
console.log(data);
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
2025-10-29 18:10:29 -03:00
|
|
|
console.error('Error:', error);
|
|
|
|
|
throw "Something went wrong, please try again";
|
2025-10-27 11:46:51 -03:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function deleteFromBatch(obj) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify(obj),
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
return fetch(
|
|
|
|
|
"https://api.odiprojects.com/api-institute/v1/UserGroups/" +
|
2025-10-29 18:10:29 -03:00
|
|
|
obj.batch_id +
|
|
|
|
|
"/DetachUsers",
|
2025-10-27 11:46:51 -03:00
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
console.log(response);
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
console.log(data);
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
console.error('Error:', error);
|
|
|
|
|
throw "Something went wrong, please try again";
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function deleteBatch(id) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "DELETE",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
return fetch(
|
|
|
|
|
"https://api.odiprojects.com/api-institute/v1/UserGroups/" + id,
|
|
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
console.log(response);
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
console.log(data);
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
// console.error('Error:', error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function deleteClass(id) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "DELETE",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
return fetch(
|
|
|
|
|
"https://api.odiprojects.com/api-institute/v1/Classes/" + id,
|
|
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
console.log(response);
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
console.log(data);
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
// console.error('Error:', error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function loadReviewQuestions(sectionId) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
if (currentUser.language_code === null) {
|
|
|
|
|
currentUser.language_code = "En";
|
|
|
|
|
currentUser.language_name = "English";
|
|
|
|
|
}
|
|
|
|
|
return fetch(
|
|
|
|
|
// "https://api.odiprojects.com/api-institute/v1"+
|
|
|
|
|
checkRole() +
|
|
|
|
|
"/ExamSections/" +
|
2025-10-29 18:10:29 -03:00
|
|
|
sectionId +
|
|
|
|
|
"/Questions",
|
2025-10-27 11:46:51 -03:00
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
authenticationService.logout();
|
|
|
|
|
window.location.reload(true);
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
// console.log(data)
|
|
|
|
|
return data;
|
|
|
|
|
})
|
2025-10-29 18:10:29 -03:00
|
|
|
.catch((error) => { });
|
2025-10-27 11:46:51 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function loadReviewQuestionsPractice(practiceId) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
if (currentUser.language_code === null) {
|
|
|
|
|
currentUser.language_code = "En";
|
|
|
|
|
currentUser.language_name = "English";
|
|
|
|
|
}
|
|
|
|
|
return fetch(
|
|
|
|
|
// "https://api.odiprojects.com/api-institute/v1"+
|
|
|
|
|
checkRole() +
|
|
|
|
|
"/Practices/" +
|
2025-10-29 18:10:29 -03:00
|
|
|
practiceId +
|
|
|
|
|
"/Questions",
|
2025-10-27 11:46:51 -03:00
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// authenticationService.logout();
|
|
|
|
|
window.location.reload(true);
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
// console.log(data)
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
throw error;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function loadSections(examId) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
if (currentUser.language_code === null) {
|
|
|
|
|
currentUser.language_code = "En";
|
|
|
|
|
currentUser.language_name = "English";
|
|
|
|
|
}
|
|
|
|
|
return fetch(
|
|
|
|
|
// "https://api.odiprojects.com/api-institute/v1"+
|
|
|
|
|
checkRole() +
|
|
|
|
|
"/Exams/" + examId,
|
|
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
authenticationService.logout();
|
|
|
|
|
window.location.reload(true);
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
// console.log(data)
|
|
|
|
|
return data;
|
|
|
|
|
})
|
2025-10-29 18:10:29 -03:00
|
|
|
.catch((error) => { });
|
2025-10-27 11:46:51 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function loadSectionsForPractice(practiceId) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
if (currentUser.language_code === null) {
|
|
|
|
|
currentUser.language_code = "En";
|
|
|
|
|
currentUser.language_name = "English";
|
|
|
|
|
}
|
|
|
|
|
return fetch(
|
|
|
|
|
// "https://api.odiprojects.com/api-institute/v1"+
|
|
|
|
|
checkRole() +
|
|
|
|
|
"/Practices/" + practiceId,
|
|
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
authenticationService.logout();
|
|
|
|
|
window.location.reload(true);
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
// console.log(data)
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
throw error;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getQuestion(question_id, questionLang = undefined) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
if (currentUser.language_code === null) {
|
|
|
|
|
currentUser.language_code = "En";
|
|
|
|
|
currentUser.language_name = "English";
|
|
|
|
|
}
|
2025-10-29 18:10:29 -03:00
|
|
|
if (!questionLang) {
|
2025-10-27 11:46:51 -03:00
|
|
|
return fetch(checkRole() + "/" + currentUser.language_code + "/Questions/" + question_id, requestOptions)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
// console.log(response);
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// authenticationService.logout();
|
|
|
|
|
// window.location.reload(true);
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
// console.log(data);
|
|
|
|
|
return data;
|
|
|
|
|
})
|
2025-10-29 18:10:29 -03:00
|
|
|
.catch((error) => { });
|
2025-10-27 11:46:51 -03:00
|
|
|
} else {
|
|
|
|
|
return fetch(checkRole() + "/" + questionLang + "/Questions/" + question_id, requestOptions)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
// console.log(response);
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// authenticationService.logout();
|
|
|
|
|
// window.location.reload(true);
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
// console.log(data);
|
|
|
|
|
return data;
|
|
|
|
|
})
|
2025-10-29 18:10:29 -03:00
|
|
|
.catch((error) => { });
|
2025-10-27 11:46:51 -03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function loadComplexity() {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
return fetch(
|
|
|
|
|
"https://api.odiprojects.com/api-admin/v1/QuestionTypes",
|
|
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
// console.error('Error:', error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
function deleteQuestions(questionArray) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "DELETE",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify({ idList: questionArray }),
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
if (currentUser.language_code === null) {
|
|
|
|
|
currentUser.language_code = "En";
|
|
|
|
|
currentUser.language_name = "English";
|
|
|
|
|
}
|
|
|
|
|
return fetch(checkRole() + "/" + currentUser.language_code + "/Questions", requestOptions)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
2025-10-29 18:10:29 -03:00
|
|
|
console.error('Error:', error);
|
2025-10-27 11:46:51 -03:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function deletePractice(practiceId) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "DELETE",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
return fetch(
|
|
|
|
|
// "https://api.odiprojects.com/api-institute/v1"+
|
|
|
|
|
checkRole() +
|
|
|
|
|
"/Practices/" + practiceId,
|
|
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
console.log(data);
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
throw error;
|
|
|
|
|
// console.error('Error:', error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function deleteExam(examId) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "DELETE",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
return fetch(
|
|
|
|
|
// "https://api.odiprojects.com/api-institute/v1"+
|
|
|
|
|
checkRole() +
|
|
|
|
|
"/Exams/" + examId,
|
|
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
console.log(data);
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
// console.error('Error:', error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function createQuestion(question) {
|
|
|
|
|
// console.log("here");
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify(question),
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
if (currentUser.language_code === null) {
|
|
|
|
|
currentUser.language_code = "En";
|
|
|
|
|
currentUser.language_name = "English";
|
|
|
|
|
}
|
|
|
|
|
// return fetch(
|
|
|
|
|
// checkRole() +
|
|
|
|
|
// "/" + currentUser.language_code +
|
|
|
|
|
// "/Questions",
|
|
|
|
|
// requestOptions
|
|
|
|
|
// )
|
|
|
|
|
// .then((response) => {
|
|
|
|
|
// // console.log(response);
|
|
|
|
|
// if (response.ok) {
|
|
|
|
|
// return response.json();
|
|
|
|
|
// }
|
|
|
|
|
// throw "Something went wrong, please try again."
|
|
|
|
|
// // window.localStorage.clear();
|
|
|
|
|
// // history.push("/login");
|
|
|
|
|
// })
|
|
|
|
|
// .then((data) => {
|
|
|
|
|
// // console.log(data);
|
|
|
|
|
// return data;
|
|
|
|
|
// })
|
|
|
|
|
// .catch((error) => {
|
|
|
|
|
// console.error('Error:', error);
|
|
|
|
|
// throw error;
|
|
|
|
|
// });
|
2025-10-29 18:10:29 -03:00
|
|
|
try {
|
|
|
|
|
const res = await fetch(checkRole() + "/" + currentUser.language_code + "/Questions", requestOptions);
|
|
|
|
|
if (res.ok) {
|
|
|
|
|
const data = await res.json();
|
|
|
|
|
return data;
|
2025-10-27 11:46:51 -03:00
|
|
|
}
|
2025-10-29 18:10:29 -03:00
|
|
|
// error handling here
|
|
|
|
|
throw "Something is wrong, please try again"
|
|
|
|
|
} catch (err) {
|
|
|
|
|
throw err;
|
|
|
|
|
}
|
2025-10-27 11:46:51 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function createBulkQuestion(questions) {
|
|
|
|
|
// /v{version}/{language}/AddBulkQuestions
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify(questions),
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
if (currentUser.language_code === null) {
|
|
|
|
|
currentUser.language_code = "En";
|
|
|
|
|
currentUser.language_name = "English";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const res = await fetch(checkRole() + "/" + currentUser.language_code + "/AddBulkQuestions", requestOptions);
|
2025-10-29 18:10:29 -03:00
|
|
|
if (res.ok) {
|
2025-10-27 11:46:51 -03:00
|
|
|
const data = await res.json();
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
// error handling here
|
|
|
|
|
throw "Uploading Failed! Questions might have been invalidated, please check the questions before submitting again."
|
|
|
|
|
} catch (err) {
|
|
|
|
|
throw err;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function editQuestion(questionID, questionModifications) {
|
|
|
|
|
// console.log("here");
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "PUT",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify(questionModifications),
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
if (currentUser.language_code === null) {
|
|
|
|
|
currentUser.language_code = "en";
|
|
|
|
|
currentUser.language_name = "English";
|
|
|
|
|
}
|
2025-10-29 18:10:29 -03:00
|
|
|
try {
|
|
|
|
|
const res = await fetch(checkRole() + "/" + currentUser.language_code + "/Questions/" + questionID, requestOptions);
|
|
|
|
|
if (res.ok) {
|
|
|
|
|
const data = await res.json();
|
|
|
|
|
return data;
|
2025-10-27 11:46:51 -03:00
|
|
|
}
|
2025-10-29 18:10:29 -03:00
|
|
|
// error handling here
|
|
|
|
|
throw "Something is wrong, please try again"
|
|
|
|
|
} catch (err) {
|
|
|
|
|
throw err;
|
|
|
|
|
}
|
2025-10-27 11:46:51 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function cloneQuestionToLanguage(questionID, questionObj) {
|
|
|
|
|
// /v{version}/{language}/Questions/{question_id}/CloneQuestionLanguage
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify(questionObj),
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
if (currentUser.language_code === null) {
|
|
|
|
|
currentUser.language_code = "en";
|
|
|
|
|
currentUser.language_name = "English";
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
const res = await fetch(checkRole() + "/" + currentUser.language_code + "/Questions/" + questionID + "/CloneQuestionLanguage", requestOptions);
|
2025-10-29 18:10:29 -03:00
|
|
|
if (res.ok) {
|
2025-10-27 11:46:51 -03:00
|
|
|
const data = await res.json();
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
// error handling here
|
|
|
|
|
throw "Something went wrong, please try again"
|
|
|
|
|
} catch (err) {
|
|
|
|
|
throw err;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function attachSectionToExam(examId, sections) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify(sections),
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
return fetch(
|
|
|
|
|
// "https://api.odiprojects.com/api-institute/v1"+
|
2025-10-29 18:10:29 -03:00
|
|
|
checkRole() +
|
2025-10-27 11:46:51 -03:00
|
|
|
"/Exams/" + examId + "/Sections",
|
|
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
// console.error('Error:', error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getExamDetails(examId) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
if (currentUser.language_code === null) {
|
|
|
|
|
currentUser.language_code = "En";
|
|
|
|
|
currentUser.language_name = "English";
|
|
|
|
|
}
|
|
|
|
|
return fetch(
|
|
|
|
|
// "https://api.odiprojects.com/api-institute/v1" +
|
2025-10-29 18:10:29 -03:00
|
|
|
checkRole() +
|
2025-10-27 11:46:51 -03:00
|
|
|
"/Exams/" + examId,
|
|
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
// console.log(response);
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
window.location.reload(true);
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
// console.log(data);
|
|
|
|
|
return data;
|
|
|
|
|
})
|
2025-10-29 18:10:29 -03:00
|
|
|
.catch((error) => { });
|
2025-10-27 11:46:51 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getPracticeDetails(practiceId) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
if (currentUser.language_code === null) {
|
|
|
|
|
currentUser.language_code = "En";
|
|
|
|
|
currentUser.language_name = "English";
|
|
|
|
|
}
|
|
|
|
|
return fetch(
|
|
|
|
|
// "https://api.odiprojects.com/api-institute/v1"+
|
|
|
|
|
checkRole() +
|
|
|
|
|
"/Practices/" + practiceId,
|
|
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
console.log(response);
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.location.reload(true);
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
console.log(data);
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
throw error;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function arrangeSectionsFromExam(examId, sections) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "PUT",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify(sections),
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
return fetch(
|
|
|
|
|
// "https://api.odiprojects.com/api-institute/v"+
|
|
|
|
|
checkRole() +
|
|
|
|
|
"/Exams/" + examId + "/ArrangeSections",
|
|
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
throw 'Something went wrong';
|
|
|
|
|
// console.error('Error:', error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function attachQuestionsToExam(examId, questions) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify(questions),
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
return fetch(
|
|
|
|
|
// "https://api.odiprojects.com/api-institute/v"+
|
2025-10-29 18:10:29 -03:00
|
|
|
checkRole() +
|
|
|
|
|
"/ExamSections/" +
|
|
|
|
|
examId +
|
|
|
|
|
"/AttachQuestions",
|
2025-10-27 11:46:51 -03:00
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
// console.error('Error:', error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function attachQuestionsToPractice(practiceId, questions) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify(questions),
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
return fetch(
|
|
|
|
|
// "https://api.odiprojects.com/api-institute/v1"+
|
|
|
|
|
checkRole() +
|
|
|
|
|
"/Practices/" + practiceId +
|
2025-10-29 18:10:29 -03:00
|
|
|
"/AttachQuestions",
|
2025-10-27 11:46:51 -03:00
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
throw error;
|
|
|
|
|
// console.error('Error:', error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function createExam(exam) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const currentClass = authenticationService.currentClassValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify(exam),
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
if (currentUser.language_code === null) {
|
|
|
|
|
currentUser.language_code = "En";
|
|
|
|
|
currentUser.language_name = "English";
|
|
|
|
|
}
|
|
|
|
|
return fetch(
|
|
|
|
|
// "https://api.odiprojects.com/api-institute/v1/" +
|
|
|
|
|
checkRole() + "/" +
|
2025-10-29 18:10:29 -03:00
|
|
|
currentUser.language_code +
|
|
|
|
|
"/Classes/" +
|
|
|
|
|
currentClass +
|
|
|
|
|
"/Exams",
|
2025-10-27 11:46:51 -03:00
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (!currentClass) {
|
|
|
|
|
throw new Error("Class not set properly, please try setting your class");
|
|
|
|
|
}
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
2025-10-29 18:10:29 -03:00
|
|
|
console.error('Error:', error);
|
2025-10-27 11:46:51 -03:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function createPractise(obj) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const currentClass = authenticationService.currentClassValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify(obj),
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
if (currentUser.language_code === null) {
|
|
|
|
|
currentUser.language_code = "En";
|
|
|
|
|
currentUser.language_name = "English";
|
2025-10-29 18:10:29 -03:00
|
|
|
}
|
2025-10-27 11:46:51 -03:00
|
|
|
return fetch(
|
|
|
|
|
// "https://api.odiprojects.com/api-institute/v1" +
|
|
|
|
|
checkRole() + "/" + currentUser.language_code +
|
|
|
|
|
"/Classes/" +
|
2025-10-29 18:10:29 -03:00
|
|
|
currentClass +
|
|
|
|
|
"/Practices",
|
2025-10-27 11:46:51 -03:00
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (!currentClass) {
|
|
|
|
|
throw new Error("Class not set properly, please try setting your class");
|
|
|
|
|
}
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
// console.error('Error:', error);
|
|
|
|
|
throw error
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function updateExam(exam) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "PUT",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify(exam),
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
if (currentUser.language_code === null) {
|
|
|
|
|
currentUser.language_code = "En";
|
|
|
|
|
currentUser.language_name = "English";
|
|
|
|
|
}
|
|
|
|
|
return fetch(
|
|
|
|
|
// "https://api.odiprojects.com/api-institute/v1" +
|
|
|
|
|
checkRole() +
|
2025-10-29 18:10:29 -03:00
|
|
|
// currentUser.language_code +
|
|
|
|
|
"/Exams/" +
|
|
|
|
|
exam.id,
|
2025-10-27 11:46:51 -03:00
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
2025-10-29 18:10:29 -03:00
|
|
|
console.error('Error:', error);
|
2025-10-27 11:46:51 -03:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function updateBookMark(questionArray, isBookmarkValue) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify({
|
|
|
|
|
idList: questionArray,
|
|
|
|
|
isBookmark: isBookmarkValue,
|
|
|
|
|
}),
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
if (currentUser.language_code === null) {
|
|
|
|
|
currentUser.language_code = "En";
|
|
|
|
|
currentUser.language_name = "English";
|
|
|
|
|
}
|
|
|
|
|
return fetch(checkRole() + "/" + currentUser.language_code + "/Questions/Bookmark", requestOptions).then((response) => {
|
2025-10-29 18:10:29 -03:00
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
2025-10-27 11:46:51 -03:00
|
|
|
.then((data) => {
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
2025-10-29 18:10:29 -03:00
|
|
|
console.error('Error:', error);
|
2025-10-27 11:46:51 -03:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function loadQuestionTypes() {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
const response = await fetch(LOAD_QUESTIONTYPES, requestOptions);
|
|
|
|
|
const data = await response.json();
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getQuestionTypes(questionType) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
return fetch(
|
|
|
|
|
"https://api.odiprojects.com/api-admin/v1/QuestionTypes/" + questionType,
|
|
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
// console.error('Error:', error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function loadLanguages() {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
return fetch(
|
|
|
|
|
// "https://api.odiprojects.com/api-admin/v1/Languages",
|
|
|
|
|
LOAD_LANGAUGES,
|
|
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
// console.error('Error:', error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function loadClasses() {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
// const response = await fetch(`${checkRole()}/Classes`, requestOptions);
|
|
|
|
|
const response = await fetch("https://api.odiprojects.com/api-student/v1/UserGroups/list", requestOptions)
|
|
|
|
|
const data = await response.json();
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function loadSubCategory(category) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
if (currentUser.language_code === null) {
|
|
|
|
|
currentUser.language_code = "En";
|
|
|
|
|
currentUser.language_name = "English";
|
|
|
|
|
}
|
|
|
|
|
return fetch(
|
|
|
|
|
// "https://api.odiprojects.com/api-institute/v1"+
|
|
|
|
|
checkRole() +
|
|
|
|
|
"/" + currentUser.language_code +
|
2025-10-29 18:10:29 -03:00
|
|
|
"/Categories/" +
|
|
|
|
|
category +
|
|
|
|
|
"/SubCategories",
|
2025-10-27 11:46:51 -03:00
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
throw new Error("Network response was not ok.");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
// console.error('Error:', error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function loadQuestions(jsonObj) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
// console.log(currentUser);
|
|
|
|
|
const currentClass = authenticationService.currentClassValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
let queryStr = "";
|
|
|
|
|
if (jsonObj.type !== undefined && jsonObj.type !== "") {
|
|
|
|
|
if (queryStr !== "") queryStr = queryStr + "&";
|
|
|
|
|
queryStr = queryStr + "type=" + jsonObj.type;
|
|
|
|
|
}
|
|
|
|
|
if (jsonObj.module_id !== undefined && jsonObj.module_id !== "") {
|
|
|
|
|
if (queryStr !== "") queryStr = queryStr + "&";
|
|
|
|
|
queryStr =
|
|
|
|
|
queryStr + "module_id=" + jsonObj.module_id + "&module=" + jsonObj.module;
|
|
|
|
|
}
|
|
|
|
|
if (jsonObj.complexity !== undefined && jsonObj.complexity !== "") {
|
|
|
|
|
if (queryStr !== "") queryStr = queryStr + "&";
|
|
|
|
|
queryStr = queryStr + "complexity=" + jsonObj.complexity;
|
|
|
|
|
}
|
|
|
|
|
if (jsonObj.authorId !== undefined && jsonObj.authorId !== "") {
|
|
|
|
|
if (queryStr !== "") queryStr = queryStr + "&";
|
|
|
|
|
queryStr = queryStr + "author_id=" + jsonObj.authorId;
|
|
|
|
|
}
|
|
|
|
|
if (queryStr !== "") {
|
|
|
|
|
queryStr = "?" + queryStr;
|
|
|
|
|
if (jsonObj.pageSize !== undefined) {
|
|
|
|
|
queryStr = queryStr + `&pageSize=${jsonObj.pageSize}`;
|
|
|
|
|
}
|
|
|
|
|
if (jsonObj.page !== undefined)
|
|
|
|
|
queryStr = queryStr + `&pageNumber=${jsonObj.page}`;
|
|
|
|
|
} else {
|
|
|
|
|
queryStr = "?";
|
|
|
|
|
if (jsonObj.pageSize !== undefined) {
|
|
|
|
|
queryStr = queryStr + `pageSize=${jsonObj.pageSize}`;
|
|
|
|
|
}
|
|
|
|
|
if (jsonObj.page !== undefined) {
|
|
|
|
|
queryStr = queryStr + `&pageNumber=${jsonObj.page}`;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (jsonObj.translationMissing) {
|
2025-10-29 18:10:29 -03:00
|
|
|
queryStr === "" ? queryStr = "?" + "translation_missing=" + jsonObj.translationMissing
|
|
|
|
|
: queryStr = queryStr + "&translation_missing=" + jsonObj.translationMissing
|
2025-10-27 11:46:51 -03:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (currentUser.language_code === null) {
|
|
|
|
|
currentUser.language_code = "En";
|
|
|
|
|
currentUser.language_name = "English";
|
|
|
|
|
}
|
|
|
|
|
return fetch(
|
|
|
|
|
checkRole() + "/" +
|
2025-10-29 18:10:29 -03:00
|
|
|
currentUser.language_code +
|
|
|
|
|
"/Classes/" +
|
|
|
|
|
currentClass +
|
|
|
|
|
"/Questions" +
|
|
|
|
|
queryStr,
|
2025-10-27 11:46:51 -03:00
|
|
|
requestOptions
|
|
|
|
|
//return fetch("https://api.odiprojects.com/api-institute/v1/en/Classes/1/Questions?module=subject&module_id=1", requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (!currentClass) {
|
|
|
|
|
throw new Error("Class not set properly, please try setting your class");
|
|
|
|
|
}
|
|
|
|
|
// console.log(response); // logs the response from api after fetching all the questions
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
// console.log('Success:', data);
|
|
|
|
|
return data;
|
|
|
|
|
|
|
|
|
|
// console.log("result", data.result.jwtToken);
|
|
|
|
|
// sessionStorage.setItem('login', true);
|
|
|
|
|
// sessionStorage.setItem('token', data.result.jwtToken);
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
2025-10-29 18:10:29 -03:00
|
|
|
console.error('Error:', error);
|
2025-10-27 11:46:51 -03:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function draftExam(jsonObj) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const currentClass = authenticationService.currentClassValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
let queryStr = "";
|
|
|
|
|
queryStr = "?";
|
|
|
|
|
if (jsonObj.pageSize !== undefined) {
|
|
|
|
|
queryStr = queryStr + `pageSize=${jsonObj.pageSize}`;
|
|
|
|
|
}
|
|
|
|
|
if (jsonObj.pageNumber !== undefined) {
|
|
|
|
|
queryStr = queryStr + `&pageNumber=${jsonObj.pageNumber}`;
|
|
|
|
|
}
|
|
|
|
|
if (currentUser.language_code === null) {
|
|
|
|
|
currentUser.language_code = "En";
|
|
|
|
|
currentUser.language_name = "English";
|
|
|
|
|
}
|
|
|
|
|
return fetch(
|
|
|
|
|
// "https://api.odiprojects.com/api-institute/v1" +
|
|
|
|
|
checkRole() +
|
2025-10-29 18:10:29 -03:00
|
|
|
"/Classes/" +
|
|
|
|
|
currentClass +
|
|
|
|
|
"/DraftExams" +
|
|
|
|
|
queryStr,
|
2025-10-27 11:46:51 -03:00
|
|
|
requestOptions
|
|
|
|
|
//return fetch("https://api.odiprojects.com/api-institute/v1/en/Classes/1/Questions?module=subject&module_id=1", requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (!currentClass) {
|
2025-10-29 18:10:29 -03:00
|
|
|
throw new Error("No class is set, please set a class and try again.");
|
2025-10-27 11:46:51 -03:00
|
|
|
}
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
// console.log('Success:', data);
|
|
|
|
|
return data;
|
|
|
|
|
|
|
|
|
|
// console.log("result", data.result.jwtToken);
|
|
|
|
|
// sessionStorage.setItem('login', true);
|
|
|
|
|
// sessionStorage.setItem('token', data.result.jwtToken);
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
2025-10-29 18:10:29 -03:00
|
|
|
console.error('Error:', error);
|
2025-10-27 11:46:51 -03:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function draftPractice(jsonObj) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const currentClass = authenticationService.currentClassValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
let queryStr = "";
|
|
|
|
|
queryStr = "?";
|
|
|
|
|
if (jsonObj.pageSize !== undefined) {
|
|
|
|
|
queryStr = queryStr + `pageSize=${jsonObj.pageSize}`;
|
|
|
|
|
}
|
|
|
|
|
if (jsonObj.pageNumber !== undefined) {
|
|
|
|
|
queryStr = queryStr + `&pageNumber=${jsonObj.pageNumber}`;
|
|
|
|
|
}
|
|
|
|
|
if (currentUser.language_code === null) {
|
|
|
|
|
currentUser.language_code = "En";
|
|
|
|
|
currentUser.language_name = "English";
|
|
|
|
|
}
|
|
|
|
|
return fetch(
|
|
|
|
|
// "https://api.odiprojects.com/api-institute/v1"+
|
|
|
|
|
checkRole() + "/Classes/" + currentClass +
|
|
|
|
|
"/DraftSubjectPractices" +
|
2025-10-29 18:10:29 -03:00
|
|
|
queryStr,
|
2025-10-27 11:46:51 -03:00
|
|
|
requestOptions
|
|
|
|
|
//return fetch("https://api.odiprojects.com/api-institute/v1/en/Classes/1/Questions?module=subject&module_id=1", requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
throw "Something went wrong, please try again."
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
// console.log('Success:', data);
|
|
|
|
|
return data;
|
|
|
|
|
|
|
|
|
|
// console.log("result", data.result.jwtToken);
|
|
|
|
|
// sessionStorage.setItem('login', true);
|
|
|
|
|
// sessionStorage.setItem('token', data.result.jwtToken);
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
2025-10-29 18:10:29 -03:00
|
|
|
console.error('Error:', error);
|
|
|
|
|
throw error;
|
2025-10-27 11:46:51 -03:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function livePractice(jsonObj) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const currentClass = authenticationService.currentClassValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
let queryStr = "";
|
|
|
|
|
queryStr = "?";
|
|
|
|
|
if (jsonObj.pageSize !== undefined) {
|
|
|
|
|
queryStr = queryStr + `pageSize=${jsonObj.pageSize}`;
|
|
|
|
|
}
|
|
|
|
|
if (jsonObj.pageNumber !== undefined) {
|
|
|
|
|
queryStr = queryStr + `&pageNumber=${jsonObj.pageNumber}`;
|
|
|
|
|
}
|
|
|
|
|
if (currentUser.language_code === null) {
|
|
|
|
|
currentUser.language_code = "En";
|
|
|
|
|
currentUser.language_name = "English";
|
|
|
|
|
}
|
|
|
|
|
return fetch(
|
|
|
|
|
// "https://api.odiprojects.com/api-institute/v1"+
|
|
|
|
|
checkRole() + "/Classes/" + currentClass +
|
|
|
|
|
"/LiveSubjectPractices" +
|
2025-10-29 18:10:29 -03:00
|
|
|
queryStr,
|
2025-10-27 11:46:51 -03:00
|
|
|
requestOptions
|
|
|
|
|
//return fetch("https://api.odiprojects.com/api-institute/v1/en/Classes/1/Questions?module=subject&module_id=1", requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
// console.log('Success:', data);
|
|
|
|
|
return data;
|
|
|
|
|
|
|
|
|
|
// console.log("result", data.result.jwtToken);
|
|
|
|
|
// sessionStorage.setItem('login', true);
|
|
|
|
|
// sessionStorage.setItem('token', data.result.jwtToken);
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
// console.error('Error:', error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function upcomingPractice(jsonObj) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const currentClass = authenticationService.currentClassValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
let queryStr = "";
|
|
|
|
|
queryStr = "?";
|
|
|
|
|
if (jsonObj.pageSize !== undefined) {
|
|
|
|
|
queryStr = queryStr + `pageSize=${jsonObj.pageSize}`;
|
|
|
|
|
}
|
|
|
|
|
if (jsonObj.pageNumber !== undefined) {
|
|
|
|
|
queryStr = queryStr + `&pageNumber=${jsonObj.pageNumber}`;
|
|
|
|
|
}
|
|
|
|
|
if (currentUser.language_code === null) {
|
|
|
|
|
currentUser.language_code = "En";
|
|
|
|
|
currentUser.language_name = "English";
|
|
|
|
|
}
|
|
|
|
|
return fetch(
|
|
|
|
|
// "https://api.odiprojects.com/api-institute/v1"+
|
2025-10-29 18:10:29 -03:00
|
|
|
checkRole() + "/Classes/" + currentClass +
|
2025-10-27 11:46:51 -03:00
|
|
|
"/UpcomingSubjectPractices" +
|
2025-10-29 18:10:29 -03:00
|
|
|
queryStr,
|
2025-10-27 11:46:51 -03:00
|
|
|
requestOptions
|
|
|
|
|
//return fetch("https://api.odiprojects.com/api-institute/v1/en/Classes/1/Questions?module=subject&module_id=1", requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
// console.log('Success:', data);
|
|
|
|
|
return data;
|
|
|
|
|
|
|
|
|
|
// console.log("result", data.result.jwtToken);
|
|
|
|
|
// sessionStorage.setItem('login', true);
|
|
|
|
|
// sessionStorage.setItem('token', data.result.jwtToken);
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
// console.error('Error:', error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function draftPracticeCategory(jsonObj) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const currentClass = authenticationService.currentClassValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
let queryStr = "";
|
|
|
|
|
queryStr = "?";
|
|
|
|
|
if (jsonObj.pageSize !== undefined) {
|
|
|
|
|
queryStr = queryStr + `pageSize=${jsonObj.pageSize}`;
|
|
|
|
|
}
|
|
|
|
|
if (jsonObj.pageNumber !== undefined) {
|
|
|
|
|
queryStr = queryStr + `&pageNumber=${jsonObj.pageNumber}`;
|
|
|
|
|
}
|
|
|
|
|
if (currentUser.language_code === null) {
|
|
|
|
|
currentUser.language_code = "En";
|
|
|
|
|
currentUser.language_name = "English";
|
|
|
|
|
}
|
|
|
|
|
return fetch(
|
|
|
|
|
// "https://api.odiprojects.com/api-institute/v1" +
|
|
|
|
|
checkRole() + "/Classes/" + currentClass +
|
2025-10-29 18:10:29 -03:00
|
|
|
"/DraftCategoryPractices" +
|
|
|
|
|
queryStr,
|
2025-10-27 11:46:51 -03:00
|
|
|
requestOptions
|
|
|
|
|
//return fetch("https://api.odiprojects.com/api-institute/v1/en/Classes/1/Questions?module=subject&module_id=1", requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
// console.log('Success:', data);
|
|
|
|
|
return data;
|
|
|
|
|
|
|
|
|
|
// console.log("result", data.result.jwtToken);
|
|
|
|
|
// sessionStorage.setItem('login', true);
|
|
|
|
|
// sessionStorage.setItem('token', data.result.jwtToken);
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
2025-10-29 18:10:29 -03:00
|
|
|
console.error('Error:', error);
|
2025-10-27 11:46:51 -03:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function livePracticeCategory(jsonObj) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const currentClass = authenticationService.currentClassValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
let queryStr = "";
|
|
|
|
|
queryStr = "?";
|
|
|
|
|
if (jsonObj.pageSize !== undefined) {
|
|
|
|
|
queryStr = queryStr + `pageSize=${jsonObj.pageSize}`;
|
|
|
|
|
}
|
|
|
|
|
if (jsonObj.pageNumber !== undefined) {
|
|
|
|
|
queryStr = queryStr + `&pageNumber=${jsonObj.pageNumber}`;
|
|
|
|
|
}
|
|
|
|
|
if (currentUser.language_code === null) {
|
|
|
|
|
currentUser.language_code = "En";
|
|
|
|
|
currentUser.language_name = "English";
|
|
|
|
|
}
|
|
|
|
|
return fetch(
|
|
|
|
|
// "https://api.odiprojects.com/api-institute/v1"+
|
|
|
|
|
checkRole() + "/Classes/" + currentClass +
|
|
|
|
|
"/LiveCategoryPractices" +
|
2025-10-29 18:10:29 -03:00
|
|
|
queryStr,
|
2025-10-27 11:46:51 -03:00
|
|
|
requestOptions
|
|
|
|
|
//return fetch("https://api.odiprojects.com/api-institute/v1/en/Classes/1/Questions?module=subject&module_id=1", requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
// console.log('Success:', data);
|
|
|
|
|
return data;
|
|
|
|
|
|
|
|
|
|
// console.log("result", data.result.jwtToken);
|
|
|
|
|
// sessionStorage.setItem('login', true);
|
|
|
|
|
// sessionStorage.setItem('token', data.result.jwtToken);
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
// console.error('Error:', error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function upcomingPracticeCategory(jsonObj) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const currentClass = authenticationService.currentClassValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
let queryStr = "";
|
|
|
|
|
queryStr = "?";
|
|
|
|
|
if (jsonObj.pageSize !== undefined) {
|
|
|
|
|
queryStr = queryStr + `pageSize=${jsonObj.pageSize}`;
|
|
|
|
|
}
|
|
|
|
|
if (jsonObj.pageNumber !== undefined) {
|
|
|
|
|
queryStr = queryStr + `&pageNumber=${jsonObj.pageNumber}`;
|
|
|
|
|
}
|
|
|
|
|
if (currentUser.language_code === null) {
|
|
|
|
|
currentUser.language_code = "En";
|
|
|
|
|
currentUser.language_name = "English";
|
|
|
|
|
}
|
|
|
|
|
return fetch(
|
|
|
|
|
// "https://api.odiprojects.com/api-institute/v1"+
|
|
|
|
|
checkRole() + "/Classes/" + currentClass +
|
|
|
|
|
"/UpcomingCategoryPractices" +
|
2025-10-29 18:10:29 -03:00
|
|
|
queryStr,
|
2025-10-27 11:46:51 -03:00
|
|
|
requestOptions
|
|
|
|
|
//return fetch("https://api.odiprojects.com/api-institute/v1/en/Classes/1/Questions?module=subject&module_id=1", requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
// console.log('Success:', data);
|
|
|
|
|
return data;
|
|
|
|
|
|
|
|
|
|
// console.log("result", data.result.jwtToken);
|
|
|
|
|
// sessionStorage.setItem('login', true);
|
|
|
|
|
// sessionStorage.setItem('token', data.result.jwtToken);
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
2025-10-29 18:10:29 -03:00
|
|
|
console.error('Error:', error);
|
2025-10-27 11:46:51 -03:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function liveExam(jsonObj) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const currentClass = authenticationService.currentClassValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
let queryStr = "";
|
|
|
|
|
queryStr = "?";
|
|
|
|
|
if (jsonObj.pageSize !== undefined) {
|
|
|
|
|
queryStr = queryStr + `pageSize=${jsonObj.pageSize}`;
|
|
|
|
|
}
|
|
|
|
|
if (jsonObj.pageNumber !== undefined) {
|
|
|
|
|
queryStr = queryStr + `&pageNumber=${jsonObj.pageNumber}`;
|
|
|
|
|
}
|
|
|
|
|
if (currentUser.language_code === null) {
|
|
|
|
|
currentUser.language_code = "En";
|
|
|
|
|
currentUser.language_name = "English";
|
|
|
|
|
}
|
|
|
|
|
return fetch(
|
|
|
|
|
// "https://api.odiprojects.com/api-institute/v1" +
|
|
|
|
|
checkRole() +
|
2025-10-29 18:10:29 -03:00
|
|
|
"/Classes/" +
|
|
|
|
|
currentClass +
|
|
|
|
|
"/LiveExams" +
|
|
|
|
|
queryStr,
|
2025-10-27 11:46:51 -03:00
|
|
|
requestOptions
|
|
|
|
|
//return fetch("https://api.odiprojects.com/api-institute/v1/en/Classes/1/Questions?module=subject&module_id=1", requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (!currentClass) {
|
|
|
|
|
throw ("No class has been set, please reload the page or set a class and try again.");
|
|
|
|
|
}
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
2025-10-29 18:10:29 -03:00
|
|
|
if (!data) throw ("Something went wrong, please reload the page and try again.");
|
2025-10-27 11:46:51 -03:00
|
|
|
// console.log('Success:', data);
|
|
|
|
|
return data;
|
|
|
|
|
|
|
|
|
|
// console.log("result", data.result.jwtToken);
|
|
|
|
|
// sessionStorage.setItem('login', true);
|
|
|
|
|
// sessionStorage.setItem('token', data.result.jwtToken);
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
2025-10-29 18:10:29 -03:00
|
|
|
console.error('Error:', error);
|
|
|
|
|
throw error;
|
2025-10-27 11:46:51 -03:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function livePracticeExams(module) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const currentClass = authenticationService.currentClassValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
let queryStr = "";
|
|
|
|
|
queryStr = "?";
|
2025-10-29 18:10:29 -03:00
|
|
|
queryStr = queryStr + `module=${module}`;
|
|
|
|
|
queryStr = queryStr + `&module_id=-1`;
|
2025-10-27 11:46:51 -03:00
|
|
|
|
|
|
|
|
if (currentUser.language_code === null) {
|
|
|
|
|
currentUser.language_code = "En";
|
|
|
|
|
currentUser.language_name = "English";
|
|
|
|
|
}
|
|
|
|
|
return fetch(
|
|
|
|
|
"https://api.odiprojects.com/api-institute/v1/" +
|
|
|
|
|
"Classes/" +
|
2025-10-29 18:10:29 -03:00
|
|
|
currentClass +
|
|
|
|
|
"/LivePractices" +
|
|
|
|
|
queryStr,
|
2025-10-27 11:46:51 -03:00
|
|
|
requestOptions
|
|
|
|
|
//return fetch("https://api.odiprojects.com/api-institute/v1/en/Classes/1/Questions?module=subject&module_id=1", requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
// console.log('Success:', data);
|
|
|
|
|
return data;
|
|
|
|
|
|
|
|
|
|
// console.log("result", data.result.jwtToken);
|
|
|
|
|
// sessionStorage.setItem('login', true);
|
|
|
|
|
// sessionStorage.setItem('token', data.result.jwtToken);
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
// console.error('Error:', error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function upcomingExam(jsonObj) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const currentClass = authenticationService.currentClassValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
let queryStr = "";
|
|
|
|
|
queryStr = "?";
|
|
|
|
|
if (jsonObj.pageSize !== undefined) {
|
|
|
|
|
queryStr = queryStr + `pageSize=${jsonObj.pageSize}`;
|
|
|
|
|
}
|
|
|
|
|
if (jsonObj.pageNumber !== undefined) {
|
|
|
|
|
queryStr = queryStr + `&pageNumber=${jsonObj.pageNumber}`;
|
|
|
|
|
}
|
|
|
|
|
if (currentUser.language_code === null) {
|
|
|
|
|
currentUser.language_code = "En";
|
|
|
|
|
currentUser.language_name = "English";
|
|
|
|
|
}
|
|
|
|
|
return fetch(
|
|
|
|
|
// "https://api.odiprojects.com/api-institute/v1" +
|
|
|
|
|
checkRole() +
|
2025-10-29 18:10:29 -03:00
|
|
|
"/Classes/" +
|
|
|
|
|
currentClass +
|
|
|
|
|
"/UpcomingExams" +
|
|
|
|
|
queryStr,
|
2025-10-27 11:46:51 -03:00
|
|
|
requestOptions
|
|
|
|
|
//return fetch("https://api.odiprojects.com/api-institute/v1/en/Classes/1/Questions?module=subject&module_id=1", requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (!currentClass) throw ("No class has been set, please reload the page or try setting the class.");
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
// console.log('Success:', data);
|
|
|
|
|
return data;
|
|
|
|
|
|
|
|
|
|
// console.log("result", data.result.jwtToken);
|
|
|
|
|
// sessionStorage.setItem('login', true);
|
|
|
|
|
// sessionStorage.setItem('token', data.result.jwtToken);
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
2025-10-29 18:10:29 -03:00
|
|
|
console.error('Error:', error);
|
2025-10-27 11:46:51 -03:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function expiredExam(jsonObj) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const currentClass = authenticationService.currentClassValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
let queryStr = "";
|
|
|
|
|
queryStr = "?";
|
|
|
|
|
if (jsonObj.pageSize !== undefined) {
|
|
|
|
|
queryStr = queryStr + `pageSize=${jsonObj.pageSize}`;
|
|
|
|
|
}
|
|
|
|
|
if (jsonObj.pageNumber !== undefined) {
|
|
|
|
|
queryStr = queryStr + `&pageNumber=${jsonObj.pageNumber}`;
|
|
|
|
|
}
|
|
|
|
|
if (currentUser.language_code === null) {
|
|
|
|
|
currentUser.language_code = "En";
|
|
|
|
|
currentUser.language_name = "English";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return fetch(
|
|
|
|
|
// "https://api.odiprojects.com/api-institute/v1" +
|
|
|
|
|
checkRole() +
|
2025-10-29 18:10:29 -03:00
|
|
|
"/Classes/" +
|
|
|
|
|
currentClass +
|
|
|
|
|
"/HistoryExams" +
|
|
|
|
|
queryStr,
|
2025-10-27 11:46:51 -03:00
|
|
|
requestOptions
|
|
|
|
|
//return fetch("https://api.odiprojects.com/api-institute/v1/en/Classes/1/Questions?module=subject&module_id=1", requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (!currentClass) {
|
|
|
|
|
throw "The class is not set. Please set the class or try reloading the page."
|
|
|
|
|
}
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
// console.log('Success:', data);
|
|
|
|
|
return data;
|
|
|
|
|
|
|
|
|
|
// console.log("result", data.result.jwtToken);
|
|
|
|
|
// sessionStorage.setItem('login', true);
|
|
|
|
|
// sessionStorage.setItem('token', data.result.jwtToken);
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
2025-10-29 18:10:29 -03:00
|
|
|
console.error('Error:', error);
|
2025-10-27 11:46:51 -03:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function loadQuestionsBookmark(jsonObj) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const currentClass = authenticationService.currentClassValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
let queryStr = "";
|
|
|
|
|
if (jsonObj.type !== undefined && jsonObj.type !== "") {
|
|
|
|
|
if (queryStr !== "") queryStr = queryStr + "&";
|
|
|
|
|
queryStr = queryStr + "type=" + jsonObj.type;
|
|
|
|
|
}
|
|
|
|
|
if (jsonObj.module_id !== undefined && jsonObj.module_id !== "") {
|
|
|
|
|
if (queryStr !== "") queryStr = queryStr + "&";
|
|
|
|
|
queryStr =
|
|
|
|
|
queryStr + "module_id=" + jsonObj.module_id + "&module=" + jsonObj.module;
|
|
|
|
|
}
|
|
|
|
|
if (jsonObj.complexity !== undefined && jsonObj.complexity !== "") {
|
|
|
|
|
if (queryStr !== "") queryStr = queryStr + "&";
|
|
|
|
|
queryStr = queryStr + "complexity=" + jsonObj.complexity;
|
|
|
|
|
}
|
|
|
|
|
if (queryStr !== "") {
|
|
|
|
|
queryStr = "?" + queryStr;
|
|
|
|
|
if (jsonObj.pageSize !== undefined) {
|
|
|
|
|
queryStr = queryStr + `&pageSize=${jsonObj.pageSize}`;
|
|
|
|
|
}
|
|
|
|
|
if (jsonObj.page !== undefined)
|
|
|
|
|
queryStr = queryStr + `&pageNumber=${jsonObj.page}`;
|
|
|
|
|
} else {
|
|
|
|
|
queryStr = "?";
|
|
|
|
|
if (jsonObj.pageSize !== undefined) {
|
|
|
|
|
queryStr = queryStr + `pageSize=${jsonObj.pageSize}`;
|
|
|
|
|
}
|
|
|
|
|
if (jsonObj.page !== undefined) {
|
|
|
|
|
queryStr = queryStr + `&pageNumber=${jsonObj.page}`;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (jsonObj.translationMissing) {
|
2025-10-29 18:10:29 -03:00
|
|
|
queryStr === "" ? queryStr = "?" + "translation_missing=" + jsonObj.translationMissing
|
|
|
|
|
: queryStr = queryStr + "&translation_missing=" + jsonObj.translationMissing
|
2025-10-27 11:46:51 -03:00
|
|
|
}
|
|
|
|
|
if (currentUser.language_code === null) {
|
|
|
|
|
currentUser.language_code = "En";
|
|
|
|
|
currentUser.language_name = "English";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return fetch(
|
|
|
|
|
checkRole() + "/" + currentUser.language_code + "/Classes/" + currentClass + "/BookmarkedQuestions" +
|
2025-10-29 18:10:29 -03:00
|
|
|
queryStr,
|
2025-10-27 11:46:51 -03:00
|
|
|
requestOptions
|
|
|
|
|
//return fetch("https://api.odiprojects.com/api-institute/v1/en/Classes/1/Questions?module=subject&module_id=1", requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (!currentClass) {
|
|
|
|
|
throw new Error("Class not set properly, please try setting your class");
|
|
|
|
|
}
|
|
|
|
|
// console.log(response);
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
// console.log('Success:', data);
|
|
|
|
|
return data;
|
|
|
|
|
|
|
|
|
|
// console.log("result", data.result.jwtToken);
|
|
|
|
|
// sessionStorage.setItem('login', true);
|
|
|
|
|
// sessionStorage.setItem('token', data.result.jwtToken);
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
2025-10-29 18:10:29 -03:00
|
|
|
console.error('Error:', error);
|
2025-10-27 11:46:51 -03:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function loadCategory(subject) {
|
2025-10-29 18:10:29 -03:00
|
|
|
if (subject != "") {
|
2025-10-27 11:46:51 -03:00
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
// console.log(subject);
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
if (currentUser.language_code === null) {
|
|
|
|
|
currentUser.language_code = "En";
|
|
|
|
|
currentUser.language_name = "English";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
2025-10-29 18:10:29 -03:00
|
|
|
const response = await fetch(`${checkRole()}/Subjects/` + subject + "/Categories", requestOptions)
|
|
|
|
|
const data = await response.json();
|
2025-10-27 11:46:51 -03:00
|
|
|
return data;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error(error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function loadSubjects(classes) {
|
|
|
|
|
const currentUser = await authenticationService.currentUserValue;
|
|
|
|
|
const currentClass = await authenticationService.currentClassValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
if (currentUser.language_code === null) {
|
|
|
|
|
currentUser.language_code = "En";
|
|
|
|
|
currentUser.language_name = "English";
|
|
|
|
|
}
|
|
|
|
|
//return was in front of fetch originally
|
|
|
|
|
try {
|
|
|
|
|
if (!currentClass) throw 'Class has not been set. Please set a class or try reloading the page again'; // error handling
|
|
|
|
|
|
2025-10-29 18:10:29 -03:00
|
|
|
const response = await fetch(`${checkRole()}/Classes` + "/" + currentClass + "/Subjects", requestOptions)
|
2025-10-27 11:46:51 -03:00
|
|
|
const data = await response.json();
|
|
|
|
|
return data;
|
|
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error(error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function myQuestion(jsonObj) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const currentClass = authenticationService.currentClassValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
let queryStr = "";
|
|
|
|
|
if (jsonObj.type !== undefined && jsonObj.type !== "") {
|
|
|
|
|
queryStr = "type=" + jsonObj.type;
|
|
|
|
|
}
|
|
|
|
|
if (jsonObj.module_id !== undefined && jsonObj.module_id !== "") {
|
|
|
|
|
if (queryStr !== "") queryStr = queryStr + "&";
|
|
|
|
|
queryStr =
|
|
|
|
|
queryStr + "module_id=" + jsonObj.module_id + "&module=" + jsonObj.module;
|
|
|
|
|
}
|
|
|
|
|
if (jsonObj.complexity !== undefined && jsonObj.complexity !== "") {
|
|
|
|
|
if (queryStr !== "") queryStr = queryStr + "&";
|
|
|
|
|
queryStr = queryStr + "complexity=" + jsonObj.complexity;
|
|
|
|
|
}
|
|
|
|
|
if (queryStr !== "") {
|
|
|
|
|
queryStr = "author_id=" + currentUser.id + "&" + queryStr;
|
|
|
|
|
}
|
|
|
|
|
if (currentUser.language_code === null) {
|
|
|
|
|
currentUser.language_code = "En";
|
|
|
|
|
currentUser.language_name = "English";
|
|
|
|
|
}
|
|
|
|
|
if (queryStr !== "") {
|
|
|
|
|
if (jsonObj.pageSize !== undefined) {
|
|
|
|
|
queryStr = queryStr + `&pageSize=${jsonObj.pageSize}`;
|
|
|
|
|
}
|
|
|
|
|
if (jsonObj.page !== undefined)
|
|
|
|
|
queryStr = queryStr + `&pageNumber=${jsonObj.page}`;
|
|
|
|
|
} else {
|
|
|
|
|
if (jsonObj.pageSize !== undefined) {
|
|
|
|
|
queryStr = queryStr + `pageSize=${jsonObj.pageSize}`;
|
|
|
|
|
}
|
|
|
|
|
if (jsonObj.page !== undefined) {
|
|
|
|
|
queryStr = queryStr + `&pageNumber=${jsonObj.page}`;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return fetch(
|
|
|
|
|
"https://api.odiprojects.com/api-institute/v1/en/Classes/" +
|
2025-10-29 18:10:29 -03:00
|
|
|
currentClass +
|
|
|
|
|
"/Questions?" +
|
|
|
|
|
queryStr,
|
2025-10-27 11:46:51 -03:00
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
// console.log('Success:', data);
|
|
|
|
|
return data;
|
|
|
|
|
|
|
|
|
|
// console.log("result", data.result.jwtToken);
|
|
|
|
|
// sessionStorage.setItem('login', true);
|
|
|
|
|
// sessionStorage.setItem('token', data.result.jwtToken);
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
// console.error('Error:', error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function draftQuestion(jsonObj) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const currentClass = authenticationService.currentClassValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
let queryStr = "";
|
|
|
|
|
if (jsonObj.type !== undefined && jsonObj.type !== "") {
|
|
|
|
|
queryStr = "?type=" + jsonObj.type;
|
|
|
|
|
}
|
|
|
|
|
if (jsonObj.module_id !== undefined && jsonObj.module_id !== "") {
|
|
|
|
|
if (queryStr !== "")
|
|
|
|
|
queryStr =
|
|
|
|
|
queryStr +
|
|
|
|
|
"&module_id=" +
|
|
|
|
|
jsonObj.module_id +
|
|
|
|
|
"&module=" +
|
|
|
|
|
jsonObj.module;
|
|
|
|
|
else
|
|
|
|
|
queryStr =
|
|
|
|
|
"?module_id=" + jsonObj.module_id + "&module=" + jsonObj.module;
|
|
|
|
|
}
|
|
|
|
|
if (jsonObj.complexity !== undefined && jsonObj.complexity !== "") {
|
2025-10-29 18:10:29 -03:00
|
|
|
queryStr !== "" ? queryStr = queryStr + "&complexity=" + jsonObj.complexity
|
|
|
|
|
: queryStr = "?complexity=" + jsonObj.complexity;
|
2025-10-27 11:46:51 -03:00
|
|
|
}
|
|
|
|
|
if (queryStr !== "") {
|
|
|
|
|
queryStr =
|
|
|
|
|
queryStr + "&pageSize=" + jsonObj.pageSize + "&page=" + jsonObj.page;
|
|
|
|
|
} else {
|
|
|
|
|
queryStr =
|
|
|
|
|
queryStr +
|
|
|
|
|
"?pageNumber=" +
|
|
|
|
|
jsonObj.page +
|
|
|
|
|
"&pageSize=" +
|
|
|
|
|
jsonObj.pageSize;
|
|
|
|
|
}
|
|
|
|
|
if (jsonObj.translationMissing) {
|
2025-10-29 18:10:29 -03:00
|
|
|
queryStr === "" ? queryStr = "?" + "translation_missing=" + jsonObj.translationMissing
|
|
|
|
|
: queryStr = queryStr + "&translation_missing=" + jsonObj.translationMissing
|
2025-10-27 11:46:51 -03:00
|
|
|
}
|
2025-10-29 18:10:29 -03:00
|
|
|
|
2025-10-27 11:46:51 -03:00
|
|
|
// console.log(queryStr);
|
|
|
|
|
if (currentUser.language_code === null) {
|
|
|
|
|
currentUser.language_code = "En";
|
|
|
|
|
currentUser.language_name = "English";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return fetch(
|
|
|
|
|
checkRole() + "/" + currentUser.language_code + "/Classes/" +
|
2025-10-29 18:10:29 -03:00
|
|
|
currentClass +
|
|
|
|
|
"/DraftQuestions" +
|
|
|
|
|
queryStr,
|
2025-10-27 11:46:51 -03:00
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (!currentClass) {
|
|
|
|
|
throw new Error("Class not set properly, please try setting your class");
|
|
|
|
|
}
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
return data;
|
|
|
|
|
// console.log("result", data.result.jwtToken);
|
|
|
|
|
// sessionStorage.setItem('login', true);
|
|
|
|
|
// sessionStorage.setItem('token', data.result.jwtToken);
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
2025-10-29 18:10:29 -03:00
|
|
|
console.error('Error:', error);
|
2025-10-27 11:46:51 -03:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function savedDraftQuestion(id, content) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "PUT",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify(content),
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
if (currentUser.language_code === null) {
|
|
|
|
|
currentUser.language_code = "En";
|
|
|
|
|
currentUser.language_name = "English";
|
|
|
|
|
}
|
|
|
|
|
return fetch(
|
|
|
|
|
"https://api.odiprojects.com/api-institute/v1/" +
|
2025-10-29 18:10:29 -03:00
|
|
|
currentUser.language_code +
|
|
|
|
|
"/Questions/" +
|
|
|
|
|
id,
|
2025-10-27 11:46:51 -03:00
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
console.log(response.json());
|
|
|
|
|
return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
// history.push('/draftQuestions');
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
console.log(data);
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
// console.error('Error:', error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
function submitcreateQuestion(id, content) {
|
|
|
|
|
const currentUser = authenticationService.currentUserValue;
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
method: "PUT",
|
|
|
|
|
headers: {
|
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
|
Accept: "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
Authorization: "Bearer ".concat(currentUser.jwtToken),
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify(content),
|
|
|
|
|
// body: JSON.stringify(this.state)
|
|
|
|
|
//body: JSON.stringify({ emailId:"sa@odiware.com", userPassword:"aaaa" })
|
|
|
|
|
};
|
|
|
|
|
if (currentUser.language_code === null) {
|
|
|
|
|
currentUser.language_code = "En";
|
|
|
|
|
currentUser.language_name = "English";
|
|
|
|
|
}
|
|
|
|
|
return fetch(
|
|
|
|
|
"https://api.odiprojects.com/api-institute/v1/" +
|
2025-10-29 18:10:29 -03:00
|
|
|
currentUser.language_code +
|
|
|
|
|
"/Questions/" +
|
|
|
|
|
id,
|
2025-10-27 11:46:51 -03:00
|
|
|
requestOptions
|
|
|
|
|
)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
// history.push("/draftQuestions");
|
|
|
|
|
return response.json();
|
|
|
|
|
// return response.json();
|
|
|
|
|
}
|
|
|
|
|
// window.localStorage.clear();
|
|
|
|
|
})
|
|
|
|
|
.then((data) => {
|
|
|
|
|
console.log(data);
|
|
|
|
|
return data;
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
// console.error('Error:', error);
|
|
|
|
|
});
|
|
|
|
|
}
|