public List <ViewResultModel> GateListOfStudentResult(int StudentId)
        {
            SqlConnection con   = new SqlConnection(connectionString);
            string        query = "select * from GetResult where StudentId = '" + StudentId + "'";
            SqlCommand    cmd   = new SqlCommand(query, con);

            con.Open();
            SqlDataReader          dataReader       = cmd.ExecuteReader();
            List <ViewResultModel> viewResultModels = new List <ViewResultModel>();

            if (dataReader.HasRows)
            {
                while (dataReader.Read())
                {
                    ViewResultModel viewResultModel = new ViewResultModel();
                    viewResultModel.StudentId      = Convert.ToInt32(dataReader["StudentID"]);
                    viewResultModel.RegisterNumber = dataReader["RegistationNumber"].ToString();
                    viewResultModel.StudentName    = dataReader["StudentName"].ToString();
                    viewResultModel.StudentEmail   = dataReader["StudentEmail"].ToString();
                    viewResultModel.CourseCode     = dataReader["CourseCode"].ToString();
                    viewResultModel.CourseName     = dataReader["CourseName"].ToString();
                    viewResultModel.Grade          = dataReader["Grade"].ToString();
                    viewResultModels.Add(viewResultModel);
                }
                dataReader.Close();
            }
            con.Close();
            return(viewResultModels);
        }
        public List <ViewResultModel> GetStudentResult(int studentId)
        {
            string query = "SELECT * FROM GetStudentResult WHERE StudentId = '" + studentId + "'";

            Command = new SqlCommand(query, Connection);
            Connection.Open();
            Reader = Command.ExecuteReader();

            List <ViewResultModel> resultModels = new List <ViewResultModel>();

            while (Reader.Read())
            {
                ViewResultModel aModel = new ViewResultModel();
                aModel.StudentId  = (int)Reader["StudentId"];
                aModel.CourseCode = Reader["CourseCode"].ToString();
                aModel.CourseName = Reader["CourseName"].ToString();
                aModel.GradeName  = Reader["GradeName"].ToString();

                if (aModel.GradeName == "")
                {
                    aModel.GradeName = "Not Graded Yet";
                }

                resultModels.Add(aModel);
            }
            Reader.Close();
            Connection.Close();

            return(resultModels);
        }
Ejemplo n.º 3
0
        public object ViewResult(int TestId)
        {
            var             test = unitOfWork.Data.GetTestByid(TestId);
            ViewResultModel obj  = new ViewResultModel
            {
                Date          = test.Date,
                TestType      = test.TestType,
                TestId        = TestId,
                AtheleteNames = unitOfWork.Data.GetAtheleteNamesWithDataByTestId(TestId)
            };

            return(Ok(obj));
        }
Ejemplo n.º 4
0
        public PartialViewResult GetEnrollCourseAndResult(int studentId)
        {
            List <ViewResultModel> viewResultList = new List <ViewResultModel>();
            var enrolledCourseList = new List <EnrollCourse>();

            enrolledCourseList = db.EnrollCourses.Include(c => c.Course).Where(s => s.StudentId == studentId).ToList();
            foreach (var anEnrolledCourse in enrolledCourseList)
            {
                ViewResultModel aViewREsultRow = new ViewResultModel();
                aViewREsultRow.Id         = anEnrolledCourse.CourseId;
                aViewREsultRow.CourseCode = anEnrolledCourse.Course.Code;
                aViewREsultRow.Name       = anEnrolledCourse.Course.Name;
                aViewREsultRow.Grade      = CheckIfEnrolledCourseHasAGradeAndGetGrade(anEnrolledCourse.CourseId, anEnrolledCourse.StudentId);
                viewResultList.Add(aViewREsultRow);
            }
            return(PartialView("~/Views/Shared/_ViewResult.cshtml", viewResultList));
        }
        public ViewResultModel GetResultForSpecificQuestion(Entities.Question q)
        {
            var allAnswers = QuestionRepository.GetSpecificResult(q.Id);

            if (allAnswers == null)
            {
                throw new Exception();
            }
            var resultsCount = allAnswers.GroupBy(a => a.responseOption).
                               Select(group =>
                                      new
            {
                Name  = group.Key,
                Count = group.Count()
            }).ToArray();

            if (resultsCount.Length == 0)
            {
                ViewResultModel emptyViewResult = new ViewResultModel();

                emptyViewResult.question = q.Title;
                return(emptyViewResult);
            }

            double totalAnswers = allAnswers.Count;
            double resultOne    = resultsCount[0].Count;
            double resultTwo    = resultsCount[1].Count;

            var name = resultsCount[0].Name;

            var optionOneInProcent = getResultInProcent(totalAnswers, resultOne);
            var optionTwoInProcent = getResultInProcent(totalAnswers, resultTwo);

            ViewResultModel viewResult = new ViewResultModel();

            viewResult.question       = q.Title;
            viewResult.option1        = resultsCount[0].Name.option.ToString();
            viewResult.option2        = resultsCount[1].Name.option.ToString();
            viewResult.procentOption1 = optionOneInProcent + " %";
            viewResult.procentOption2 = optionTwoInProcent + " %";
            viewResult.countOption1   = resultOne;
            viewResult.countOption2   = resultTwo;

            return(viewResult);
        }
        public IHttpActionResult GetResultForSpecificQuestion(int id)
        {
            var question = QuestionRepository.GetQuestionById(id);

            if (question == null)
            {
                return(StatusCode(HttpStatusCode.NotFound));
            }

            var allAnswers = QuestionRepository.GetSpecificResult(id);

            if (allAnswers == null)
            {
                return(StatusCode(HttpStatusCode.NoContent));
            }
            var resultsCount = allAnswers.GroupBy(a => a.responseOption).
                               Select(group =>
                                      new
            {
                Name  = group.Key,
                Count = group.Count()
            }).ToArray();

            double totalAnswers = allAnswers.Count;
            double resultOne    = resultsCount[0].Count;
            double resultTwo    = resultsCount[1].Count;

            var name = resultsCount[0].Name;

            var optionOneInProcent = getResultInProcent(totalAnswers, resultOne);
            var optionTwoInProcent = getResultInProcent(totalAnswers, resultTwo);

            ViewResultModel viewResult = new ViewResultModel();

            viewResult.question       = question.Title;
            viewResult.option1        = resultsCount[0].Name.option.ToString();
            viewResult.option2        = resultsCount[1].Name.option.ToString();
            viewResult.procentOption1 = optionOneInProcent + " %";
            viewResult.procentOption2 = optionTwoInProcent + " %";
            viewResult.countOption1   = resultOne;
            viewResult.countOption2   = resultTwo;

            return(Ok(viewResult));
        }
        public List<ViewResultModel> GetAllStudentsRegistrationNo()
        {
            string query = "SELECT * FROM RegisterStudent";

            Command = new SqlCommand(query, Connection);
            Connection.Open();
            Reader = Command.ExecuteReader();

            List<ViewResultModel> students = new List<ViewResultModel>();
            while (Reader.Read())
            {
                ViewResultModel student = new ViewResultModel();
                student.RegNo = Reader["RegNo"].ToString();
                //student.Name = Reader["Name"].ToString();
                students.Add(student);
            }

            Reader.Close();
            Connection.Close();
            return students;
        }
        public ViewResultModel GetIdByStudentInfo(int id)
        {
            SqlConnection con   = new SqlConnection(connectionString);
            string        query = "select * from EnrollByDepartment where StudentId = '" + id + "'";
            SqlCommand    cmd   = new SqlCommand(query, con);

            con.Open();
            SqlDataReader   dataReader      = cmd.ExecuteReader();
            ViewResultModel viewResultModel = new ViewResultModel();

            if (dataReader.HasRows)
            {
                while (dataReader.Read())
                {
                    viewResultModel.CourseName     = dataReader["StudentName"].ToString();
                    viewResultModel.StudentEmail   = dataReader["StudentEmail"].ToString();
                    viewResultModel.DepartmentName = dataReader["DepartName"].ToString();
                }
                dataReader.Close();
            }
            con.Close();
            return(viewResultModel);
        }
        public List<ViewResultModel> GetStudentByRegNo(string regNo)
        {
            string query = "select r.Name as StudentName, r.Email as StudentEmail," +
                           " d.DepartmentName as DepartmentName, c.CourseName as CourseName  ," +
                           " c.CourseCode as CourseCode , g.Grade as Grade" +
                           " from RegisterStudent as r inner join Department as d on r.DeptId= d.Id inner join " +
                           "EnrollACourse as e on r.Id= e.StudentId" +
                           " inner join Course as c on c.Id = e.CourseId" +
                           " left join Grade as g on g.Id= e.GradeId" +
                           " where r.RegNo='" + regNo + "'";


            Command = new SqlCommand(query, Connection);
            Connection.Open();
            Reader = Command.ExecuteReader();
            List<ViewResultModel> students = new List<ViewResultModel>();

            while (Reader.Read())
            {
                ViewResultModel student = new ViewResultModel();
                student.StudentName = Reader["StudentName"].ToString();
                student.StudentEmail = Reader["StudentEmail"].ToString();
                student.DepartmentName = Reader["DepartmentName"].ToString();
                student.CourseCode = Reader["CourseCode"].ToString();
                student.CourseName = Reader["CourseName"].ToString();
                student.Grade = Reader["Grade"].ToString();

                students.Add(student);
            }

            Reader.Close();
            Connection.Close();
            return students;


        }
Ejemplo n.º 10
0
        public async Task <IActionResult> Add(ViewResultModel viewResultModel)
        {
            Dictionary <string, string> value = new Dictionary <string, string>();

            return(Ok(value));
        }
Ejemplo n.º 11
0
        public async Task <IActionResult> Add([FromServices] IHostingEnvironment environment, ViewResultModel viewResult)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            string file_path = string.Empty;

            file_path = Path.Combine("file", Guid.NewGuid().ToString() + Path.GetExtension(viewResult.FilePath.FileName));
            file_path = environment.WebRootPath + "/" + file_path;

            using (var sream = new FileStream(file_path, FileMode.Create)) {
                viewResult.FilePath.CopyTo(sream);
            }

            await _resultDao.InsertAsync(new Models.Result()
            {
                StuName    = viewResult.StuName,
                Title      = viewResult.Title,
                Discrption = viewResult.Discrption,
                Create     = DateTime.Now,
                TypeId     = viewResult.TypeId,
                PassWord   = viewResult.PassWord,
                FilePath   = file_path
            });

            return(RedirectToAction("Index"));
        }
 public PartialViewResult GetEnrollCourseAndResult(int studentId)
 {
     List<ViewResultModel> viewResultList = new List<ViewResultModel>();
     var enrolledCourseList = new List<EnrollCourse>();
     enrolledCourseList = db.EnrollCourses.Include(c => c.Course).Where(s => s.StudentId == studentId).ToList();
     foreach (var anEnrolledCourse in enrolledCourseList)
     {
         ViewResultModel aViewREsultRow = new ViewResultModel();
         aViewREsultRow.Id = anEnrolledCourse.CourseId;
         aViewREsultRow.CourseCode = anEnrolledCourse.Course.Code;
         aViewREsultRow.Name = anEnrolledCourse.Course.Name;
         aViewREsultRow.Grade = CheckIfEnrolledCourseHasAGradeAndGetGrade(anEnrolledCourse.CourseId, anEnrolledCourse.StudentId);
         viewResultList.Add(aViewREsultRow);
     }
     return PartialView("~/Views/Shared/_ViewResult.cshtml", viewResultList);
 }