Added more comment
This commit is contained in:
@@ -106,23 +106,20 @@ interface SkillsFeedbackResponse extends SkillsFeedbackRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const getSkillsFeedback = async (sections: SkillsFeedbackRequest[]) => {
|
const getSkillsFeedback = async (sections: SkillsFeedbackRequest[]) => {
|
||||||
try {
|
const backendRequest = await axios.post(
|
||||||
const backendRequest = await axios.post(
|
`${process.env.BACKEND_URL}/grading_summary`,
|
||||||
`${process.env.BACKEND_URL}/grading_summary`,
|
{ sections },
|
||||||
{ sections },
|
{
|
||||||
{
|
headers: {
|
||||||
headers: {
|
Authorization: `Bearer ${process.env.BACKEND_JWT}`,
|
||||||
Authorization: `Bearer ${process.env.BACKEND_JWT}`,
|
},
|
||||||
},
|
}
|
||||||
}
|
);
|
||||||
);
|
|
||||||
|
|
||||||
return backendRequest.data?.sections;
|
return backendRequest.data?.sections;
|
||||||
} catch (err) {
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// perform the request with several retries if needed
|
||||||
const handleSkillsFeedbackRequest = async (
|
const handleSkillsFeedbackRequest = async (
|
||||||
sections: SkillsFeedbackRequest[]
|
sections: SkillsFeedbackRequest[]
|
||||||
): Promise<SkillsFeedbackResponse[] | null> => {
|
): Promise<SkillsFeedbackResponse[] | null> => {
|
||||||
@@ -150,6 +147,8 @@ const generateQRCode = async (link: string) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Radial Progress PNGs were generated with only two colors
|
||||||
|
// and they use some baseline score (10%, 20%, 30%..)
|
||||||
type RADIAL_PROGRESS_COLOR = "laranja" | "azul";
|
type RADIAL_PROGRESS_COLOR = "laranja" | "azul";
|
||||||
|
|
||||||
const getRadialProgressPNG = (
|
const getRadialProgressPNG = (
|
||||||
@@ -157,6 +156,8 @@ const getRadialProgressPNG = (
|
|||||||
score: number,
|
score: number,
|
||||||
total: number
|
total: number
|
||||||
) => {
|
) => {
|
||||||
|
// calculate the percentage of the score
|
||||||
|
// and round it to the closest available image
|
||||||
const percent = (score / total) * 100;
|
const percent = (score / total) * 100;
|
||||||
const remainder = percent % 10;
|
const remainder = percent % 10;
|
||||||
const roundedPercent = percent - remainder;
|
const roundedPercent = percent - remainder;
|
||||||
|
|||||||
Reference in New Issue
Block a user