forked from balfroim/MuTEd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquestions2latex.py
162 lines (150 loc) · 5.88 KB
/
questions2latex.py
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#!/usr/bin/env python3
import csv
QA = [
"What was your knowledge of Java before you started this experiment?",
[
"No knowledge",
"Basic knowledge",
"Intermediate knowledge",
"Advanced knowledge",
],
"What was your knowledge of software testing before you started this experiment?",
[
"No knowledge",
"Basic knowledge",
"Intermediate knowledge",
"Advanced knowledge",
],
"Do you think it is interesting to present the concepts of mutation testing together with the basics of programming?",
[
"Yes",
"Yes but superficially",
"No",
],
"What could be the consequences of the use of mutation testing by novice programmers?",
[
"Better programs",
"More competent programmers",
"Better programs and more competent programmers",
"Neither",
],
"Do you consider classical testing tools (JUnit) to be useful for teaching programming fundamentals?",
[
"Yes",
"Yes, but only with basic functionality",
"No",
],
"Do you consider mutation testing tools to be useful for teaching the fundamentals of programming?",
[
"Yes",
"Yes, but only with basic functionality",
"No",
],
"Considering your background so far (without taking this presentation into account), you feel that the concepts of software testing have been:",
[
"Fairly well presented",
"Insufficiently presented",
"Not presented",
],
"Do you think that using software testing tools for learning purposes could be useful for creating good programming habits?",
[
"Yes",
"No",
],
"Do you think that creating test cases through mutation testing is useful for improving the learning ability of novice programmers?",
[
"Yes",
"No",
],
"How did you find creating tests manually, without the help of a tool?",
[
"Easy in general",
"Difficult, especially with regard to the completeness of my tests (sufficient code coverage)",
"Difficult, especially to follow a logical order in the design of test cases",
],
"What is your perception of software testing after applying mutation testing to your tests?",
[
"It has changed the way I design tests",
"This allowed me to discover parts of the code that were not sufficiently tested",
"The mutants do not seem to me to be particularly useful for improving the quality of my tests",
],
"The reports generated by the tool used in the second session:",
[
"Were sufficiently understandable",
"Lacked comprehensibility but were still usable",
"Were not understandable enough to be usable",
],
"Compared to your original self-assessment, you feel:",
[
"You have assessed yourself correctly",
"You have overestimated yourself",
"You have undervalued yourself",
],
"From a practical point of view, mutation testing:",
[
"Is very useful",
"Is very useful but not comfortable to use",
"Does not compensate for the effort required to use it",
],
]
QUESTIONS = QA[::2]
ANSWERS = QA[1::2]
GROUPS = ["pit", "reneri"]
HEADER_LATEX = r"""% Generated from script
{\footnotesize\begin{longtable}{m{0.55\linewidth}rrr}
\caption{Questions and Answers by Group}
\label{tab:questionnaire} \\
\hline
& \textbf{Both} & \textbf{PIT} & \textbf{Reneri} \\
\hline
\endfirsthead
\hline
& \textbf{Both} & \textbf{PIT} & \textbf{Reneri} \\
\hline
\endhead
\hline
\multicolumn{4}{r}{\textit{Continued on next page}} \\ \hline
\endfoot
\hline
\endlastfoot"""
def write_table_questionaire():
with open("data/questions.csv", "r") as file:
reader = csv.reader(file)
answers_both, answers_per_group = count_answers(reader)
# Format
buffer = HEADER_LATEX
for question_i, question in enumerate(QUESTIONS):
buffer += "\n"
buffer += r""" \multicolumn{4}{m{0.9\linewidth}}{\textit{Q%d.~%s}} \\*""" % (question_i + 1, question)
for answer_i, answer in enumerate(ANSWERS[question_i]):
sum_both = sum(answers_both[question_i])
sum_per_group = [sum(answers_per_group[group_i][question_i]) for group_i in range(len(GROUPS))]
both = answers_both[question_i][answer_i]
per_group = [answers_per_group[group_i][question_i][answer_i] for group_i in range(len(GROUPS))]
percentage_both = round(both / sum_both * 100)
percentage_per_group = [round(per_group[0] / sum_per_group[0] * 100),
round(per_group[1] / sum_per_group[1] * 100)]
last = answer_i == len(ANSWERS[question_i]) - 1
buffer += r""" %s & %d (%d\%%) & %d (%d\%%) & %d (%d\%%) """ % (
answer, both, percentage_both, per_group[0], percentage_per_group[0], per_group[1],
percentage_per_group[1])
buffer += r"\\ \hline" if last else r"\\*"
buffer += "\n"
buffer += "\n" + r"""\end{longtable}}""" + "\n"
with open("output/tables/questions.tex", "w") as f:
f.write(buffer)
def count_answers(reader: '_csv.reader'):
answers_both = [[0 for _ in q] for q in ANSWERS]
answers_per_group = [[[0 for _ in q] for q in ANSWERS] for _ in GROUPS]
next(reader) # Skip header
for row in reader:
name, group, *answers = row
group_i = GROUPS.index(group)
for question_i, answer in enumerate(answers):
try:
answer_i = int(answer) - 1
answers_both[question_i][answer_i] += 1
answers_per_group[group_i][question_i][answer_i] += 1
except ValueError:
pass
return answers_both, answers_per_group