Skip to content

Commit

Permalink
Merge pull request #249 from hpi-swa-teaching/bugfix/csv_export
Browse files Browse the repository at this point in the history
Bugfix/csv export
  • Loading branch information
leaantonia authored Jun 3, 2024
2 parents 02ff362 + 5f64933 commit 9e3b055
Show file tree
Hide file tree
Showing 23 changed files with 81 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ printDataOn: aStream for: orderedQuestionIDs with: aDelimiter

orderedQuestionIDs do: [:answerId |
self answers at: answerId ifPresent: [:printedAnswer | printedAnswer printDataOn: aStream].
aStream nextPutAll: aDelimiter]
aStream nextPutAll: aDelimiter].
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"initialize" : "JT 8/2/2022 16:53",
"pollId" : "JS 5/18/2021 18:38",
"pollId:" : "JS 5/18/2021 18:37",
"printDataOn:for:with:" : "bn 8/5/2022 20:39",
"printDataOn:for:with:" : "leli 5/21/2024 11:35",
"token" : "JT 8/2/2022 16:55",
"token:" : "JT 8/2/2022 16:55" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
instance creation
pathToExport
^ FileDirectory default fullName , FileDirectory default pathNameDelimiter , 'DataExports'
20 changes: 14 additions & 6 deletions packages/Liquid-Core.package/LQPoll.class/instance/exportCSV.st
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
printing
exportCSV

| stream |

stream := WriteStream on: String new.
self printDataOn: stream withDelimiter: ';'.
^ stream contents
| filePath directory |
directory := FileDirectory on: self class pathToExport.
directory exists
ifFalse: [FileDirectory default createDirectory: self class pathToExport].
filePath := self class pathToExport , FileDirectory default pathNameDelimiter , self id , '.csv'.
(FileDirectory default fileExists: filePath)
ifTrue: [| confirmDeletion |
confirmDeletion := UIManager default confirm: 'A poll CSV file with that id already exists. Delete it and recreate it?'.
confirmDeletion
ifFalse: [^ self].
FileDirectory default deleteFileNamed: filePath].
FileStream
newFileNamed: filePath
do: [:aStream | self printDataOn: aStream withDelimiter: ';']

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
printing
printDataOn: aStream withDelimiter: aDelimiter

printDataOn: aStream withDelimiter: aDelimiter
| orderedIds |

orderedIds := self pollDraft questionList collect: [:aQuestion | aQuestion id].
self pollDraft questionList do: [:aQuestion |
aStream nextPutAll: aQuestion title.
aStream nextPutAll: aDelimiter].
orderedIds := self pollDraft questionList
collect: [:aQuestion | aQuestion id].
self pollDraft questionList
do: [:aQuestion |
aStream nextPutAll: aQuestion title.
aStream nextPutAll: aDelimiter].
aStream nextPut: Character cr.
self answerSets do: [:answer |
answer printDataOn: aStream for: orderedIds with: aDelimiter.
aStream nextPut: Character cr]
self answerSets
do: [:answer |
answer
printDataOn: aStream for: orderedIds with: aDelimiter.
aStream nextPut: Character cr].
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
printing
returnDataWithDelimiter: aDelimiter
| aStream |
aStream := String new writeStream.
self printDataOn: aStream withDelimiter: $;.
^ aStream contents
11 changes: 6 additions & 5 deletions packages/Liquid-Core.package/LQPoll.class/methodProperties.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"class" : {
"newWithPollDraft:" : "CG 7/30/2021 19:06" },
"newWithPollDraft:" : "CG 7/30/2021 19:06",
"pathToExport" : "vl 5/23/2024 16:53" },
"instance" : {
"addAnswerSet:" : "kge 8/1/2022 19:01",
"answerSets" : "JS 5/25/2021 15:32",
"answerSets:" : "JT 8/2/2022 17:07",
"answeredByUser:" : "kge 8/3/2022 21:34",
"closeWithPassword:" : "kge 8/1/2022 19:17",
"countNumberOfAnswersWithChoice:ForQuestion:" : "kge 8/3/2022 22:06",
"exportCSV" : "leli 5/10/2024 09:58",
"exportCSVDownloadsPath" : "leli 5/10/2024 21:06",
"exportCSV" : "vl 6/2/2024 12:09",
"getChoiceIdentifiersFor:" : "kge 5/15/2022 13:02",
"getChoiceNamesFor:" : "kge 5/15/2022 13:02",
"getVotedChoicesPerChoiceFor:" : "kge 8/3/2022 22:04",
Expand All @@ -26,10 +26,11 @@
"myUserWithToken:" : "kge 8/3/2022 20:51",
"pollDraft" : "JS 5/25/2021 15:33",
"pollDraft:" : "JS 5/25/2021 15:33",
"printDataOn:" : "leli 5/10/2024 09:55",
"printDataOn:withDelimiter:" : "JT 8/2/2022 20:46",
"printDataOn:" : "leli 5/21/2024 12:11",
"printDataOn:withDelimiter:" : "leli 5/21/2024 11:33",
"questionList" : "kge 8/3/2022 20:48",
"requiresAuthentication" : "kge 6/25/2022 16:46",
"returnDataWithDelimiter:" : "vl 5/30/2024 17:24",
"sanitized" : "ms 8/4/2022 21:26",
"startTime" : "JS 5/25/2021 15:55",
"startTime:" : "CG 7/30/2021 19:06",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"class" : {
"replaceAll:in:" : "vl 6/1/2024 14:31" },
"replaceAll:in:" : "vl 5/30/2024 17:23" },
"instance" : {
} }
Empty file.

This file was deleted.

This file was deleted.

14 changes: 0 additions & 14 deletions packages/Liquid-Tests.package/LQCsvTest.class/properties.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
testing
testCSVExport
| filePath fileStream buffer match |
self poll addAnswerSet: self as1.
filePath := LQPoll pathToExport , FileDirectory default pathNameDelimiter , self poll id , '.csv'.
FileDirectory default
deleteFileNamed: filePath
ifAbsent: [].
self poll exportCSV.
fileStream := FileStream fileNamed: filePath.
buffer := fileStream contents.
match := 'Question 1;Question 2;
Q1A1:Q1A2;Q1A2;
'.
self assert: match equals: buffer.
fileStream close

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
},
"instance" : {
"testAnswerSetPollID" : "ms 8/5/2022 20:38",
"testCSVExport" : "vl 5/30/2024 17:58",
"testClosePoll" : "ms 8/5/2022 20:38",
"testCsvPrinting" : "ms 8/5/2022 20:38",
"testIDsAreUUIDsToPreventCollisions" : "JT 8/4/2022 23:31",
"testMyUserSet" : "ms 8/5/2022 20:39",
"testMyUserSetWithUserSetNotInRepo" : "ms 8/5/2022 20:39",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"setUp" : "JT 8/5/2022 19:17",
"testHostMenuCanBeBuilt" : "bwe 6/26/2022 13:48",
"testParticipantMenuCanBeBuilt" : "JT 8/5/2022 19:17",
"testResultsViewCanBeBuilt" : "bwe 6/27/2022 00:12",
"testResultsViewCanBeBuilt" : "5/22/2024 19:59:29",
"testRunningPollViewCanBeBuilt" : "JT 8/5/2022 19:18",
"testStartMenuCanBeBuilt" : "bwe 6/26/2022 13:51",
"testUserSetMenuCanBeBuilt" : "bwe 6/26/2022 13:52" } }
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ buildShowResultsButtonWith: aBuilder

^ aBuilder pluggableButtonSpec new
model: self;
label: 'Show Results';
help: 'Display poll results in a CSV format';
action: #showResults;
label: 'Export Results';
help: 'Export poll results in a CSV format';
action: #exportResults;
frame: (LayoutFrame new
topFraction: 0;
bottomFraction: 0.3;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
modifying
exportResults
| pollNameInput foundPoll |
pollNameInput := UIManager default request: 'Enter Poll ID'.
pollNameInput
ifEmpty: [^ self].
foundPoll := LQRemotePollRepoServer pollRepo
at: pollNameInput
ifAbsent: [^ UIManager default inform: 'This poll does not exist.'].
foundPoll exportCSV

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"instance" : {
"buildCreatePollButtonWith:" : "bn 8/2/2022 16:52",
"buildPollInteractionButtonWith:" : "NM 7/30/2021 19:42",
"buildShowResultsButtonWith:" : "JT 5/19/2022 22:11",
"buildShowResultsButtonWith:" : "vl 5/30/2024 15:01",
"buildUserSetButtonWith:" : "ape 6/15/2022 17:24",
"buildVisualizeResultsButtonWith:" : "JT 8/5/2022 18:28",
"buildWith:" : "ms 8/4/2022 10:55",
"closePoll" : "JT 8/5/2022 18:29",
"createPoll" : "bn 8/2/2022 18:05",
"exportResults" : "vl 5/30/2024 17:25",
"extent" : "ms 8/4/2022 10:55",
"openUserSetMenu" : "bn 8/2/2022 16:52",
"showResults" : "JT 8/5/2022 18:29",
"visualizeResults" : "JT 8/5/2022 18:29" } }
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
modifying
getResults

^ self poll exportCSVDownloadsPath
^ self poll exportCSV
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"class" : {
"newWithPoll:" : "CG 7/30/2021 19:06",
"open" : "CG 7/30/2021 19:06" },
"newWithPoll:" : "5/22/2024 19:59:29",
"open" : "5/22/2024 19:59:29" },
"instance" : {
"buildResultsTextBoxWith:" : "CG 7/30/2021 19:06",
"buildWith:" : "ms 8/4/2022 11:26",
"getResults" : "leli 5/10/2024 20:50",
"getResults" : "vl 5/22/2024 19:59",
"poll" : "CG 7/30/2021 19:06",
"poll:" : "CG 7/30/2021 19:06" } }

0 comments on commit 9e3b055

Please sign in to comment.