-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue #CO-229 #CO-230 #CO-316 fix: {Reraising PR on release-6.0.0} #303
Changes from all commits
8656429
0b37f67
9c4622e
ba0fe42
f180ae8
4774ce6
9220d28
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,16 +18,23 @@ const { | |
convertInchesToTwip, | ||
} = docx; | ||
const _ = require("lodash"); | ||
const basicDetails={ | ||
english : require('./lang/english.json'), | ||
hindi : require('./lang/hindi.json') | ||
} | ||
|
||
function create(data, paperData) { | ||
const defaultLanguage = 'english'; | ||
const language = (paperData && paperData.language) ? paperData.language.toLowerCase(): defaultLanguage; | ||
|
||
const doc = new Document({ | ||
sections: [ | ||
{ | ||
properties: {}, | ||
children: [ | ||
headers( | ||
"Student Name:..............................................................", | ||
"Roll Number:............................." | ||
getLanguageKey(language, 'studentName') + ":..................................................", | ||
getLanguageKey(language, 'rollNo') + ":............................." | ||
), | ||
new Paragraph({ | ||
children: [], // Just newline without text | ||
|
@@ -49,7 +56,7 @@ function create(data, paperData) { | |
alignment: AlignmentType.CENTER, | ||
children: [ | ||
new TextRun({ | ||
text: `Grade: ${paperData.className}`, | ||
text: getLanguageKey(language, 'class')+ `:${paperData.className}`, | ||
bold: true, | ||
}), | ||
], | ||
|
@@ -61,15 +68,15 @@ function create(data, paperData) { | |
alignment: AlignmentType.CENTER, | ||
children: [ | ||
new TextRun({ | ||
text: `Subject: ${paperData.subject}`, | ||
text: getLanguageKey(language, 'subject')+ `:${paperData.subject}`, | ||
bold: true, | ||
}), | ||
], | ||
}), | ||
new Paragraph({ | ||
children: [], // Just newline without text | ||
}), | ||
headers("Time:............", "Marks:............"), | ||
headers(getLanguageKey(language, 'time')+":" + `${paperData.maxTime}`, getLanguageKey(language, 'marks')+":"+`${paperData.maxScore}`), | ||
new Paragraph({ | ||
alignment: AlignmentType.CENTER, | ||
children: [ | ||
|
@@ -81,7 +88,7 @@ function create(data, paperData) { | |
], | ||
}), | ||
|
||
instructionHead(paperData.instructions), | ||
instructionHead(paperData.instructions, language), | ||
instructions(paperData.instructions), | ||
new Paragraph({ | ||
alignment: AlignmentType.CENTER, | ||
|
@@ -226,9 +233,9 @@ function create(data, paperData) { | |
count++; | ||
}); | ||
arr.push( | ||
new Paragraph({ | ||
children: [], // Just newline without text | ||
}) | ||
// new Paragraph({ | ||
// children: [], // Just newline without text | ||
// }) | ||
); | ||
arr.push(optionsTabel(testimage)); | ||
arr.push( | ||
|
@@ -287,13 +294,13 @@ function create(data, paperData) { | |
return doc; | ||
} | ||
|
||
function instructionHead(data) { | ||
function instructionHead(data, language) { | ||
const arr = []; | ||
|
||
if (!_.isUndefined(data)) { | ||
arr.push( | ||
new TextRun({ | ||
text: `Instructions:`, | ||
text: (getLanguageKey(language, 'instructionHead')+":"), | ||
bold: true, | ||
}) | ||
); | ||
|
@@ -691,9 +698,9 @@ function displayNumber(data) { | |
type: WidthType.DXA, | ||
}, | ||
margins: { | ||
top: convertInchesToTwip(0.0693701), | ||
bottom: convertInchesToTwip(0.0693701), | ||
left: convertInchesToTwip(0.3493701), | ||
top: convertInchesToTwip(0.0093701), | ||
bottom: convertInchesToTwip(0.0093701), | ||
left: convertInchesToTwip(0.0693701), | ||
right: convertInchesToTwip(0.0693701), | ||
}, | ||
verticalAlign: VerticalAlign.CENTER, | ||
|
@@ -711,9 +718,9 @@ function displayNumber(data) { | |
type: WidthType.DXA, | ||
}, | ||
margins: { | ||
top: convertInchesToTwip(0.0693701), | ||
bottom: convertInchesToTwip(0.0693701), | ||
left: convertInchesToTwip(0.3493701), | ||
top: convertInchesToTwip(0.0093701), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not the right way of fixing the margins. It should be common across all sides. Any specific reason why the margins are different for the document. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While printing paper having MCQ questions, the line height between line 1 of options and line 2 of options was a bit higher. It was done to reduce the line height space to consume less physical paper. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not convinced.. Can you share the snapshot of the UI. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
bottom: convertInchesToTwip(0.0093701), | ||
left: convertInchesToTwip(0.0693701), | ||
right: convertInchesToTwip(0.0693701), | ||
}, | ||
verticalAlign: VerticalAlign.CENTER, | ||
|
@@ -992,6 +999,12 @@ function optionsTabel(testimage) { | |
}); | ||
} | ||
|
||
function getLanguageKey(lang, key) { | ||
return basicDetails[lang] && basicDetails[lang][key] ? | ||
basicDetails[lang][key] : | ||
basicDetails[defaultLanguage][key] | ||
} | ||
|
||
module.exports = { | ||
create, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"studentName" : "Student Name", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These files should be taken from blob rather than adding to the code repo. Any new language should not require any code code, it will be configuration driven. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where must i save these language files and how we will be using them. If there is any reference, please share. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @vaivk369 , please help me with this if you can. |
||
"rollNo": "Roll Number", | ||
"subject": "Subject", | ||
"class": "Class", | ||
"time": "Time", | ||
"marks": "Marks", | ||
"instructionHead": "Instructions" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hope you enjoyed writing the code.. looks fine.
@vaivk369 @shubhambansaltarento
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes i did, Thank you for guidance.