Ejemplo n.º 1
0
        public dynamic DisableQuestionStore(W_QuestionStore model)
        {
            W_QuestionStore newModel = mapper.GetQuestionStore(model.ID);

            newModel.Valid = model.Valid;
            return(Success(mapper.DisableQuestionStore(newModel) ? "操作成功" : "操作失败"));
        }
Ejemplo n.º 2
0
 public dynamic AddQuestionStore(W_QuestionStore model)
 {
     model.System_Station_ID = this.System_Station_ID;
     model.AddPerson         = this.AccountID;
     model.AddTime           = DateTime.Now;
     model.Valid             = 1;//默认启用
     return(Success(mapper.AddQuestionStore(model) ? "操作成功" : "操作失败"));
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 获取题库信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public W_QuestionStore GetQuestionStore(int id)
        {
            W_QuestionStore model = Orm.Single <W_QuestionStore>(x => x.ID == id && x.IsDelete == 0);

            if (model == null)
            {
                throw new ApiException("题库不存在或者已删除");
            }
            return(model);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 添加题库
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool AddQuestionStore(W_QuestionStore model)
 {
     if (string.IsNullOrEmpty(model.Name))
     {
         throw new ApiException("题库名称不能为空");
     }
     if (model.Discipline_ID == 0)
     {
         throw new ApiException("请选择科次");
     }
     return(Orm.Insert(model, true) > 0);
 }
Ejemplo n.º 5
0
        public dynamic ModifyQuestionStore(W_QuestionStore model)
        {
            W_QuestionStore newModel = mapper.GetQuestionStore(model.ID);

            //修改(只能修改名称)
            if (!string.IsNullOrEmpty(model.Name))
            {
                newModel.Name = model.Name;
            }
            //删除
            else if (model.IsDelete == 1)
            {
                newModel.IsDelete = 1;
            }
            return(Success(mapper.UpdateQuestionStore(newModel) ? "操作成功" : "操作失败"));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 禁用题库信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool DisableQuestionStore(W_QuestionStore model)
        {
            W_Question questionModel = Orm.Single <W_Question>(x => x.QuestionStore_ID == model.ID);

            if (questionModel != null)
            {
                throw new ApiException("题库里面存在题目,不能禁用");
            }

            W_ExamPaper examModel = Orm.Single <W_ExamPaper>(x => x.QuestionStore_ID == model.ID);

            if (examModel != null)
            {
                throw new ApiException("题库里面存在试卷,不能禁用");
            }
            return(Orm.Update(model) > 0);
        }
Ejemplo n.º 7
0
        /// <summary>
        ///删除学科及对应的关系表 DeleteDiscipline
        /// </summary>
        public bool RemoveDiscipline(int ID, int System_Station_ID)
        {
            if (ID <= 0)
            {
                throw new ApiException("无效参数!");
            }
            //判断是不是该机构添加的学科
            W_Discipline model = Orm.Single <W_Discipline>(x => x.ID == ID && x.System_Station_ID == System_Station_ID);

            if (model == null)
            {
                throw new ApiException("操作失败,未找到对应的数据!");
            }
            ///判断学科启用状态
            if (model.Valid == 1)
            {
                throw new ApiException("学科启用状态,不能删除!");
            }
            W_Discipline modelCid = Orm.Single <W_Discipline>(x => x.CID == ID && x.System_Station_ID == System_Station_ID);

            ///判断学科子集是否存在课程
            if (modelCid != null)
            {
                throw new ApiException("该学科下面存在课程,不能删除!");
            }
            W_QuestionStore modelstore = Orm.Single <W_QuestionStore>(x => x.Discipline_ID == ID && x.System_Station_ID == System_Station_ID && x.IsDelete == 0);

            ///判断题库是否应用该学科
            if (modelstore != null)
            {
                throw new ApiException("题库应用了该学科,不能删除!");
            }
            W_CourseWare modelware = Orm.Single <W_CourseWare>(x => x.Discipline_ID == ID && x.System_Station_ID == System_Station_ID);

            ///判断资源库是否应用该学科
            if (modelware != null)
            {
                throw new ApiException("资源库应用了该学科,不能删除!");
            }
            //删除数据
            if (Orm.Delete <W_Discipline>(x => x.ID == ID && x.System_Station_ID == System_Station_ID) > 0)
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 添加题目
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool AddQuestion(W_Question model)
        {
            if (string.IsNullOrEmpty(model.Title))
            {
                throw new ApiException("题目不能为空");
            }
            W_QuestionStore store = Orm.Single <W_QuestionStore>(x => x.ID == model.QuestionStore_ID);

            if (store.Valid == 0)
            {
                throw new ApiException("选择的题库已被禁用,请重试");
            }
            if (string.IsNullOrEmpty(model.Body))
            {
                model.Body = "";
            }
            return(Orm.Insert(model, true) > 0);
        }
Ejemplo n.º 9
0
        public string GetPraticeInfo(int chapterId, int storeId)
        {
            W_Chapter chapter = Orm.Single <W_Chapter>(x => x.ID == chapterId);

            if (chapter == null)
            {
                return("未知章节练习");
            }
            W_Chapter parent = Orm.Single <W_Chapter>(x => x.ID == chapter.CID);

            if (parent == null)
            {
                return("未知章节练习");
            }
            W_QuestionStore store = Orm.Single <W_QuestionStore>(x => x.ID == storeId);

            if (store == null)
            {
                return("未知章节练习");
            }
            return(store.Name + " " + parent.Name + " " + chapter.Name);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 添加试卷
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool AddExamPaper(W_ExamPaper model)
        {
            if (string.IsNullOrEmpty(model.Title))
            {
                throw new ApiException("试卷名称不能为空");
            }
            if (model.Time < 0)
            {
                throw new ApiException("考试时间必须大于等于0");
            }
            if (model.PassScore < 0)
            {
                throw new ApiException("合格分数必须大于等于0");
            }
            W_QuestionStore store = Orm.Single <W_QuestionStore>(x => x.ID == model.QuestionStore_ID);

            if (store.Valid == 0)
            {
                throw new ApiException("选择的题库已被禁用,请重试");
            }
            return(Orm.Insert(model, true) > 0);
        }
Ejemplo n.º 11
0
 /// <summary>
 /// 修改题库信息
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool UpdateQuestionStore(W_QuestionStore model)
 {
     return(Orm.Update(model) > 0);
 }