File size: 2,169 Bytes
3b532bd
 
026d6c2
 
3b532bd
 
 
cfef55a
a40dc73
3b532bd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ca9f984
3b532bd
 
cfef55a
3b532bd
cfef55a
3b532bd
 
6c16b75
e9a7c93
3b532bd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
from docx import Document
from docx.shared import Inches
import random


def get_Options(MCQS ,no):
  Options=MCQS.get("questions")[no].get('options')
  answer=MCQS.get("questions")[no].get('answer')
  return Options,answer

def get_MCQS_Statement(MCQS,i):
  text=MCQS.get("questions")[i].get("question_statement")
  return text

def get_sq(sq_result,i):
  text=sq_result.get('questions')[i].get('Question')
  return text
def get_Paragraph(pararesult):
  text=pararesult.get('Question')
  return text

def get_Paragraph_Question(pararesult):
  text=pararesult.get("Paraphrased Questions")
  return text

def GenerateMCQSDocument(MCQS):
  document = Document()

  document.add_heading('Quiz', 0)



  table = document.add_table(rows=1, cols=5)
  hdr_cells = table.rows[0].cells
  hdr_cells[0].text = 'Statement'
  hdr_cells[1].text = 'A'
  hdr_cells[2].text = 'B'
  for i in range(0,3,1):
    state=get_MCQS_Statement(MCQS,i)
    print(state)
    MCqs_Options,ans=get_Options(MCQS,i)
    print(MCqs_Options)
    print(ans)
    row_cells = table.add_row().cells
    row_cells[0].text = str(state)
    row_cells[1].text = MCqs_Options[0]
    row_cells[3].text = ans

  document.add_page_break()

  document.save('Document.docx')


def GenerateSQDocument(sq_result):
  document = Document()

  document.add_heading('Quiz', 0)



  table = document.add_table(rows=1, cols=1)
  hdr_cells = table.rows[0].cells
  hdr_cells[0].text = 'Questions'
  for i in range(0,3,1):
    ques=get_sq(sq_result,i)
    print(ques)
    row_cells = table.add_row().cells
    row_cells[0].text = str(ques)

  document.add_page_break()

  document.save('Document1.docx')



def GenerateParaphraseDocument(pararesult):
  document = Document()
  paragraph=get_Paragraph(pararesult)
  Question=get_Paragraph_Question(pararesult)
  document.add_heading('Quiz', 0)
  document.add_paragraph(paragraph,style='Intense Quote')
  table = document.add_table(rows=1, cols=1)
  hdr_cells = table.rows[0].cells
  hdr_cells[0].text = 'Questions'
  for i in range(0,3,1):
    row_cells = table.add_row().cells
    row_cells[0].text = Question[i]

  document.add_page_break()

  document.save('Document2.docx')