Commit 3361ed64 authored by 吴春's avatar 吴春

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

parents d8602c30 1a398e12
...@@ -33,5 +33,10 @@ namespace Edu.Model.ViewModel.Exam ...@@ -33,5 +33,10 @@ namespace Edu.Model.ViewModel.Exam
/// 是否查询文件夹 /// 是否查询文件夹
/// </summary> /// </summary>
public int IsQueryFolder { get; set; } public int IsQueryFolder { get; set; }
/// <summary>
/// 创建人
/// </summary>
public string CreateByName { get; set; }
} }
} }
...@@ -10,6 +10,7 @@ using Edu.Common.Plugin; ...@@ -10,6 +10,7 @@ using Edu.Common.Plugin;
using Edu.Module.Question; using Edu.Module.Question;
using Edu.Repository.Question; using Edu.Repository.Question;
using Edu.Model.ViewModel.Question; using Edu.Model.ViewModel.Question;
using System.Text.RegularExpressions;
namespace Edu.Module.Exam namespace Edu.Module.Exam
{ {
...@@ -521,9 +522,13 @@ namespace Edu.Module.Exam ...@@ -521,9 +522,13 @@ namespace Edu.Module.Exam
/// <returns></returns> /// <returns></returns>
public RB_Examination_Paper_ViewModel GetExaminationPaperModule(object PaperId) public RB_Examination_Paper_ViewModel GetExaminationPaperModule(object PaperId)
{ {
// 定义正则表达式用来匹配 img 标签
string str = @"<img\b[^<>]*?\bsrc[\s\t\r\n]*=[\s\t\r\n]*[""']?[\s\t\r\n]*(?<imgUrl>[^\s\t\r\n""'<>]*)[^<>]*?/?[\s\t\r\n]*>";
var extModel = examination_PaperRepository.GetEntity<RB_Examination_Paper_ViewModel>(PaperId); var extModel = examination_PaperRepository.GetEntity<RB_Examination_Paper_ViewModel>(PaperId);
if (extModel != null && extModel.PaperId > 0) if (extModel != null && extModel.PaperId > 0)
{ {
extModel.CreateByName = UserReidsCache.GetUserLoginInfo(extModel.CreateBy)?.AccountName ?? "";
extModel.GroupList = GetExaminationGroupListModule(new RB_Examination_Group_ViewModel() extModel.GroupList = GetExaminationGroupListModule(new RB_Examination_Group_ViewModel()
{ {
PaperId = extModel.PaperId PaperId = extModel.PaperId
...@@ -539,10 +544,22 @@ namespace Edu.Module.Exam ...@@ -539,10 +544,22 @@ namespace Edu.Module.Exam
gItem.DetailsList = detailsList?.Where(qitem => qitem.QuestionTypeId == gItem.QuestionTypeId)?.ToList() ?? new List<RB_Examination_Details_ViewModel>(); gItem.DetailsList = detailsList?.Where(qitem => qitem.QuestionTypeId == gItem.QuestionTypeId)?.ToList() ?? new List<RB_Examination_Details_ViewModel>();
if (gItem.DetailsList != null && gItem.DetailsList.Count > 0) if (gItem.DetailsList != null && gItem.DetailsList.Count > 0)
{ {
gItem.GScore = gItem?.DetailsList?.Sum(qitem => qitem.Score) ?? 0;
foreach (var sItem in gItem.DetailsList) foreach (var sItem in gItem.DetailsList)
{ {
sItem.QuestionContentObj = analysisQuestion.ParsingQuestion(sItem.QuestionTypeKey, sItem.QuestionContent); sItem.QuestionContentObj = analysisQuestion.ParsingQuestion(sItem.QuestionTypeKey, sItem.QuestionContent);
sItem.ShowTitle = Common.Plugin.StringHelper.FilterHtml(sItem.Title); string newTitle = sItem.Title;
try
{
newTitle = Regex.Replace(newTitle, str, "[图片]");
newTitle = Regex.Replace(newTitle, @"<iframe\s*[^>]*>", "[音频", RegexOptions.IgnoreCase);
newTitle = Regex.Replace(newTitle, @"</iframe>", "]", RegexOptions.IgnoreCase);
}
catch
{
newTitle = sItem.Title;
}
sItem.ShowTitle = newTitle;
} }
} }
} }
...@@ -591,18 +608,29 @@ namespace Edu.Module.Exam ...@@ -591,18 +608,29 @@ namespace Edu.Module.Exam
public bool RemoveExamnationPaperModule(int PaperId) public bool RemoveExamnationPaperModule(int PaperId)
{ {
var flag = true; var flag = true;
var model = GetExaminationPaperModule(PaperId);
var childList = examination_PaperRepository.GetExaminationPaperChildRepository(PaperId.ToString());
if (PaperId > 0) if (PaperId > 0)
{ {
flag = examination_PaperRepository.DeleteOne(new WhereHelper(nameof(RB_Examination_Paper_ViewModel.PaperId), PaperId)); flag = examination_PaperRepository.DeleteOne(new WhereHelper(nameof(RB_Examination_Paper_ViewModel.PaperId), PaperId));
} }
if (flag) if (flag && model.GroupList != null && model.GroupList.Count > 0)
{ {
flag = examination_GroupRepository.DeleteOne(new WhereHelper(nameof(RB_Examination_Group_ViewModel.PaperId), PaperId)); flag = examination_GroupRepository.DeleteOne(new WhereHelper(nameof(RB_Examination_Group_ViewModel.PaperId), PaperId));
} }
if (flag) if (flag && model.GroupList != null && model.GroupList.Count > 0 && model.GroupList[0].DetailsList != null && model.GroupList[0].DetailsList.Count > 0)
{ {
flag = examination_DetailsRepository.DeleteOne(new WhereHelper(nameof(RB_Examination_Details_ViewModel.PaperId), PaperId)); flag = examination_DetailsRepository.DeleteOne(new WhereHelper(nameof(RB_Examination_Details_ViewModel.PaperId), PaperId));
} }
if (childList != null && childList.Count > 0)
{
foreach (var item in childList)
{
examination_PaperRepository.DeleteOne(new WhereHelper(nameof(RB_Examination_Paper_ViewModel.PaperId), item.PaperId));
examination_GroupRepository.DeleteOne(new WhereHelper(nameof(RB_Examination_Group_ViewModel.PaperId), item.PaperId));
examination_DetailsRepository.DeleteOne(new WhereHelper(nameof(RB_Examination_Details_ViewModel.PaperId), item.PaperId));
}
}
return flag; return flag;
} }
......
...@@ -354,6 +354,20 @@ namespace Edu.WebApi.Controllers.Course ...@@ -354,6 +354,20 @@ namespace Edu.WebApi.Controllers.Course
return ApiResult.Failed(message: message); return ApiResult.Failed(message: message);
} }
} }
//判断题
else if (extModel.QuestionTypeKey == "judge")
{
var optionItems = Common.Plugin.JsonHelper.DeserializeObject<List<optionItem>>(extModel.QuestionContent);
string message = CheckChoose(optionItems);
if (!string.IsNullOrEmpty(message))
{
return ApiResult.Failed(message: message);
}
if (string.IsNullOrEmpty(extModel.Answer))
{
extModel.Answer = optionItems.Where(qitem => qitem.IsAnswer == true)?.FirstOrDefault()?.Name;
}
}
//填空题 //填空题
else if (extModel.QuestionTypeKey == "fill-in") else if (extModel.QuestionTypeKey == "fill-in")
{ {
...@@ -364,6 +378,7 @@ namespace Edu.WebApi.Controllers.Course ...@@ -364,6 +378,7 @@ namespace Edu.WebApi.Controllers.Course
return ApiResult.Failed(message: fillMessage); return ApiResult.Failed(message: fillMessage);
} }
} }
//简答题 //简答题
else if (extModel.QuestionTypeKey == "short-answer") else if (extModel.QuestionTypeKey == "short-answer")
{ {
......
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