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

Bug: Monitoring #669

Merged
merged 24 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
bc8da96
fix: remove min visibility
rajuAhmed1705 Jul 27, 2024
fc97d9b
chore: Apply static analysis changes
rajuAhmed1705 Jul 27, 2024
1cafc94
fix: tooltip message
rajuAhmed1705 Jul 27, 2024
4b4dee7
fix: translation
rajuAhmed1705 Jul 28, 2024
2b05168
fix: remove bar chart if no participant
rajuAhmed1705 Jul 28, 2024
63c964e
fix: sort arrow
rajuAhmed1705 Jul 28, 2024
c724d64
fix: intervention and observation wrong number in table
rajuAhmed1705 Aug 5, 2024
c9c0627
chore: format
rajuAhmed1705 Aug 5, 2024
8733e1b
fix: participant info max intervention and survey count
johannesvedder Aug 9, 2024
9e39491
fix: remove min visibility
rajuAhmed1705 Jul 27, 2024
1dcd14d
chore: Apply static analysis changes
rajuAhmed1705 Jul 27, 2024
4e59828
fix: tooltip message
rajuAhmed1705 Jul 27, 2024
35c0d6e
fix: translation
rajuAhmed1705 Jul 28, 2024
1eec650
fix: remove bar chart if no participant
rajuAhmed1705 Jul 28, 2024
0dfd757
fix: sort arrow
rajuAhmed1705 Jul 28, 2024
3716d0e
fix: intervention and observation wrong number in table
rajuAhmed1705 Aug 5, 2024
2104f22
chore: format
rajuAhmed1705 Aug 5, 2024
3f339e5
fix: participant info max intervention and survey count
johannesvedder Aug 9, 2024
434fabe
fix: overflow issues
johannesvedder Aug 12, 2024
789f778
fix: translation
johannesvedder Aug 12, 2024
ef1828a
Merge branch 'bug/monitoring' of github.com:hpi-studyu/studyu into bu…
ibrahimozkn Aug 12, 2024
491cb51
fix: legend overflow
johannesvedder Aug 12, 2024
ab4e489
Merge branch 'bug/monitoring' of github.com:hpi-studyu/studyu into bu…
ibrahimozkn Aug 12, 2024
97e1fa4
fix: legend spacing
ibrahimozkn Aug 12, 2024
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
20 changes: 20 additions & 0 deletions designer_v2/lib/domain/study_monitoring.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class StudyMonitorItem extends Equatable {
final bool droppedOut;
final List<Set<String>> missedTasksPerDay;
final List<Set<String>> completedTasksPerDay;
final int totalInterventionTasks;
final int totalSurveyTasks;

const StudyMonitorItem({
required this.studySubject,
Expand All @@ -36,6 +38,8 @@ class StudyMonitorItem extends Equatable {
required this.droppedOut,
required this.missedTasksPerDay,
required this.completedTasksPerDay,
required this.totalInterventionTasks,
required this.totalSurveyTasks,
}) : assert(missedTasksPerDay.length == currentDayOfStudy),
assert(completedTasksPerDay.length == currentDayOfStudy);

Expand Down Expand Up @@ -130,6 +134,20 @@ extension StudyMonitoringX on Study {
final missedInterventions = totalInterventions - completedInterventions;
final missedSurveys = totalSurveys - completedSurveys;

// Calculate total number of tasks for all interventions for this participant
final totalInterventionTasks = interventions
.where((i) => participant.selectedInterventionIds.contains(i.id))
.map((i) => i.tasks.length)
.fold(0, (prev, element) => prev + element) *
schedule.phaseDuration *
schedule.numberOfCycles;

//calculate the total number of surveys for this participant
final totalSurveyTasks = observations
.where((o) => requiredSurveyTaskIds.contains(o.id))
.length *
schedule.length;

items.add(
StudyMonitorItem(
studySubject: participant,
Expand All @@ -146,6 +164,8 @@ extension StudyMonitoringX on Study {
droppedOut: participant.isDeleted,
missedTasksPerDay: missedTasksPerDay,
completedTasksPerDay: completedTasksPerDay,
totalInterventionTasks: totalInterventionTasks,
totalSurveyTasks: totalSurveyTasks,
),
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ class ParticipantInfo extends ConsumerWidget {
),
_buildInfoRow(
tr.monitoring_table_column_completed_interventions,
'${monitorItem.completedInterventions}/${monitorItem.completedInterventions + monitorItem.missedInterventions}',
'${monitorItem.completedInterventions}/${monitorItem.totalInterventionTasks}',
),
_buildInfoRow(
tr.monitoring_table_column_completed_surveys,
'${monitorItem.completedSurveys}/${monitorItem.completedSurveys + monitorItem.missedSurveys}',
'${monitorItem.completedSurveys}/${monitorItem.totalSurveyTasks}',
),
],
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,23 @@ class ParticipantLegend extends StatelessWidget {
style: const TextStyle(fontWeight: FontWeight.bold),
),
const SizedBox(height: 8.0),
Row(
children: [
_buildLegendItem(
color: completeColor,
tr.participant_details_color_legend_completed,
tr.participant_details_completed_legend_tooltip,
),
const SizedBox(width: 16.0),
_buildLegendItem(
color: partiallyCompleteColor,
tr.participant_details_color_legend_partially_completed,
tr.participant_details_partially_completed_legend_tooltip,
gradient: true,
),
const SizedBox(width: 16.0),
_buildLegendItem(
color: incompleteColor,
tr.participant_details_color_legend_missed,
tr.participant_details_incomplete_legend_tooltip,
),
],
_buildLegendItem(
color: completeColor,
tr.participant_details_color_legend_completed,
tr.participant_details_completed_legend_tooltip,
),
const SizedBox(height: 18.0),
_buildLegendItem(
color: partiallyCompleteColor,
tr.participant_details_color_legend_partially_completed,
tr.participant_details_partially_completed_legend_tooltip,
gradient: true,
),
const SizedBox(height: 16.0),
_buildLegendItem(
color: incompleteColor,
tr.participant_details_color_legend_missed,
tr.participant_details_incomplete_legend_tooltip,
),
const SizedBox(height: 16.0),
Text(
Expand Down
18 changes: 10 additions & 8 deletions designer_v2/lib/features/monitor/study_monitor_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ class StudyMonitorScreen extends StudyPageWidget {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
_monitorSectionHeader(context, studyMonitorData),
const SizedBox(height: 32.0),
if (studyMonitorData.isNotEmpty) ...[
_monitorSectionHeader(context, studyMonitorData),
const SizedBox(height: 32.0),
SelectableText(
tr.monitoring_participants_title,
style: Theme.of(context).textTheme.headlineSmall,
Expand Down Expand Up @@ -58,7 +58,8 @@ class StudyMonitorScreen extends StudyPageWidget {
) {
final theme = Theme.of(context);
final int total = monitorData.length;
const double minPercentage = 0.01; // Minimum percentage for visibility
const double minPercentage =
0; // Minimum percentage for visibility, change to 0.01 if min visibility is required.

double activePercentage = monitorData.activeParticipants.length / total;
double inactivePercentage = monitorData.inactiveParticipants.length / total;
Expand Down Expand Up @@ -101,7 +102,7 @@ class StudyMonitorScreen extends StudyPageWidget {
children: [
const Spacer(),
SizedBox(
width: 400,
width: 450,
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Expand All @@ -113,25 +114,25 @@ class StudyMonitorScreen extends StudyPageWidget {
percentage: activePercentage,
color: activeColor,
tooltip:
'${tr.monitoring_active}: ${monitorData.activeParticipants.map((e) => e.participantId)}',
'${tr.monitoring_active}: ${monitorData.activeParticipants.map((e) => e.participantId).length}',
),
_buildStat(
percentage: inactivePercentage,
color: inactiveColor,
tooltip:
'${tr.monitoring_inactive}: ${monitorData.inactiveParticipants.map((e) => e.participantId)}',
'${tr.monitoring_inactive}: ${monitorData.inactiveParticipants.map((e) => e.participantId).length}',
),
_buildStat(
percentage: dropoutPercentage,
color: dropoutColor,
tooltip:
'${tr.monitoring_dropout}: ${monitorData.dropoutParticipants.map((e) => e.participantId)}',
'${tr.monitoring_dropout}: ${monitorData.dropoutParticipants.map((e) => e.participantId).length}',
),
_buildStat(
percentage: completedPercentage,
color: completedColor,
tooltip:
'${tr.monitoring_completed}: ${monitorData.completedParticipants.map((e) => e.participantId)}',
'${tr.monitoring_completed}: ${monitorData.completedParticipants.map((e) => e.participantId).length}',
),
],
),
Expand Down Expand Up @@ -222,6 +223,7 @@ class StudyMonitorScreen extends StudyPageWidget {
showModalSideSheet(
context: context,
title: tr.participant_details_title,
width: 550,
body: ParticipantDetailsView(
monitorItem: item,
study: study,
Expand Down
8 changes: 4 additions & 4 deletions designer_v2/lib/features/monitor/study_monitor_table.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class StudyMonitorTable extends ConsumerWidget {
(a, b) => a.participantId.compareTo(b.participantId),
(a, b) =>
a.inviteCode != null ? a.inviteCode!.compareTo(b.inviteCode!) : 0,
(a, b) => a.startedAt.compareTo(b.startedAt),
(a, b) => a.lastActivityAt.compareTo(b.lastActivityAt),
(a, b) => b.startedAt.compareTo(a.startedAt),
(a, b) => b.lastActivityAt.compareTo(a.lastActivityAt),
(a, b) => a.currentDayOfStudy.compareTo(b.currentDayOfStudy),
(a, b) => a.completedInterventions.compareTo(b.completedInterventions),
(a, b) => a.completedSurveys.compareTo(b.completedSurveys),
Expand Down Expand Up @@ -142,12 +142,12 @@ class StudyMonitorTable extends ConsumerWidget {
_buildProgressCell(
context,
item.completedInterventions,
item.completedInterventions + item.missedInterventions,
item.totalInterventionTasks,
),
_buildProgressCell(
context,
item.completedSurveys,
item.completedSurveys + item.missedSurveys,
item.totalSurveyTasks,
),
];
}
Expand Down
10 changes: 5 additions & 5 deletions designer_v2/lib/localization/app_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -546,10 +546,10 @@
"participant_details_study_days_description": "Dieser Abschnitt bietet einen Überblick über die täglichen Aktivitäten des Teilnehmers in der Studie. Die Farblegende zeigt den Status der täglichen Aufgaben an. Bewege den Mauszeiger über die Studientage, um mehr Details über die tägliche Aktivität des Teilnehmers zu erfahren.",
"participant_details_color_legend_title": "Legende",
"participant_details_color_tooltip_legend_title": "Aktivitätsdetail Legende",
"participant_details_color_legend_completed_task": "Completed task",
"participant_details_color_legend_completed_task_tooltip": "The participant has completed this task",
"participant_details_color_legend_missed_task": "Missed task",
"participant_details_color_legend_missed_task_tooltip": "The participant has missed this task",
"participant_details_color_legend_completed_task": "Abgeschlossene Aufgabe",
"participant_details_color_legend_completed_task_tooltip": "Der Teilnehmer hat diese Aufgabe erledigt",
"participant_details_color_legend_missed_task": "Verpasste Aufgabe",
"participant_details_color_legend_missed_task_tooltip": "Der Teilnehmer hat diese Aufgabe verpasst",
"participant_details_color_legend_completed": "Alle Aufgaben abgeschlossen",
"participant_details_color_legend_partially_completed": "Einige Aufgaben unvollständig",
"participant_details_color_legend_missed": "Alle Aufgaben verpasst",
Expand All @@ -566,7 +566,7 @@
"monitoring_active_tooltip": "Anzahl der Teilnehmer, die derzeit in der Studie sind",
"monitoring_inactive": "Inaktiv",
"monitoring_inactive_tooltip": "Anzahl der Teilnehmer, die 3 Tage hintereinander keine Aktivität in der Studie gezeigt haben",
"monitoring_dropout": "Dropout",
"monitoring_dropout": "Abgebrochen",
"monitoring_dropout_tooltip": "Anzahl der Teilnehmer, die die Studie vorzeitig abgebrochen haben oder für 5 Tage hintereinander keine Aktivität in der Studie gezeigt haben",
"monitoring_completed": "Abgeschlossen",
"monitoring_completed_tooltip": "Anzahl der Teilnehmer, die das Ende der Studie erreicht haben",
Expand Down
Loading