Ejemplo n.º 1
0
        private void CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (!this.dataGridInitialised || e.ColumnIndex <= -1 || e.RowIndex <= -1)
            {
                return;
            }

            DataGridViewCell cell    = dataGrid[e.ColumnIndex, e.RowIndex];
            AbstractMark     mark    = this.markGrid[e.ColumnIndex, e.RowIndex];
            Assignment       task    = this.taskIdToTask[mark.GetTaskId()];
            Student          student = this.studentIdToStudent[mark.GetStudentId()];

            string newValue = cell.EditedFormattedValue.ToString();
            int    newScore = 0;
            bool   isDigit  = Int32.TryParse(newValue, out newScore);

            if (!isDigit || newScore < 0 || newScore > task.maxScore)
            {
                return;
            }

            // Changed mark from N/A
            if (mark.GetFeedback() == null)
            {
                mark.UpdateFeedback("No feedback given.");   // NO API CALLS MADE IN THIS METHOD
            }
            mark.UpdateScore(newScore);                      // NO API CALLS MADE IN THIS METHOD

            this.markGrid[e.ColumnIndex, e.RowIndex] = mark; // Update cell data
            cell.Style.BackColor = ScoreGrade(mark, task.maxScore, student);
            APIHandler.GiveFeedback(student, task, newScore, mark.GetFeedback());
        }
Ejemplo n.º 2
0
        private void sendFeedbackButtonClick(object sender, EventArgs e)
        {
            string feedback = feedbackTextBox.Text;
            int    score    = -1;

            if (!Int32.TryParse(scoreTextBox.Text, out score))
            {
                MessageBox.Show("Score must be an integer.");
                return;
            }
            if (score > assignment.maxScore)
            {
                MessageBox.Show("You cannot have a score higher than the maximum score.");
                return;
            }
            if (feedback.Length > 511)
            {
                MessageBox.Show("Your feedback must be shorter. Please shorten it and try again.");
                return;
            }

            APIHandler.GiveFeedback(currentStudent, assignment, score, feedback);
            MessageBox.Show("Feedback provided!");
        }