题库内容保存Html标签 新增HtmlEncode

master
xiaochanghai 1 year ago
parent a83f0bbc6c
commit cedc3fa304
  1. 22
      Tiobon.Core.Services/Ghre/Ghre_QuestionServices.cs

@ -1,6 +1,5 @@
 using System.Data;
using System.Collections.Generic; using System.Net;
using System.Data;
using AgileObjects.AgileMapper; using AgileObjects.AgileMapper;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
@ -214,12 +213,14 @@ public class Ghre_QuestionServices : BaseServices<Ghre_Question, Ghre_QuestionDt
filter.pageSize = 10000; filter.pageSize = 10000;
var data = await Db.SqlQueryable<Ghre_QuestionDto>(sql) var data = await Db.SqlQueryable<Ghre_QuestionDto>(sql)
.OrderBy(filter.orderBy) .OrderBy(filter.orderBy)
.ToPageListAsync(filter.pageNum, filter.pageSize, totalCount); .ToPageListAsync(filter.pageNum, filter.pageSize, totalCount);
data.ForEach(async x => data.ForEach(async x =>
{ {
x.DifficultyLevelLabel = await GetParaLabel("DifficultyLevel", x.DifficultyLevel); x.DifficultyLevelLabel = await GetParaLabel("DifficultyLevel", x.DifficultyLevel);
x.QuestionTypeLabel = await GetParaLabel("QuestionType", x.QuestionType); x.QuestionTypeLabel = await GetParaLabel("QuestionType", x.QuestionType);
x.QuestionContent = WebUtility.HtmlDecode(x.QuestionContent);
}); });
@ -378,6 +379,8 @@ public class Ghre_QuestionServices : BaseServices<Ghre_Question, Ghre_QuestionDt
questionType.detail.answer = answers.Where(x => x.IsCorrect == true).FirstOrDefault()?.QuestionNo; questionType.detail.answer = answers.Where(x => x.IsCorrect == true).FirstOrDefault()?.QuestionNo;
questionType.detail.answer1 = answers.Where(x => x.IsCorrect == true).Select(x => x.QuestionNo).ToList(); questionType.detail.answer1 = answers.Where(x => x.IsCorrect == true).Select(x => x.QuestionNo).ToList();
questionType.detail.content = question.QuestionContent; questionType.detail.content = question.QuestionContent;
questionType.detail.content = WebUtility.HtmlDecode(questionType.detail.content);
questionType.detail.RemarkSz = question.QuestionAnalysis; questionType.detail.RemarkSz = question.QuestionAnalysis;
questionType.detail.answerList = answers.Select(x => new FromGhre_QuestionQuestionAnswerList() questionType.detail.answerList = answers.Select(x => new FromGhre_QuestionQuestionAnswerList()
{ {
@ -417,6 +420,8 @@ public class Ghre_QuestionServices : BaseServices<Ghre_Question, Ghre_QuestionDt
{ {
string questionTypeName = ConvertQuestionType(questionType.type); string questionTypeName = ConvertQuestionType(questionType.type);
questionType.detail.content = WebUtility.HtmlEncode(questionType.detail.content);
#region 判断是否重复 #region 判断是否重复
for (int j = 0; j < insertModel.baseData.courseID.Count; j++) for (int j = 0; j < insertModel.baseData.courseID.Count; j++)
{ {
@ -485,6 +490,9 @@ public class Ghre_QuestionServices : BaseServices<Ghre_Question, Ghre_QuestionDt
{ {
var questionType = editModel.questionType.Where(x => x.isActive == 1).FirstOrDefault(); var questionType = editModel.questionType.Where(x => x.isActive == 1).FirstOrDefault();
questionType.detail.content = WebUtility.HtmlEncode(questionType.detail.content);
#region 填空题处理 #region 填空题处理
if (questionType.type == "Completion") if (questionType.type == "Completion")
questionType.detail.answerList = questionType.detail.answer1 questionType.detail.answerList = questionType.detail.answer1
@ -520,6 +528,8 @@ public class Ghre_QuestionServices : BaseServices<Ghre_Question, Ghre_QuestionDt
} }
#endregion #endregion
var data = await base.QueryById(Id); var data = await base.QueryById(Id);
await _ghre_QuestionAnswerServices.Delete(x => x.QuestionId == Id); await _ghre_QuestionAnswerServices.Delete(x => x.QuestionId == Id);
var edit = Mapper.Map(data).ToANew<EditGhre_QuestionInput>(); var edit = Mapper.Map(data).ToANew<EditGhre_QuestionInput>();

Loading…
Cancel
Save