@@ -58,13 +58,17 @@ const Output = () => {
58
58
} ) ;
59
59
}
60
60
61
- if ( questionType === "get_mcq" ) {
61
+ if ( questionType === "get_mcq" ) {
62
62
qaPairsFromStorage [ "output" ] . forEach ( ( qaPair ) => {
63
- const options = qaPair . options ;
64
- const correctAnswer = qaPair . answer ;
63
+ const options = qaPair . answer
64
+ . filter ( ( ans ) => ! ans . correct )
65
+ . map ( ( ans ) => ans . answer ) ;
66
+ const correctAnswer = qaPair . answer . find (
67
+ ( ans ) => ans . correct
68
+ ) ?. answer ;
65
69
66
70
combinedQaPairs . push ( {
67
- question : qaPair . question_statement ,
71
+ question : qaPair . question ,
68
72
question_type : "MCQ_Hard" ,
69
73
options : options ,
70
74
answer : correctAnswer ,
@@ -127,40 +131,18 @@ const Output = () => {
127
131
let y = 700 ; // Starting y position for content
128
132
let questionIndex = 1 ;
129
133
130
- console . log ( "here inside downloading" , qaPairs )
131
-
132
134
qaPairs . forEach ( ( qaPair ) => {
133
135
if ( y < 50 ) {
134
136
page = pdfDoc . addPage ( ) ;
135
137
y = 700 ;
136
138
}
137
139
138
- // i'm implementing a question text wrapping logic so that it doesn't overflow the page
139
- const questionText = `Q${ questionIndex } ) ${ qaPair . question } ` ;
140
- const maxLineLength = 67 ;
141
- const lines = [ ] ;
142
-
143
- let start = 0 ;
144
- while ( start < questionText . length ) {
145
- let end = start + maxLineLength ;
146
- if ( end < questionText . length && questionText [ end ] !== ' ' ) {
147
- while ( end > start && questionText [ end ] !== ' ' ) {
148
- end -- ;
149
- }
150
- }
151
- if ( end === start ) {
152
- end = start + maxLineLength ;
153
- }
154
- lines . push ( questionText . substring ( start , end ) . trim ( ) ) ;
155
- start = end + 1 ;
156
- }
157
-
158
- lines . forEach ( ( line ) => {
159
- page . drawText ( line , { x : 50 , y, size : 15 } ) ;
160
- y -= 20 ;
140
+ page . drawText ( `Q${ questionIndex } ) ${ qaPair . question } ` , {
141
+ x : 50 ,
142
+ y,
143
+ size : 15 ,
161
144
} ) ;
162
-
163
- y -= 10 ;
145
+ y -= 30 ;
164
146
165
147
if ( qaPair . question_type === "Boolean" ) {
166
148
// Create radio buttons for True/False
@@ -208,11 +190,6 @@ const Output = () => {
208
190
} ;
209
191
drawRadioButton ( option , false ) ;
210
192
} ) ;
211
-
212
- if ( questionIndex % 5 === 0 ) {
213
- page = pdfDoc . addPage ( ) ;
214
- y = 700 ;
215
- }
216
193
} else if ( qaPair . question_type === "Short" ) {
217
194
// Text field for Short answer
218
195
const answerField = form . createTextField (
0 commit comments