|
|
|
@ -5,10 +5,12 @@ using System.Text.RegularExpressions; |
|
|
|
|
using AgileObjects.AgileMapper; |
|
|
|
|
using Microsoft.AspNetCore.Http; |
|
|
|
|
using MongoDB.Driver.Linq; |
|
|
|
|
using Newtonsoft.Json; |
|
|
|
|
using Newtonsoft.Json.Linq; |
|
|
|
|
using SqlSugar; |
|
|
|
|
using Tiobon.Core.Common; |
|
|
|
|
using Tiobon.Core.Common.Caches; |
|
|
|
|
using Tiobon.Core.Common.Helper; |
|
|
|
|
using Tiobon.Core.Common.UserManager; |
|
|
|
|
using Tiobon.Core.IRepository.Base; |
|
|
|
|
using Tiobon.Core.IServices; |
|
|
|
@ -663,7 +665,7 @@ namespace Tiobon.Core.Services |
|
|
|
|
delete from Ghre_ExamPaperQuestion WHERE ExamPaperId='{id}';");
|
|
|
|
|
|
|
|
|
|
var insert = new EditGhre_ExamPaperInput(); |
|
|
|
|
|
|
|
|
|
var paper = await base.QueryById(id); |
|
|
|
|
insert = Mapper.Map(insertModel.baseData).ToANew<EditGhre_ExamPaperInput>(); |
|
|
|
|
insert.PaperNo = await GenerateContinuousSequence("Ghre_ExamPaper", "PaperNo", "P"); |
|
|
|
|
insert.LinkId = insertModel.baseData.LinkType == "CourseId" ? insertModel.baseData.CourseId : insertModel.baseData.CourseSceneId; |
|
|
|
@ -673,6 +675,24 @@ delete from Ghre_ExamPaperQuestion WHERE ExamPaperId='{id}';"); |
|
|
|
|
insert.SetMethod = insertModel.examPaperSetType; |
|
|
|
|
insert.Status = "Draft"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 串联试卷和课程关系 |
|
|
|
|
if ( |
|
|
|
|
(insert.LinkType == "CourseId" && insert.LinkType == paper.LinkType && paper.LinkId != insert.LinkId) || |
|
|
|
|
(insert.LinkType == "CourseSceneId" && insert.LinkType != paper.LinkType) |
|
|
|
|
) |
|
|
|
|
{ |
|
|
|
|
var courses = await _ghre_CourseServices.Query(x =>x.Id == paper.LinkId && x.ExamPaperId.Contains(id.ObjToString())); |
|
|
|
|
courses.ForEach(async x => |
|
|
|
|
{ |
|
|
|
|
var ids = JsonHelper.JsonToObj<List<long?>>(x.ExamPaperId); |
|
|
|
|
ids = ids.Where(o => o != id).ToList(); |
|
|
|
|
x.ExamPaperId = JsonHelper.ObjToJson(ids); |
|
|
|
|
await Db.Updateable(x).UpdateColumns(it => new { it.ExamPaperId }).ExecuteCommandAsync(); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
await Update(id, insert); |
|
|
|
|
var configs = Mapper.Map(insertModel.examPaperSetData).ToANew<List<Ghre_ExamPaperConfig>>(); |
|
|
|
|
configs.ForEach(x => x.ExamPaperId = id); |
|
|
|
|