Updated the PDF report to show the level instead of the score
This commit is contained in:
@@ -4,13 +4,14 @@ import React from "react";
|
|||||||
import {View, Text, Image} from "@react-pdf/renderer";
|
import {View, Text, Image} from "@react-pdf/renderer";
|
||||||
import {styles} from "../styles";
|
import {styles} from "../styles";
|
||||||
import {ModuleScore} from "@/interfaces/module.scores";
|
import {ModuleScore} from "@/interfaces/module.scores";
|
||||||
|
import {calculateBandScore} from "@/utils/score";
|
||||||
|
|
||||||
export const RadialResult = ({module, score, total, png}: ModuleScore) => (
|
export const RadialResult = ({module, score, total, png}: ModuleScore) => (
|
||||||
<View style={[styles.textFont, styles.radialContainer]}>
|
<View style={[styles.textFont, styles.radialContainer]}>
|
||||||
<Text style={[styles.textColor, styles.textBold, {fontSize: 10}]}>{module}</Text>
|
<Text style={[styles.textColor, styles.textBold, {fontSize: 10}]}>{module}</Text>
|
||||||
<Image src={png} style={styles.image64}></Image>
|
<Image src={png} style={styles.image64}></Image>
|
||||||
<View style={[styles.textColor, styles.radialResultContainer]}>
|
<View style={[styles.textColor, styles.radialResultContainer]}>
|
||||||
<Text style={styles.textBold}>{Math.floor(score)}</Text>
|
<Text style={styles.textBold}>{calculateBandScore(score, total, module, "academic")}</Text>
|
||||||
<Text style={{fontSize: 8}}>out of 9.0</Text>
|
<Text style={{fontSize: 8}}>out of 9.0</Text>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ const levelMarking: {[key: number]: number} = {
|
|||||||
0: 0, // Beginner
|
0: 0, // Beginner
|
||||||
};
|
};
|
||||||
|
|
||||||
const moduleMarkings: {[key in Module]: {[key in Type]: {[key: number]: number}}} = {
|
const moduleMarkings: {[key in Module | "Overall"]: {[key in Type]: {[key: number]: number}}} = {
|
||||||
reading: {
|
reading: {
|
||||||
academic: academicMarking,
|
academic: academicMarking,
|
||||||
general: readingGeneralMarking,
|
general: readingGeneralMarking,
|
||||||
@@ -124,9 +124,13 @@ const moduleMarkings: {[key in Module]: {[key in Type]: {[key: number]: number}}
|
|||||||
academic: levelMarking,
|
academic: levelMarking,
|
||||||
general: levelMarking,
|
general: levelMarking,
|
||||||
},
|
},
|
||||||
|
Overall: {
|
||||||
|
academic: levelMarking,
|
||||||
|
general: levelMarking,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const calculateBandScore = (correct: number, total: number, module: Module, type: Type) => {
|
export const calculateBandScore = (correct: number, total: number, module: Module | "Overall", type: Type) => {
|
||||||
const marking = moduleMarkings[module][type];
|
const marking = moduleMarkings[module][type];
|
||||||
const percentage = (correct * 100) / total;
|
const percentage = (correct * 100) / total;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user