Exemplo n.º 1
0
        public IActionResult Questionnaire()
        {
            CourseProcess courseprocess = new CourseProcess(_context);
            QuestionAns   questionnaire = new QuestionAns();

            questionnaire.staffcourses = courseprocess.getCourses();
            return(View(questionnaire));
        }
        public async Task <IActionResult> Update([FromBody] CourseProcessViewModel courseProcessViewModel)
        {
            try
            {
                CourseProcess courseProcess = await courseProcessRepository.GetByStudentIdAndCourseId(courseProcessViewModel.StudentId, courseProcessViewModel.CourseId);

                if (courseProcess == null)
                {
                    courseProcess = new CourseProcess()
                    {
                        StudentId   = courseProcessViewModel.StudentId,
                        CourseId    = courseProcessViewModel.CourseId,
                        LectureId   = courseProcessViewModel.LectureId,
                        LastUpdated = DateTime.Now
                    };

                    await courseProcessRepository.Add(courseProcess);
                }
                else
                {
                    courseProcess.LectureId   = courseProcessViewModel.LectureId;
                    courseProcess.LastUpdated = DateTime.Now;

                    await courseProcessRepository.Update(courseProcess);
                }


                double completionRate = await lectureRepository.GetCompletionRateByCourseIdAndLectureId(courseProcessViewModel.CourseId, courseProcessViewModel.LectureId);


                return(Ok(new
                {
                    Results = new
                    {
                        CourseProcess = courseProcess,
                        CompletionRate = completionRate
                    }
                }));
            }
            catch (Exception e)
            {
                Console.WriteLine($"ErrorMesages: {e}");

                return(BadRequest(new
                {
                    Errors = new { Code = "InvalidInputParameters", Description = "Invalid Input Parameters!" }
                }));
            }
        }
        public async Task <IActionResult> GetByStudentIdAndCourseId([FromQuery] string studentId, int courseId)
        {
            try
            {
                CourseProcess courseProcess = await courseProcessRepository.GetByStudentIdAndCourseId(studentId, courseId);

                if (courseProcess == null)
                {
                    return(Ok(new
                    {
                        Results = new
                        {
                            CourseProcess = courseProcess,
                            CompletionRate = 0.0
                        }
                    }));
                }
                else
                {
                    //double completionRate = await lectureRepository.GetCompletionRateByCourseIdAndLectureId(courseProcess.CourseId, courseProcess.LectureId);


                    return(Ok(new
                    {
                        Results = new
                        {
                            CourseProcess = courseProcess
                                            //CompletionRate = completionRate
                        }
                    }));
                }
            }
            catch (Exception e)
            {
                Console.WriteLine($"ErrorMesages: {e}");

                return(BadRequest(new
                {
                    Errors = new { Code = "InvalidInputParameters", Description = "Invalid Input Parameters!" }
                }));
            }
        }
Exemplo n.º 4
0
        public ActionResult GetUserCourseInfoList(UserCourseModelP model)
        {
            APIInvokeResult         result = new APIInvokeResult();
            List <CourserWareModel> list;
            int count = 0;
            var id    = LoginUserInfo();

            list  = _courseRepository.RelatedFinishCourseList(id, model.Finish, model.Page, model.Rows, out int totalcount);
            count = totalcount;
            var json = new ResultInfo <CourseInfo>
            {
                TotalCount = count,
                List       = list.Select((s, i) =>
                {
                    CourseProcess cpquery = new CourseProcess();
                    cpquery.CourseId      = int.Parse(s.Id.ToString());
                    cpquery.UserId        = LoginUserInfo();
                    var cplist            = s.Learning;
                    var lastpostion       = cplist;
                    var lastnodeid        = "S001";
                    //var examstring = string.Empty;
                    //foreach (var exam in s.Course.Exam.Where(w=>w.PortalExam.Any(a=>a.PortalId==PortalId)))
                    //{
                    //  //  examstring+=exam.Name+""+exam
                    //}
                    var channel   = s.channelName;
                    var onlineurl = "";
                    //if (s.Course.Standards == CourseStandards.Office.ToString())
                    //{
                    //    if (!string.IsNullOrWhiteSpace(onlineurl))
                    //    {
                    //        onlineurl = "/api/mobile/GetOffice?file=" + VerifyEncrypt.UrlEncode(onlineurl);
                    //        // onlineurl = "/Content/plugins/pdf/web/viewer.html?file=" + VerifyEncrypt.UrlEncode(onlineurl);
                    //    }
                    //}
                    return(new CourseInfo
                    {
                        Index = (i + 1),
                        CourseId = s.Id.ToString(),
                        CourseName = s.Name,
                        Credit = s.Credit.ToString(),
                        CourseType = "Mp4",
                        CreateDate = s.CreateDate,
                        FinishDate = DateTime.Now,
                        BrowseScore = ((decimal)s.Times / (decimal)s.Length * 100).ToString("F2") + "%",
                        LastLocation = 0,                  ////TODO 2015-02-28 09:24:08 添加LastNodeID
                        LastNodeId = lastnodeid ?? "S001", // lastnodeid,
                        TeacherName = s.Teacher,
                        Description = s.Description,
                        Duration = s.Length.ToString(),
                        OnlineUrl = onlineurl,// online != null ? online.Url : "",
                        CourseImg = "http://www.cszsjy.com/Fwadmin/Manager/Admin/Lession/Save/" + s.Img,
                        ChannelName = s.channelName,
                        RequiredFlag = "",
                        DownloadUrl = "",
                        DownloadUrlLow = "",
                        ExamId = "",
                        CommentCredit = "",
                        SelectFlag = "已选",
                        AvgScore = "0",
                        ClickCount = s.ClickCount.ToString(),
                        CourseSize = "",
                        Remainder = (s.Length - s.Times).ToString()
                    });
                }).ToList()
            };

            result.Data = json;
            return(Json(result));
        }
Exemplo n.º 5
0
        public ActionResult UploadTimeNode(Mp4CourseProcessDataModel model)
        {
            APIInvokeResult result   = new APIInvokeResult();
            var             courseid = model.CourseId;
            //string playingCourseKey = string.Format(CacheKey.PlayingCourseKey, LoginUserId);

            //JYCache.OneCacheMananger().Add(playingCourseKey, courseid);
            //var course = ServicesItems.CourseServices.GetCourse(courseid);
            var     course        = _courseRepository.GetEntity(m => m.COURSE_ID == courseid);
            string  coruse_number = course.COURSE_NUMBER;
            var     userid        = LoginUserInfo();
            var     userNm        = _userRepository.GetEntity(j => j.USER_ID == userid).USER_NM;
            decimal time          = 0;
            var     videoLength   = _channelMmrRepository.GetEntity(n => n.CourseID == courseid);
            var     len           = videoLength.Video_Length > 0 ? videoLength.Video_Length : 100;

            if (course != null && !string.IsNullOrEmpty(model.TimeNode))
            {
                var h = Convert.ToDecimal(model.TimeNode.Substring(0, 2));
                var m = Convert.ToDecimal(model.TimeNode.Substring(2, 2));
                var s = Convert.ToDecimal(model.TimeNode.Substring(4, 2));
                time = h * 3600 + m * 60 + s;
                //Debug.WriteLine(time);
                //  Console.WriteLine(time + ":::::");
                CourseProcess process = new CourseProcess
                {
                    //PortalId = PortalId,
                    PortalId = "",
                    UserId   = LoginUserInfo(),
                    Position = time,
                    CourseId = courseid
                };

                var courseProcess = _courseProcessRepository.GetEntity(mm => mm.COURSE_ID == coruse_number && mm.STUDENT_ID == userid);
                if (courseProcess != null)
                {
                    courseProcess.timems = int.Parse(time.ToString());
                    _courseProcessRepository.Update(courseProcess);
                }
                else
                {
                    AICC_J_HIGH_SCORE pp = new AICC_J_HIGH_SCORE
                    {
                        COURSE_ID        = coruse_number,
                        length           = int.Parse(len.ToString()),
                        OBJ_FIRST_DATE   = DateTime.Now,
                        OBJ_HIGH_SCORE   = "0",
                        OBJ_OBJECTIVE_ID = "1",
                        SESSION_ID       = "0",
                        STUDENT_ID       = userid,
                        timems           = int.Parse(time.ToString())
                    };
                    _courseProcessRepository.Insert(pp);
                }
            }
            var courseProcesss = _courseProcessRepository.GetEntity(mm => mm.COURSE_ID == coruse_number && mm.STUDENT_ID == userid);

            UserStudyInfo usi = new UserStudyInfo();

            usi.CourseId  = courseid.ToString();
            usi.StartTime = courseProcesss.OBJ_FIRST_DATE != null?Convert.ToDateTime(courseProcesss.OBJ_FIRST_DATE) : Convert.ToDateTime("1900-01-01");

            usi.CurrentProgress = ((decimal)courseProcesss.timems.Value / (decimal)videoLength.Video_Length.Value).ToString("F2");
            usi.LastLoation     = courseProcesss.timems.ToString();
            usi.LastNodeId      = "0";
            usi.NodeList        = new List <NodeInfo>();
            result.Data         = usi;
            return(Json(result));
        }