Пример #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
        /// <summary>
        /// 根据课文ID取查询课文的单词 适用于作业模式
        /// </summary>
        /// <param name="workId"></param>
        /// <returns></returns>
        public WorkConents <List <WordContract> > GetWordsByWorkId(long contentId, long publishId)
        {
            var workPackage  = workService.GetWorkPackage(publishId);  //获取作业布置信息
            var workResource = workService.GetWorkResource(contentId); //获取作业资源包信息

            if (null == workPackage || null == workResource)
            {
                throw new Exception("未找到指定的作业资源");
            }

            var words = new List <WordContract>();                                                        //定义作业单词数据列表容器

            if (workResource.IsFull)                                                                      //如果子资源就取子资源内容
            {
                var wordIds = workService.GetResourceParts(contentId).Select(t => t.VersionId).ToArray(); //查询子资源中单词ID列表
                words = this.GetByVersionIds <WordContract>(wordIds).Data.ToList();
            }
            else //没有布置子资源取全文单词列表
            {
                words = GetWordsByVersionId(workResource.VersionId).ResList;//查询单词列表
            }

            //处理音频文件为空的情况
            words.ForEach(t =>
            {
                if (t.AudioUrl == null || t.AudioUrl == "False")
                {
                    t.AudioUrl = "";
                }
                t.Sentences.ToList().ForEach(item =>
                {
                    if (item.AudioUrl == null || item.AudioUrl == "False")
                    {
                        item.AudioUrl = "";
                    }
                });
            });

            //返回作业单词内容
            return(new CiWong.Resource.Preview.DataContracts.WorkConents <List <CiWong.Tools.Workshop.DataContracts.WordContract> >()
            {
                Content = words,
                WorkInfo = workResource,
                WorkPublishInfo = workPackage
            });
        }
Пример #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));
        }