Commit 1921f49b authored by 黄奎's avatar 黄奎

yemxiug

parent 378ec10d
......@@ -10,6 +10,7 @@ using Edu.Common.Plugin;
using Edu.Module.Question;
using Edu.Repository.Question;
using Edu.Model.ViewModel.Question;
using System.Text.RegularExpressions;
namespace Edu.Module.Exam
{
......@@ -485,6 +486,9 @@ namespace Edu.Module.Exam
/// <returns></returns>
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);
if (extModel != null && extModel.PaperId > 0)
{
......@@ -503,10 +507,22 @@ namespace Edu.Module.Exam
gItem.DetailsList = detailsList?.Where(qitem => qitem.QuestionTypeId == gItem.QuestionTypeId)?.ToList() ?? new List<RB_Examination_Details_ViewModel>();
if (gItem.DetailsList != null && gItem.DetailsList.Count > 0)
{
gItem.GScore = gItem?.DetailsList?.Sum(qitem => qitem.Score) ?? 0;
foreach (var sItem in gItem.DetailsList)
{
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;
}
}
}
......
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