Commit 7fc7df60 authored by Bharat Kashyap's avatar Bharat Kashyap
Browse files

fix: SB-26189 issues with FTB questions with image

Showing with 22 additions and 4 deletions
+22 -4
......@@ -70,7 +70,7 @@ const getQuestionForSection = async (id) => {
})
.then((r) => {
if (status === 200) {
if (r.result.content.itemSets.length > 0) {
if (r.result.content.itemSets && r.result.content.itemSets.length > 0) {
const itemset = r.result.content.itemSets[0];
return getItemsFromItemset(itemset.identifier);
} else {
......@@ -84,8 +84,9 @@ const getQuestionForSection = async (id) => {
})
.catch((e) => {
error = true;
if (e.name === "PDFDataImportError") errorMsg = e.message;
if (e.name === "PDFDataImportError");
else e.message = "Uncaught Exception";
let errorMsg = e.message
return {
error,
errorMsg,
......
......@@ -307,8 +307,8 @@ function Marks(data) {
}
function createFTBObject(data) {
const arr = [];
data.text
if(data.text) {
data.text
.map((text) => {
if (typeof text === "object") {
arr.push(new TextRun(text));
......@@ -321,6 +321,23 @@ function createFTBObject(data) {
}
})
.reduce((prev, curr) => prev.concat(curr), []);
}
else if(data.image) {
if (data.image.includes("data:image/")) {
let image = getBufferImg(data.image);
return new Paragraph({
children: [
new ImageRun({
data: image,
transformation: {
width: data.width,
height: data.height,
},
}),
],
});
}
}
return new Paragraph({
alignment: AlignmentType.LEFT,
children: arr,
......
Supports Markdown
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