Commit 9a7fb9ab authored by 黄奎's avatar 黄奎

新增配置

parent 3fcff474
...@@ -368,5 +368,16 @@ namespace Edu.Common ...@@ -368,5 +368,16 @@ namespace Edu.Common
return JiaoWuZhang; return JiaoWuZhang;
} }
} }
/// <summary>
/// 数字选择题前缀符号
/// </summary>
public static string NumberQuestionChar
{
get
{
return "@";
}
}
} }
} }
\ No newline at end of file
...@@ -371,6 +371,67 @@ namespace Edu.Common.Data ...@@ -371,6 +371,67 @@ namespace Edu.Common.Data
model.ChooseOptionCount = (index + 1).ToString(); model.ChooseOptionCount = (index + 1).ToString();
} }
} }
//数字选择题
else if (model.QuestionAnswer.Contains(Common.Config.NumberQuestionChar))
{
if (model.QuestionAnswer.Replace(Common.Config.NumberQuestionChar,"").Length == 1)
{
model.QuestionTypeName = "单选题(数字)";
}
int index = 0;
int chooseCount = 0;
foreach (var item in tempArray)
{
string pattern = @"[@][123456789][.、]";
var tempArray2 = Regex.Split(item, pattern);
if (tempArray2 != null && tempArray2.Length == 2)
{
var tempStr = tempArray2[1].Replace(". ", "").Replace("、", "").Trim();
if (!string.IsNullOrEmpty(tempStr))
{
chooseCount++;
}
if (index == 0)
{
model.OptionA = tempStr;
}
if (index == 1)
{
model.OptionB = tempStr;
}
if (index == 2)
{
model.OptionC = tempStr;
}
if (index == 3)
{
model.OptionD = tempStr;
}
if (index == 4)
{
model.OptionE = tempStr;
}
if (index == 5)
{
model.OptionF = tempStr;
}
if (index == 6)
{
model.OptionG = tempStr;
}
if (index == 7)
{
model.OptionH = tempStr;
}
if (!string.IsNullOrEmpty(tempStr))
{
index++;
}
}
}
model.ChooseOptionCount = chooseCount.ToString();
model.QuestionAnswer = model.QuestionAnswer.Replace(Common.Config.NumberQuestionChar, "");
}
//简答题 //简答题
else else
{ {
......
...@@ -288,7 +288,7 @@ namespace Edu.Common ...@@ -288,7 +288,7 @@ namespace Edu.Common
public static string GetImageString(string base64) public static string GetImageString(string base64)
{ {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"<img src='data:image/png;base64,{0}' />", base64); builder.AppendFormat(@"<p><img src='data:image/png;base64,{0}' /></p>", base64);
return builder.ToString(); return builder.ToString();
} }
} }
......
...@@ -93,16 +93,19 @@ namespace Edu.Common.Plugin ...@@ -93,16 +93,19 @@ namespace Edu.Common.Plugin
// \r\n【图一】\r\n // \r\n【图一】\r\n
string imgPattern = @"\r\n[【][图][一二三四五六七八九十]*[】]"; string imgPattern = @"\r\n[【][图][一二三四五六七八九十]*[】]";
Regex imgReg = new Regex(imgPattern); Regex imgReg = new Regex(imgPattern);
//有图片 //判断是否有图片
if (imgReg.IsMatch(questionStr)) if (imgReg.IsMatch(questionStr))
{ {
var matchs = Regex.Matches(questionStr, imgPattern); //匹配需要替换的图片
if (matchs != null && matchs.Count > 0) var imgMatchs = Regex.Matches(questionStr, imgPattern);
if (imgMatchs != null && imgMatchs.Count > 0)
{ {
foreach (var item in matchs) foreach (var item in imgMatchs)
{ {
//获取文档中“【图一】、【图二】...”中的“一、二”
var numStr = item.ToString().Replace("【", "").Replace("】", "").Replace("图", "").Trim(); var numStr = item.ToString().Replace("【", "").Replace("】", "").Replace("图", "").Trim();
var newNumber= ConvertHelper.ConvertStringToNumber(numStr); //将“一、二”转成数字"1,2"
var newNumber = ConvertHelper.ConvertStringToNumber(numStr);
if (newNumber > 0) if (newNumber > 0)
{ {
string filePath = imageList != null && imageList.Count >= newNumber ? imageList[newNumber - 1] : ""; string filePath = imageList != null && imageList.Count >= newNumber ? imageList[newNumber - 1] : "";
...@@ -154,7 +157,6 @@ namespace Edu.Common.Plugin ...@@ -154,7 +157,6 @@ namespace Edu.Common.Plugin
questionWordData.BigTitle = "默认"; questionWordData.BigTitle = "默认";
questionWordData.QuestionList = AnalysisQuestionList(tempArray); questionWordData.QuestionList = AnalysisQuestionList(tempArray);
} }
return questionWordData; return questionWordData;
} }
......
...@@ -69,5 +69,10 @@ namespace Edu.Model.ViewModel.Question ...@@ -69,5 +69,10 @@ namespace Edu.Model.ViewModel.Question
/// 难易程度 /// 难易程度
/// </summary> /// </summary>
public string DifficultyTypeStr { get { return this.DifficultyType.ToName(); } } public string DifficultyTypeStr { get { return this.DifficultyType.ToName(); } }
/// <summary>
/// 大类名称
/// </summary>
public string CategoryName { get; set; }
} }
} }
\ No newline at end of file
...@@ -160,6 +160,10 @@ namespace Edu.Module.Question ...@@ -160,6 +160,10 @@ namespace Edu.Module.Question
case "other": case "other":
obj = data; obj = data;
break; break;
//单选题(数字)
case "single-number":
obj = Common.Plugin.JsonHelper.DeserializeObject<List<optionItem>>(data);
break;
} }
return obj; return obj;
} }
......
...@@ -7,8 +7,8 @@ namespace Edu.Test ...@@ -7,8 +7,8 @@ namespace Edu.Test
static void Main(string[] args) static void Main(string[] args)
{ {
string filePath = ""; string filePath = "";
filePath = @"C:/Users/qiaoyajun/Desktop/模板二.docx"; filePath = @"C:/Users/qiaoyajun/Desktop/数字选项测试.docx";
filePath = @"C:/Users/qiaoyajun/Desktop/EduWordTemplate.doc"; //filePath = @"C:/Users/qiaoyajun/Desktop/EduWordTemplate.doc";
var data = Common.Data.QuestionHelper.GetWordQuestionData(filePath); var data = Common.Data.QuestionHelper.GetWordQuestionData(filePath);
Console.WriteLine(Common.Plugin.JsonHelper.Serialize(data)); Console.WriteLine(Common.Plugin.JsonHelper.Serialize(data));
if (data != null && data.Count > 0) if (data != null && data.Count > 0)
......
using Edu.Cache.User; using Edu.Cache.User;
using Edu.Common.API; using Edu.Common.API;
using Edu.Common.Data; using Edu.Common.Data;
using Edu.Common.Enum.Course;
using Edu.Common.Enum.Question; using Edu.Common.Enum.Question;
using Edu.Common.Plugin; using Edu.Common.Plugin;
using Edu.Model.ViewModel.Question; using Edu.Model.ViewModel.Question;
...@@ -101,8 +102,9 @@ namespace Edu.WebApi.Controllers.Course ...@@ -101,8 +102,9 @@ namespace Edu.WebApi.Controllers.Course
item.CreateByName, item.CreateByName,
item.CreateTimeStr, item.CreateTimeStr,
item.DifficultyType, item.DifficultyType,
CategoryName = item.Category.ToName(),
DifficultyTypeName = item.DifficultyType.ToName(), DifficultyTypeName = item.DifficultyType.ToName(),
}); }); ;
} }
pageModel.Count = rowsCount; pageModel.Count = rowsCount;
pageModel.PageData = resultList; pageModel.PageData = resultList;
...@@ -365,6 +367,22 @@ namespace Edu.WebApi.Controllers.Course ...@@ -365,6 +367,22 @@ namespace Edu.WebApi.Controllers.Course
{ {
DifficultyType = DifficultyTypeEnum.Difficult; DifficultyType = DifficultyTypeEnum.Difficult;
} }
var Category = QuestionCategoryEnum.Default;
if (!string.IsNullOrEmpty(item.Category))
{
switch (item.Category)
{
case "日语选择题":
Category = QuestionCategoryEnum.JapaneseChoose;
break;
case "中文选择题":
Category = QuestionCategoryEnum.ChineseChoose;
break;
case "阅读理解":
Category = QuestionCategoryEnum.ReadingComprehensio;
break;
}
}
var questionTypeModel = questionTypeList?.Where(qitem => qitem.Name == item.QuestionTypeName)?.FirstOrDefault(); var questionTypeModel = questionTypeList?.Where(qitem => qitem.Name == item.QuestionTypeName)?.FirstOrDefault();
RB_Question_ViewModel model = new RB_Question_ViewModel RB_Question_ViewModel model = new RB_Question_ViewModel
{ {
...@@ -374,6 +392,7 @@ namespace Edu.WebApi.Controllers.Course ...@@ -374,6 +392,7 @@ namespace Edu.WebApi.Controllers.Course
QuestionTypeId = questionTypeModel?.QId ?? 0, QuestionTypeId = questionTypeModel?.QId ?? 0,
QuestionTypeKey = questionTypeModel?.Key ?? "", QuestionTypeKey = questionTypeModel?.Key ?? "",
QuestionTypeName= questionTypeModel?.Name??"", QuestionTypeName= questionTypeModel?.Name??"",
Category=Category
}; };
Int32.TryParse(item.ChooseOptionCount, out int ChooseOptionCount); Int32.TryParse(item.ChooseOptionCount, out int ChooseOptionCount);
switch (item.QuestionTypeName) switch (item.QuestionTypeName)
...@@ -697,6 +716,10 @@ namespace Edu.WebApi.Controllers.Course ...@@ -697,6 +716,10 @@ namespace Edu.WebApi.Controllers.Course
model.QuestionTypeKey = tempModel?.Key ?? ""; model.QuestionTypeKey = tempModel?.Key ?? "";
} }
break; break;
case "单选题(数字)":
AnalysisSingle(ChooseOptionCount, item, model, questionTypeList,isNumChoose:true);
break;
} }
model.QuestionContentObj = questionModule.ParsingQuestionModule(model.QuestionTypeKey, model.QuestionContent); model.QuestionContentObj = questionModule.ParsingQuestionModule(model.QuestionTypeKey, model.QuestionContent);
return model; return model;
...@@ -709,7 +732,8 @@ namespace Edu.WebApi.Controllers.Course ...@@ -709,7 +732,8 @@ namespace Edu.WebApi.Controllers.Course
/// <param name="item"></param> /// <param name="item"></param>
/// <param name="model"></param> /// <param name="model"></param>
/// <param name="questionTypeList"></param> /// <param name="questionTypeList"></param>
private void AnalysisSingle(int ChooseOptionCount, ImportModel item, RB_Question_ViewModel model, List<RB_Question_Type_ViewModel> questionTypeList) /// <param name="isNumChoose">是否数字选择题</param>
private void AnalysisSingle(int ChooseOptionCount, ImportModel item, RB_Question_ViewModel model, List<RB_Question_Type_ViewModel> questionTypeList,bool isNumChoose=false)
{ {
if (ChooseOptionCount > 0) if (ChooseOptionCount > 0)
{ {
...@@ -722,6 +746,11 @@ namespace Edu.WebApi.Controllers.Course ...@@ -722,6 +746,11 @@ namespace Edu.WebApi.Controllers.Course
Content = "", Content = "",
IsAnswer = item.QuestionAnswer.Contains(Common.ConvertHelper.GetEnChar(i)) IsAnswer = item.QuestionAnswer.Contains(Common.ConvertHelper.GetEnChar(i))
}; };
if (isNumChoose)
{
singleModel.Name = (i + 1).ToString();
singleModel.IsAnswer = item.QuestionAnswer.Contains((i + 1).ToString());
}
if (i == 0) if (i == 0)
{ {
singleModel.Content = item.OptionA; singleModel.Content = item.OptionA;
...@@ -764,7 +793,8 @@ namespace Edu.WebApi.Controllers.Course ...@@ -764,7 +793,8 @@ namespace Edu.WebApi.Controllers.Course
} }
if (model.QuestionTypeId == 0) if (model.QuestionTypeId == 0)
{ {
var tempModel = questionTypeList.Where(qitem => qitem.Key == "single")?.FirstOrDefault(); string key = isNumChoose ? "single-number" : "single";
var tempModel = questionTypeList.Where(qitem => qitem.Key == key)?.FirstOrDefault();
model.QuestionTypeId = tempModel?.QId ?? 0; model.QuestionTypeId = tempModel?.QId ?? 0;
model.QuestionTypeKey = tempModel?.Key ?? ""; model.QuestionTypeKey = tempModel?.Key ?? "";
} }
......
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