Rehman1603 commited on
Commit
3b532bd
1 Parent(s): 2d62082

Create fileCreator.py

Browse files
Files changed (1) hide show
  1. fileCreator.py +95 -0
fileCreator.py ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from docx import Document
2
+ from docx.shared import Inches
3
+
4
+ def get_Options(MCQS ,no):
5
+ Options=MCQS.get("questions")[no].get('options')
6
+ Options.append(MCQS.get("questions")[no].get('answer'))
7
+ random.shuffle(Options)
8
+ return Options
9
+
10
+ def get_MCQS_Statement(MCQS,i):
11
+ text=MCQS.get("questions")[i].get("question_statement")
12
+ return text
13
+
14
+ def get_sq(sq_result,i):
15
+ text=sq_result.get('questions')[i].get('Question')
16
+ return text
17
+ def get_Paragraph(pararesult):
18
+ text=pararesult.get('Question')
19
+ return text
20
+
21
+ def get_Paragraph_Question(pararesult):
22
+ text=pararesult.get("Paraphrased Questions")
23
+ return text
24
+
25
+ def GenerateMCQSDocument(MCQS):
26
+ document = Document()
27
+
28
+ document.add_heading('Quiz', 0)
29
+
30
+
31
+
32
+ table = document.add_table(rows=1, cols=5)
33
+ hdr_cells = table.rows[0].cells
34
+ hdr_cells[0].text = 'Statement'
35
+ hdr_cells[1].text = 'A'
36
+ hdr_cells[2].text = 'B'
37
+ hdr_cells[3].text = 'C'
38
+ hdr_cells[4].text = 'D'
39
+ for i in range(0,3,1):
40
+ state=get_MCQS_Statement(MCQS,i)
41
+ print(state)
42
+ MCqs_Options=get_Options(MCQS,i)
43
+ print(MCqs_Options)
44
+ row_cells = table.add_row().cells
45
+ row_cells[0].text = str(state)
46
+ row_cells[1].text = MCqs_Options[0]
47
+ row_cells[2].text = MCqs_Options[1]
48
+ row_cells[3].text = MCqs_Options[2]
49
+ row_cells[4].text = MCqs_Options[3]
50
+
51
+ document.add_page_break()
52
+
53
+ document.save('Document.docx')
54
+
55
+
56
+ def GenerateSQDocument(sq_result):
57
+ document = Document()
58
+
59
+ document.add_heading('Quiz', 0)
60
+
61
+
62
+
63
+ table = document.add_table(rows=1, cols=1)
64
+ hdr_cells = table.rows[0].cells
65
+ hdr_cells[0].text = 'Questions'
66
+ for i in range(0,3,1):
67
+ ques=get_sq(sq_result,i)
68
+ print(ques)
69
+ row_cells = table.add_row().cells
70
+ row_cells[0].text = str(ques)
71
+
72
+ document.add_page_break()
73
+
74
+ document.save('Document1.docx')
75
+
76
+
77
+
78
+ def GenerateParaphraseDocument(pararesult):
79
+ document = Document()
80
+ paragraph=get_Paragraph(pararesult)
81
+ Question=get_Paragraph_Question(pararesult)
82
+ document.add_heading('Quiz', 0)
83
+ document.add_paragraph(paragraph,style='Intense Quote')
84
+ table = document.add_table(rows=1, cols=1)
85
+ hdr_cells = table.rows[0].cells
86
+ hdr_cells[0].text = 'Questions'
87
+ for i in range(0,3,1):
88
+ row_cells = table.add_row().cells
89
+ row_cells[0].text = Question[i]
90
+
91
+ document.add_page_break()
92
+
93
+ document.save('Document2.docx')
94
+
95
+