-
Notifications
You must be signed in to change notification settings - Fork 4
/
SUSStud.py
109 lines (90 loc) · 3.8 KB
/
SUSStud.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
from Result import Result
import statistics
class SUSStud:
# Class for calculating and handling a whole dataset of SUS-Scores.
def __init__(self, results, name):
self.Results = results
self.Score = self.calcSUS()
self.avgScorePerQuestion, self.scoresPerQuestion = self.calcSUSScorePerQuestion()
self.name = name
self.standardDevPerQuestion = self.calcStandardDevPerQuestion()
self.popStandardDevOverall = self.calcPopulationStandardDev()
self.standardDevOverall = self.calcStandardDev()
self.median = self.calcMedian()
self.rawResultPerQuestion = self.getRawResultPerQuestion()
# Calculates the overall SUS-Score with all the SUS-Results in the dataset.
def calcSUS(self):
score_sum = 0
for res in self.Results:
score_sum += res.SUSScore
return score_sum / len(self.Results)
# Returns a ordered list with the scores for each of the Results (so, for each participant who filled in a
# SUS-Survey).
def getAllSUSScores(self):
scores = []
for res in self.Results:
scores.append(res.SUSScore)
return scores
# Returns an ordered list of average SUS Scores for each of the 10 SUS-Questions.
def calcSUSScorePerQuestion(self, removeIdxs=None):
if removeIdxs is None:
removeIdxs = []
avgScorePerQuestion = []
scoresPerQuestion = {}
for res in self.Results:
for idx, questionScore in enumerate(res.getScorePerQuestionExcluding(removeIdxs)):
if idx < len(avgScorePerQuestion):
avgScorePerQuestion[idx] += questionScore
scoresPerQuestion[idx].append(questionScore)
else:
avgScorePerQuestion.append(questionScore)
scoreList = [questionScore]
scoresPerQuestion[idx] = scoreList
for idx, questionScoreRaw in enumerate(avgScorePerQuestion):
avgScorePerQuestion[idx] = questionScoreRaw / len(self.Results)
return avgScorePerQuestion, scoresPerQuestion
def getRawResultPerQuestion(self):
rawResultPerQuestion = [[],
[],
[],
[],
[],
[],
[],
[],
[],
[]]
for result in self.Results:
for i, singleAnswer in enumerate(result.resultsRaw):
rawResultPerQuestion[i].append(result.resultsRaw[i])
return rawResultPerQuestion
def addResult(self, result):
self.Results.append(result)
self.Score = self.calcSUS()
self.avgScorePerQuestion = self.calcSUSScorePerQuestion()
def calcStandardDevPerQuestion(self):
standardDeviations = []
for question in self.scoresPerQuestion.values():
try:
standardDeviations.append(statistics.stdev(question))
except statistics.StatisticsError:
standardDeviations.append(0)
return standardDeviations
def calcStandardDev(self):
try:
standardDev = statistics.stdev(self.getAllSUSScores())
except statistics.StatisticsError:
standardDev = 0
return standardDev
def calcMedian(self):
try:
median = statistics.median(self.getAllSUSScores())
except statistics.StatisticsError:
median = 0
return median
def calcPopulationStandardDev(self):
try:
standardDev = statistics.pstdev(self.getAllSUSScores())
except statistics.StatisticsError:
standardDev = 0
return standardDev