Skip to content

Commit cf774ff

Browse files
committed
Allow to use linebreaks in answer texts
1 parent 7133fe1 commit cf774ff

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

Readme.markdown

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ AskMeItems is a little questionnaire presenter and can be used for scientific st
5858
1) :) (will give 1 point)
5959
2) :( (will give 2 points)
6060

61+
### Using linebreaks
62+
63+
* It is possible to use linebreaks in answer texts
64+
65+
ABC_2: Hello, how are you?
66+
1) good
67+
2) bad\nvery bas (will introduce a linebreak)
68+
6169

6270
### Running a series of questionnaires
6371

samples/Likert.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,5 @@ LIK_3: How do you do?
3737
7)
3838
8)
3939
9)
40-
10) very bad
40+
10) very bad\nreally bad
41+
11) worst

src/app/AskMeItems.Model/Parser/AnswerParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ static Answer BuildAnswer(string line)
2424
var answerParts = line.Split(')');
2525
var code = answerParts[0].Trim(' ').Trim('\t');
2626
var textParts = answerParts[1].Split(new[] {" - "}, StringSplitOptions.None);
27-
var text = textParts[0].Trim(' ');
27+
var text = textParts[0].Trim(' ').Replace("\\n","\r\n");
2828
var points = ParsePoints(textParts, code);
2929

3030
return new Answer(code, text, points);

src/test/AskMeItems.Model.Specs/Parsing/SamplesParsingSpecs.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using System.Linq;
2+
13
using Machine.Specifications;
24

35
namespace AskMeItems.Model.Specs.Parsing
@@ -9,11 +11,14 @@ public class when_parsing_a_likert_questionnaire : when_parsing_from_file
911
It should_use_the_filename_as_questionnaire_code = () => Questionnaire.Code.ShouldEqual("Likert");
1012
It should_be_a_likert_questionnaire = () => Questionnaire.Type.ShouldEqual(QuestionnaireType.Likert);
1113
It should_contain_two_items = () => Questionnaire.Items.Count.ShouldEqual(3);
12-
It should_contain_the__LIK_1_item = () => GetItem(0).Code.ShouldEqual("LIK_1");
14+
It should_contain_the_LIK_1_item = () => GetItem(0).Code.ShouldEqual("LIK_1");
1315
It should_contain_the_text_for_the_first_answer = () => GetAnswer(0, 0).Text.ShouldEqual("sehr");
1416
It should_contain_no_text_for_the_second_answer = () => GetAnswer(0, 1).Text.ShouldEqual("");
1517
It should_contain_the_points_for_the_second_answer = () => GetAnswer(0, 1).Points.ShouldEqual(2);
1618
It should_contain_the_default_points_if_no_points_are_given = () => GetAnswer(0, 3).Points.ShouldEqual(4);
19+
20+
It should_contain_the_LIK3_item = () => GetItem(2).Code.ShouldEqual("LIK_3");
21+
It should_contain_a_linebreak_in_the_LIK3_answer = () => GetItem(2).Answers["10"].Text.ShouldEqual("very bad\r\nreally bad");
1722
}
1823

1924
public class when_parsing_a_ADS_questionnaire : when_parsing_from_file

0 commit comments

Comments
 (0)