diff --git a/src/service/print/dataImporter.js b/src/service/print/dataImporter.js index 84f9b8dfb584274d7dbda569011c273ca05d903e..bfd6544649f14589e7bafc2c20aca99f30b8f652 100644 --- a/src/service/print/dataImporter.js +++ b/src/service/print/dataImporter.js @@ -83,7 +83,6 @@ const getQuestionForSection = async (id) => { } }) .catch((e) => { - console.log("Here", e.name, e.message); error = true; if (e.name === "PDFDataImportError") errorMsg = e.message; else e.message = "Uncaught Exception"; @@ -110,7 +109,11 @@ const getData = async (id) => { const questionIds = sections.map((section) => { if (section.children) - return section.children.map((child) => child.identifier); + return section.children + .filter( + (child) => data.acceptedContents.indexOf(child.identifier) > -1 + ) + .map((child) => child.identifier); else return []; }); // Hierarchy diff --git a/src/service/print/pdf.js b/src/service/print/pdf.js index 2d138e4323ff4bbc12313e4bc1a1b0180a3be665..80693f75fa53cf1e5bb856c8b81f4d1b2be9b335 100644 --- a/src/service/print/pdf.js +++ b/src/service/print/pdf.js @@ -97,35 +97,31 @@ const buildPDFWithCallback = (id, callback) => { questionPaperContent.push(sectionTitle); const section = d.section; - d.questions - .filter((question) => { - return question.status === "Live"; - }) - .map((question, index) => { - // Check question type and proceed based on that. - questionCounter += 1; - const marks = section.children[index].marks; - let questionContent; - try { - if (question.category === "MCQ") - questionContent = renderMCQ(question, questionCounter, marks); - else if (question.category === "FTB") { - questionContent = renderFTB(question, questionCounter, marks); - } else if (question.category === "SA") { - questionContent = renderSA(question, questionCounter, marks); - } else if (question.category === "LA") { - questionContent = renderLA(question, questionCounter, marks); - } else if (question.category === "VSA") { - questionContent = renderVSA(question, questionCounter, marks); - } else if (question.category === "TF") { - questionContent = renderTF(question, questionCounter, marks); - } - - questionPaperContent.push(questionContent); - } catch (e) { - console.log(e); + d.questions.map((question, index) => { + // Check question type and proceed based on that. + questionCounter += 1; + const marks = section.children[index].marks; + let questionContent; + try { + if (question.category === "MCQ") + questionContent = renderMCQ(question, questionCounter, marks); + else if (question.category === "FTB") { + questionContent = renderFTB(question, questionCounter, marks); + } else if (question.category === "SA") { + questionContent = renderSA(question, questionCounter, marks); + } else if (question.category === "LA") { + questionContent = renderLA(question, questionCounter, marks); + } else if (question.category === "VSA") { + questionContent = renderVSA(question, questionCounter, marks); + } else if (question.category === "TF") { + questionContent = renderTF(question, questionCounter, marks); } - }); + + questionPaperContent.push(questionContent); + } catch (e) { + console.log(e); + } + }); }); docDefinition.content = contentBase.concat(questionPaperContent); @@ -229,7 +225,7 @@ function renderSA(question, questionCounter, marks) { function renderLA(question, questionCounter, marks) { const questionTitle = questionCounter + ". " + cleanHTML(question.editorState.question); - return getLA(questionTitle, detectLanguage(questionTitle[0]), mark); + return getLA(questionTitle, detectLanguage(questionTitle[0]), marks); } function renderVSA(question, questionCounter, marks) {