Commit 3bc8cfbb authored by Gamage B.G.J's avatar Gamage B.G.J

Merge branch 'feature/marks-calculator-updated-version' into 'master'

Feature/marks calculator updated version

See merge request !35
parents 3e742aa7 501a3cb2
This diff is collapsed.
...@@ -322,7 +322,7 @@ const Tutorial = () => { ...@@ -322,7 +322,7 @@ const Tutorial = () => {
((selectedItemContent?.taskItemMark! * parseInt(marksCalculator?.confidence!)) / 100)!, ((selectedItemContent?.taskItemMark! * parseInt(marksCalculator?.confidence!)) / 100)!,
0 0
)) ))
} }
dispatch(toInitialState()) dispatch(toInitialState())
} }
}, [success]) }, [success])
...@@ -398,7 +398,10 @@ const Tutorial = () => { ...@@ -398,7 +398,10 @@ const Tutorial = () => {
</span> </span>
</Typography> </Typography>
<Typography variant="h4" sx={{ pt: 3, pb: 1, zIndex: 1 }}> <Typography variant="h4" sx={{ pt: 3, pb: 1, zIndex: 1 }}>
{(data?.tutorialMarkUser! / data?.tutorialMarks!) * 100}% Completed {((data?.tutorialMarkUser! / data?.tutorialMarks!) * 100).toLocaleString(undefined, {
minimumFractionDigits: 2,
maximumFractionDigits: 2,
})}% Completed
</Typography> </Typography>
<Box sx={{ maxWidth: '60%' }}> <Box sx={{ maxWidth: '60%' }}>
<LinearProgress variant="determinate" color="success" value={(data?.tutorialMarkUser! / data?.tutorialMarks!) * 100} /> <LinearProgress variant="determinate" color="success" value={(data?.tutorialMarkUser! / data?.tutorialMarks!) * 100} />
......
...@@ -53,7 +53,10 @@ const CurriculumSection = ({ curriculum, curriculumIndex }: { curriculum: curric ...@@ -53,7 +53,10 @@ const CurriculumSection = ({ curriculum, curriculumIndex }: { curriculum: curric
Your learning capacity is 80% as daily analytics Your learning capacity is 80% as daily analytics
</Typography> </Typography>
<Typography variant="h4" color="white" sx={{ pt: 8, pb: 1, zIndex: 1 }}> <Typography variant="h4" color="white" sx={{ pt: 8, pb: 1, zIndex: 1 }}>
{(curriculum?.curriculumMarkUser! / curriculum?.curriculumMark!) * 100}% Completed {((curriculum?.curriculumMarkUser! / curriculum?.curriculumMark!) * 100).toLocaleString(undefined, {
minimumFractionDigits: 2,
maximumFractionDigits: 2,
})}% Completed
</Typography> </Typography>
<Box sx={{ maxWidth: '60%' }}> <Box sx={{ maxWidth: '60%' }}>
<LinearProgress variant="determinate" color="success" value={(curriculum?.curriculumMarkUser! / curriculum?.curriculumMark!) * 100} /> <LinearProgress variant="determinate" color="success" value={(curriculum?.curriculumMarkUser! / curriculum?.curriculumMark!) * 100} />
......
...@@ -41,11 +41,17 @@ const slice = createSlice({ ...@@ -41,11 +41,17 @@ const slice = createSlice({
state.isLoading = false; state.isLoading = false;
}, },
// POST USER // POST marksCalculatorSuccess
marksCalculatorSuccess(state, action) { marksCalculatorSuccess(state, action) {
state.marksCalculator = action.payload.result; state.marksCalculator = action.payload.result;
state.success = "Marks Calculated Successfully." state.success = "Marks Calculated Successfully."
}, },
// POST default marksCalculatorSuccess
defaultMarksCalculatorSuccess(state, action) {
state.marksCalculator = action.payload.result;
state.success = "Marks Calculated Successfully."
},
} }
}); });
...@@ -76,8 +82,7 @@ export function CalculateMarks(curriculumIndex: number, tutorialIndex: number, i ...@@ -76,8 +82,7 @@ export function CalculateMarks(curriculumIndex: number, tutorialIndex: number, i
return async () => { return async () => {
dispatch(slice.actions.startLoading()); dispatch(slice.actions.startLoading());
try { try {
// Construct the request body as needed (e.g., for formData)
const formData = new FormData(); const formData = new FormData();
formData.append('image', imageData); formData.append('image', imageData);
formData.append('class', targetClass); formData.append('class', targetClass);
...@@ -91,3 +96,29 @@ export function CalculateMarks(curriculumIndex: number, tutorialIndex: number, i ...@@ -91,3 +96,29 @@ export function CalculateMarks(curriculumIndex: number, tutorialIndex: number, i
} }
}; };
}; };
/**
* POST Default Marks Calculator
* @param original_image
* @param user_input_image
* @returns
*/
export function DefaultCalculateMarks(original_image: any, user_input_image: any) {
return async () => {
dispatch(slice.actions.startLoading());
try {
const formData = new FormData();
formData.append('original_image', original_image);
formData.append('user_input_image', user_input_image);
const response = await axiosServices.post(`/rest_node/marks-calculator/default`, formData);
dispatch(slice.actions.marksCalculatorSuccess(response.data));
} catch (error) {
dispatch(slice.actions.hasError(error));
} finally {
dispatch(slice.actions.finishLoading());
}
};
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment