예제 #1
0
        public GradingItemForm(Response r, Criteria criteria, Student student)
        {
            Cancelled = true; // fail closed rather than open

            GraderResponse = r;

            InitializeComponent();

            studentNameLabel.Text = string.Format("{0}, {1}", student.LastName, student.FirstName);

            criteriaDescLabel.Text = criteria.Description;

            pointsReceivedNumericUpDown.Maximum = criteria.MaxPoints;

            pointsReceivedNumericUpDown.Minimum = 0;

            if (GraderResponse.PointsReceived < 0)
            {
                GraderResponse.PointsReceived = 0;
            }
            else if (GraderResponse.PointsReceived > criteria.MaxPoints)
            {
                GraderResponse.PointsReceived = criteria.MaxPoints;
            }

            pointsReceivedNumericUpDown.Value = GraderResponse.PointsReceived;

            maxPointsLabel.Text = string.Format("Pts out of {0} Pts", criteria.MaxPoints.ToString());

            graderCommentTextBox.Text = GraderResponse.GraderComment;
        }
예제 #2
0
 public bool UpdateResponse(int assignmentID, int studentID, int criteriaID, Response response)
 {
     string query = String.Format("UPDATE {0} SET ", tables.Response.TableName);
     query += String.Format("{0} = @{0}, ", tables.Response.StudentID);
     query += String.Format("{0} = @{0}, ", tables.Response.CriteriaID);
     query += String.Format("{0} = @{0}", tables.Response.PointsReceived);
     if (response.GraderComment != string.Empty)
     {
         query += String.Format(", {0} = @{0}", tables.Response.GraderComment);
     }
     query += String.Format(" WHERE {0} = @{0};", tables.Response.ResponseID);
     OleDbCommand update = new OleDbCommand(query, dbConnection);
     update.Parameters.Add(new OleDbParameter("@" + tables.Response.StudentID, OleDbType.Integer)).Value = studentID;
     update.Parameters.Add(new OleDbParameter("@" + tables.Response.CriteriaID, OleDbType.Integer)).Value = criteriaID;
     update.Parameters.Add(new OleDbParameter("@" + tables.Response.PointsReceived, OleDbType.Integer)).Value = response.PointsReceived;
     if (response.GraderComment != string.Empty)
     {
         update.Parameters.Add(new OleDbParameter("@" + tables.Response.GraderComment, OleDbType.VarChar)).Value = response.GraderComment;
     }
     update.Parameters.Add(new OleDbParameter("@" + tables.Response.ResponseID, OleDbType.Integer)).Value = response.ResponseID;
     if (update.ExecuteNonQuery() == 1)
     { // we only want to affect one row
         return true;
     }
     else
     {
         return false;
     }
 }
예제 #3
0
 public bool AddResponse(int assignmentID, int studentID, int criteriaID, Response response)
 {
     string query = String.Format("INSERT INTO {0} (", tables.Response.TableName);
     query += String.Format("{0}, ", tables.Response.StudentID);
     query += String.Format("{0}, ", tables.Response.CriteriaID);
     query += String.Format("{0}", tables.Response.PointsReceived);
     if (response.GraderComment != string.Empty)
     {
         query += String.Format(", {0}", tables.Response.GraderComment);
     }
     query += ") VALUES (";
     query += String.Format("@{0}, ", tables.Response.StudentID);
     query += String.Format("@{0}, ", tables.Response.CriteriaID);
     query += String.Format("@{0}", tables.Response.PointsReceived);
     if (response.GraderComment != string.Empty)
     {
         query += String.Format(", @{0}", tables.Response.GraderComment);
     }
     query += ");";
     OleDbCommand insert = new OleDbCommand(query, dbConnection);
     insert.Parameters.Add(new OleDbParameter("@" + tables.Response.StudentID, OleDbType.Integer)).Value = studentID;
     insert.Parameters.Add(new OleDbParameter("@" + tables.Response.CriteriaID, OleDbType.Integer)).Value = criteriaID;
     insert.Parameters.Add(new OleDbParameter("@" + tables.Response.PointsReceived, OleDbType.Integer)).Value = response.PointsReceived;
     if (response.GraderComment != string.Empty)
     {
         insert.Parameters.Add(new OleDbParameter("@" + tables.Response.GraderComment, OleDbType.VarChar)).Value = response.GraderComment;
     }
     try
     {
         insert.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         Debug.WriteLine("Could not insert response.");
         return false;
     }
     return true;
 }