优化考试随机出题

master
xiaochanghai 2 months ago
parent 9adea0cedf
commit f4ba01a27b
  1. 9
      Tiobon.Core.Services/Ghre/Ghre_CourseSceneServices.cs
  2. 3
      Tiobon.Core.Services/Ghre/Ghre_ExamPaperServices.cs
  3. 25
      Tiobon.Core.Services/Ghre/Ghre_ExamRecordServices.cs
  4. 12
      Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs

@ -34,9 +34,12 @@ public class Ghre_CourseSceneServices : BaseServices<Ghre_CourseScene, Ghre_Cour
else
t.CourseIds = new List<string>();
});
var coures = await Db.Queryable<Ghre_Course>().Where(x => x.CourseSceneIds != null && (x.CourseSceneIds.Contains(body.id.ObjToString()) || x.CourseSceneId == body.id) && x.Status == Consts.DIC_COURSE_STATUS.RELEASED).ToListAsync();
if (DT_TableDataT1.Any())
DT_TableDataT1[0].Courses = coures;
if (body.id.IsNotEmptyOrNull())
{
var coures = await Db.Queryable<Ghre_Course>().Where(x => x.CourseSceneIds != null && (x.CourseSceneIds.Contains(body.id.ObjToString()) || x.CourseSceneId == body.id) && x.Status == Consts.DIC_COURSE_STATUS.RELEASED).ToListAsync();
if (DT_TableDataT1.Any())
DT_TableDataT1[0].Courses = coures;
}
result.result.DT_TableDataT1 = DT_TableDataT1;
return result;
}

@ -1,5 +1,4 @@
using MongoDB.Driver.Linq;
using NPOI.SS.Formula.Functions;
using System.Net;
using System.Text.RegularExpressions;
@ -608,7 +607,7 @@ public class Ghre_ExamPaperServices : BaseServices<Ghre_ExamPaper, Ghre_ExamPape
if (!string.IsNullOrWhiteSpace(insert.QuestionType))
sql += $" AND QuestionType='{insert.QuestionType}'";
if (insert.CourseId != null)
sql += $" AND CourseId='{insert.CourseId}'";
sql += $" AND (CourseId='{insert.CourseId}' OR CourseIds like '%{insert.CourseId}%')";
if (insert.QuestionId != null)
sql += $" AND Id='{insert.QuestionId}'";
sql += $" ORDER BY GuidValue ASC";

@ -1,4 +1,5 @@
using AgileObjects.AgileMapper.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using MongoDB.Driver.Linq;
using System.Net;
@ -226,11 +227,25 @@ public class Ghre_ExamRecordServices : BaseServices<Ghre_ExamRecord, Ghre_ExamRe
var record = await QuerySingle(x => x.Id == examRecordId || x.StudyRecordId == examRecordId);
examRecordId = record.Id;
var details = await Db.Queryable<Ghre_ExamRecordDetail>().Where(x => x.ExamRecordId == record.Id).ToListAsync();
var detailIds = details.Select(x => x.Id).ToList();
var recordAnswers = await Db.Queryable<Ghre_ExamRecordAnswer>()
using var _context = ContextFactory.CreateContext();
var src = _context.Ghre_ExamRecordDetail.Where(x => x.ExamRecordId == record.Id);
var src1 = _context.Ghre_ExamRecordAnswer
.OrderBy(x => x.TaxisNo)
.Where(x => x.ExamRecordDetailId != null && detailIds.Contains(x.ExamRecordDetailId.Value))
.Where(x => x.ExamRecordDetailId != null && x.ExamRecordId == record.Id);
if (groupId != null)
src = src.Where(x => x.GroupId == groupId);
else
src = src.Where(x => x.IsEnable == 1);
var details = await src
.ToListAsync();
var detailIds = details.Select(x => x.Id).ToList();
src1 = src1.Where(x => detailIds.Contains(x.ExamRecordDetailId.Value));
var recordAnswers = await src1
.ToListAsync();
if (record.ScoreStatus == Consts.DIC_EXAM_RECORD_SCORE_STATUS.NO_SCORE)
await ExamHelper.SystemMarkAsync(Db, record, details, recordAnswers);
@ -636,7 +651,7 @@ public class Ghre_ExamRecordServices : BaseServices<Ghre_ExamRecord, Ghre_ExamRe
if (!string.IsNullOrWhiteSpace(config.QuestionType))
sql += $" AND QuestionType='{config.QuestionType}'";
if (config.CourseId != null)
sql += $" AND CourseId='{config.CourseId}'";
sql += $" AND (CourseId='{config.CourseId}' OR CourseIds like '%{config.CourseId}%')";
if (config.QuestionId != null)
sql += $" AND Id='{config.QuestionId}'";
if (examPaperQuestionIds.Any())

@ -1443,11 +1443,11 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr
await Db.Updateable(studyRecords).UpdateColumns(it => new { it.ExamId }).ExecuteCommandAsync();
#endregion
if (entity.DateType == DicExamDateType.EXAM_DATE)
{
courseEndTime = entity.EndTime.Value.Date.AddDays(1);
courseTime = courseEndTime.AddDays(-(snap?.ValidityPeriod ?? 1) * 30);
}
//if (entity.DateType == DicExamDateType.EXAM_DATE)
//{
// courseEndTime = entity.EndTime.Value.Date.AddDays(1);
// courseTime = courseEndTime.AddDays(-(snap?.ValidityPeriod ?? 1) * 30);
//}
for (int i = 0; i < staffs.Count; i++)
{
@ -1466,7 +1466,7 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr
CourseSnapId = snap?.Id,
CourseId = entity.CourseId,
CourseSceneId = entity.CourseSceneId,
JoinTime = DateTime.Now,
JoinTime = courseTime,
CourseBeginTime = courseTime.Date,
CourseEndTime = courseEndTime,
CourseType = DIC_EXAM_STAFF_SOURCE.MANUAL_REQUIRED,

Loading…
Cancel
Save