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

新增配置

parent 3fcff474
......@@ -368,5 +368,16 @@ namespace Edu.Common
return JiaoWuZhang;
}
}
/// <summary>
/// 数字选择题前缀符号
/// </summary>
public static string NumberQuestionChar
{
get
{
return "@";
}
}
}
}
\ No newline at end of file
......@@ -371,6 +371,67 @@ namespace Edu.Common.Data
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
{
......
......@@ -288,7 +288,7 @@ namespace Edu.Common
public static string GetImageString(string base64)
{
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();
}
}
......
......@@ -93,16 +93,19 @@ namespace Edu.Common.Plugin
// \r\n【图一】\r\n
string imgPattern = @"\r\n[【][图][一二三四五六七八九十]*[】]";
Regex imgReg = new Regex(imgPattern);
//有图片
//判断是否有图片
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 newNumber= ConvertHelper.ConvertStringToNumber(numStr);
//将“一、二”转成数字"1,2"
var newNumber = ConvertHelper.ConvertStringToNumber(numStr);
if (newNumber > 0)
{
string filePath = imageList != null && imageList.Count >= newNumber ? imageList[newNumber - 1] : "";
......@@ -154,7 +157,6 @@ namespace Edu.Common.Plugin
questionWordData.BigTitle = "默认";
questionWordData.QuestionList = AnalysisQuestionList(tempArray);
}
return questionWordData;
}
......
......@@ -69,5 +69,10 @@ namespace Edu.Model.ViewModel.Question
/// 难易程度
/// </summary>
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
case "other":
obj = data;
break;
//单选题(数字)
case "single-number":
obj = Common.Plugin.JsonHelper.DeserializeObject<List<optionItem>>(data);
break;
}
return obj;
}
......
......@@ -7,8 +7,8 @@ namespace Edu.Test
static void Main(string[] args)
{
string filePath = "";
filePath = @"C:/Users/qiaoyajun/Desktop/模板二.docx";
filePath = @"C:/Users/qiaoyajun/Desktop/EduWordTemplate.doc";
filePath = @"C:/Users/qiaoyajun/Desktop/数字选项测试.docx";
//filePath = @"C:/Users/qiaoyajun/Desktop/EduWordTemplate.doc";
var data = Common.Data.QuestionHelper.GetWordQuestionData(filePath);
Console.WriteLine(Common.Plugin.JsonHelper.Serialize(data));
if (data != null && data.Count > 0)
......
using Edu.Cache.User;
using Edu.Common.API;
using Edu.Common.Data;
using Edu.Common.Enum.Course;
using Edu.Common.Enum.Question;
using Edu.Common.Plugin;
using Edu.Model.ViewModel.Question;
......@@ -101,8 +102,9 @@ namespace Edu.WebApi.Controllers.Course
item.CreateByName,
item.CreateTimeStr,
item.DifficultyType,
CategoryName = item.Category.ToName(),
DifficultyTypeName = item.DifficultyType.ToName(),
});
}); ;
}
pageModel.Count = rowsCount;
pageModel.PageData = resultList;
......@@ -365,6 +367,22 @@ namespace Edu.WebApi.Controllers.Course
{
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();
RB_Question_ViewModel model = new RB_Question_ViewModel
{
......@@ -374,6 +392,7 @@ namespace Edu.WebApi.Controllers.Course
QuestionTypeId = questionTypeModel?.QId ?? 0,
QuestionTypeKey = questionTypeModel?.Key ?? "",
QuestionTypeName= questionTypeModel?.Name??"",
Category=Category
};
Int32.TryParse(item.ChooseOptionCount, out int ChooseOptionCount);
switch (item.QuestionTypeName)
......@@ -697,6 +716,10 @@ namespace Edu.WebApi.Controllers.Course
model.QuestionTypeKey = tempModel?.Key ?? "";
}
break;
case "单选题(数字)":
AnalysisSingle(ChooseOptionCount, item, model, questionTypeList,isNumChoose:true);
break;
}
model.QuestionContentObj = questionModule.ParsingQuestionModule(model.QuestionTypeKey, model.QuestionContent);
return model;
......@@ -709,7 +732,8 @@ namespace Edu.WebApi.Controllers.Course
/// <param name="item"></param>
/// <param name="model"></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)
{
......@@ -722,6 +746,11 @@ namespace Edu.WebApi.Controllers.Course
Content = "",
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)
{
singleModel.Content = item.OptionA;
......@@ -764,7 +793,8 @@ namespace Edu.WebApi.Controllers.Course
}
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.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