-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHTML_PDFGen.rb
More file actions
96 lines (75 loc) · 1.74 KB
/
HTML_PDFGen.rb
File metadata and controls
96 lines (75 loc) · 1.74 KB
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
95
96
require "prawn"
require "cgi"
require_relative "EquationGenerator"
class HTMLPDFGen
@@eqGen = EquationGenerator.new
@@allTests
def GenTests
@@allTests = []
10.times do |i|
@@allTests << @@eqGen.Kvadratno
end
end
def PDFGen name
pdf = Prawn::Document.new
10.times do |i|
pdf.text ((i+1).to_s + GetQuest( i, 2))
end
pdf.render_file ("Test_" + name)
end
def PDFGenAnswers name
pdf = Prawn::Document.new
10.times do |i|
pdf.text ((i+1).to_s + GetQuest( i, 2))
pdf.text (GetQuest i, 0)
pdf.text (GetQuest i, 1)
pdf.text "\n"
end
pdf.render_file ("Test_" + name.gsub(/.pdf/, "") + "Answers.pdf")
end
def HTMLGen name
name+=".html"
cgi = CGI.new("html4")
file = File.open("Test_" + name.gsub(/.html/, "") + ".html", "w")
file.puts cgi.html{ cgi.body{ cgi.h2{"Test " + name.gsub(/.html/, "")} + "\n" + "\n" } }
10.times do |i|
file.puts cgi.html {
cgi.head{
"\n" + cgi.title{"Test " + name.gsub(/.html/, "")}
} +
cgi.body{
"\n" +
cgi.form{
cgi.p{(i+1).to_s + GetQuest(i, 2)} + "\n"
}
}
}
end
file.close()
end
def HTMLGenAnswers name
name+=".html"
cgi = CGI.new("html4")
file = File.open("Test_" + name.gsub(/.html/, "") + "Answers.html", "w")
file.puts cgi.html{ cgi.body{ cgi.h2{"Test " + name.gsub(/.html/, "") + " Answers"} + "\n" + "\n" } }
10.times do |i|
file.puts cgi.html {
cgi.head{
"\n" + cgi.title{"Test " + name.gsub(/.html/, "")}
} +
cgi.body{
"\n" +
cgi.form{
cgi.p{(i+1).to_s + GetQuest(i, 2)} +
cgi.p{GetQuest(i, 0)} +
cgi.p{GetQuest(i, 1)} + cgi.br
}
}
}
end
file.close()
end
def GetQuest x, y
@@allTests[x][y]
end
end