Skip to content

Commit 74fcfbc

Browse files
authored
Merge pull request #1816 from bcgov/dev
Dev
2 parents c1e21dc + 5118e14 commit 74fcfbc

62 files changed

Lines changed: 6309 additions & 448 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

applications/Unity.GrantManager/modules/Unity.Flex/src/Unity.Flex.Application.Contracts/Scoresheets/QuestionDto.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ public class QuestionDto : ExtensibleEntityDto<Guid>
1919

2020
public virtual string? Answer { get; set; }
2121
public virtual string? Definition { get; set; } = "{}";
22+
public virtual bool IsHumanConfirmed { get; set; } = true;
23+
public virtual string? AICitation { get; set; }
24+
public virtual int? AIConfidence { get; set; }
2225

2326
public string? GetMin()
2427
{

applications/Unity.GrantManager/modules/Unity.Flex/src/Unity.Flex.Application/FlexApplicationAutoMapperProfile.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ public FlexApplicationAutoMapperProfile()
3434

3535
CreateMap<Question, QuestionDto>()
3636
.ForMember(dest => dest.ExtraProperties, opt => opt.Ignore())
37-
.ForMember(dest => dest.Answer, opt => opt.Ignore());
37+
.ForMember(dest => dest.Answer, opt => opt.Ignore())
38+
.ForMember(dest => dest.IsHumanConfirmed, opt => opt.Ignore())
39+
.ForMember(dest => dest.AICitation, opt => opt.Ignore())
40+
.ForMember(dest => dest.AIConfidence, opt => opt.Ignore());
3841
CreateMap<ScoresheetSection, ScoresheetSectionDto>()
3942
.ForMember(dest => dest.Fields, opt => opt.MapFrom(src => src.Fields))
4043
.ForMember(dest => dest.ExtraProperties, opt => opt.Ignore());

applications/Unity.GrantManager/modules/Unity.Flex/src/Unity.Flex.Web/Views/Shared/Components/QuestionNumberWidget/Default.cshtml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,33 @@
44

55
<div class="mb-3">
66
<label for="answer-number-@Model.QuestionId" class="form-label unt-form-label">Answer</label>
7-
<input type="number" required="@Model.Required" class="form-control answer-number-input"
7+
<input type="number" required="@Model.Required" class="form-control answer-number-input @(!Model.IsHumanConfirmed ? "ai-generated-answer" : "human-confirmed-answer")"
88
min="@Model.Min"
99
max="@Model.Max"
1010
disabled="@Model.IsDisabled"
1111
id="answer-number-@Model.QuestionId"
1212
name="Answer-Number-@Model.QuestionId"
1313
value="@Model.Answer"
1414
data-original-value="@Model.Answer"
15-
oninput="handleInputChange('@Model.QuestionId','answer-number-')" />
15+
data-is-human-confirmed="@Model.IsHumanConfirmed.ToString().ToLower()"
16+
oninput="handleInputChange('@Model.QuestionId','answer-number-'); markAsHumanConfirmed(this)"
17+
/>
18+
19+
@if (!Model.IsHumanConfirmed && Model.Answer.HasValue)
20+
{
21+
<div class="ai-answer-indicator">
22+
🤖 AI-generated answer
23+
@if (Model.AIConfidence.HasValue)
24+
{
25+
<span class="ai-confidence-score"> (Confidence: @Model.AIConfidence%)</span>
26+
}
27+
</div>
28+
@if (!string.IsNullOrEmpty(Model.AICitation))
29+
{
30+
<div class="ai-citation">
31+
<small><strong>AI Reasoning:</strong> @Model.AICitation</small>
32+
</div>
33+
}
34+
}
1635
<span id="error-message-@Model.QuestionId" class="text-danger field-validation-error" ></span>
1736
</div>

applications/Unity.GrantManager/modules/Unity.Flex/src/Unity.Flex.Web/Views/Shared/Components/QuestionNumberWidget/QuestionNumberViewModel.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@ public class QuestionNumberViewModel : RequiredFieldViewModel
99
public double? Answer { get; set; }
1010
public string? Min { get; set; }
1111
public string? Max { get; set; }
12+
public bool IsHumanConfirmed { get; set; } = true;
13+
public string? AICitation { get; set; }
14+
public int? AIConfidence { get; set; }
1215
}

applications/Unity.GrantManager/modules/Unity.Flex/src/Unity.Flex.Web/Views/Shared/Components/QuestionNumberWidget/QuestionNumberWidget.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ public async Task<IViewComponentResult> InvokeAsync(Guid questionId,
2121
double? answer,
2222
string? min,
2323
string? max,
24-
bool required = false)
24+
bool required = false,
25+
bool isHumanConfirmed = true,
26+
string? aiCitation = null,
27+
int? aiConfidence = null)
2528
{
2629
return View(await Task.FromResult(new QuestionNumberViewModel()
2730
{
@@ -30,7 +33,10 @@ public async Task<IViewComponentResult> InvokeAsync(Guid questionId,
3033
Answer = answer,
3134
Min = min,
3235
Max = max,
33-
Required = required
36+
Required = required,
37+
IsHumanConfirmed = isHumanConfirmed,
38+
AICitation = aiCitation,
39+
AIConfidence = aiConfidence
3440
}));
3541
}
3642

applications/Unity.GrantManager/modules/Unity.Flex/src/Unity.Flex.Web/Views/Shared/Components/QuestionSelectListWidget/Default.cshtml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,35 @@
88
<div class="mb-3">
99
<label for="answer-selectlist-@Model.QuestionId" class="form-label unt-form-label">Answer</label>
1010
<select id="answer-selectlist-@Model.QuestionId"
11-
class="form-select form-control answer-selectlist-input"
11+
class="form-select form-control answer-selectlist-input @(!Model.IsHumanConfirmed ? "ai-generated-answer" : "human-confirmed-answer")"
1212
name="Answer-SelectList-@Model.QuestionId"
1313
data-original-value="@Model.Answer"
14+
data-is-human-confirmed="@Model.IsHumanConfirmed.ToString().ToLower()"
1415
disabled="@Model.IsDisabled"
15-
onchange="handleInputChange('@Model.QuestionId','answer-selectlist-')">
16+
onchange="handleInputChange('@Model.QuestionId','answer-selectlist-'); markAsHumanConfirmed(this)">
1617
<option data-numeric-value="0" value="">Please choose...</option>
1718
@foreach (var item in ((QuestionSelectListDefinition?)Model.Definition?.ConvertDefinition(QuestionType.SelectList))?.Options ?? [])
1819
{
1920
var truncatedValue = item.Value.Length > 70 ? item.Value.Substring(0, 70) + " ..." : item.Value;
20-
<!option @(Model.Answer == @item.Value ? "selected" : "") data-numeric-value="@item.NumericValue" value="@item.Value" title="@item.Value">@truncatedValue</!option>
21+
<!option @(Model.Answer == @item.Value ? "selected" : "") data-numeric-value="@item.NumericValue" value="@item.Value" title="@item.Value" selected="@(Model.Answer == item.Value)">@truncatedValue</!option>
2122
}
2223
</select>
24+
@if (!Model.IsHumanConfirmed && !string.IsNullOrEmpty(Model.Answer))
25+
{
26+
<div class="ai-answer-indicator">
27+
🤖 AI-generated answer
28+
@if (Model.AIConfidence.HasValue)
29+
{
30+
<span class="ai-confidence-score"> (Confidence: @Model.AIConfidence%)</span>
31+
}
32+
</div>
33+
@if (!string.IsNullOrEmpty(Model.AICitation))
34+
{
35+
<div class="ai-citation">
36+
<small><strong>AI Reasoning:</strong> @Model.AICitation</small>
37+
</div>
38+
}
39+
}
2340
</div>
2441

2542

applications/Unity.GrantManager/modules/Unity.Flex/src/Unity.Flex.Web/Views/Shared/Components/QuestionSelectListWidget/QuestionSelectListViewModel.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,8 @@ public class QuestionSelectListViewModel
88
public bool IsDisabled { get; set; }
99
public string Answer { get; set; } = string.Empty;
1010
public string Definition { get; set; } = "{}";
11+
public bool IsHumanConfirmed { get; set; } = true;
12+
public string? AICitation { get; set; }
13+
public int? AIConfidence { get; set; }
1114
}
1215
}

applications/Unity.GrantManager/modules/Unity.Flex/src/Unity.Flex.Web/Views/Shared/Components/QuestionSelectListWidget/QuestionSelectListWidget.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ namespace Unity.Flex.Web.Views.Shared.Components.QuestionSelectListWidget
1616
AutoInitialize = true)]
1717
public class QuestionSelectListWidget : AbpViewComponent
1818
{
19-
public async Task<IViewComponentResult> InvokeAsync(Guid questionId, bool isDisabled, string? answer, string definition)
19+
public async Task<IViewComponentResult> InvokeAsync(Guid questionId, bool isDisabled, string? answer, string definition, bool isHumanConfirmed = true, string? aiCitation = null, int? aiConfidence = null)
2020
{
21-
return View(await Task.FromResult(new QuestionSelectListViewModel() { QuestionId = questionId, IsDisabled = isDisabled, Answer = answer ?? string.Empty, Definition = definition }));
21+
return View(await Task.FromResult(new QuestionSelectListViewModel() { QuestionId = questionId, IsDisabled = isDisabled, Answer = answer ?? string.Empty, Definition = definition, IsHumanConfirmed = isHumanConfirmed, AICitation = aiCitation, AIConfidence = aiConfidence }));
2222
}
2323

2424
public class QuestionSelectListWidgetStyleBundleContributor : BundleContributor

applications/Unity.GrantManager/modules/Unity.Flex/src/Unity.Flex.Web/Views/Shared/Components/QuestionTextAreaWidget/Default.cshtml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,30 @@
66
<label for="answer-text-@Model.QuestionId" class="form-label unt-form-label">Answer</label>
77
<textarea rows="@Model.Rows"
88
required="@Model.Required"
9-
class="form-control answer-text-input"
9+
class="form-control answer-text-input @(!Model.IsHumanConfirmed ? "ai-generated-answer" : "human-confirmed-answer")"
1010
minlength="@Model.MinLength"
1111
maxlength="@Model.MaxLength"
1212
disabled="@Model.IsDisabled"
1313
id="answer-textarea-@Model.QuestionId"
1414
name="Answer-Textarea-@Model.QuestionId"
1515
data-original-value="@Model.Answer"
16-
oninput="handleInputChange('@Model.QuestionId','answer-textarea-')">@Model.Answer</textarea>
16+
data-is-human-confirmed="@Model.IsHumanConfirmed.ToString().ToLower()"
17+
oninput="handleInputChange('@Model.QuestionId','answer-textarea-'); markAsHumanConfirmed(this)">@Model.Answer</textarea>
18+
@if (!Model.IsHumanConfirmed && !string.IsNullOrEmpty(Model.Answer))
19+
{
20+
<div class="ai-answer-indicator">
21+
🤖 AI-generated answer
22+
@if (Model.AIConfidence.HasValue)
23+
{
24+
<span class="ai-confidence-score"> (Confidence: @Model.AIConfidence%)</span>
25+
}
26+
</div>
27+
@if (!string.IsNullOrEmpty(Model.AICitation))
28+
{
29+
<div class="ai-citation">
30+
<small><strong>AI Reasoning:</strong> @Model.AICitation</small>
31+
</div>
32+
}
33+
}
1734
<span id="error-message-@Model.QuestionId" class="text-danger field-validation-error"></span>
1835
</div>

applications/Unity.GrantManager/modules/Unity.Flex/src/Unity.Flex.Web/Views/Shared/Components/QuestionTextAreaWidget/QuestionTextAreaViewModel.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,8 @@ public class QuestionTextAreaViewModel : RequiredFieldViewModel
1010
public string? MinLength { get; set; }
1111
public string? MaxLength { get; set; }
1212
public uint? Rows { get; set; } = 1;
13+
public bool IsHumanConfirmed { get; set; } = true;
14+
public string? AICitation { get; set; }
15+
public int? AIConfidence { get; set; }
1316
}
1417
}

0 commit comments

Comments
 (0)