コード例 #1
0
        public ActionResult assignmentsubmitted(tbl_AssignmentSubmittedValidation SA, int id)
        {
            int    studentid = Convert.ToInt32(Session["Student"]);
            int    tempclassid;
            int    originalclassid;
            int    schoolid;
            string Regno;
            var    getstudentid = db.Students.Find(studentid);

            tempclassid = getstudentid.Class_Id;
            schoolid    = getstudentid.School_Id;
            Regno       = getstudentid.RegNo;
            var classid = db.Tbl_Class.Where(x => x.Class_Id == tempclassid).SingleOrDefault();

            originalclassid = classid.Class_Id;



            if (SA.UserdocFIle == null)
            {
                ModelState.AddModelError("CustomError", "Please Select File");
                return(View());
            }
            if (!(SA.UserdocFIle.ContentType == "application/pdf" || SA.UserdocFIle.ContentType == "application/pdf"))
            {
                ModelState.AddModelError("CustomError", "Select Doc or Pdf extention file only ");
                return(View());
            }

            try
            {
                SubmitAssignment sassignemnt = new SubmitAssignment();


                string fileName = Guid.NewGuid() + Path.GetExtension(SA.UserdocFIle.FileName);
                SA.UserdocFIle.SaveAs(Path.Combine(Server.MapPath("~/FrontEnd/File_upload/Assignment/"), fileName));
                sassignemnt.UploadUrl    = fileName;
                sassignemnt.CourseId     = Convert.ToInt32(TempData["id"]);
                sassignemnt.CreatedDate  = DateTime.Now;
                sassignemnt.AssignmentId = id;
                sassignemnt.SchoolId     = schoolid;
                sassignemnt.UserId       = Convert.ToInt32(Session["Student"]);

                db.SubmitAssignments.Add(sassignemnt);

                db.SaveChanges();

                ModelState.Clear();


                ViewBag.Message = "Data Submitted";
            }
            catch (Exception ex)
            {
                ViewBag.Message = "Not Submitted";
                return(View());
            }

            return(View());
        }
コード例 #2
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            HttpContext.Session.SetInt32("AssignmentID", (int)id);
            submitAssignment = _context.SubmitAssignments.ToList();

            submitAssignment = submitAssignment.Where(x => x.AssignmentID == HttpContext.Session.GetInt32("AssignmentID")).ToList();
            scoreArray       = new int[submitAssignment.Count()];



            for (int i = 0; i < submitAssignment.Count(); i++)
            {
                scoreArray[i] = submitAssignment[i].Points;
            }
            List <int> scoreList     = scoreArray.ToList();
            List <int> boxPlotScores = SubmitAssignment.calulateBoxPlot(scoreList);

            min = boxPlotScores[0];
            q1  = boxPlotScores[1];
            med = boxPlotScores[2];
            q3  = boxPlotScores[3];
            max = boxPlotScores[4];

            if (submitAssignment == null)
            {
                return(NotFound());
            }
            return(Page());
        }
コード例 #3
0
        public async Task OnGetAsync(int?id)
        {
            SubmitAssignment = await _context.SubmitAssignments.ToListAsync();

            SubmitAssignment = SubmitAssignment.Where(x => x.AssignmentID == HttpContext.Session.GetInt32("AssignmentID")).ToList();
            UserInfo         = _context.UserInfo.ToList();
        }
コード例 #4
0
        public void TestingPossibleScore()
        {
            List <int> scores = new List <int> {
                33, 78, 42, 69, 50
            };

            Assert.AreEqual(SubmitAssignment.calcPossibleScore(scores), 272, "Calculation Error");
        }
コード例 #5
0
        public void TestcalcScoreWithNegatives()
        {
            //Test if Possible Score still calculates with a negative
            List <int> scores = new List <int> {
                -1, 89, 77, 32, 10
            };

            Assert.AreEqual(SubmitAssignment.calcScore(scores), 207, "Calculation Error - Negatives");
        }
コード例 #6
0
        public int getPossibleScore()
        {
            List <SubmitAssignment> arr = _context.SubmitAssignments.ToList();

            arr = arr.Where(x => x.CourseID == HttpContext.Session.GetInt32("CourseID")).ToList();
            arr = arr.Where(x => x.UserID == HttpContext.Session.GetInt32("UserID")).ToList();
            List <int> func = new List <int>();

            foreach (SubmitAssignment item in arr)
            {
                func.Add(item.maxPoints);
            }
            return(SubmitAssignment.calcPossibleScore(func));
        }
コード例 #7
0
        public async Task <IActionResult> OnPostDownloadFile()
        {
            SubmitAssignment submitAssignment = _context.SubmitAssignments.First(x => x.SAssignmentID == HttpContext.Session.GetInt32("SAssignmentID"));
            //return File(submitAssignment.AssignmentLocation + ".FILE", submitAssignment.submissionType, submitAssignment.AssignmentLocation);
            string fileLocationString = "~/../Assignments/" + submitAssignment.AssignmentLocation;
            var    memory             = new System.IO.MemoryStream();

            using (var stream = new FileStream(fileLocationString, FileMode.Open))
            {
                await stream.CopyToAsync(memory);
            }
            memory.Position = 0;
            return(File(memory, submitAssignment.submissionType, submitAssignment.AssignmentLocation));
        }
コード例 #8
0
        public void TestingBoxPlot()
        {
            //Testing Even indexed arrays
            List <int> escores = new List <int> {
                1, 2, 3, 4, 5, 6, 7, 8, 9, 10
            };
            List <int> eshouldReturn = new List <int> {
                1, 3, 5, 8, 10
            };
            List <int> etemp = SubmitAssignment.calulateBoxPlot(escores);

            CollectionAssert.AreEqual(etemp, eshouldReturn);

            //Testing Odd indexed arrays
            List <int> oscores = new List <int> {
                1, 2, 3, 4, 5, 6, 7, 8, 9
            };
            List <int> oshouldReturn = new List <int> {
                1, 2, 5, 7, 9
            };
            List <int> otemp = SubmitAssignment.calulateBoxPlot(oscores);

            CollectionAssert.AreEqual(otemp, oshouldReturn);

            //Testing Even indexed arrays
            List <int> zscores       = new List <int>();
            List <int> zshouldReturn = new List <int> {
                0, 0, 0, 0, 0
            };
            List <int> ztemp = SubmitAssignment.calulateBoxPlot(zscores);

            CollectionAssert.AreEqual(ztemp, zshouldReturn);

            //Testint Arrays with one index
            List <int> sscores = new List <int> {
                5
            };
            List <int> sshouldReturn = new List <int> {
                5, 5, 5, 5, 5
            };
            List <int> stemp = SubmitAssignment.calulateBoxPlot(sscores);

            CollectionAssert.AreEqual(stemp, sshouldReturn);
        }
コード例 #9
0
 public void TestUserID()
 {
     // Testing that submitAssignment has a UserID attached
     Assert.AreEqual(SubmitAssignment.UserID(1), true, "No UserID attached to submitAssignment");
 }
コード例 #10
0
 public void TestCourseID()
 {
     // Testing that submitAssignment has a CourseID attached
     Assert.AreEqual(SubmitAssignment.CourseID(1), true, "No CourseID attached to submitAssignment");
 }