示例#1
0
        public ActionResult Work(User user, long doworkId, long contentId)
        {
            var doWorkBase   = workBaseService.GetDoWorkBase(doworkId);
            var workResource = workService.GetWorkResource(contentId);

            if (null == doWorkBase || null == workResource)
            {
                return(RedirectToErrorAction(1, "未找到作业"));
            }
            var url = string.Empty;

            if (user.UserID == doWorkBase.SubmitUserID)
            {
                url = string.Concat(RedirectHelper.GetRedirectUrl(workResource.ModuleId.ToString()), "/dowork?doworkId=", doworkId, "&contentId=", contentId);
            }
            else if (user.UserID == doWorkBase.PublishUserId)
            {
                if (workResource.ModuleId == 5 || workResource.ModuleId == 18 || workResource.ModuleId == 15)
                {
                    url = string.Concat(RedirectHelper.GetRedirectUrl(workResource.ModuleId.ToString()), "/correct?doworkId=", doworkId, "&contentId=", contentId);
                }
                else
                {
                    url = "/home/error?message=暂不支持当前作业的批改";
                }
            }
            else
            {
                url = string.Format("/home/error?message=暂无查看权限,请检查当前登录用户{0}({1})", user.UserID, user.UserName);
            }

            return(Redirect(url));
        }
示例#2
0
        public JsonResult SaveCorrect(User user, long doId, long versionId, int sid, int assess, decimal itemScore, Guid moduleId)
        {
            var unitWork = workService.GetUserUnitWork(doId);

            if (null == unitWork)
            {
                return(Json(new ReturnResult(1, "未找到指定的作业!")));
            }
            var doWorkBase = workBaseService.GetDoWorkBase(unitWork.DoWorkId);

            if (doWorkBase.PublishUserId != user.UserID)
            {
                return(Json(new ReturnResult(2, string.Format("暂无当前作业批改权限.登陆ID:{0}({1})!", user.UserID, user.UserName))));
            }
            if (unitWork.Status != 2 && unitWork.Status != 3)
            {
                return(Json(new ReturnResult(3, "当前作业尚未完成,您还不能批改!")));
            }

            var workAnswer = workService.GetAnswer(doId, 1, versionId);

            var oldScore = null == workAnswer ? 0m : workAnswer.Score;

            if (moduleId == ResourceModuleOptions.ListeningAndSpeakingExam)
            {
                workAnswer = listenPaperCorrect(workAnswer, doId, versionId, sid, assess, itemScore);
            }
            else
            {
                workAnswer = paperCorrect(workAnswer, doId, versionId, sid, assess, itemScore);
            }

            unitWork.ActualScore += workAnswer.Score - oldScore;

            if (workService.CorrectAnswer(unitWork, workAnswer))
            {
                return(Json(new ReturnResult <decimal>(unitWork.ActualScore)));
            }
            else
            {
                return(Json(new ReturnResult(4, "保存批改失败")));
            }
        }
示例#3
0
        /// <summary>
        /// 作业参数验证与基础信息赋值
        /// </summary>
        public static ReturnResult <WorkParam> CheckWorkParams(this HttpRequestBase request, User user, WorkBaseService workBaseService, WorkService workService, PackageService packageService, bool isGetParts = true, bool isRedirectBuy = true)
        {
            var query  = request.Url.ParseQueryString();
            var client = new RestClient(100001);

            var defectParams = worksParamsArray.Except(query.AllKeys.Select(t => t.ToLower()));

            if (defectParams.Any())
            {
                return(new ReturnResult <WorkParam>(1, null, string.Concat("基础参数验证失败,参数:", string.Join(",", defectParams), "未找到")));
            }

            var baseParam = new WorkParam()
            {
                User     = user,
                ViewType = 2
            };

            long doWorkId = Convert.ToInt64(query.Get("doWorkId")), contentId = Convert.ToInt64(query.Get("contentId"));

            ///请求用户个人列表
            baseParam.DoWorkBase = workBaseService.GetDoWorkBase(doWorkId);

            if (null == baseParam.DoWorkBase || baseParam.DoWorkBase.WorkType < 101)
            {
                return(new ReturnResult <WorkParam>(2, baseParam, "未找到符合条件的作业"));
            }
            if (baseParam.DoWorkBase.SubmitUserID != user.UserID && baseParam.DoWorkBase.PublishUserId != user.UserID)
            {
                return(new ReturnResult <WorkParam>(3, baseParam, "暂无作业权限"));
            }
            if (baseParam.DoWorkBase.WorkBaseStatus != 0)
            {
                return(new ReturnResult <WorkParam>(7, baseParam, "这份作业已经被老师取消布置啦,再去作业系统看看有没有重新布置哦!"));
            }

            var recordId = Convert.ToInt64(baseParam.DoWorkBase.RedirectParm.Split('.')[0].Replace("bid_", string.Empty));

            baseParam.WorkResource = workService.GetWorkResource(contentId);

            if (null == baseParam.WorkResource || baseParam.WorkResource.RecordId != recordId)
            {
                return(new ReturnResult <WorkParam>(4, baseParam, "未找到符合条件的作业"));
            }

            baseParam.Package = packageService.GetPackage(baseParam.WorkResource.PackageId);

            baseParam.PackageType = baseParam.Package.GroupType;

            baseParam.UnitWork = workService.GetUserUnitWork(contentId, doWorkId);

            baseParam.workStatus = null == baseParam.UnitWork ? 0 : baseParam.UnitWork.Status;

            #region 使用权限判断

            if (!string.IsNullOrEmpty(baseParam.WorkResource.RelationPath))
            {
                long rootVersion = Convert.ToInt64(baseParam.WorkResource.RelationPath.Split('/').First());

                var packageResults = packageService.GetTaskResultContents(baseParam.Package.PackageId, rootVersion);

                if (null == packageResults || !packageResults.Any())
                {
                    return(new ReturnResult <WorkParam>(5, baseParam, "未找到指定资源"));
                }

                ////  DateTime.Now < DateTime.Parse("2015-09-01")  时间小于九月一号的所有资源免费开放
                if (baseParam.workStatus > 0 || packageResults.Any(t => t.IsFree) || DateTime.Now < DateTime.Parse("2015-09-01"))                 //如果免费资源或者已经完成的作业,则不进行验证
                {
                    baseParam.PackagePermission = new PackagePermissionContract()
                    {
                        IsFree = true
                    };
                }
                else
                {
                    //判断用户使用权限 VipCode(1:已购买书籍 2:无使用权限 3:已购买但已过期  4:免费资源  5:已开通会员服务 6:已经开通服务但已经过期)
                    //var result = new RestClient(user.UserID, "http://192.168.1.61:8123").ExecuteGet<ReturnResult<PackagePermissionContract>>("/bookcase/home/IsCan", new { packageId = baseParam.Package.PackageId, userid = user.UserID });
                    var result = new RestClient(user.UserID).ExecuteGet <ReturnResult <PackagePermissionContract> >(WebApi.UserIsCan, new { packageId = baseParam.Package.PackageId, userid = user.UserID });

                    if (result.Ret == 0 && null != result.Data)
                    {
                        baseParam.PackagePermission = result.Data;
                    }

                    if (null == baseParam.PackagePermission && (baseParam.WorkResource.ModuleId != 5 || baseParam.WorkResource.ModuleId != 9))
                    {
                        return(new ReturnResult <WorkParam>(102, baseParam, "您还未购买,请购买后再使用!"));
                    }
                    if (baseParam.WorkResource.ModuleId != 5 && baseParam.WorkResource.ModuleId != 9)
                    {
                        if (null != baseParam.PackagePermission && baseParam.PackagePermission.ExpirationDate < DateTime.Now)
                        {
                            return(new ReturnResult <WorkParam>(103, baseParam, "产品已过期,请重新购买!"));
                        }
                    }
                }
            }
            #endregion

            if (baseParam.WorkResource.IsFull && isGetParts)
            {
                baseParam.WorkResource.resourceParts = workService.GetResourceParts(contentId);
            }

            if (baseParam.DoWorkBase.PublishUserId == user.UserID && baseParam.DoWorkBase.SubmitUserID != user.UserID && baseParam.workStatus != 3)
            {
                return(new ReturnResult <WorkParam>(6, baseParam, "学生未完成作业,无法查看"));
            }

            return(new ReturnResult <WorkParam>(baseParam));
        }