Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Education
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄奎
Education
Commits
9a7fb9ab
Commit
9a7fb9ab
authored
Jan 19, 2021
by
黄奎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增配置
parent
3fcff474
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
125 additions
and
12 deletions
+125
-12
Config.cs
Edu.Common/Config.cs
+11
-0
QuestionHelper.cs
Edu.Common/Data/QuestionHelper.cs
+61
-0
ConvertHelper.cs
Edu.Common/Plugin/ConvertHelper.cs
+1
-1
WordHelper.cs
Edu.Common/Plugin/WordHelper.cs
+8
-6
RB_Question_ViewModel.cs
Edu.Model/ViewModel/Question/RB_Question_ViewModel.cs
+5
-0
AnalysisQuestionTypeModule.cs
Edu.Module.Question/AnalysisQuestionTypeModule.cs
+4
-0
Program.cs
Edu.Test/Program.cs
+2
-2
QuestionController.cs
Edu.WebApi/Controllers/Course/QuestionController.cs
+33
-3
No files found.
Edu.Common/Config.cs
View file @
9a7fb9ab
...
...
@@ -368,5 +368,16 @@ namespace Edu.Common
return
JiaoWuZhang
;
}
}
/// <summary>
/// 数字选择题前缀符号
/// </summary>
public
static
string
NumberQuestionChar
{
get
{
return
"@"
;
}
}
}
}
\ No newline at end of file
Edu.Common/Data/
Xls
QuestionHelper.cs
→
Edu.Common/Data/QuestionHelper.cs
View file @
9a7fb9ab
...
...
@@ -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
{
...
...
Edu.Common/Plugin/ConvertHelper.cs
View file @
9a7fb9ab
...
...
@@ -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
();
}
}
...
...
Edu.Common/Plugin/WordHelper.cs
View file @
9a7fb9ab
...
...
@@ -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
m
atchs
)
foreach
(
var
item
in
imgM
atchs
)
{
//获取文档中“【图一】、【图二】...”中的“一、二”
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
;
}
...
...
Edu.Model/ViewModel/Question/RB_Question_ViewModel.cs
View file @
9a7fb9ab
...
...
@@ -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
Edu.Module.Question/AnalysisQuestionTypeModule.cs
View file @
9a7fb9ab
...
...
@@ -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
;
}
...
...
Edu.Test/Program.cs
View file @
9a7fb9ab
...
...
@@ -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
)
...
...
Edu.WebApi/Controllers/Course/QuestionController.cs
View file @
9a7fb9ab
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
??
""
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment