public static Color ScoreGrade(AbstractMark mark, int maxScore, Student student) { /// <summary> /// Returns a cell colour for a `mark`. The ALPS grade of `student` is used. /// </summary> // Get prerequesites float percentage = (float)mark.GetScore() / (float)maxScore; // Convert to floats to avoid integer division - https://stackoverflow.com/questions/37641472/how-do-i-calculate-a-percentage-of-a-number-in-c float adjustedAlps = (float)student.alps / 100f; float diff = adjustedAlps - percentage; if (diff > 0.4) { return(Color.Red); } else if (diff > 0.25) { return(Color.Orange); } else { return(Color.Green); } }
private void CellToolTipTextNeeded(object sender, DataGridViewCellToolTipTextNeededEventArgs e) { if (e.RowIndex <= -1 || e.ColumnIndex <= -1) { return; } AbstractMark mark = this.markGrid[e.ColumnIndex, e.RowIndex]; if (mark != null) { Assignment assignment = taskIdToTask[mark.GetTaskId()]; Student student = studentIdToStudent[mark.GetStudentId()]; e.ToolTipText = "Score: " + mark.GetScore().ToString() + "\nOut of: " + assignment.maxScore + "\nALPs grade: " + student.GetAlpsString() + "\nFeedback provided: " + mark.GetFeedback(); } else { e.ToolTipText = "Feedback not yet provided"; } }