-
Notifications
You must be signed in to change notification settings - Fork 4
/
SUSDataset.py
94 lines (80 loc) · 3.3 KB
/
SUSDataset.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
import operator
class SUSDataset:
def __init__(self, SUSStuds):
self.SUSStuds = SUSStuds
self.sortBy('alphabetically')
self.avgScorePerQuestion = self.calcAvgScorePerQuestion()
self.allAbsoluteSingleScores = self.calcAllAbsoluteSingleScores()
self.allSUSScoresPerParticipant = self.calcAllSUSScoresPerParticipant()
self.allStudiesAvgSUSScore = self.calcAllStudiesAvgSUSScore()
self.rawResultPerQuestion = self.getRawResultPerQuestion()
def calcAvgScorePerQuestion(self):
avgScorePerQuestion = []
for i, study in enumerate(self.SUSStuds):
for j, questionScore in enumerate(study.avgScorePerQuestion):
if j < len(avgScorePerQuestion):
avgScorePerQuestion[j] += questionScore
else:
avgScorePerQuestion.append(questionScore)
for i in range(0, 9):
avgScorePerQuestion[i] = avgScorePerQuestion[i] / len(self.SUSStuds)
return avgScorePerQuestion
def calcAllAbsoluteSingleScores(self):
allAbsoluteScores = []
for study in self.SUSStuds:
for result in study.Results:
allAbsoluteScores.extend(result.scorePerQuestion)
return allAbsoluteScores
def calcAllSUSScoresPerParticipant(self):
allSUSScoresPerParticipant = []
for study in self.SUSStuds:
for result in study.Results:
allSUSScoresPerParticipant.append(result.SUSScore)
return allSUSScoresPerParticipant
def calcAllStudiesAvgSUSScore(self):
tempScore = 0
for study in self.SUSStuds:
tempScore += study.Score
return tempScore / len(self.SUSStuds)
def sortBy(self, sortKey):
if sortKey == 'alphabetically':
sortedStuds = sorted(self.SUSStuds, key=operator.attrgetter('name'))
self.SUSStuds = sortedStuds
return
elif sortKey == 'mean':
sortedStuds = sorted(self.SUSStuds, key=operator.attrgetter('Score'))
self.SUSStuds = sortedStuds
return
elif sortKey == 'median':
sortedStuds = sorted(self.SUSStuds, key=operator.attrgetter('median'))
self.SUSStuds = sortedStuds
return
def getAllStudNames(self):
studies = []
for study in self.SUSStuds:
studies.append(study.name)
return studies
def getIndividualStudyData(self, name):
for study in self.SUSStuds:
if study.name == name:
return study
def getAllResults(self):
results = []
for study in self.SUSStuds:
results.append(study.Results)
return results
def getRawResultPerQuestion(self):
rawResultPerQuestion = [[],
[],
[],
[],
[],
[],
[],
[],
[],
[]]
for study in self.SUSStuds:
for i, resultsPerQuestion in enumerate(study.getRawResultPerQuestion()):
rawResultPerQuestion[i].extend(resultsPerQuestion)
return rawResultPerQuestion