예제 #1
0
        /// <summary>
        /// 保存批改答案
        /// </summary>
        /// <param name="workAnswer"></param>
        /// <returns></returns>
        public bool CorrectAnswer(WorkAnswerContract workAnswer)
        {
            var bulider = string.Empty;

            if (workAnswer.Id == 0)
            {
                bulider = @"INSERT INTO workanswer(DoId,VersionId,AnswerType,AnswerContent,ResourceType,Score,Assess)
							VALUES (@DoId,@VersionId,@AnswerType,@AnswerContent,@ResourceType,@Score,@Assess)"                            ;
            }
            else
            {
                bulider = @"REPLACE INTO workanswer(Id,DoId,VersionId,AnswerType,AnswerContent,ResourceType,Score,Assess)
							VALUES (@Id,@DoId,@VersionId,@AnswerType,@AnswerContent,@ResourceType,@Score,@Assess)"                            ;
            }
            var _params = new IDataParameter[] {
                AdoProvide.BuildParameter("@Id", workAnswer.Id),
                AdoProvide.BuildParameter("@DoId", workAnswer.DoId),
                AdoProvide.BuildParameter("@VersionId", workAnswer.VersionId),
                AdoProvide.BuildParameter("@AnswerType", workAnswer.AnswerType),
                AdoProvide.BuildParameter("@AnswerContent", workAnswer.AnswerContent ?? string.Empty),
                AdoProvide.BuildParameter("@ResourceType", workAnswer.ResourceType),
                AdoProvide.BuildParameter("@Score", workAnswer.Score),
                AdoProvide.BuildParameter("@Assess", workAnswer.Assess)
            };

            return(AdoProvide.ExecuteNonQuery(WriteConnectionString, bulider, _params.ToArray()) > 0);
        }
예제 #2
0
        /// <summary>
        /// 批量添加答案记录
        /// </summary>
        /// <param name="doId"></param>
        /// <param name="answerType"></param>
        /// <param name="list"></param>
        /// <returns></returns>
        public int Insert(long doId, int answerType, IEnumerable <WorkAnswerContract> list)
        {
            if (doId == 0 || null == list || !list.Any())
            {
                return(0);
            }

            var rowIndex = 0;
            var _params  = new List <IDataParameter>()
            {
                AdoProvide.BuildParameter("@DoId", doId),
                AdoProvide.BuildParameter("@AnswerType", answerType),
            };

            var builder = new StringBuilder(@"DELETE FROM workanswer WHERE DoId=@DoId AND AnswerType=@AnswerType;");

            builder.Append("INSERT INTO workanswer(DoId,VersionId,AnswerType,AnswerContent,ResourceType,Score,Assess) VALUES");
            list.ToList().ForEach(item =>
            {
                builder.AppendFormat("(@DoId,@VersionId{0},@AnswerType,@AnswerContent{0},@ResourceType{0},@Score{0},@Assess{0}),", rowIndex);
                _params.Add(AdoProvide.BuildParameter("@VersionId" + rowIndex, item.VersionId));
                _params.Add(AdoProvide.BuildParameter("@AnswerContent" + rowIndex, item.AnswerContent ?? string.Empty));
                _params.Add(AdoProvide.BuildParameter("@ResourceType" + rowIndex, item.ResourceType ?? string.Empty));
                _params.Add(AdoProvide.BuildParameter("@Score" + rowIndex, item.Score));
                _params.Add(AdoProvide.BuildParameter("@Assess" + rowIndex, item.Assess));
                rowIndex++;
            });
            builder.Remove(builder.Length - 1, 1);
            //写入数据库
            return(AdoProvide.ExecuteNonQuery(WriteConnectionString, builder.ToString(), _params.ToArray()));
        }
        /// <summary>
        /// 批量添加作业附件
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        public int InsertWorkFileResources(IEnumerable <WorkFileResourceContract> list, long recordId)
        {
            if (null == list || !list.Any())
            {
                return(0);
            }

            var _params = new List <IDataParameter>();

            _params.Add(AdoProvide.BuildParameter("@RecordId", recordId));
            var builder  = new StringBuilder("INSERT INTO workfileresource(RecordId,FileName,FileUrl,FileExt,FileType,FileDesc) VALUES");
            var rowIndex = 0;

            list.ToList().ForEach(item =>
            {
                builder.AppendFormat("(@RecordId,@FileName{0},@FileUrl{0},@FileExt{0},@FileType{0},@FileDesc{0}),", rowIndex);
                _params.Add(AdoProvide.BuildParameter("@FileName" + rowIndex, item.FileName));
                _params.Add(AdoProvide.BuildParameter("@FileUrl" + rowIndex, item.FileUrl));
                _params.Add(AdoProvide.BuildParameter("@FileExt" + rowIndex, item.FileExt));
                _params.Add(AdoProvide.BuildParameter("@FileType" + rowIndex, item.FileType));
                _params.Add(AdoProvide.BuildParameter("@FileDesc" + rowIndex, item.FileDesc));
                rowIndex++;
            });

            builder.Remove(builder.Length - 1, 1);

            //批量写入数据库
            return(AdoProvide.ExecuteNonQuery(WriteConnectionString, builder.ToString(), _params.ToArray()));
        }
예제 #4
0
        /// <summary>
        /// 批量添加试题子资源
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        public int InsertResourceParts(IEnumerable <ResourcePartsContract> list)
        {
            if (null == list || !list.Any())
            {
                return(0);
            }

            var _params  = new List <IDataParameter>();
            var builder  = new StringBuilder("INSERT INTO resourceParts VALUES");
            var rowIndex = 0;

            list.ToList().ForEach(item =>
            {
                builder.AppendFormat("(@C{0},@V{0},@R{0}),", rowIndex);
                _params.Add(AdoProvide.BuildParameter("@C" + rowIndex, item.ContentId));
                _params.Add(AdoProvide.BuildParameter("@V" + rowIndex, item.VersionId));
                _params.Add(AdoProvide.BuildParameter("@R" + rowIndex, item.ResourceType));
                rowIndex++;
            });

            builder.Remove(builder.Length - 1, 1);

            //批量写入数据库
            return(AdoProvide.ExecuteNonQuery(WriteConnectionString, builder.ToString(), _params.ToArray()));
        }
예제 #5
0
        /// <summary>
        /// 是否完成本次所有的单元作业
        /// </summary>
        /// <param name="recordId"></param>
        /// <param name="doWorkId"></param>
        /// <returns></returns>
        public bool IsCompletedAllUnits(long recordId, long doWorkId)
        {
            var builder = "SELECT COUNT(*) = (SELECT COUNT(*) FROM workResource WHERE RecordId = @recordId) FROM unitworks WHERE DoWorkId = @doWorkId AND RecordId = @recordId AND `Status` = 3";

            var _params = new IDataParameter[] {
                AdoProvide.BuildParameter("@recordId", recordId),
                AdoProvide.BuildParameter("@doWorkId", doWorkId)
            };

            return(AdoProvide.ExecuteScalar <int>(WriteConnectionString, builder, _params) == 1);
        }
예제 #6
0
        /// <summary>
        /// 查询作业答案(无效方法)
        /// </summary>
        /// <param name="doId"></param>
        /// <param name="answerType"></param>
        /// <returns></returns>
        public List <WorkAnswerContract <FlowReadAnswerEntity> > GetReadAnswers(long doId, int answerType)
        {
            var builder = new SelectBuilder("SELECT * FROM workanswer where DoId =@DoId and AnswerType=@AnswerType GROUP BY VersionId ORDER BY Score desc");

            var _params = new IDataParameter[] {
                AdoProvide.BuildParameter("@DoId", doId),
                AdoProvide.BuildParameter("@AnswerType", answerType)
            };

            return(AdoProvide.ExecuteReader(ReadConnectionString, builder, reader => EntityHelper.GetEntity <WorkAnswerContract <FlowReadAnswerEntity> >(reader)).ToList());
        }
예제 #7
0
        /// <summary>
        /// 更新单元汇总
        /// </summary>
        /// <param name="contentId"></param>
        /// <param name="workId"></param>
        /// <param name="recordId"></param>
        /// <param name="totalNum"></param>
        public void SetUnitSummary(long contentId, long workId, long recordId, int totalNum)
        {
            var builder = "CALL Proc_CensusUnitSummary(@contentId,@workId,@recordId,@totalNum)";

            var _params = new IDataParameter[] {
                AdoProvide.BuildParameter("@contentId", contentId),
                AdoProvide.BuildParameter("@workId", workId),
                AdoProvide.BuildParameter("@recordId", recordId),
                AdoProvide.BuildParameter("@totalNum", totalNum)
            };

            AdoProvide.ExecuteNonQuery(WriteConnectionString, builder, _params);
        }
예제 #8
0
        /// <summary>
        /// 更新做作业信息以及统计数据
        /// </summary>
        /// <param name="doworkId"></param>
        /// <param name="submitDate"></param>
        /// <returns></returns>
        public bool UpdateDoWorkStatus(long doworkId, DateTime submitDate, int workStatus, int workLong, decimal actualScore)
        {
            var builder = "CALL Proc_SetWorkOnlineInfo(@DoWorkID,@SubmitDate,@WorkStatus,@WorkLong,@ActualScore,0,0)";

            var _params = new IDataParameter[] {
                AdoProvide.BuildParameter("@DoWorkID", doworkId),
                AdoProvide.BuildParameter("@SubmitDate", submitDate),
                AdoProvide.BuildParameter("@WorkStatus", workStatus),
                AdoProvide.BuildParameter("@WorkLong", workLong),
                AdoProvide.BuildParameter("@ActualScore", actualScore)
            };

            return(AdoProvide.ExecuteScalar <int>(WriteConnectionString, builder, _params) == 1);
        }
예제 #9
0
        /// <summary>
        /// 作业点评
        /// </summary>
        /// <param name="userIds"></param>
        /// <param name="workId"></param>
        /// <param name="contentId"></param>
        /// <param name="content"></param>
        /// <param name="commentType"></param>
        /// <returns></returns>
        public bool CommentUnitWorks(IEnumerable <int> userIds, long workId, long contentId, string content, int commentType)
        {
            if (null == userIds || !userIds.Any() || string.IsNullOrWhiteSpace(content))
            {
                return(false);
            }

            var builder = @"UPDATE unitworks SET `Comment` = @comment,CommentType = @commentType
                            WHERE WorkId = @workId AND ContentId = @contentId AND SubmitUserId IN({0})";

            builder = string.Format(builder, string.Join(",", userIds));

            var _params = new IDataParameter[] {
                AdoProvide.BuildParameter("@workId", workId),
                AdoProvide.BuildParameter("@contentId", contentId),
                AdoProvide.BuildParameter("@commentType", commentType),
                AdoProvide.BuildParameter("@comment", content)
            };

            return(AdoProvide.ExecuteNonQuery(WriteConnectionString, builder, _params) > 0);
        }
예제 #10
0
        /// <summary>
        /// 批量批改作业
        /// </summary>
        /// <param name="workId"></param>
        /// <param name="userIdList"></param>
        /// <returns></returns>
        public bool UpdateDoWorkStatus(IEnumerable <int> userIdList, long workId, int workStatus, decimal actualScore)
        {
            if (null == userIdList || !userIdList.Any())
            {
                return(false);
            }

            string sql = string.Empty;

            if (actualScore < 0)
            {
                sql = string.Format("UPDATE doworkbase SET WorkStatus = @WorkStatus WHERE WorkId = @WorkId AND SubmitUserId IN ({0});", string.Join(",", userIdList));
            }
            else
            {
                sql = string.Format("UPDATE doworkbase SET WorkStatus = @WorkStatus, ActualScore = @ActualScore WHERE WorkId = @WorkId AND SubmitUserId IN ({0});", string.Join(",", userIdList));
            }

            sql += @"UPDATE workbase SET CompletedNum = (SELECT COUNT(*) FROM doworkbase WHERE doworkbase.WorkStatus IN(2,3,5) AND doworkbase.WorkID = workbase.WorkID),
				     MarkNum = (SELECT COUNT(*) FROM doworkbase WHERE doworkbase.WorkStatus = 3 AND doworkbase.WorkID = workbase.WorkID) WHERE WorkID = @workId;"                ;

            return(AdoProvide.ExecuteNonQuery(WriteConnectionString, sql, AdoProvide.BuildParameter("@WorkId", workId), AdoProvide.BuildParameter("@ActualScore", actualScore), AdoProvide.BuildParameter("@WorkStatus", workStatus)) > 0);
        }