public void GradeSubmission() { var db = Utils.MakeMockDatabase(); var controller = MakeController(db); string uid = StudentControllerTests.AddOneStudent(db); uint cid = AddCourseAndClass(db); Enroll(uid, cid, db); AddAssignmentAndCategory(cid, db); Submissions newSubmission = new Submissions { UId = uid, AId = 999, Content = "This is some serious content", Time = DateTime.Now, Score = 78, }; db.Submissions.Add(newSubmission); db.SaveChanges(); var jsonResult = controller.GradeSubmission("CS", 3550, "Spring", 2019, "Quizzes", "Bonus Quiz", uid, 79) as JsonResult; Assert.True(Utils.ResultSuccessValue(jsonResult)); }
public void GetStudentsInClassOneStudent() { var db = Utils.MakeMockDatabase(); var controller = MakeController(db); string uid = StudentControllerTests.AddOneStudent(db); uint cid = 101; Courses newCourse = new Courses { CatalogId = "12345", Listing = "CS", Name = "Algorithms", Number = "3550" }; db.Courses.Add(newCourse); Classes newClass = new Classes { CId = cid, CatalogId = "12345", SemesterYear = 2019, SemesterSeason = "Spring", Location = "On the moon", StartTime = new TimeSpan(), EndTime = new TimeSpan() }; db.Classes.Add(newClass); Enroll(uid, cid, db); db.SaveChanges(); var jsonResult = controller.GetStudentsInClass("CS", 3550, "Spring", 2019) as JsonResult; dynamic resultValue = jsonResult.Value as dynamic; Assert.Single(resultValue); var oneStudent = resultValue[0] as dynamic; Assert.True(Utils.HasField(oneStudent, "fname")); Assert.True(Utils.HasField(oneStudent, "lname")); Assert.True(Utils.HasField(oneStudent, "uid")); Assert.True(Utils.HasField(oneStudent, "dob")); Assert.True(Utils.HasField(oneStudent, "grade")); Assert.False(Utils.HasField(oneStudent, "two heads")); Assert.Equal("Brian", Utils.GetValue <string>(oneStudent, "fname")); Assert.Equal("Landes", Utils.GetValue <string>(oneStudent, "lname")); Assert.Equal("--", Utils.GetValue <string>(oneStudent, "grade")); }
public void GradeSubmissionUpdateGradeOneSumbissionD() { var db = Utils.MakeMockDatabase(); var controller = MakeController(db); string uid = StudentControllerTests.AddOneStudent(db); uint cid = AddCourseAndClass(db); Enroll(uid, cid, db); AssignmentCategories assCat = new AssignmentCategories { AcId = 1002, Name = "Quizzes", GradingWeight = 100, CId = cid }; db.AssignmentCategories.Add(assCat); Assignments newAssignment = new Assignments { AId = 999, AcId = 1002, Name = "Bonus Quiz", MaxPointValue = 100, DueDate = DateTime.Now, Content = "oanklaks fl lja", }; db.Assignments.Add(newAssignment); Submissions newSubmission = new Submissions { UId = uid, AId = 999, Content = "This is some serious content", Time = DateTime.Now, Score = 78, }; db.Submissions.Add(newSubmission); db.SaveChanges(); AssertGradeEquals(uid, "--", db); var jsonResult = controller.GradeSubmission("CS", 3550, "Spring", 2019, "Quizzes", "Bonus Quiz", uid, 65) as JsonResult; Assert.True(Utils.ResultSuccessValue(jsonResult)); AssertGradeEquals(uid, "D", db); }
public void GetAssignmentsNoCategory() { var db = Utils.MakeMockDatabase(); var controller = MakeController(db); string uid = StudentControllerTests.AddOneStudent(db); uint cid = AddCourseAndClass(db); Enroll(uid, cid, db); AddAssignmentAndCategory(cid, db); Submissions newSubmission = new Submissions { UId = uid, AId = 999, Content = "This is some serious content", Time = DateTime.Now, Score = 78, }; db.Submissions.Add(newSubmission); db.SaveChanges(); var jsonResult = controller.GetAssignmentsInCategory("CS", 3550, "Spring", 2019, null) as JsonResult; Utils.AssertJsonResultIsArrayOfLength(jsonResult, 1); var oneAssignment = Utils.JsonResultValueAtIndex(jsonResult, 0); Assert.True(Utils.HasField(oneAssignment, "aname")); Assert.True(Utils.HasField(oneAssignment, "cname")); Assert.True(Utils.HasField(oneAssignment, "due")); Assert.True(Utils.HasField(oneAssignment, "submissions")); var numSubmissions = Utils.GetValue <int>(oneAssignment, "submissions"); Assert.Equal(1, numSubmissions); }
public void GradeSubmissionTrivialFailure() { var db = Utils.MakeMockDatabase(); var controller = MakeController(db); string uid = StudentControllerTests.AddOneStudent(db); uint cid = AddCourseAndClass(db); Enroll(uid, cid, db); AddAssignmentAndCategory(cid, db); // no submission db.SaveChanges(); var jsonResult = controller.GradeSubmission("CS", 3550, "Spring", 2019, "Quizzes", "Bonus Quiz", uid, 79) as JsonResult; Assert.False(Utils.ResultSuccessValue(jsonResult)); }
public void GetAssignmentsNoCategory2() { var db = Utils.MakeMockDatabase(); var controller = MakeController(db); string uid = StudentControllerTests.AddOneStudent(db); uint cid = AddCourseAndClass(db); Enroll(uid, cid, db); int numAssCats = 10; for (int i = 0; i < numAssCats; i++) { AssignmentCategories assCat = new AssignmentCategories { AcId = 1002 + (uint)i, Name = "Quizzes" + i, GradingWeight = 50, CId = cid }; db.AssignmentCategories.Add(assCat); Assignments newAssignment = new Assignments { AId = 999 + (uint)i, AcId = 1002 + (uint)i, Name = "Bonus Quiz", MaxPointValue = 102, DueDate = DateTime.Now, Content = "oanklaks fl lja", }; db.Assignments.Add(newAssignment); Submissions newSubmission = new Submissions { UId = uid, AId = 999 + (uint)i, Content = "This is some serious content", Time = DateTime.Now, Score = 78, }; db.Submissions.Add(newSubmission); } db.SaveChanges(); var jsonResult = controller.GetAssignmentsInCategory("CS", 3550, "Spring", 2019, null) as JsonResult; Utils.AssertJsonResultIsArrayOfLength(jsonResult, numAssCats); for (int i = 0; i < numAssCats; i++) { var oneAssignment = Utils.JsonResultValueAtIndex(jsonResult, i); Assert.True(Utils.HasField(oneAssignment, "aname")); Assert.True(Utils.HasField(oneAssignment, "cname")); Assert.True(Utils.HasField(oneAssignment, "due")); Assert.True(Utils.HasField(oneAssignment, "submissions")); var numSubmissions = Utils.GetValue <int>(oneAssignment, "submissions"); Assert.Equal(1, numSubmissions); } }