Commit 8eb41185 authored by 吴春's avatar 吴春

Merge branch 'master' of http://gitlab.oytour.com/Kui2/education

parents 3e12f67d f9c15d25
......@@ -4,6 +4,7 @@ using System.Data;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using Edu.Common.Plugin;
namespace Edu.Common.Data
{
......@@ -114,7 +115,7 @@ namespace Edu.Common.Data
public static List<ImportModel> GetWordQuestionData(string filePath)
{
List<ImportModel> list = new List<ImportModel>();
var questionList = Common.Plugin.WordHelper.GetWordData(filePath);
var questionList = Common.Plugin.WordHelper.GetWordData(filePath,out List<QuestionTitleData> htmlList);
if (questionList != null && questionList.Count > 0)
{
foreach (var rootItem in questionList)
......@@ -136,7 +137,7 @@ namespace Edu.Common.Data
SubQuestionList = new List<ImportModel>(),
QuestionTypeName= "阅读理解"
};
AnalysisReadingQuestion(item, model);
AnalysisReadingQuestion(item, model, htmlList);
list.Add(model);
}
}
......@@ -152,7 +153,7 @@ namespace Edu.Common.Data
};
if (!string.IsNullOrEmpty(item))
{
AnalysisQuestionTitle(item, model);
AnalysisQuestionTitle(item, model, htmlList);
list.Add(model);
}
}
......@@ -168,14 +169,52 @@ namespace Edu.Common.Data
/// </summary>
/// <param name="item"></param>
/// <param name="model"></param>
private static void AnalysisQuestionTitle(string item, ImportModel model)
private static void AnalysisQuestionTitle(string item, ImportModel model,List<QuestionTitleData> htmlList)
{
string pattern = @"\r\n";
var tempArray = Regex.Split(item, pattern);
string answerObj = "";//答案
if (tempArray != null && tempArray.Length > 0)
{
model.QuestionTitle = tempArray[0].Trim();
string strTitle = tempArray[0].Trim();
if (htmlList != null && htmlList.Count > 0)
{
foreach (var hItem in htmlList)
{
try
{
if (strTitle.Contains(hItem.UnderLine))
{
foreach (var subItem in htmlList.Where(qitem => qitem.UnderLine == hItem.UnderLine))
{
if (subItem.BeforeAfter != null)
{
if (subItem.BeforeAfter.Count == 1)
{
if (strTitle.Contains(subItem.BeforeAfter[0]))
{
strTitle = strTitle.Replace(hItem.UnderLine, Common.ConvertHelper.GetSpanString(hItem.UnderLine));
}
}
else if (subItem.BeforeAfter.Count == 2)
{
if (strTitle.Contains(subItem.BeforeAfter[0]) || strTitle.Contains(subItem.BeforeAfter[1]))
{
strTitle = strTitle.Replace(hItem.UnderLine, Common.ConvertHelper.GetSpanString(hItem.UnderLine));
}
}
}
}
}
}
catch (Exception ex)
{
throw new Exception();
}
}
}
model.QuestionTitle = strTitle;
foreach (var subItem in tempArray)
{
if (!string.IsNullOrEmpty(subItem))
......@@ -523,7 +562,7 @@ namespace Edu.Common.Data
/// </summary>
/// <param name="questionStr"></param>
/// <param name="model"></param>
private static void AnalysisReadingQuestion(string questionStr, ImportModel model)
private static void AnalysisReadingQuestion(string questionStr, ImportModel model,List<QuestionTitleData> htmlList)
{
string[] tempArray = null;
//“\r\n”开始+“1234567890”出现1次到多次+“、或.”结尾
......@@ -539,7 +578,7 @@ namespace Edu.Common.Data
if (index > 0)
{
ImportModel subQuestion = new ImportModel();
AnalysisQuestionTitle(item, subQuestion);
AnalysisQuestionTitle(item, subQuestion,htmlList);
model.SubQuestionList.Add(subQuestion);
model.AnswerAnalysis += "<p>"+(index) + "、" + subQuestion.AnswerAnalysis+"</p>";
}
......
using Edu.Common.Plugin;
using System;
using System.Collections.Generic;
using System.Text;
namespace Edu.Common.Enum.Question
{
/// <summary>
/// 考级程度
/// </summary>
public enum LevelTypeEnum
{
/// <summary>
/// N5
/// </summary>
[EnumField("N5")]
N5 = 5,
/// <summary>
///N4
/// </summary>
[EnumField("N4")]
N4 = 4,
/// <summary>
///N3
/// </summary>
[EnumField("N3")]
N3 = 3,
/// <summary>
///N2
/// </summary>
[EnumField("N2")]
N2 = 2,
/// <summary>
///N1
/// </summary>
[EnumField("N1")]
N1 = 1,
}
}
......@@ -291,5 +291,12 @@ namespace Edu.Common
builder.AppendFormat(@"<p><img src='data:image/png;base64,{0}' /></p>", base64);
return builder.ToString();
}
public static string GetSpanString(string value)
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"<span style='text-decoration: underline;'>{0}</span>", value);
return builder.ToString();
}
}
}
\ No newline at end of file
......@@ -6,7 +6,9 @@ using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Xml;
namespace Edu.Common.Plugin
{
......@@ -20,18 +22,79 @@ namespace Edu.Common.Plugin
/// </summary>
/// <param name="filePath"></param>
/// <returns></returns>
public static List<QuestionWordData> GetWordData(string filePath)
public static List<QuestionWordData> GetWordData(string filePath,out List<QuestionTitleData> htmlList)
{
List<QuestionWordData> list = new List<QuestionWordData>();
Spire.Doc.Document document = new Spire.Doc.Document();
document.LoadFromFile(filePath);
string basepath = AppContext.BaseDirectory;
string tempPath = basepath + "\\upfile\\temporary\\" + DateTime.Now.ToString("yyyyMMdd") + "\\";
List<string> imageList = new List<string>();
string tempPath = basepath + "\\upfile\\temporary\\" + DateTime.Now.ToString("yyyyMMdd") + "\\html\\";
document.LoadFromFile(filePath);
if (!Directory.Exists(tempPath))
{
Directory.CreateDirectory(tempPath);
}
string htmlName = tempPath + DateTime.Now.Ticks + ".html";
document.SaveToFile(htmlName, FileFormat.Html);
htmlList = new List<QuestionTitleData>();
try
{
Stream myStream = new FileStream(htmlName, FileMode.Open);
Encoding encode = System.Text.Encoding.GetEncoding("utf-8");//若是格式为utf-8的需要将gb2312替换
StreamReader myStreamReader = new StreamReader(myStream, encode);
string strhtml = myStreamReader.ReadToEnd();
string htmlRule = @"<p.*?>(.*?)</p>";
MatchCollection p_matchs =Regex.Matches(strhtml, htmlRule);
foreach (var item in p_matchs)
{
if (item != null && !string.IsNullOrEmpty(item.ToString()) && item.ToString().Contains("underline"))
{
string spanRule = @"<span[^>]+>([^<]+)</span>";
MatchCollection span_matchs= Regex.Matches(item.ToString(), spanRule);
string key = "";
List<string> contentList = new List<string>();
for (var i = 0; i < span_matchs.Count; i++)
{
var subItem = span_matchs[i];
string newStr = Common.Plugin.HtmlHelper.StripHT(subItem.ToString());
if (subItem != null && !string.IsNullOrEmpty(subItem.ToString()) && subItem.ToString().Contains("underline"))
{
key = newStr;
if (i > 0)
{
string upContent = Common.Plugin.HtmlHelper.StripHT(span_matchs[i - 1].ToString());
if (!string.IsNullOrEmpty(upContent)&& upContent.Length>1)
{
contentList.Add(upContent.TrimStart('、'));
}
}
if ((i + 1) < span_matchs.Count)
{
string nextContent = Common.Plugin.HtmlHelper.StripHT(span_matchs[i + 1].ToString());
if (!string.IsNullOrEmpty(nextContent)&&nextContent.Length>1)
{
contentList.Add(nextContent.TrimStart('、'));
}
}
if (!string.IsNullOrEmpty(key) && contentList != null && contentList.Count > 0)
{
htmlList.Add(new QuestionTitleData()
{
UnderLine = key,
BeforeAfter = contentList
});
}
}
}
}
}
}
catch
{
}
List<string> imageList = new List<string>();
foreach (Section section in document.Sections)
{
foreach (Paragraph paragraph in section.Paragraphs)
......@@ -52,6 +115,7 @@ namespace Edu.Common.Plugin
}
}
string str = document.GetText();
str = str.Replace("Evaluation Warning: The document was created with Spire.Doc for .NET.", "");
//解析大类
string categoryRule1 = @"[第][一二三四五六七八九十][部][分]";
......@@ -66,7 +130,7 @@ namespace Edu.Common.Plugin
{
if (!string.IsNullOrEmpty(item))
{
var model = AnalysisQuestionCategory(item, imageList, isBigType: true);
var model = AnalysisQuestionCategory(item, imageList,isBigType: true);
if (model != null && !string.IsNullOrEmpty(model.BigTitle))
{
list.Add(model);
......@@ -88,7 +152,7 @@ namespace Edu.Common.Plugin
/// <param name="questionStr"></param>
/// <param name="isBigType">是否是大类</param>
/// <returns></returns>
private static QuestionWordData AnalysisQuestionCategory(string questionStr, List<string> imageList, bool isBigType = false)
private static QuestionWordData AnalysisQuestionCategory(string questionStr, List<string> imageList,bool isBigType = false)
{
QuestionWordData questionWordData = new QuestionWordData();
// \r\n【图一】\r\n
......@@ -199,4 +263,20 @@ namespace Edu.Common.Plugin
/// </summary>
public List<string> QuestionList { get; set; }
}
/// <summary>
/// 替换标题下划线实体
/// </summary>
public class QuestionTitleData
{
/// <summary>
/// 下划线内容
/// </summary>
public string UnderLine { get; set; }
/// <summary>
/// 下划线内容前后文字
/// </summary>
public List<string> BeforeAfter { get; set; }
}
}
......@@ -7,7 +7,7 @@ using VT.FW.DB;
namespace Edu.Model.Entity.Question
{
/// <summary>
/// 题库实体类
/// 问题实体类
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
......@@ -23,6 +23,11 @@ namespace Edu.Model.Entity.Question
/// </summary>
public int CourseId { get; set; }
/// <summary>
/// 题库编号
/// </summary>
public int BankId { get; set; }
/// <summary>
/// 问题名称
/// </summary>
......@@ -107,5 +112,10 @@ namespace Edu.Model.Entity.Question
/// 题目所属大类
/// </summary>
public QuestionCategoryEnum? Category { get; set; }
/// <summary>
/// 考级程度
/// </summary>
public LevelTypeEnum? LevelType { get; set; }
}
}
using Edu.Common.Enum;
using System;
using VT.FW.DB;
namespace Edu.Model.Entity.Question
{
/// <summary>
/// 题库实体类
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Question_Bank
{
/// <summary>
/// 题库编号(主键)
/// </summary>
public int BankId { get; set; }
/// <summary>
/// BankName
/// </summary>
public string BankName { get; set; }
/// <summary>
/// 集团编号
/// </summary>
public int Group_Id { get; set; }
/// <summary>
/// 学校编号
/// </summary>
public int School_Id { get; set; }
/// <summary>
/// 创建人
/// </summary>
public int CreateBy { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime CreateTime { get; set; }
/// <summary>
/// 修改人
/// </summary>
public int UpdateBy { get; set; }
/// <summary>
/// 更新时间
/// </summary>
public DateTime UpdateTime { get; set; }
/// <summary>
/// 删除状态
/// </summary>
public DateStateEnum Status { get; set; }
}
}
using Edu.Common;
using Edu.Model.Entity.Question;
namespace Edu.Model.ViewModel.Question
{
/// <summary>
/// 题库视图实体类
/// </summary>
public class RB_Question_Bank_ViewModel : RB_Question_Bank
{
/// <summary>
/// 创建人
/// </summary>
public string CreateByName { get; set; }
/// <summary>
/// 修改人
/// </summary>
public string UpdateByName { get; set; }
/// <summary>
/// 创建时间字符串
/// </summary>
public string CreateTimeStr { get { return this.CreateTime.FormatTime(); } }
/// <summary>
/// 更新时间字符串
/// </summary>
public string UpdateTimeStr { get { return this.UpdateTime.FormatTime(); } }
/// <summary>
/// 题量
/// </summary>
public int QuestionCount { get; set; }
}
}
......@@ -85,5 +85,16 @@ namespace Edu.Model.ViewModel.Question
/// 分类编号
/// </summary>
public string QCategoryId { get; set; }
/// <summary>
/// 考级程度
/// </summary>
public string LevelTypeName
{
get
{
return Common.Plugin.EnumHelper.ToName(this.LevelType);
}
}
}
}
\ No newline at end of file
......@@ -879,7 +879,44 @@ namespace Edu.Module.Course
}
}
/// <summary>
/// 设置订单应收金额
/// </summary>
/// <param name="orderId"></param>
/// <param name="preferPrice"></param>
/// <param name="userInfo"></param>
/// <returns></returns>
public bool SetOrderPreferPrice(int orderId, decimal preferPrice, UserInfo userInfo)
{
var orderModel = orderRepository.GetEntity(orderId);
if (orderModel == null) { return false; }
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Order_ViewModel.PreferPrice),preferPrice}
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Order_ViewModel.OrderId),
FiledValue=orderId,
OperatorEnum=OperatorEnum.Equal
}
};
var flag = orderRepository.Update(keyValues, wheres);
if (flag)
{
changeLogRepository.Insert(new Model.Entity.Log.RB_User_ChangeLog()
{
Id = 0,
Type = 2,
CreateBy = userInfo.Id,
CreateTime = DateTime.Now,
Group_Id = userInfo.Group_Id,
LogContent = "修改订单应收总额,由【" + orderModel.PreferPrice + "】修改为【" + preferPrice + "】",
School_Id = userInfo.School_Id,
SourceId = orderId
});
}
return flag;
}
/// <summary>
/// 获取班级订单列表
......
......@@ -19,7 +19,7 @@ namespace Edu.Module.Question
private readonly RB_Question_TypeRepository question_TypeRepository = new RB_Question_TypeRepository();
/// <summary>
/// 题库仓储层对象
/// 问题仓储层对象
/// </summary>
private readonly RB_QuestionRepository questionRepository = new RB_QuestionRepository();
......@@ -34,6 +34,74 @@ namespace Edu.Module.Question
/// </summary>
private readonly AnalysisQuestionTypeModule analysisQuestion = new AnalysisQuestionTypeModule();
/// <summary>
/// 题库仓储层对象
/// </summary>
private readonly RB_Question_BankRepository question_BankRepository = new RB_Question_BankRepository();
/// <summary>
/// 获取题库分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Question_Bank_ViewModel> GetQuestionBankPageListModule(int pageIndex, int pageSize, out long rowsCount, RB_Question_Bank_ViewModel query)
{
return question_BankRepository.GetQuestionBankPageListRepository(pageIndex, pageSize, out rowsCount, query);
}
/// <summary>
/// 新增修改题库
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool SetQuestionBankModule(RB_Question_Bank_ViewModel model)
{
bool flag;
if (model.BankId > 0)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Question_Bank_ViewModel.BankName), model.BankName }
};
flag = question_BankRepository.Update(fileds, new WhereHelper(nameof(RB_Question_Bank_ViewModel.BankId), model.BankId));
}
else
{
var newId = question_BankRepository.Insert(model);
model.BankId = newId;
flag = newId > 0;
}
return flag;
}
/// <summary>
/// 根据编号获取题库
/// </summary>
/// <param name="BankId"></param>
/// <returns></returns>
public RB_Question_Bank_ViewModel GetQuestionBankModule(object BankId)
{
return question_BankRepository.GetEntity<RB_Question_Bank_ViewModel>(BankId);
}
/// <summary>
/// 删除题库
/// </summary>
/// <param name="bankId"></param>
/// <param name="status"></param>
/// <returns></returns>
public bool RemoveQuestionBankModule(int bankId, int status)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Question_Bank_ViewModel.Status),status }
};
return question_BankRepository.Update(fileds, new WhereHelper(nameof(RB_Question_Bank_ViewModel.BankId), bankId));
}
/// <summary>
/// 获取题目类型列表
/// </summary>
......@@ -45,7 +113,7 @@ namespace Edu.Module.Question
}
/// <summary>
/// 获取题库分页列表
/// 获取问题分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
......@@ -58,7 +126,7 @@ namespace Edu.Module.Question
}
/// <summary>
/// 获取题库列表
/// 获取问题列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
......@@ -92,6 +160,7 @@ namespace Edu.Module.Question
{nameof(RB_Question_ViewModel.Answer),model.Answer },
{nameof(RB_Question_ViewModel.IsMutex),model.IsMutex },
{nameof(RB_Question_ViewModel.Category),model.Category },
{nameof(RB_Question_ViewModel.LevelType),model.LevelType },
};
flag = questionRepository.Update(fileds, new WhereHelper(nameof(RB_Question_ViewModel.QuestionId), model.QuestionId));
}
......@@ -100,6 +169,14 @@ namespace Edu.Module.Question
var newId = questionRepository.Insert(model);
model.QuestionId = newId;
flag = newId > 0;
if (flag)
{
Dictionary<string, object> sortFileds = new Dictionary<string, object>()
{
{nameof(RB_Question_ViewModel.SortNum),newId },
};
flag = questionRepository.Update(sortFileds, new WhereHelper(nameof(RB_Question_ViewModel.QuestionId), newId));
}
}
return flag;
}
......@@ -123,7 +200,7 @@ namespace Edu.Module.Question
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Question_ViewModel.Status),(int )DateStateEnum.Delete},
{nameof(RB_Question_ViewModel.Status),(int)DateStateEnum.Delete},
};
bool flag = questionRepository.Update(fileds, new WhereHelper(nameof(RB_Question_ViewModel.QuestionId), QuestionId));
return flag;
......@@ -136,9 +213,11 @@ namespace Edu.Module.Question
[TransactionCallHandler]
public virtual bool UpdateQuestionSortModule(int curQId, int targetQId)
{
var currentModel = GetQuestionModule(curQId);
var targetModel = GetQuestionModule(targetQId);
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Question_ViewModel.SortNum),targetQId},
{nameof(RB_Question_ViewModel.SortNum),targetModel.SortNum},
};
bool flag = questionRepository.Update(fileds, new WhereHelper(nameof(RB_Question_ViewModel.QuestionId), curQId));
if (flag)
......@@ -146,7 +225,7 @@ namespace Edu.Module.Question
//排序修改
Dictionary<string, object> fileds2 = new Dictionary<string, object>()
{
{nameof(RB_Question_ViewModel.SortNum),curQId},
{nameof(RB_Question_ViewModel.SortNum),currentModel.SortNum},
};
flag = questionRepository.Update(fileds2, new WhereHelper(nameof(RB_Question_ViewModel.QuestionId), targetQId));
}
......@@ -178,7 +257,7 @@ namespace Edu.Module.Question
/// <param name="questionKey"></param>
/// <param name="questionContent"></param>
/// <returns></returns>
public object ParsingQuestionModule(string questionKey,string questionContent)
public object ParsingQuestionModule(string questionKey, string questionContent)
{
return analysisQuestion.ParsingQuestion(questionKey, questionContent);
}
......
......@@ -8,12 +8,12 @@ using VT.FW.DB.Dapper;
namespace Edu.Repository.Question
{
/// <summary>
/// 题库仓储层
/// 问题仓储层
/// </summary>
public class RB_QuestionRepository : BaseRepository<Model.Entity.Question.RB_Question>
{
/// <summary>
/// 获取题库列表
/// 获取问题列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
......@@ -40,7 +40,7 @@ WHERE 1=1
}
/// <summary>
/// 获取题库分页列表
/// 获取问题分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
......@@ -63,6 +63,10 @@ WHERE 1=1 ");
}
else
{
if (query.BankId > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Question_ViewModel.BankId), query.BankId);
}
if (query.CourseId > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Question_ViewModel.CourseId), query.CourseId);
......@@ -89,9 +93,10 @@ WHERE 1=1 ");
{
builder.AppendFormat(" AND A.{0} IN({1}) ", nameof(RB_Question_ViewModel.Category), query.QCategoryId);
}
builder.AppendFormat(" ORDER BY A.{0} DESC ", nameof(RB_Question_ViewModel.QuestionId));
builder.AppendFormat(" ORDER BY A.{0} ASC ", nameof(RB_Question_ViewModel.SortNum));
return GetPage<RB_Question_ViewModel>(pageIndex, pageSize, out rowsCount, builder.ToString(), parameters).ToList();
}
}
}
}
\ No newline at end of file
using Edu.Common.Enum;
using Edu.Model.Entity.Question;
using Edu.Model.ViewModel.Question;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VT.FW.DB.Dapper;
namespace Edu.Repository.Question
{
/// <summary>
/// 题库仓储层
/// </summary>
public class RB_Question_BankRepository : BaseRepository<RB_Question_Bank>
{
/// <summary>
/// 获取题库分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Question_Bank_ViewModel> GetQuestionBankPageListRepository(int pageIndex, int pageSize, out long rowsCount, RB_Question_Bank_ViewModel query)
{
rowsCount = 0;
var parameters = new DynamicParameters();
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT A.*,IFNULL(B.QuestionCount,0) AS QuestionCount
FROM RB_Question_Bank AS A LEFT JOIN (SELECT BankId,COUNT(1) AS QuestionCount FROM rb_question WHERE `Status`=0 GROUP BY BankId) AS B ON A.BankId=B.BankId
WHERE 1=1 ");
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Question_Bank_ViewModel.Status), (int)DateStateEnum.Normal);
if (query == null)
{
return new List<RB_Question_Bank_ViewModel>();
}
else
{
if (query.Group_Id > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Question_Bank_ViewModel.Group_Id), query.Group_Id);
}
if (query.BankId > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Question_Bank_ViewModel.BankId), query.BankId);
}
if (!string.IsNullOrEmpty(query.BankName))
{
builder.AppendFormat(" AND A.{0} LIKE @BankName ", nameof(RB_Question_Bank_ViewModel.BankName));
parameters.Add("BankName", "%" + query.BankName.Trim() + "%");
}
builder.AppendFormat(" ORDER BY A.{0} DESC ", nameof(RB_Question_Bank_ViewModel.BankId));
return GetPage<RB_Question_Bank_ViewModel>(pageIndex, pageSize, out rowsCount, builder.ToString(), parameters).ToList();
}
}
}
}
\ No newline at end of file
......@@ -161,10 +161,7 @@ FROM
SELECT A.*,IFNULL(B.AssistName,'') AS AccountName,B.AssistIcon AS UserIcon,B.Dept_Id,B.Post_Id
FROM rb_account AS A INNER JOIN rb_assist AS B ON A.AccountId=B.AId AND A.AccountType=3
WHERE 1=1 {0}
UNION ALL
SELECT A.*,IFNULL(B.StuName,'') AS AccountName,B.StuIcon AS UserIcon,0 AS Dept_Id,0 AS Post_Id
FROM rb_account AS A INNER JOIN rb_student AS B ON A.AccountId=B.StuId AND A.AccountType=4
WHERE 1=1 {0}
) AS A LEFT JOIN rb_group AS g ON A.Group_Id=g.GId
LEFT JOIN rb_school AS s ON A.School_Id=s.SId
LEFT JOIN rb_department AS d ON A.Dept_Id=d.DeptId
......
......@@ -299,6 +299,30 @@ namespace Edu.WebApi.Controllers.Course
return orderModule.SetClassOrder(demodel, userInfo);
}
/// <summary>
/// 设置订单应收总额
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SetOrderPreferPrice() {
var userInfo = base.UserInfo;
JObject parms = JObject.Parse(RequestParm.Msg.ToString());
int OrderId = parms.GetInt("OrderId", 0);
decimal PreferPrice = parms.GetDecimal("PreferPrice");
if (OrderId <= 0) {
return ApiResult.ParamIsNull("请传递订单id");
}
bool flag = orderModule.SetOrderPreferPrice(OrderId, PreferPrice, userInfo);
if (flag)
{
return ApiResult.Success();
}
else {
return ApiResult.Failed();
}
}
/// <summary>
/// 获取订单详情
/// </summary>
......
......@@ -28,6 +28,86 @@ namespace Edu.WebApi.Controllers.Course
private readonly QuestionModule questionModule = AOP.AOPHelper.CreateAOPObject<QuestionModule>();
#region 题库管理
/// <summary>
/// 获取课程问题分页列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetQuestionBankPageList()
{
var pageModel = Common.Plugin.JsonHelper.DeserializeObject<ResultPageModel>(RequestParm.Msg.ToString());
var query = new RB_Question_Bank_ViewModel()
{
BankId = base.ParmJObj.GetInt("BankId"),
BankName = base.ParmJObj.GetStringValue("BankName"),
};
query.Group_Id = base.UserInfo.Group_Id;
var list = questionModule.GetQuestionBankPageListModule(pageModel.PageIndex, pageModel.PageSize, out long rowsCount, query);
List<object> resultList = new List<object>();
foreach (var item in list)
{
if (item.CreateBy > 0)
{
item.CreateByName = UserReidsCache.GetUserLoginInfo(item.CreateBy)?.AccountName ?? "";
}
resultList.Add(new
{
item.BankId,
item.BankName,
item.CreateByName,
item.QuestionCount
});
}
pageModel.Count = rowsCount;
pageModel.PageData = resultList;
return ApiResult.Success(data: pageModel);
}
/// <summary>
/// 获取题库实体
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetQuestionBank()
{
var BankId = base.ParmJObj.GetInt("BankId", 0);
var extModel = questionModule.GetQuestionBankModule(BankId);
return ApiResult.Success(data: extModel);
}
/// <summary>
/// 添加修改题库
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SetQuestionBank()
{
var extModel = Common.Plugin.JsonHelper.DeserializeObject<RB_Question_Bank_ViewModel>(RequestParm.Msg.ToString());
extModel.CreateTime = DateTime.Now;
extModel.CreateBy = base.UserInfo.Id;
extModel.UpdateBy = base.UserInfo.Id;
extModel.UpdateTime = DateTime.Now;
extModel.Status = Common.Enum.DateStateEnum.Normal;
extModel.Group_Id = base.UserInfo.Group_Id;
extModel.School_Id = base.UserInfo.School_Id;
bool flag = questionModule.SetQuestionBankModule(extModel);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
/// <summary>
/// 删除题库
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult RemoveQuestionBank()
{
var bankId = base.ParmJObj.GetInt("bankId", 0);
int status= base.ParmJObj.GetInt("status", 0);
var flag = questionModule.RemoveQuestionBankModule(bankId, status);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
/// <summary>
/// 获取题目类型列表
......@@ -54,6 +134,7 @@ namespace Edu.WebApi.Controllers.Course
CourseId = base.ParmJObj.GetInt("CourseId"),
Title = base.ParmJObj.GetStringValue("Title"),
PointName = base.ParmJObj.GetStringValue("PointName"),
BankId=base.ParmJObj.GetInt("BankId")
};
try
{
......@@ -91,6 +172,7 @@ namespace Edu.WebApi.Controllers.Course
}
var list = questionModule.GetQuestionPageListModule(pageModel.PageIndex, pageModel.PageSize, out long rowsCount, query);
List<object> resultList = new List<object>();
int index = 1;
foreach (var item in list)
{
if (item.CreateBy > 0)
......@@ -108,24 +190,26 @@ namespace Edu.WebApi.Controllers.Course
{
newTitle = Regex.Replace(item.Title, str, "[图片]");
}
catch (Exception ex)
catch
{
newTitle = item.Title;
}
resultList.Add(new
{
Number=(pageModel.PageIndex-1)*pageModel.PageSize+index,
item.QuestionId,
item.CourseId,
Title= newTitle,
item.QuestionTypeId,
item.QuestionTypeKey,
item.QuestionTypeName,
QuestionTypeName=item.QuestionTypeKey!= "single-number" ? item.QuestionTypeName:"选择题",
item.CreateByName,
item.CreateTimeStr,
item.DifficultyType,
item.CategoryName,
DifficultyTypeName = item.DifficultyType.ToName(),
}); ;
index++;
}
pageModel.Count = rowsCount;
pageModel.PageData = resultList;
......@@ -572,13 +656,14 @@ namespace Edu.WebApi.Controllers.Course
var list = Common.Plugin.JsonHelper.DeserializeObject<List<RB_Question_ViewModel>>(RequestParm.Msg.ToString());
if (list != null && list.Count > 0)
{
flag = questionModule.SetQuestionBatchModule(list);
foreach (var item in list)
{
flag = questionModule.SetQuestionModule(item);
}
}
return flag ? ApiResult.Success() : ApiResult.Failed();
}
/// <summary>
/// 删除课程问题
/// </summary>
......@@ -604,6 +689,34 @@ namespace Edu.WebApi.Controllers.Course
return flag ? ApiResult.Success() : ApiResult.Failed();
}
/// <summary>
/// 复制问题
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult CopyQuestion()
{
var questionId = base.ParmJObj.GetInt("QuestionId", 0);
if (questionId > 0)
{
var copyModel = questionModule.GetQuestionModule(questionId);
if (copyModel != null)
{
copyModel.QuestionId = 0;
copyModel.CreateTime = DateTime.Now;
copyModel.CreateBy = base.UserInfo.Id;
copyModel.UpdateBy = base.UserInfo.Id;
copyModel.UpdateTime = DateTime.Now;
}
var flag = questionModule.SetQuestionModule(copyModel);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
else
{
return ApiResult.Failed(message: "请选择要复制的问题!");
}
}
/// <summary>
/// 获取课程问题知识点列表
/// </summary>
......@@ -719,7 +832,7 @@ namespace Edu.WebApi.Controllers.Course
/// <param name="CourseId"></param>
/// <param name="Uid"></param>
/// <returns></returns>
public ApiResult ImportWordQuestion(string filePath, int CourseId, int Uid)
public ApiResult ImportWordQuestion(string filePath, int CourseId, int Uid, bool isDelete = false)
{
var userInfo = base.GetUserInfo(Uid);
var resultList = new List<RB_Question_ViewModel>();
......@@ -738,7 +851,10 @@ namespace Edu.WebApi.Controllers.Course
resultList.Add(model);
}
}
System.IO.File.Delete(filePath);
if (isDelete)
{
System.IO.File.Delete(filePath);
}
return ApiResult.Success(data: resultList);
}
......
......@@ -79,7 +79,7 @@ namespace Edu.WebApi.Controllers.Upload
//导入Word文件
if (Analysis == 1 && Word == 1 )
{
return new QuestionController().ImportWordQuestion(path_server, CourseId, Uid);
return new QuestionController().ImportWordQuestion(path_server, CourseId, Uid,isDelete:true);
}
return ApiResult.Success("", new { Name = filename, Path = path_server });
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment