Added more comment

This commit is contained in:
Joao Ramos
2024-01-08 19:04:44 +00:00
parent 0f029a21f7
commit 63998b50d6

View File

@@ -106,7 +106,6 @@ 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 },
@@ -118,11 +117,9 @@ const getSkillsFeedback = async (sections: SkillsFeedbackRequest[]) => {
); );
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;