Esempio n. 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;
        }
Esempio n. 2
0
 public RubricNode(Criteria c)
 {
     Criteria = c;
     Children = new LinkedList<int>();
 }
Esempio n. 3
0
 /// <summary>
 /// Adds a new node to the given parent.
 /// </summary>
 /// <param name="c">A criteria with a key given by the database. The criteria should have a key already (it should not be NoID).</param>
 /// <param name="parentKey">The valid parent key that the node should be added to.</param>
 /// <returns>The criterias key (which references it in the dictionary as well as the DB).</returns>
 public int AddNewNode(Criteria c, int parentKey)
 {
     RubricNode parentNode;
     if (Nodes.TryGetValue(parentKey, out parentNode))
     {
         Nodes.Add(c.CriteriaID, new RubricNode(c));
         parentNode.Children.AddLast(c.CriteriaID);
         return c.CriteriaID;
     }
     else
     {
         // The parent doesn't exist in the dictionary!
         return -1;
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Takes a Criteria and creates a new CriteriaTreeNode at the root of the collection.
 /// </summary>
 /// <param name="c">A criteria with a key given by the database. The criteria should have a key already (it should not be NoID).</param>
 /// <returns>The criterias key (which references it in the dictionary as well as the DB).</returns>
 public int AddNewNode(Criteria c)
 {
     RubricNode node = new RubricNode(c);
     Nodes.Add(node.Criteria.CriteriaID, node);
     RootNodes.AddLast(node.Criteria.CriteriaID);
     return node.Criteria.CriteriaID;
 }
        private void setCriteria(LinkedList<CriteriaNode> list)
        {
            Criteria criteria;
            foreach (CriteriaNode c in list)
            {
                criteria = new Criteria();
                criteria.Description = c.Description;
                criteria.MaxPoints = c.Points;

                if (c.NumberOfChildren > 0)
                {
                    setCriteria(c.ChildList);
                }
                // TODO: save criteria to the database... :D
            }
        }
Esempio n. 6
0
 private void setCriteria(TreeNodeCollection tree, int parentID, int assignmentID)
 {
     Criteria criteria;
     foreach (CriteriaNode c in tree)
     {
         criteria = new Criteria();
         criteria.Description = c.Description;
         if (c.Nodes.Count > 0)
         {
             criteria.MaxPoints = 0;
         }
         else
         {
             criteria.MaxPoints = c.Points;
         }
         int criteriaID = dbConnention.AddCriteria(criteria,parentID,assignmentID);
         setCriteria(c.Nodes, criteriaID, assignmentID);
     }
 }
Esempio n. 7
0
        public int AddCriteria(Criteria criteria, int parentID, int assignmentID)
        {
            if (criteria.HasID())
            {
                Debug.WriteLine("You should not add criteria if it already has an ID assigned.");
                return criteria.CriteriaID;
            }
            else
            {
                // We need to insert rather than update because the criteria has no key.
                string query = String.Format("INSERT INTO {0} (", tables.Criteria.TableName);
                query += String.Format("{0}, ", tables.Criteria.Description);
                query += String.Format("{0}, ", tables.Criteria.Points);
                if (parentID != -1)
                {
                    query += String.Format("{0}, ", tables.Criteria.ParentCriteriaID);
                }
                query += String.Format("{0}", tables.Criteria.AssignmentID);

                query += ") VALUES (";
                query += String.Format("@{0}, ", tables.Criteria.Description);
                query += String.Format("@{0}, ", tables.Criteria.Points);
                if (parentID != -1)
                {
                    query += String.Format("@{0}, ", tables.Criteria.ParentCriteriaID);
                }
                query += String.Format("@{0}", tables.Criteria.AssignmentID);
                query += ");";
                OleDbCommand insert = new OleDbCommand(query, dbConnection);
                insert.Parameters.Add(new OleDbParameter("@" + tables.Criteria.Description, OleDbType.VarChar)).Value = criteria.Description;
                insert.Parameters.Add(new OleDbParameter("@" + tables.Criteria.Points, OleDbType.VarChar)).Value = criteria.MaxPoints;
                if(parentID != -1){
                    insert.Parameters.Add(new OleDbParameter("@" + tables.Criteria.ParentCriteriaID, OleDbType.VarChar)).Value = parentID;
                }
                insert.Parameters.Add(new OleDbParameter("@" + tables.Criteria.AssignmentID, OleDbType.VarChar)).Value = assignmentID;
                try
                {
                    insert.ExecuteNonQuery();
                }
                catch
                {
                    Debug.WriteLine("Could not insert criteria.");
                }

                // Now that we inserted the student, we need to get its ID
                query = "SELECT @@IDENTITY;";
                OleDbCommand getID = new OleDbCommand(query, dbConnection);
                int key = criteria.CriteriaID;
                try
                {
                    key = (int)getID.ExecuteScalar();
                }
                catch
                {
                    Debug.WriteLine("Could not retrieve criteria ID.");
                }
                return key;
            }
        }
Esempio n. 8
0
 private void setCriteria(LinkedList<CriteriaNode> list, int assignid)
 {
     Criteria criteria;
     foreach (CriteriaNode c in list)
     {
         criteria = new Criteria();
         criteria.Description = c.Description;
         criteria.MaxPoints = c.Points;
         c.CriteriaID = dbConnention.AddCriteria(criteria);
         if (c.NumberOfChildren > 0)
         {
             foreach (CriteriaNode cn in c.ChildList)
             {
                 cn.ParentID = c.CriteriaID;
             }
             setCriteria(c.ChildList,assignid);
         }
     }
 }