Example #1
0
        public ActionResult StudentSubmit(MilestoneViewModel model, HttpPostedFileBase ZipFile)
        {
            if (ZipFile != null)
            {
                var ZipType   = "zip";
                var ZipEnding = System.IO.Path.GetExtension(ZipFile.FileName).Substring(1);
                if (!ZipType.Contains(ZipEnding))
                {
                    return(RedirectToAction("StudentMilestones", "User", new { id = model.ID, SubID = model.SubmissionID }));
                }
                SubmissionViewModel submission = new SubmissionViewModel();

                try
                {
                    // compiler called
                    submission = US.StudentCompile(model, ZipFile);
                }
                catch
                {
                    // return error, compile failed, invalid file?
                    throw new Exception();
                }
                submission.Grade = Math.Round(LS.CalculateSimilarity(submission.Output, model.Output) * 10, 2);

                submission.Status = false;
                if (submission.Output == model.Output)
                {
                    submission.Status = true;
                }
                // checks for dr.memory error
                if (!submission.DrMemory.Contains("NO ERRORS FOUND:"))
                {
                    submission.Grade  = submission.Grade - 1;
                    submission.Status = false;
                }
                SS.AddSubmission(submission);

                var ViewModel = US.GetUserOverviewByUserName(User.Identity.GetUserName(), model.CourseID);

                if (ViewModel.Submissions != null)
                {
                    foreach (var m in ViewModel.Submissions)
                    {
                        m.AssignmentName = AS.GetAssignmentByID(m.AssignmentID).Name;
                    }
                }

                // auto grading system, checks which submission is the best.
                if (ViewModel.Assignments != null)
                {
                    foreach (var ass in ViewModel.Assignments)
                    {
                        var submissions = ViewModel.Submissions.Where(x => x.AssignmentID == ass.ID).ToList();
                        ass.Grade = AS.GetGradeForAssignment(ass.Milestones, submissions);
                    }
                }
            }

            return(RedirectToAction("StudentMilestones", "User", new { id = model.ID, SubID = model.SubmissionID }));
        }
Example #2
0
        public ActionResult StudentHome(int?id)
        {
            var ViewModel = US.GetUserOverviewByUserName(User.Identity.GetUserName(), id);

            if (ViewModel.Submissions != null)
            {
                foreach (var m in ViewModel.Submissions)
                {
                    m.AssignmentName = AS.GetAssignmentByID(m.AssignmentID).Name;
                }
            }

            if (ViewModel.Assignments != null)
            {
                foreach (var ass in ViewModel.Assignments)
                {
                    var submissions = ViewModel.Submissions.Where(x => x.AssignmentID == ass.ID).ToList();
                    ass.Grade = AS.GetGradeForAssignment(ass.Milestones, submissions);
                }
            }

            return(View(ViewModel));
        }