Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dropdown + Comment + Rating #2

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
9e2bfec
Add dropdown item and builder
Nov 18, 2019
5cb17fc
Moved item type asignement from builders to entities
Nov 18, 2019
adb8a97
Added Comment item and builder
Nov 18, 2019
af59b52
Refactor Item builders: Added SurveyItemBuilderBase, which includes a…
Nov 18, 2019
a6516b2
Moved all common logic back to builders. BuilderItemBase did not work
Nov 18, 2019
dbeba59
added rating ite, element and builder
Nov 18, 2019
9938d35
Refactored tests. Now every test is separated
Nov 22, 2019
38e6f25
Added resources to validate all different components
Nov 22, 2019
ea0b270
Added image picker with individual unit tests
Nov 22, 2019
527a39e
Added boolean item and builder
Nov 22, 2019
c1f54e5
Added html editor item and builder
Nov 22, 2019
b4a0774
Added file item and builder
Nov 22, 2019
877a769
Refactor: Rename items to Questions to match surveyjs naming
Nov 23, 2019
444eb04
Added xls file for quiestions properties listing
Nov 23, 2019
dbc7200
Fixed tests
Nov 24, 2019
758b3c9
Added Matrix single choice
Nov 24, 2019
cfdcafc
Added MAtrix Mutiple value
Nov 24, 2019
6fc38c3
Added Multiple text question
Nov 24, 2019
96bd4eb
Rreamed namespace ChoiceItems to QuestionElements
Nov 24, 2019
d8295df
Removed page add item methods having extra parameters
Nov 24, 2019
d4e59be
Added panel element and builder
Nov 25, 2019
b08fe7a
Rename enums
cgxarrie Dec 7, 2019
a1df3ff
Renqme abstract class SurveyQuestion to Question
cgxarrie Dec 7, 2019
482e9c0
Finetune on questions properties
cgxarrie Dec 7, 2019
6fcf851
Green tests
cgxarrie Dec 7, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added QuestionsProperties.xlsx
Binary file not shown.
64 changes: 64 additions & 0 deletions src/SurveyExtensions/Builders/BooleanQuestionBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
namespace SurveyExtensions.Builders
{
using Elements;
using SurveyExtensions.Elements.Questions;

public class BooleanQuestionBuilder<TEntity> :
QuestionBuilderBase<TEntity, BooleanQuestion>,
IBuilder<SurveyItem> where TEntity : new()
{

public BooleanQuestionBuilder<TEntity> HasName(string value)
{
_item.Name = value;
return this;
}
public BooleanQuestionBuilder<TEntity> HasTitle(string value)
{
_item.Title = value;
return this;
}

public BooleanQuestionBuilder<TEntity> HasDescription(string value)
{
_item.Description = value;
return this;
}

public BooleanQuestionBuilder<TEntity> IsRequired()
{
_item.IsRequired = true;
return this;
}

public BooleanQuestionBuilder<TEntity> IsHidden()
{
_item.Visible = false;
return this;
}

public BooleanQuestionBuilder<TEntity> ContinueInSameLine()
{
_item.StartWithNewLine = false;
return this;
}

public BooleanQuestionBuilder<TEntity> HasLabel(string label)
{
_item.Label = label;
return this;
}

public BooleanQuestionBuilder<TEntity> HasLabelTrue(string labelTrue)
{
_item.LabelTrue = labelTrue;
return this;
}

public BooleanQuestionBuilder<TEntity> HasLabelFalse(string labelFalse)
{
_item.LabelFalse = labelFalse;
return this;
}
}
}
94 changes: 94 additions & 0 deletions src/SurveyExtensions/Builders/CheckboxQuestionBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
namespace SurveyExtensions.Builders
{
using System;
using Elements;
using SurveyExtensions.Elements.QuestionElements;
using SurveyExtensions.Elements.Questions;
using SurveyExtensions.Enums;

public class CheckboxQuestionBuilder<TEntity> :
QuestionBuilderBase<TEntity, CheckboxQuestion>,
IBuilder<SurveyItem> where TEntity : new()
{

public CheckboxQuestionBuilder<TEntity> HasName(string value)
{
_item.Name = value;
return this;
}
public CheckboxQuestionBuilder<TEntity> HasTitle(string value)
{
_item.Title = value;
return this;
}

public CheckboxQuestionBuilder<TEntity> HasDescription(string value)
{
_item.Description = value;
return this;
}

public CheckboxQuestionBuilder<TEntity> IsRequired()
{
_item.IsRequired = true;
return this;
}

public CheckboxQuestionBuilder<TEntity> IsHidden()
{
_item.Visible = false;
return this;
}

public CheckboxQuestionBuilder<TEntity> ContinueInSameLine()
{
_item.StartWithNewLine = false;
return this;
}

public CheckboxQuestionBuilder<TEntity> HasColumnCount(int value)
{
_item.ColCount = value;
return this;
}

public CheckboxQuestionBuilder<TEntity> SetChoicesOrder(ChoicesOrderOprions order)
{
string enumName = Enum.GetName(typeof(ChoicesOrderOprions), order);
if (enumName != null)
{
_item.ChoicesOrder = enumName.ToLowerInvariant();
}

return this;
}

public CheckboxQuestionBuilder<TEntity> HasOtherChoice(string choiceText)
{
_item.OtherText = choiceText;
_item.HasNone = true;
return this;
}

public CheckboxQuestionBuilder<TEntity> HasSelectAllChoice(string choiceText)
{
_item.HasSelectAll = true;
_item.SelectAllText = choiceText;
return this;
}

public CheckboxQuestionBuilder<TEntity> HasSelectNoneChoice(string choiceText)
{
_item.HasNone = true;
_item.NoneText = choiceText;
return this;
}

public CheckboxQuestionBuilder<TEntity> AddChoice(string choiceValue, string choiceText)
{
_item.Choices.Add(new Choice() { Value = choiceValue, Text = choiceText });
return this;
}

}
}
59 changes: 59 additions & 0 deletions src/SurveyExtensions/Builders/CommentQuestionBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
namespace SurveyExtensions.Builders
{
using System;
using Elements;
using SurveyExtensions.Elements.Questions;

public class CommentQuestionBuilder<TEntity> :
QuestionBuilderBase<TEntity, CommentsQuestion>,
IBuilder<SurveyItem> where TEntity : new()
{

public CommentQuestionBuilder<TEntity> HasName(string value)
{
_item.Name = value;
return this;
}
public CommentQuestionBuilder<TEntity> HasTitle(string value)
{
_item.Title = value;
return this;
}

public CommentQuestionBuilder<TEntity> HasDescription(string value)
{
_item.Description = value;
return this;
}

public CommentQuestionBuilder<TEntity> IsRequired()
{
_item.IsRequired = true;
return this;
}

public CommentQuestionBuilder<TEntity> IsHidden()
{
_item.Visible = false;
return this;
}

public CommentQuestionBuilder<TEntity> ContinueInSameLine()
{
_item.StartWithNewLine = false;
return this;
}

public CommentQuestionBuilder<TEntity> HasPlaceHolder(string placeholder)
{
_item.PlaceHolder = placeholder;
return this;
}

public CommentQuestionBuilder<TEntity> HasRows(int rows)
{
_item.Rows = rows;
return this;
}
}
}
81 changes: 81 additions & 0 deletions src/SurveyExtensions/Builders/DropdownQuestionBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
namespace SurveyExtensions.Builders
{
using System;
using Elements;
using SurveyExtensions.Elements.QuestionElements;
using SurveyExtensions.Elements.Questions;
using SurveyExtensions.Enums;

public class DropdownQuestionBuilder<TEntity> :
QuestionBuilderBase<TEntity, DropdownIQuestion>,
IBuilder<SurveyItem> where TEntity : new()
{

public DropdownQuestionBuilder<TEntity> HasName(string value)
{
_item.Name = value;
return this;
}
public DropdownQuestionBuilder<TEntity> HasTitle(string value)
{
_item.Title = value;
return this;
}

public DropdownQuestionBuilder<TEntity> HasDescription(string value)
{
_item.Description = value;
return this;
}

public DropdownQuestionBuilder<TEntity> IsRequired()
{
_item.IsRequired = true;
return this;
}

public DropdownQuestionBuilder<TEntity> IsHidden()
{
_item.Visible = false;
return this;
}

public DropdownQuestionBuilder<TEntity> ContinueInSameLine()
{
_item.StartWithNewLine = false;
return this;
}

public DropdownQuestionBuilder<TEntity> SetChoicesOrder(ChoicesOrderOprions order)
{
string enumName = Enum.GetName(typeof(ChoicesOrderOprions), order);
if (enumName != null)
{
_item.ChoicesOrder = enumName.ToLowerInvariant();
}

return this;
}

public DropdownQuestionBuilder<TEntity> HasOtherChoice(string choiceText)
{
_item.HasOther = true;
_item.OtherText = choiceText;
return this;
}

public DropdownQuestionBuilder<TEntity> AddChoice(string choiceValue, string choiceText)
{
_item.Choices.Add(new Choice() { Value = choiceValue, Text = choiceText });
return this;
}

public DropdownQuestionBuilder<TEntity> AutoChoices(int minChoice, int maxChoice, int choiceStep)
{
_item.ChoicesMin = minChoice;
_item.ChoicesMax = maxChoice;
_item.ChoicesStep = choiceStep;
return this;
}
}
}
37 changes: 37 additions & 0 deletions src/SurveyExtensions/Builders/FileQuestionBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
namespace SurveyExtensions.Builders
{
using System;
using Elements;
using SurveyExtensions.Elements.Questions;

public class FileQuestionBuilder<TEntity> :
QuestionBuilderBase<TEntity, FileQuestion>,
IBuilder<SurveyItem> where TEntity : new()
{

public FileQuestionBuilder<TEntity> HasName(string value)
{
_item.Name = value;
return this;
}

public FileQuestionBuilder<TEntity> IsHidden()
{
_item.Visible = false;
return this;
}

public FileQuestionBuilder<TEntity> ContinueInSameLine()
{
_item.StartWithNewLine = false;
return this;
}

public FileQuestionBuilder<TEntity> HasMaxSize(int maxSize)
{
_item.MaxSize = maxSize;
return this;
}

}
}
37 changes: 37 additions & 0 deletions src/SurveyExtensions/Builders/HtmlEditorQuestionBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
namespace SurveyExtensions.Builders
{
using System;
using Elements;
using SurveyExtensions.Elements.Questions;

public class HtmlEditorQuestionBuilder<TEntity> :
QuestionBuilderBase<TEntity, HtmlEditorQuestion>,
IBuilder<SurveyItem> where TEntity : new()
{

public HtmlEditorQuestionBuilder<TEntity> HasName(string value)
{
_item.Name = value;
return this;
}

public HtmlEditorQuestionBuilder<TEntity> IsHidden()
{
_item.Visible = false;
return this;
}

public HtmlEditorQuestionBuilder<TEntity> ContinueInSameLine()
{
_item.StartWithNewLine = false;
return this;
}

public HtmlEditorQuestionBuilder<TEntity> HasHtml(string html)
{
_item.Html = html;
return this;
}

}
}
Loading