/// <summary> /// This is just for testing use other constructor /// </summary> public AssignmentService() { assignments = new List <Assignment>(); String here = Directory.GetCurrentDirectory(); //roster Location String rosterLocation = Path.GetFullPath(@"..\Services\TestingResources\classroom_roster.csv"); //repo location String repoLocation = Path.GetFullPath(@"..\Services\TestingResources\ClassRepo"); //instructor unit test UnitLocation String instUnitLocation = Path.GetFullPath(@"..\Services\TestingResources\UnitTests_InstructorVersion.cpp"); UserInfo currentUser = new UserInfo("CS4450-Final-Group-Summer2019", "PassW0rd4450"); ClassRoom classroom = new ClassRoom("weberstate4450summer2019", rosterLocation, "4450FinalClassroom"); string useKey = currentUser.UserName + ":" + currentUser.Password; Analyze.run(classroom, "test-assignment", repoLocation, useKey, rosterLocation, "23456"); foreach (Student s in classroom.Students) { //Calculate the time. Integer division is done intentionally int seconds = (int)s.AvgTimeBetweenCommits; int days = seconds / 86400; seconds = seconds % 86400; int hours = seconds / 3600; seconds = seconds % 3600; int minutes = seconds / 60; seconds = seconds % 60; //format string AvgTimeBetweenCommits = days + ":" + hours + ":" + minutes + ":" + seconds; Assignment assignment = new Assignment() { AssignmentName = "test-assignment", StudentName = s.Name, Compiler = s.Compiler, Rating = s.Rating, Score = s.StudentScore.ToString(), NumCommits = s.NumStudentCommits, AvgTimeCommit = AvgTimeBetweenCommits, StDevCommit = s.StdDev.ToString("0,0.00"), ReasonsWhy = s.getReasonsWhy() }; assignments.Add(assignment); } }
/// <summary> /// This is the main method the runs the analyzer /// </summary> /// <param name="assignmentName">Name of the assigment</param> /// <param name="targetFolder">The folder to save student projects</param> /// <param name="userkey">User key for GitHub</param> /// <param name="unitTestLocation">The file location of the instructors unit test</param> /// <param name="gradingKey">The security code used for grading</param> public void run(ClassRoom CurrentClass, string assignmentName, string targetFolder, string userkey, string unitTestLocation, string gradingKey) { try { hasRun = true; //get the class list, and load it up CurrentClass.CloneStudentRepositorys(assignmentName, targetFolder, userkey); foreach (Student student in CurrentClass.Students) { //build each class and get a score student.StudentScore = CurrentSystem.BuildAssignment(student.ProjectLocation, unitTestLocation, gradingKey, assignmentName); analyze(student); } //Calculate the std dev for the class List <int> averages = new List <int>(); int classAvg = 0; //loop through and get data for each student foreach (Student student in CurrentClass.Students) { classAvg += (int)student.AvgTimeBetweenCommits; averages.Add((int)student.AvgTimeBetweenCommits); } //calculate the class average time between commits, and the standerd dev //of the averages classAvg = classAvg / CurrentClass.Students.Count(); CurrentClass.AvgStdDev = (int)Math.Sqrt(averages.Sum(x => Math.Pow(x - classAvg, 2)) / (CurrentClass.Students.Count() - 1)); int lowerThreshold = classAvg - (2 * CurrentClass.AvgStdDev); //now, find the students with commits below the lower threshold foreach (Student student in CurrentClass.Students) { if ((int)student.AvgTimeBetweenCommits < lowerThreshold) { student.Rating = "Yellow"; student.addReasonWhy("Yellow: Avg time between commits below threshold"); } } } catch (Exception ex) { throw new Exception(MethodInfo.GetCurrentMethod().DeclaringType.Name + "." + MethodInfo.GetCurrentMethod().Name + " -> " + ex.Message); } }//run
public AssignmentService(ClassRoom classroom, string instructorUnitTestLocation, string assignName, string securityKey, string repoLocation, string githubUsername, string githubPassword) { assignments = new List <Assignment>(); //Inputted username and login (hopefully) UserInfo currentUser = new UserInfo(githubUsername, githubPassword); string useKey = currentUser.UserName + ":" + currentUser.Password; Analyze.run(classroom, assignName, repoLocation, useKey, instructorUnitTestLocation, securityKey); foreach (Student s in classroom.Students) { //Calculate the time. Integer division is done intentionally int seconds = (int)s.AvgTimeBetweenCommits; int days = seconds / 86400; seconds = seconds % 86400; int hours = seconds / 3600; seconds = seconds % 3600; int minutes = seconds / 60; seconds = seconds % 60; //format string AvgTimeBetweenCommits = days + ":" + hours + ":" + minutes + ":" + seconds; Assignment assignment = new Assignment() { AssignmentName = assignName, StudentName = s.Name, Compiler = s.Compiler, Rating = s.Rating, Score = s.StudentScore.ToString(), NumCommits = s.NumStudentCommits, AvgTimeCommit = AvgTimeBetweenCommits, StDevCommit = s.StdDev.ToString("0,0.00"), ReasonsWhy = s.getReasonsWhy() }; assignments.Add(assignment); } }
public IActionResult Assignments(ProfScreenViewModel model) { string instructorUTPath = ""; Services.ClassRoom classR = GetClassroom(model); bool login; if (model.githubPass == null || model.githubUser == null) { login = false; } else { login = TestGithubLogin.TestLogin(model.githubUser, model.githubPass).Result; } if (login == false && model.returnFromDetails == false) { var classes = _classroomRepository.GetAllClassrooms().OrderBy(c => c.className); var students = _studentRepository.GetAllStudents().OrderBy(s => s.classId); model.Classrooms = classes.ToList(); model.Students = students.ToList(); model.errorText = "ERROR: invalid login"; return(View("ProfScreen", model)); } if (ModelState.IsValid) { if (model.professorUnitTest != null) { //creates the needed directory if it doesn't exist System.IO.Directory.CreateDirectory(_hostingEnvironment.WebRootPath + @"/" + "instructorUnitTest"); string uploadFolder = Path.Combine(_hostingEnvironment.WebRootPath, "instructorUnitTest"); instructorUTPath = Path.Combine(uploadFolder, model.assignmentName + "InstructorUnitTest.cpp"); model.professorUnitTest.CopyTo(new FileStream(instructorUTPath, FileMode.Create)); } } //creates the needed directory if it doesn't exist System.IO.Directory.CreateDirectory(_hostingEnvironment.WebRootPath + @"/" + "studentRepo"); string studentRepo = Path.Combine(_hostingEnvironment.WebRootPath, @"studentRepo/"); //if using the return button assignname is null if (model.assignmentName != null) { myAssignmentService.assignService = new AssignmentService(classR, instructorUTPath, model.assignmentName, model.securityKey, studentRepo, model.githubUser, model.githubPass); } var assignments = myAssignmentService.assignService.GetAssignment(); //deleted the uploaded instructor unit test after the program is done if (!String.IsNullOrWhiteSpace(instructorUTPath)) { System.IO.File.Delete(instructorUTPath); } //HttpContext.Session["assignments"] = _assignmentService.GetAssignment(); //_contextAccessor.HttpContext.Session.SetString //Session["assignments"] = _assignmentService.GetAssignment(); return(View(assignments)); }