Merged in pdf-bullet-points (pull request #48)
Added support for PDF bulletpoints Approved-by: Tiago Ribeiro
This commit is contained in:
24
src/exams/pdf/list.item.tsx
Normal file
24
src/exams/pdf/list.item.tsx
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
import { Text, View, StyleSheet } from "@react-pdf/renderer";
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
row: {
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "row",
|
||||||
|
},
|
||||||
|
bullet: {
|
||||||
|
height: "100%",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const ListItem = ({ text, textStyle }: { text: string, textStyle: any[] }) => {
|
||||||
|
return (
|
||||||
|
<View style={styles.row}>
|
||||||
|
<View style={styles.bullet}>
|
||||||
|
<Text style={textStyle}>{"\u2022" + " "}</Text>
|
||||||
|
</View>
|
||||||
|
<Text style={textStyle}>{text}</Text>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ListItem;
|
||||||
@@ -6,11 +6,17 @@ import { styles } from "./styles";
|
|||||||
|
|
||||||
import { StyleSheet } from "@react-pdf/renderer";
|
import { StyleSheet } from "@react-pdf/renderer";
|
||||||
import TestReportFooter from "./test.report.footer";
|
import TestReportFooter from "./test.report.footer";
|
||||||
|
import ListItem from "./list.item";
|
||||||
|
|
||||||
const customStyles = StyleSheet.create({
|
const customStyles = StyleSheet.create({
|
||||||
testDetails: {
|
testDetails: {
|
||||||
display: "flex",
|
display: "flex",
|
||||||
gap: 4,
|
gap: 4,
|
||||||
},
|
},
|
||||||
|
testDetailsContainer: {
|
||||||
|
display: "flex",
|
||||||
|
gap: 16,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -149,16 +155,47 @@ const TestReport = ({
|
|||||||
.filter(
|
.filter(
|
||||||
({ suggestions, evaluation }) => suggestions || evaluation
|
({ suggestions, evaluation }) => suggestions || evaluation
|
||||||
)
|
)
|
||||||
.map(({ module, suggestions, evaluation }) => (
|
.map(
|
||||||
<View key={module} style={customStyles.testDetails}>
|
({
|
||||||
<Text style={[...defaultSkillsTitleStyle, styles.textBold]}>
|
module,
|
||||||
|
suggestions,
|
||||||
|
evaluation,
|
||||||
|
bullet_points = [],
|
||||||
|
}) => (
|
||||||
|
<View key={module} style={customStyles.testDetailsContainer}>
|
||||||
|
<View style={customStyles.testDetails}>
|
||||||
|
<Text
|
||||||
|
style={[...defaultSkillsTitleStyle, styles.textBold]}
|
||||||
|
>
|
||||||
{module}
|
{module}
|
||||||
</Text>
|
</Text>
|
||||||
<Text style={defaultSkillsTextStyle}>{evaluation}</Text>
|
<Text style={defaultSkillsTextStyle}>{evaluation}</Text>
|
||||||
<Text style={defaultSkillsTextStyle}>{suggestions}</Text>
|
<Text style={defaultSkillsTextStyle}>{suggestions}</Text>
|
||||||
</View>
|
</View>
|
||||||
|
<View style={customStyles.testDetails}>
|
||||||
|
{bullet_points.length > 0 && (
|
||||||
|
<>
|
||||||
|
<Text
|
||||||
|
style={defaultSkillsTitleStyle}
|
||||||
|
>
|
||||||
|
How to Improve:
|
||||||
|
</Text>
|
||||||
|
<View>
|
||||||
|
{bullet_points.map((text: string) => (
|
||||||
|
<ListItem
|
||||||
|
key={text}
|
||||||
|
text={text}
|
||||||
|
textStyle={defaultSkillsTextStyle}
|
||||||
|
/>
|
||||||
))}
|
))}
|
||||||
</View>
|
</View>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
)
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
<View style={styles.alignRightRow}>
|
<View style={styles.alignRightRow}>
|
||||||
<Image src={qrcode} style={styles.qrcode} />
|
<Image src={qrcode} style={styles.qrcode} />
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ export interface ModuleScore {
|
|||||||
png?: string;
|
png?: string;
|
||||||
evaluation?: string;
|
evaluation?: string;
|
||||||
suggestions?: string;
|
suggestions?: string;
|
||||||
|
bullet_points?: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface StudentData {
|
export interface StudentData {
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ interface SkillsFeedbackRequest {
|
|||||||
interface SkillsFeedbackResponse extends SkillsFeedbackRequest {
|
interface SkillsFeedbackResponse extends SkillsFeedbackRequest {
|
||||||
evaluation: string;
|
evaluation: string;
|
||||||
suggestions: string;
|
suggestions: string;
|
||||||
|
bullet_points?: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
const getSkillsFeedback = async (sections: SkillsFeedbackRequest[]) => {
|
const getSkillsFeedback = async (sections: SkillsFeedbackRequest[]) => {
|
||||||
@@ -225,6 +226,7 @@ async function post(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
...result,
|
...result,
|
||||||
evaluation: feedback?.evaluation,
|
evaluation: feedback?.evaluation,
|
||||||
suggestions: feedback?.suggestions,
|
suggestions: feedback?.suggestions,
|
||||||
|
bullet_points: feedback?.bullet_points,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user