From ff99b5492012244dd9e9874e6b375fd544d1cf50 Mon Sep 17 00:00:00 2001 From: snehar-nd <sneha@navadhiti.com> Date: Wed, 19 Jan 2022 13:22:33 +0530 Subject: [PATCH] Fix for Instructions in question paper(Instruction values are missing sometimes.) --- src/service/print/printDocxV1.0/dataImporter.js | 17 ++++------------- src/service/print/printDocxV1.0/docx.js | 2 +- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/src/service/print/printDocxV1.0/dataImporter.js b/src/service/print/printDocxV1.0/dataImporter.js index 42e014a..1d48167 100644 --- a/src/service/print/printDocxV1.0/dataImporter.js +++ b/src/service/print/printDocxV1.0/dataImporter.js @@ -45,7 +45,7 @@ const getQuestionSet = async (id) => { headers, }; - return axios(request).then((r) => { + return axios(request).then(async (r) => { const data = r.data.result.questionSet; let sections; if (data && "children" in data) sections = data.children; @@ -65,17 +65,8 @@ const getQuestionSet = async (id) => { }); else return []; }); // Hierarchy - - const instructions = getQuestionForSet(id).then((resp) => { - return resp.instructions.default; - }); - - var introData - - instructions.then((result)=>{ - introData = result - }) - + + const instructions = await getQuestionForSet(id); const promiseMap = questionIds.map((sec) => sec.map((question) => { @@ -109,7 +100,7 @@ const getQuestionSet = async (id) => { return { sectionData, paperData: data, - instructions: introData + instructions: instructions.instructions.default }; }); }); diff --git a/src/service/print/printDocxV1.0/docx.js b/src/service/print/printDocxV1.0/docx.js index 3847873..7f2f7ad 100644 --- a/src/service/print/printDocxV1.0/docx.js +++ b/src/service/print/printDocxV1.0/docx.js @@ -20,11 +20,11 @@ const buildDOCX_1_WithCallback = async (id, callback) => { callback(null, data.error, data.errorMsg); } else { let subject, grade, examName, instructions, language, description; + if(data.instructions) instructions = data.instructions; if (data.paperData) { subject = data.paperData.subject && data.paperData.subject[0]; grade = data.paperData.gradeLevel && data.paperData.gradeLevel[0]; examName = data.paperData.name; - instructions = data.instructions; language = data.paperData.medium && data.paperData.medium[0]; } -- GitLab