Skip to content

Commit 43e6b9f

Browse files
Copilotdwarwick
andcommitted
Add visual indicators and validation for Last Questions
Co-authored-by: dwarwick <15970276+dwarwick@users.noreply.github.com>
1 parent 88bb89a commit 43e6b9f

File tree

3 files changed

+51
-2
lines changed

3 files changed

+51
-2
lines changed

JwtIdentity.Client/Pages/Survey/BranchingSurveyEdit.razor

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,13 @@ else
143143
@foreach (var question in groupQuestions)
144144
{
145145
<MudListItem T="string">
146-
<MudText>Q@(question.QuestionNumber): @question.Text</MudText>
146+
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="2">
147+
<MudText>Q@(question.QuestionNumber): @question.Text</MudText>
148+
@if (question.IsLastQuestion)
149+
{
150+
<MudChip Size="MudBlazor.Size.Small" Color="Color.Warning" Icon="@Icons.Material.Filled.Flag">Last</MudChip>
151+
}
152+
</MudStack>
147153
</MudListItem>
148154
}
149155
</MudList>
@@ -174,10 +180,15 @@ else
174180
<MudListItem T="string" Class="@questionColorClass">
175181
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="2">
176182
<span class="@($"group-badge group-badge-{question.GroupId % 10}")">Group @question.GroupId</span>
183+
@if (question.IsLastQuestion)
184+
{
185+
<MudChip Size="MudBlazor.Size.Small" Color="Color.Warning" Icon="@Icons.Material.Filled.Flag">Last Question</MudChip>
186+
}
177187
<MudText Style="flex: 1;">Q@(question.QuestionNumber): @question.Text</MudText>
178188
<MudSelect T="int" Label="Assign to Group" Value="question.GroupId"
179189
ValueChanged="@(async value => { await MoveQuestionToGroup(question, value); await RefreshDiagram(); })"
180-
Variant="Variant.Outlined" Dense="true" Style="width: 250px;">
190+
Variant="Variant.Outlined" Dense="true" Style="width: 250px;"
191+
Disabled="@question.IsLastQuestion">
181192
@foreach (var g in QuestionGroups.OrderBy(x => x.GroupNumber))
182193
{
183194
<MudSelectItem Value="@g.GroupNumber">
@@ -199,6 +210,7 @@ else
199210
@foreach (var group in QuestionGroups.OrderBy(g => g.GroupNumber))
200211
{
201212
var groupQuestions = Survey.Questions.Where(q => q.GroupId == group.GroupNumber &&
213+
!q.IsLastQuestion && // Exclude Last Questions from branching configuration
202214
(q.QuestionType == QuestionType.MultipleChoice ||
203215
q.QuestionType == QuestionType.SelectAllThatApply ||
204216
q.QuestionType == QuestionType.TrueFalse)).OrderBy(q => q.QuestionNumber).ToList();

JwtIdentity.Client/Pages/Survey/EditSurvey.razor

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@
101101
{
102102
<MudText Color="Color.Error" Typo="Typo.caption" Class="RequiredStar">*</MudText>
103103
}
104+
105+
@if (question.IsLastQuestion)
106+
{
107+
<MudChip Size="MudBlazor.Size.Small" Color="Color.Warning" Icon="@Icons.Material.Filled.Flag">Last</MudChip>
108+
}
104109

105110
</MudStack>
106111
<div style="height: 2px; background-color: blueviolet; width: 100%;"></div>

JwtIdentity.Client/Pages/Survey/EditSurvey.razor.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,38 @@ protected async Task AddQuestionToSurvey()
301301
return;
302302
}
303303

304+
// Validation: Last Questions cannot have branching rules defined
305+
if (IsLastQuestion && SelectedQuestion != null)
306+
{
307+
if (SelectedQuestion.QuestionType == QuestionType.MultipleChoice)
308+
{
309+
var mcQuestion = SelectedQuestion as MultipleChoiceQuestionViewModel;
310+
if (mcQuestion?.Options?.Any(o => o.BranchToGroupId.HasValue) == true)
311+
{
312+
_ = Snackbar.Add("Cannot mark as Last Question: This question has branching rules defined. Remove branching rules first.", Severity.Warning);
313+
return;
314+
}
315+
}
316+
else if (SelectedQuestion.QuestionType == QuestionType.SelectAllThatApply)
317+
{
318+
var saQuestion = SelectedQuestion as SelectAllThatApplyQuestionViewModel;
319+
if (saQuestion?.Options?.Any(o => o.BranchToGroupId.HasValue) == true)
320+
{
321+
_ = Snackbar.Add("Cannot mark as Last Question: This question has branching rules defined. Remove branching rules first.", Severity.Warning);
322+
return;
323+
}
324+
}
325+
else if (SelectedQuestion.QuestionType == QuestionType.TrueFalse)
326+
{
327+
var tfQuestion = SelectedQuestion as TrueFalseQuestionViewModel;
328+
if (tfQuestion?.BranchToGroupIdOnTrue.HasValue == true || tfQuestion?.BranchToGroupIdOnFalse.HasValue == true)
329+
{
330+
_ = Snackbar.Add("Cannot mark as Last Question: This question has branching rules defined. Remove branching rules first.", Severity.Warning);
331+
return;
332+
}
333+
}
334+
}
335+
304336
ResetQuestions = true;
305337

306338
switch (SelectedQuestionType.Replace(" ", ""))

0 commit comments

Comments
 (0)