// TODO: Make sure headers are unchecked if they have no checked children public void LoadAssignment(Assignment assignment) { currentAssignment = assignment; titleLabel.Text = currentAssignment.Name; this.Text = currentAssignment.Name; dueLabel.Text = currentAssignment.DueDate.ToString("MM/dd/yyyy"); rubricTreeView.BeginUpdate(); rubricTreeView.Nodes.Clear(); if (assignment.Rubric != null) { foreach (int node in assignment.Rubric.RootNodes) { RubricNode child = assignment.Rubric.Nodes[node]; TreeNode treeViewNode = rubricTreeView.Nodes.Add(child.ToString()); treeViewNode.Name = child.Criteria.CriteriaID.ToString(); AddChildNodes(treeViewNode, assignment.Rubric, child.Criteria.CriteriaID); } } else { Debug.WriteLine("ERROR: The assignment doesn't have a rubric yet!"); } rubricTreeView.EndUpdate(); maxPointsLabel.Text = string.Format("out of {0} Pts", assignment.Rubric.MaxPoints().ToString()); }
public GradingAssignmentForm() { InitializeComponent(); currentAssignment = null; currentResponseList = null; DeletedAdjustments = new LinkedList<int>(); }
public GradeEmailForm(GAClass mainClass, Dictionary<int, Student> students, Assignment assignment, Dictionary<int,ResponseList> responseLists) { InitializeComponent(); this.Text = "Email Grades - " + assignment.Name + " - " + mainClass.ClassName; this.AcceptButton = buttonSendEmails; this.CancelButton = buttonCancel; this.mainClass = mainClass; this.students = students; this.currentAssignment = assignment; this.responseLists = responseLists; this.Text = "Email Grades - " + currentAssignment.Name + " - " + mainClass.ClassName; studentScores = getStudentTotals(); totalScore = 0; foreach (int i in studentScores.Values) { try { totalScore += i; if (i == 0) { numZeros++; } } catch (Exception ex) { MessageBox.Show("Crazy error! Glad I'm not you, man (or woman).\nYeah, I've got nothing for you." + ex.ToString(), "Umm..."); } } textBoxEmailAddress.Text = mainClass.FromAddress; }
public int AddAssignment(Assignment assignment) { if (assignment.HasID()) { Debug.WriteLine("You should not add and Assignment if it already has an ID assigned."); return assignment.AssignmentID; } else { // We need to insert rather than update because the criteria has no key. string query = String.Format("INSERT INTO {0} (", tables.Assignment.TableName); query += String.Format("{0}, ", tables.Assignment.Name); query += String.Format("{0}", tables.Assignment.DueDate); query += ") VALUES ("; query += String.Format("@{0}, ", tables.Assignment.Name); query += String.Format("@{0}", tables.Assignment.DueDate); query += ");"; OleDbCommand insert = new OleDbCommand(query, dbConnection); insert.Parameters.Add(new OleDbParameter("@" + tables.Assignment.Name, OleDbType.VarChar)).Value = assignment.Name; insert.Parameters.Add(new OleDbParameter("@" + tables.Assignment.DueDate, OleDbType.VarChar)).Value = assignment.DueDate; try { insert.ExecuteNonQuery(); } catch { Debug.WriteLine("Could not insert assignment."); } // Now that we inserted the student, we need to get its ID query = "SELECT @@IDENTITY;"; OleDbCommand getID = new OleDbCommand(query, dbConnection); int key = assignment.AssignmentID; try { key = (int)getID.ExecuteScalar(); } catch { Debug.WriteLine("Could not retrieve assignment ID."); } return key; } }
public GradeEmailForm(GAClass mainClass, Dictionary<int, Student> students, Assignment assignment, Dictionary<int,ResponseList> responseLists) { InitializeComponent(); this.Text = "Email Grades - " + assignment.Name + " - " + mainClass.ClassName; this.AcceptButton = buttonSendEmails; this.CancelButton = buttonCancel; this.mainClass = mainClass; this.students = students; this.currentAssignment = assignment; this.responseLists = responseLists; this.useHtml = mainClass.FormatAsHTML; textBoxSMTPServer.Text = mainClass.ServerName; this.smtpPort = mainClass.PortNumber; this.Text = "Email Grades - " + currentAssignment.Name + " - " + mainClass.ClassName; for (int i = 0; i < this.students.Values.Count; i++) { comboBoxStudentSelect.Items.Add(this.students.Values.ToList()[i]); } studentScores = getStudentTotals(); totalScore = 0; foreach (int i in studentScores.Values) { try { totalScore += i; if (i == 0) { numZeros++; } } catch (Exception ex) { MessageBox.Show( "Crazy error! Glad I'm not you, man (or woman).\nYeah, here's some error stuff!\n\n" + ex.ToString(), "Umm..."); } } textBoxEmailAddress.Text = mainClass.FromAddress; }
public Assignment GetAssignment(int assignmentID) { Assignment assignment = new Assignment(); string assignmentQuery = String.Format("SELECT * FROM {0} WHERE {1} = {2}", tables.Assignment.TableName, tables.Assignment.AssignmentID, assignmentID); try { DataSet assignmentDataSet = runQuery(assignmentQuery); if (assignmentDataSet.Tables.Count > 0) { if (assignmentDataSet.Tables[0].Rows.Count > 0) { assignment = new Assignment(assignmentID, (string)assignmentDataSet.Tables[0].Rows[0][tables.Assignment.Name], (DateTime)assignmentDataSet.Tables[0].Rows[0][tables.Assignment.DueDate]); string criteriaQuery = String.Format("SELECT * FROM {0} WHERE {1} = {2} AND {3} IS NULL", tables.Criteria.TableName, tables.Criteria.AssignmentID, assignmentID, tables.Criteria.ParentCriteriaID); try { Stack<int> toVisit = new Stack<int>(); //first we get the roots... DataSet criteriaDataSet = runQuery(criteriaQuery); if (criteriaDataSet.Tables.Count > 0) { foreach (DataRow row in criteriaDataSet.Tables[0].Rows) { int cID = (int)row[tables.Criteria.CriteriaID]; string cDescription = (string)row[tables.Criteria.Description]; int cPoints = 0; if (!row.IsNull(tables.Criteria.Points)) { cPoints = (int)row[tables.Criteria.Points]; } assignment.Rubric.AddNewNode(new Criteria(cID, cDescription, cPoints)); toVisit.Push(cID); } } else { Debug.WriteLine("No criteria table found in results."); } criteriaDataSet.Dispose(); // ...then we get their CHILDREN! HAHAHAHAHAHA! while (toVisit.Count > 0) { int parent = toVisit.Pop(); criteriaQuery = String.Format("SELECT * FROM {0} WHERE {1} = {2} AND {3} = {4}", tables.Criteria.TableName, tables.Criteria.AssignmentID, assignmentID, tables.Criteria.ParentCriteriaID, parent); criteriaDataSet = runQuery(criteriaQuery); if (criteriaDataSet.Tables.Count > 0) { foreach (DataRow row in criteriaDataSet.Tables[0].Rows) { int cID = (int)row[tables.Criteria.CriteriaID]; string cDescription = (string)row[tables.Criteria.Description]; int cPoints = 0; if (!row.IsNull(tables.Criteria.Points)) { cPoints = (int)row[tables.Criteria.Points]; } assignment.Rubric.AddNewNode(new Criteria(cID, cDescription, cPoints), parent); toVisit.Push(cID); } } else { Debug.WriteLine("No criteria table found in child table results."); } criteriaDataSet.Dispose(); } } catch (Exception ex) { Debug.WriteLine("Unable to fetch criteria for assignment ID = " + assignmentID + "\n"); } } } } catch (Exception ex) { Debug.WriteLine("Could not load assignment from DB."); } return assignment; }