Skip to content

Commit

Permalink
Merge pull request Sunbird-coKreat#273 from snehar-nd/snehar-nd/print…
Browse files Browse the repository at this point in the history
…docx

Snehar nd/printdocx
  • Loading branch information
pallakartheekreddy authored Feb 23, 2022
2 parents 6564072 + cd1caef commit 0f29b7f
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions src/service/print/csv.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,20 +264,22 @@ async function renderMCQ(
answerOptions = ["A", "B", "C", "D"];
let questionTitle;
let finalQuestion = "";

for (const [index, qo] of question.editorState.options.entries()) {
let qoBody = qo.value.body;
let qoData =
qoBody.search("img") >= 0 ||
qoBody.search("sup") >= 0 ||
qoBody.search("sub") >= 0 ||
(qoBody.match(/<p>/g) && qoBody.match(/<p>/g).length > 1) ||
(qoBody.match(/<ol>/g) && qoBody.match(/<ol>/g).length >= 1)
? await getStack(qoBody, answerOptions[index])
: [`${cleanHTML(qoBody)}`];
questionOptions.push(qoData);
if (question.editorState.options) {
for (const [index, qo] of question.editorState.options.entries()) {
let qoBody = qo.value.body;
let qoData =
qoBody.search("img") >= 0 ||
qoBody.search("sup") >= 0 ||
qoBody.search("sub") >= 0 ||
(qoBody.match(/<p>/g) && qoBody.match(/<p>/g).length > 1) ||
(qoBody.match(/<ol>/g) && qoBody.match(/<ol>/g).length >= 1)
? await getStack(qoBody, answerOptions[index])
: [`${cleanHTML(qoBody)}`];
questionOptions.push(qoData);
}
}
let q = question.editorState.question;

questionTitle =
q.search("img") >= 0 ||
q.search("sub") >= 0 ||
Expand Down Expand Up @@ -366,16 +368,15 @@ async function renderMCQ(
}
}
}

let data = {
Class: grade,
Subject: subject,
QuestionSetName: examName,
Questions: finalQuestion,
Option1: questionOptions[0][0],
Option2: questionOptions[1][0],
Option3: questionOptions[2][0],
Option4: questionOptions[3][0],
Option1: questionOptions.length !== 0 ? questionOptions[0][0] : "",
Option2: questionOptions.length !== 0 ? questionOptions[1][0] : "",
Option3: questionOptions.length !== 0 ? questionOptions[2][0] : "",
Option4: questionOptions.length !== 0 ? questionOptions[3][0] : "",
"CorrectAnswer(1/2/3/4)": question.answer,
Competencies: learningOutcome,
Skills: blooms,
Expand All @@ -385,6 +386,7 @@ async function renderMCQ(
RightColumn: "",
LeftColumn: "",
};

return data;
}

Expand Down

0 comments on commit 0f29b7f

Please sign in to comment.