-
Notifications
You must be signed in to change notification settings - Fork 4
/
Result.py
63 lines (54 loc) · 2.56 KB
/
Result.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
import statistics
class Result:
# One single Result-Dataset of an SUS-Questionnaire. It contains the SUS-Result of one SUS survey participant.
def __init__(self, resultsRaw, participantID):
self.resultsRaw = resultsRaw
self.scorePerQuestion = []
self.SUSScore = self.calcSingleScore()
self.participantID = participantID
self.standardDeviationPerQuestion = self.calcStandardDeviation()
self.rawResultPerQuestion = self.getRawResultPerQuestion()
# Calculates the overall score for this result-dataset. Also saves the Score per Question in the scorePerQuestion-
# list
def calcSingleScore(self):
rawScore = 0
idx = 1
for val in self.resultsRaw:
if val is None:
print(self.resultsRaw)
val = int(val)
if val < 1 or val > 5:
raise Exception('SUS-Values must be between 1 and 5.')
if idx % 2 == 0:
tempScore = 5 - val
self.scorePerQuestion.append(tempScore * 2.5)
rawScore += tempScore
else:
tempScore = val - 1
self.scorePerQuestion.append(tempScore * 2.5)
rawScore += tempScore
idx += 1
return rawScore * 2.5
def getScorePerQuestionExcluding(self, excludeQuestionIdxs):
filteredQuestionsScore = [i for j, i in enumerate(self.scorePerQuestion) if j not in excludeQuestionIdxs]
return filteredQuestionsScore
def calcStandardDeviation(self):
return statistics.stdev(self.scorePerQuestion)
def getRawResultPerQuestion(self):
rawResultPerQuestionDict = {"Question 1": self.resultsRaw[0],
"Question 2": self.resultsRaw[1],
"Question 3": self.resultsRaw[2],
"Question 4": self.resultsRaw[3],
"Question 5": self.resultsRaw[4],
"Question 6": self.resultsRaw[5],
"Question 7": self.resultsRaw[6],
"Question 8": self.resultsRaw[7],
"Question 9": self.resultsRaw[8],
"Question 10": self.resultsRaw[9]}
return rawResultPerQuestionDict
if __name__ == "__main__":
resultOne = Result([3, 2, 5, 1, 4, 5, 3, 4, 5, 2], 0)
resultTwo = Result([1, 4, 3, 4, 4, 5, 2, 1, 4, 3], 1)
print(resultOne.participantID)
print(resultOne.scorePerQuestion)
print(resultTwo.scorePerQuestion)