-
Pretest
+
Exercise
diff --git a/src/roles/user/exercise/views/components/MatchingPairsQuestion.jsx b/src/roles/user/exercise/views/components/MatchingPairsQuestion.jsx
index d1767b5..b006fef 100644
--- a/src/roles/user/exercise/views/components/MatchingPairsQuestion.jsx
+++ b/src/roles/user/exercise/views/components/MatchingPairsQuestion.jsx
@@ -96,7 +96,6 @@ const MatchingPairsQuestion = ({ question, onAnswer, studentAnswer, index }) =>
const selectedRightValue = rightOptions[rightIndex];
newPairs[leftIndex].right = selectedRightValue;
setPairs(newPairs);
- // console.log(newPairs);
setSelectedLeft(null);
setSelectedRight(null);
@@ -104,9 +103,15 @@ const MatchingPairsQuestion = ({ question, onAnswer, studentAnswer, index }) =>
const allPairsMatched = newPairs.every((pair) => pair.right !== '');
if (allPairsMatched && !isComplete) {
setIsComplete(true);
-
+
const rightAnswers = newPairs.map((pair) => pair.right);
- onAnswer(index, arrayToString(rightAnswers), question.ID_ADMIN_EXERCISE);
+
+ const stringPairs = newPairs
+ .map(pair => `${pair.left}>${pair.right}`)
+ .join("| ");
+
+ // onAnswer(index, arrayToString(rightAnswers), question.ID_ADMIN_EXERCISE);
+ onAnswer(index, stringPairs, question.ID_ADMIN_EXERCISE);
}
};
diff --git a/src/roles/user/history/hooks/useHirtories.jsx b/src/roles/user/history/hooks/useHirtories.jsx
index c6072c3..dcd03a0 100644
--- a/src/roles/user/history/hooks/useHirtories.jsx
+++ b/src/roles/user/history/hooks/useHirtories.jsx
@@ -58,6 +58,7 @@ const useHistories = () => {
} else {
data = await serviceHistory.fetchHistoryBySection(sectionSlugMap[activeTab]);
}
+ console.log(data.payload);
setHistoryData(data.payload);
} catch (error) {
if (error.status == 404) {
diff --git a/src/roles/user/history/services/historyService.jsx b/src/roles/user/history/services/historyService.jsx
index 01c8585..8ee7044 100644
--- a/src/roles/user/history/services/historyService.jsx
+++ b/src/roles/user/history/services/historyService.jsx
@@ -25,10 +25,10 @@ const fetchAllHistory = async () => {
const fetchHistoryBySection = async (section) => {
try {
const response = await axiosInstance.get(`/learningHistory/section/${section}`);
- const historyData = response.data.payload;
+ const historyData = response.data.payload.history;
const validHistory = historyData.filter(history => history.STUDENT_FINISH !== null);
-
- return {message: response.data.message, payload: validHistory, status: response.data.statusCode,};
+
+ return {message: response.data.message, payload: validHistory, status: response.data.statusCode};
} catch (error) {
return {payload: []};
}
@@ -37,7 +37,7 @@ const fetchHistoryBySection = async (section) => {
const fetchHistoryByTopic = async (topic) => {
try {
const response = await axiosInstance.get(`/learningHistory/topic/${topic}`);
- const historyData = response.data.payload;
+ const historyData = response.data.payload.history;
const validHistory = historyData.filter(history => history.STUDENT_FINISH !== null);
return {message: response.data.message, payload: validHistory, status: response.data.statusCode,};
diff --git a/src/roles/user/history/views/ExerciseHistory.jsx b/src/roles/user/history/views/ExerciseHistory.jsx
index 36f6348..3e71541 100644
--- a/src/roles/user/history/views/ExerciseHistory.jsx
+++ b/src/roles/user/history/views/ExerciseHistory.jsx
@@ -28,23 +28,21 @@ const ExerciseHistory = () => {
Your Exercise History!
Track your progress with a personalized overview of all your workouts.
-
+
{ setActiveTab(k); setSelectedTopic(''); }}>
-
- {/* Your Exercise History!
- Track your progress with a personalized overview of all your workouts.
*/}
-
+
{topics.length > 0 && (
@@ -86,40 +84,84 @@ const ExerciseHistory = () => {
historyData.map((history, index) => (
-
+ {/*
- Exercise
- Submission: {formatLocalDate(history.STUDENT_FINISH)}
+ {history.CURRENT_LEVEL}
{history.SECTION_NAME}
- {history.TOPIC_NAME}
- {history.CURRENT_LEVEL}
+ {history.TOPIC_NAME}
+ Submission: {formatLocalDate(history.STUDENT_FINISH)}
-
- {history.SCORE}/100
+
+ {history.SCORE}/100
- {compareLevels(history.CURRENT_LEVEL, history.NEXT_LEVEL) === 'jump' ?(
-
-
- Jump to Level {history.NEXT_LEVEL}
-
+
+ {compareLevels(history.CURRENT_LEVEL, history.NEXT_LEVEL) === 'jump' ?(
+
+
+ Jump to Level {history.NEXT_LEVEL}
+
- ) : (
- compareLevels(history.CURRENT_LEVEL, history.NEXT_LEVEL) === 'down' ?(
-
-
- Go Down to Level {history.NEXT_LEVEL}
-
) : (
-
-
- Stay in Level {history.NEXT_LEVEL}
-
+ compareLevels(history.CURRENT_LEVEL, history.NEXT_LEVEL) === 'down' ?(
+
+
+ Go Down to Level {history.NEXT_LEVEL}
+
+ ) : (
+
+
+ Stay in Level {history.NEXT_LEVEL}
+
+ )
+ )}
+
Review
+
+
+ */}
+
+
+
{history.CURRENT_LEVEL}
+
+ {history.SECTION_NAME}
+ {history.TOPIC_NAME}
+
+
Submission: {formatLocalDate(history.STUDENT_FINISH)}
+
+
+ {history.SCORE}/100
+
+
+
+ {history.IS_PASS == 1?(
+
+
+ Topic Finished!
+
+ ):(
+ compareLevels(history.CURRENT_LEVEL, history.NEXT_LEVEL) === 'jump' ?(
+
+
+ Jump to {history.NEXT_LEVEL}
+
+ ) : (
+ compareLevels(history.CURRENT_LEVEL, history.NEXT_LEVEL) === 'down' ?(
+
+
+ Go Down to {history.NEXT_LEVEL}
+
+ ) : (
+
+
+ Stay in {history.NEXT_LEVEL}
+
+ )
)
)}
+ Review
diff --git a/src/roles/user/level/hooks/useLevels.jsx b/src/roles/user/level/hooks/useLevels.jsx
index 64dea61..0b45b01 100644
--- a/src/roles/user/level/hooks/useLevels.jsx
+++ b/src/roles/user/level/hooks/useLevels.jsx
@@ -59,7 +59,8 @@ const useLevels = (section, topic) => {
const isLevelUnlocked = (levelIndex) => {
if (levelIndex !== 0) {
- if (levels[levelIndex].CONTENT) {
+ console.log(levels[levelIndex]);
+ if ("CONTENT" in levels[levelIndex]) {
return true;
}else{
return false;
diff --git a/src/roles/user/level/views/Level.jsx b/src/roles/user/level/views/Level.jsx
index e417004..dc925d7 100644
--- a/src/roles/user/level/views/Level.jsx
+++ b/src/roles/user/level/views/Level.jsx
@@ -66,28 +66,38 @@ const Level = () => {
{levelDesc[index]}
- {!isLevelUnlocked(index) ? (
+
+
+ {level.IS_PRETEST === 1 && level.SCORE !== null ?(
- Not Allowed
+ Review
- ) : (
- // level.SCORE < 65 ?(
- //
- // ) : (
- //
- // Finished
- //
- // )
-
+ ):(
+ !isLevelUnlocked(index) ? (
+
+ Not Allowed
+
+ ) : (
+ // level.SCORE < 65 ?(
+ //
+ // ) : (
+ //
+ // Finished
+ //
+ // )
+
+ )
)}
+
+
))}
diff --git a/src/roles/user/setting/services/SettingService.jsx b/src/roles/user/setting/services/SettingService.jsx
index fb395d3..be4bdf1 100644
--- a/src/roles/user/setting/services/SettingService.jsx
+++ b/src/roles/user/setting/services/SettingService.jsx
@@ -1,5 +1,4 @@
-import axios from 'axios';
-import { API_URL } from '../../../../utils/Constant';
+import axiosInstance from '../../../../utils/axiosInstance';
const config = {
headers: {
@@ -9,7 +8,7 @@ const config = {
const fetchProfile = async () => {
try {
- const response = await axios.get(`${API_URL}/getMe`, config);
+ const response = await axiosInstance.get(`/getMe`, config);
return response.data;
} catch (error) {
throw error;
@@ -17,16 +16,8 @@ const fetchProfile = async () => {
};
const updateProfile = async (id, formData) => {
-
- const cfg = {
- headers: {
- 'Content-Type': 'multipart/form-data',
- Authorization: localStorage.getItem('token')
- },
- };
-
try {
- const response = await axios.put(`${API_URL}/user/update/${id}`, formData, cfg);
+ const response = await axiosInstance.put(`/user/update/${id}`, formData);
return response.data;
} catch (error) {
throw error;
@@ -34,14 +25,8 @@ const updateProfile = async (id, formData) => {
};
const updatePassword = async (userId, passwordData) => {
- const cfg = {
- headers: {
- Authorization: localStorage.getItem('token'),
- 'Content-Type': 'application/json',
- },
- };
try {
- const response = await axios.put(`${API_URL}/user/update/password/${userId}`, passwordData, cfg);
+ const response = await axiosInstance.put(`/user/update/password/${userId}`, passwordData);
return response.data;
} catch (error) {
throw error;
diff --git a/src/utils/Constant.jsx b/src/utils/Constant.jsx
index 4c87bbd..a886da4 100644
--- a/src/utils/Constant.jsx
+++ b/src/utils/Constant.jsx
@@ -1,6 +1,10 @@
export const API_URL = 'http://54.173.167.62/api';
export const MEDIA_URL = 'http://54.173.167.62/api/uploads';
+export let headerSection = 'section';
+export let headerTopic = 'topic';
+export let headerLevel = 'level';
+
export const slugify = (text) => {
if (!text) {
return '';
@@ -25,4 +29,10 @@ export const unSlugify = (text) => {
.toLowerCase()
.replace(/-/g, ' ')
.replace(/\b\w/g, (char) => char.toUpperCase());
-};
\ No newline at end of file
+};
+
+export const setReviewHeader = (section, topic, level) => {
+ headerSection = section;
+ headerTopic = topic;
+ headerLevel = level;
+}
\ No newline at end of file