12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMISOnline.DataLogic.Repositories;
- using EMISOnline.ViewModel.ExamView;
- using EMISOnline.Entities;
- using System.Linq.Expressions;
- namespace EMISOnline.DataLogic.ExamSetting
- {
- public class QuestionSettingDAL
- {
- public base_question_typeRepository typeRepository { get; set; }
- public questionRepository questionRepository { get; set; }
- public question_provid_answerRepository answerRepository { get; set; }
- public question_libaryRepository libaryRepository { get; set; }
- public base_paramRepository paramRepository { get; set; }
- /// 获取试题列表
- /// </summary>
- public IQueryable<ExamQuestionView> GetQuestionList( Expression<Func<test_question, bool>> expWhere)
- {
- var query = from q in questionRepository.Entities.Where(expWhere)
- join lib in libaryRepository.Entities on q.test_question_libary_id equals lib.test_question_libary_id
- where q.test_question_ParentId == null
- orderby q.test_question_Id descending
- select new ExamQuestionView
- {
- test_question_Id = q.test_question_Id,
- content = q.content,
- base_question_type_id = q.base_question_type_id,
- question_type_name = q.test_base_question_type.Name,
- difficulty_degree = q.difficulty_degree,//(from p in context.test_base_param where p.base_param_parent_id == 3 && p.base_param_id == q.difficulty_degree select p.name).Single(),
- test_question_libary_id = q.test_question_libary_id,
- questione_lib_name = lib.name,
- answers = q.answers,
- is_vaild = q.is_vaild,
- used_count = q.used_count,
- created_date = q.created_date
- }
- ;
- return query;
- }
- /// <summary>
- /// 获取所有子类库
- /// </summary>
- /// <param name="isFill">是否归档,Null查询所有</param>
- /// <param name="parentid">类库ID</param>
- /// <param name="subList">子类列表</param>
- public void GetSubLibary(bool? isFill, decimal parentid, IList<test_question_libary> subList)
- {
- var query = from lib in libaryRepository.Entities
- where lib.parent_id == parentid && (isFill == null || lib.filled == isFill)
- select lib;
- foreach (var subLib in query.ToList())
- {
- subList.Add(subLib);
- GetSubLibary(isFill, subLib.test_question_libary_id, subList);
- }
- }
- }
- }
|