diff --git a/StepChallenge/ClientApp/src/App.css b/StepChallenge/ClientApp/src/App.css
index 0711206..e4ac676 100644
--- a/StepChallenge/ClientApp/src/App.css
+++ b/StepChallenge/ClientApp/src/App.css
@@ -13,3 +13,8 @@
font-size: 0.55em;
text-align: center;
font-weight: 700; }
+
+.goldStar {
+ border: "1px solid red";
+ text-decoration: underline;
+}
diff --git a/StepChallenge/ClientApp/src/components/TeamScoreboard.js b/StepChallenge/ClientApp/src/components/TeamScoreboard.js
index e5e3b51..0a4a9c2 100644
--- a/StepChallenge/ClientApp/src/components/TeamScoreboard.js
+++ b/StepChallenge/ClientApp/src/components/TeamScoreboard.js
@@ -8,7 +8,7 @@ async function loadUserSteps(id) {
var apiHelper = new ApiHelper()
var query = `{"query": "query teamQuery( $teamId : ID! )
{ teamSteps( teamId : $teamId )
- {stepCount, dateOfSteps, participantsStepsStatus { participantName, participantAddedStepCount} },
+ {stepCount, dateOfSteps, participantsStepsStatus { participantName, participantAddedStepCount, participantHighestStepper} },
team (teamId: $teamId )
{teamName, numberOfParticipants, participants { participantName }}
} ",
diff --git a/StepChallenge/ClientApp/src/components/TeamStep.js b/StepChallenge/ClientApp/src/components/TeamStep.js
index fb32edc..aa20380 100644
--- a/StepChallenge/ClientApp/src/components/TeamStep.js
+++ b/StepChallenge/ClientApp/src/components/TeamStep.js
@@ -33,12 +33,14 @@ class TeamStep extends Component {
var status = {
name : "User not registered yet",
initials: "-",
- steps: false
+ steps: false,
+ highestStepper: false
}
if(this.state.participantsStatus[i] != null ){
status.name = this.state.participantsStatus[i].participantName
status.initials = this.state.participantsStatus[i].participantName.charAt(0).toUpperCase()
status.steps = this.state.participantsStatus[i].participantAddedStepCount
+ status.highestStepper = this.state.participantsStatus[i].participantHighestStepper
}
info[i] = status
}
@@ -50,7 +52,7 @@ class TeamStep extends Component {
{info.map(s =>
- {s.initials}
+ {s.initials}
)}
@@ -58,5 +60,4 @@ class TeamStep extends Component {
}
}
-
export default TeamStep;
\ No newline at end of file
diff --git a/StepChallenge/DataModels/TeamScoreBoard.cs b/StepChallenge/DataModels/TeamScoreBoard.cs
index d8fbf2a..1a26913 100644
--- a/StepChallenge/DataModels/TeamScoreBoard.cs
+++ b/StepChallenge/DataModels/TeamScoreBoard.cs
@@ -16,5 +16,7 @@ public class ParticipantsStepsStatus
public string ParticipantName { get; set; }
public int ParticipantId { get; set; }
public bool ParticipantAddedStepCount { get; set; }
+ public int ParticipantStepCount { get; set; }
+ public bool ParticipantHighestStepper { get; set; }
}
}
\ No newline at end of file
diff --git a/StepChallenge/Model/GraphQL/ParticipantStepStatus.cs b/StepChallenge/Model/GraphQL/ParticipantStepStatus.cs
index a883618..a69be46 100644
--- a/StepChallenge/Model/GraphQL/ParticipantStepStatus.cs
+++ b/StepChallenge/Model/GraphQL/ParticipantStepStatus.cs
@@ -12,6 +12,7 @@ public ParticipantStepStatusType()
Field(x => x.ParticipantName, type: typeof(StringGraphType)).Description("The Date of the step count");
Field(x => x.ParticipantAddedStepCount, type: typeof(BooleanGraphType)).Description("If the participant has filled in their steps or not");
+ Field(x => x.ParticipantHighestStepper, type: typeof(BooleanGraphType)).Description("Participants with the highest step count will be set to true");
}
}
diff --git a/StepChallenge/Services/StepsService.cs b/StepChallenge/Services/StepsService.cs
index e906032..07eb0e4 100644
--- a/StepChallenge/Services/StepsService.cs
+++ b/StepChallenge/Services/StepsService.cs
@@ -99,7 +99,7 @@ public List GetTeamScores(IQueryable teams, DateTime thisMonda
{
TeamId = t.TeamId,
TeamName = t.TeamName,
- NumberOfParticipants = t.NumberOfParticipants, //TODO - need to know how many are in a team, if participants haven't registered yet then we can't rely on counting all participants
+ NumberOfParticipants = t.NumberOfParticipants,
TeamStepCount = t.Participants.Sum(p => p.Steps
.Where(s => s.DateOfSteps >= startDate && s.DateOfSteps < thisMonday
|| t.Participants.All(u => u.Steps.All(x => x.StepCount == 0)))
@@ -107,6 +107,7 @@ public List GetTeamScores(IQueryable teams, DateTime thisMonda
})
.ToList();
+ // add a pretend participant with averaged steps to teams with less participants
foreach (var teamScore in sortedTeams.Where(t => t.NumberOfParticipants != averageTeamSize && t.NumberOfParticipants != 0))
{
teamScore.TeamStepCount = ((teamScore.TeamStepCount / teamScore.NumberOfParticipants) *
diff --git a/StepChallenge/Services/TeamService.cs b/StepChallenge/Services/TeamService.cs
index f9b38fb..b2780d5 100644
--- a/StepChallenge/Services/TeamService.cs
+++ b/StepChallenge/Services/TeamService.cs
@@ -54,13 +54,28 @@ public List GetTeamScoreBoard(int teamId)
foreach (var teamStep in teamSteps)
{
- teamStep.ParticipantsStepsStatus = participants
+ var stepsStatuses = participants
.Select(p => new ParticipantsStepsStatus
{
ParticipantName = p.ParticipantName,
ParticipantId = p.ParticipantId,
- ParticipantAddedStepCount = p.Steps.Any(ps => ps.DateOfSteps == teamStep.DateOfSteps && ps.StepCount != 0)
+ ParticipantAddedStepCount =
+ p.Steps.Any(ps => ps.DateOfSteps == teamStep.DateOfSteps && ps.StepCount != 0),
+ ParticipantStepCount = p.Steps.Where(ps => ps.DateOfSteps == teamStep.DateOfSteps).Sum(ps => ps.StepCount),
})
+ .OrderByDescending(p => p.ParticipantStepCount)
+ .ToList();
+
+ var highest = stepsStatuses.First().ParticipantStepCount;
+ if (highest != 0)
+ {
+ foreach (var stepStatus in stepsStatuses.Where(p => p.ParticipantStepCount == highest))
+ {
+ stepStatus.ParticipantHighestStepper = true;
+ }
+ }
+
+ teamStep.ParticipantsStepsStatus = stepsStatuses
.OrderBy(p => p.ParticipantName)
.ToList();
}