|
|
|
@ -1,27 +1,21 @@ |
|
|
|
|
|
|
|
|
|
using Tiobon.Core.IServices; |
|
|
|
|
using Tiobon.Core.Model.Models; |
|
|
|
|
using Tiobon.Core.Services.BASE; |
|
|
|
|
using Tiobon.Core.IRepository.Base; |
|
|
|
|
using Tiobon.Core.Model; |
|
|
|
|
using System.Dynamic; |
|
|
|
|
using Newtonsoft.Json.Linq; |
|
|
|
|
using AgileObjects.AgileMapper; |
|
|
|
|
using Mysqlx.Crud; |
|
|
|
|
using AgileObjects.AgileMapper.Extensions; |
|
|
|
|
using System.Data; |
|
|
|
|
using AgileObjects.AgileMapper; |
|
|
|
|
using Tiobon.Core.Common; |
|
|
|
|
using Tiobon.Core.Common.DB.Dapper; |
|
|
|
|
using MySqlX.XDevAPI.Common; |
|
|
|
|
using System.Collections.Generic; |
|
|
|
|
using Tiobon.Core.IRepository.Base; |
|
|
|
|
using Tiobon.Core.IServices; |
|
|
|
|
using Tiobon.Core.Model; |
|
|
|
|
using Tiobon.Core.Model.Models; |
|
|
|
|
using Tiobon.Core.Services.BASE; |
|
|
|
|
|
|
|
|
|
namespace Tiobon.Core.Services; |
|
|
|
|
|
|
|
|
|
namespace Tiobon.Core.Services |
|
|
|
|
/// <summary> |
|
|
|
|
/// 题目 (服务) |
|
|
|
|
/// </summary> |
|
|
|
|
public class Ghre_QuestionServices : BaseServices<Ghre_Question, Ghre_QuestionDto, InsertGhre_QuestionInput, EditGhre_QuestionInput>, IGhre_QuestionServices |
|
|
|
|
{ |
|
|
|
|
/// <summary> |
|
|
|
|
/// 题目 (服务) |
|
|
|
|
/// </summary> |
|
|
|
|
public class Ghre_QuestionServices : BaseServices<Ghre_Question, Ghre_QuestionDto, InsertGhre_QuestionInput, EditGhre_QuestionInput>, IGhre_QuestionServices |
|
|
|
|
{ |
|
|
|
|
private readonly IBaseRepository<Ghre_Question> _dal; |
|
|
|
|
private IGhre_QuestionAnswerServices _ghre_QuestionAnswerServices; |
|
|
|
|
private IGhre_CourseServices _ghre_CourseServices; |
|
|
|
@ -54,17 +48,7 @@ namespace Tiobon.Core.Services |
|
|
|
|
x.DifficultyLevel = "普通"; |
|
|
|
|
else if (x.DifficultyLevel == "Hard") |
|
|
|
|
x.DifficultyLevel = "困难"; |
|
|
|
|
|
|
|
|
|
if (x.QuestionType == "Single") |
|
|
|
|
x.QuestionType = "单选题"; |
|
|
|
|
else if (x.QuestionType == "Multiple") |
|
|
|
|
x.QuestionType = "多选题"; |
|
|
|
|
else if (x.QuestionType == "TrueOrFalse") |
|
|
|
|
x.QuestionType = "判断题"; |
|
|
|
|
else if (x.QuestionType == "Completion") |
|
|
|
|
x.QuestionType = "填空题"; |
|
|
|
|
else if (x.QuestionType == "ShortAnswer") |
|
|
|
|
x.QuestionType = "简答题"; |
|
|
|
|
x.QuestionType = ConvertQuestionType(x.QuestionType); |
|
|
|
|
|
|
|
|
|
if (x.CourseId != null) |
|
|
|
|
{ |
|
|
|
@ -75,10 +59,7 @@ namespace Tiobon.Core.Services |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return new ServicePageResult<Ghre_QuestionDto>(body.pageNum, data1.result.DT_TablePageInfoT1.TotalCount, body.pageSize, data); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
@ -229,17 +210,7 @@ namespace Tiobon.Core.Services |
|
|
|
|
public async Task<ServiceResult> InsertFrom(FromGhre_QuestionPageData insertModel) |
|
|
|
|
{ |
|
|
|
|
var questionType = insertModel.questionType.Where(x => x.isActive == 1).FirstOrDefault(); |
|
|
|
|
string questionTypeName = string.Empty; |
|
|
|
|
if (questionType.type == "Single") |
|
|
|
|
questionTypeName = "单选题"; |
|
|
|
|
else if (questionType.type == "Multiple") |
|
|
|
|
questionTypeName = "多选题"; |
|
|
|
|
else if (questionType.type == "TrueOrFalse") |
|
|
|
|
questionTypeName = "判断题"; |
|
|
|
|
else if (questionType.type == "Completion") |
|
|
|
|
questionTypeName = "填空题"; |
|
|
|
|
else if (questionType.type == "ShortAnswer") |
|
|
|
|
questionTypeName = "简答题"; |
|
|
|
|
string questionTypeName = ConvertQuestionType(questionType.type); |
|
|
|
|
|
|
|
|
|
#region 判断是否重复 |
|
|
|
|
for (int j = 0; j < insertModel.baseData.courseID.Count; j++) |
|
|
|
@ -296,17 +267,7 @@ namespace Tiobon.Core.Services |
|
|
|
|
public async Task<ServiceResult> UpdareFrom(long Id, FromGhre_QuestionPageData editModel) |
|
|
|
|
{ |
|
|
|
|
var questionType = editModel.questionType.Where(x => x.isActive == 1).FirstOrDefault(); |
|
|
|
|
string questionTypeName = string.Empty; |
|
|
|
|
if (questionType.type == "Single") |
|
|
|
|
questionTypeName = "单选题"; |
|
|
|
|
else if (questionType.type == "Multiple") |
|
|
|
|
questionTypeName = "多选题"; |
|
|
|
|
else if (questionType.type == "TrueOrFalse") |
|
|
|
|
questionTypeName = "判断题"; |
|
|
|
|
else if (questionType.type == "Completion") |
|
|
|
|
questionTypeName = "填空题"; |
|
|
|
|
else if (questionType.type == "ShortAnswer") |
|
|
|
|
questionTypeName = "简答题"; |
|
|
|
|
string questionTypeName = ConvertQuestionType(questionType.type); |
|
|
|
|
|
|
|
|
|
#region 判断是否重复 |
|
|
|
|
for (int j = 0; j < editModel.baseData.courseID.Count; j++) |
|
|
|
@ -454,5 +415,20 @@ namespace Tiobon.Core.Services |
|
|
|
|
} |
|
|
|
|
catch (Exception) { throw; } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static string ConvertQuestionType(string type) |
|
|
|
|
{ |
|
|
|
|
string questionTypeName = string.Empty; |
|
|
|
|
if (type == "Single") |
|
|
|
|
questionTypeName = "单选题"; |
|
|
|
|
else if (type == "Multiple") |
|
|
|
|
questionTypeName = "多选题"; |
|
|
|
|
else if (type == "TrueOrFalse") |
|
|
|
|
questionTypeName = "判断题"; |
|
|
|
|
else if (type == "Completion") |
|
|
|
|
questionTypeName = "填空题"; |
|
|
|
|
else if (type == "ShortAnswer") |
|
|
|
|
questionTypeName = "简答题"; |
|
|
|
|
return questionTypeName; |
|
|
|
|
} |
|
|
|
|
} |