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
24d45f6c
Commit
24d45f6c
authored
Aug 16, 2021
by
黄奎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
页面修改
parent
3d21e9e5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
46 deletions
+56
-46
RB_Question_ViewModel.cs
Edu.Model/ViewModel/Question/RB_Question_ViewModel.cs
+5
-0
QuestionController.cs
Edu.WebApi/Controllers/Course/QuestionController.cs
+51
-46
No files found.
Edu.Model/ViewModel/Question/RB_Question_ViewModel.cs
View file @
24d45f6c
...
...
@@ -101,5 +101,10 @@ namespace Edu.Model.ViewModel.Question
return
Common
.
Plugin
.
EnumHelper
.
ToName
(
this
.
LevelType
);
}
}
/// <summary>
/// 是否返回所有字段
/// </summary>
public
int
IsShowAllQuestion
{
get
;
set
;
}
}
}
\ No newline at end of file
Edu.WebApi/Controllers/Course/QuestionController.cs
View file @
24d45f6c
...
...
@@ -53,7 +53,7 @@ namespace Edu.WebApi.Controllers.Course
}
resultList
.
Add
(
new
{
RowNum
=(
pageModel
.
PageIndex
-
1
)*
pageModel
.
PageSize
+
index
,
RowNum
=
(
pageModel
.
PageIndex
-
1
)
*
pageModel
.
PageSize
+
index
,
item
.
BankId
,
item
.
BankNo
,
item
.
BankName
,
...
...
@@ -107,7 +107,7 @@ namespace Edu.WebApi.Controllers.Course
public
ApiResult
RemoveQuestionBank
()
{
var
bankId
=
base
.
ParmJObj
.
GetInt
(
"bankId"
,
0
);
int
status
=
base
.
ParmJObj
.
GetInt
(
"status"
,
0
);
int
status
=
base
.
ParmJObj
.
GetInt
(
"status"
,
0
);
var
flag
=
questionModule
.
RemoveQuestionBankModule
(
bankId
,
status
);
return
flag
?
ApiResult
.
Success
()
:
ApiResult
.
Failed
();
}
...
...
@@ -138,7 +138,8 @@ namespace Edu.WebApi.Controllers.Course
CourseId
=
base
.
ParmJObj
.
GetInt
(
"CourseId"
),
Title
=
base
.
ParmJObj
.
GetStringValue
(
"Title"
),
PointName
=
base
.
ParmJObj
.
GetStringValue
(
"PointName"
),
BankId
=
base
.
ParmJObj
.
GetInt
(
"BankId"
)
BankId
=
base
.
ParmJObj
.
GetInt
(
"BankId"
),
IsShowAllQuestion
=
base
.
ParmJObj
.
GetInt
(
"IsShowAllQuestion"
),
};
try
{
...
...
@@ -171,8 +172,8 @@ namespace Edu.WebApi.Controllers.Course
}
}
catch
{
{
}
var
list
=
questionModule
.
GetQuestionPageListModule
(
pageModel
.
PageIndex
,
pageModel
.
PageSize
,
out
long
rowsCount
,
query
);
List
<
object
>
resultList
=
new
List
<
object
>();
...
...
@@ -188,18 +189,11 @@ namespace Edu.WebApi.Controllers.Course
item
.
UpdateByName
=
UserReidsCache
.
GetUserLoginInfo
(
item
.
UpdateBy
)?.
AccountName
??
""
;
}
// 定义正则表达式用来匹配 img 标签
string
str
=
@"<img\b[^<>]*?\bsrc[\s\t\r\n]*=[\s\t\r\n]*[""']?[\s\t\r\n]*(?<imgUrl>[^\s\t\r\n""'<>]*)[^<>]*?/?[\s\t\r\n]*>"
;
string
str
=
@"<img\b[^<>]*?\bsrc[\s\t\r\n]*=[\s\t\r\n]*[""']?[\s\t\r\n]*(?<imgUrl>[^\s\t\r\n""'<>]*)[^<>]*?/?[\s\t\r\n]*>"
;
string
newTitle
=
item
.
Title
;
try
{
newTitle
=
Regex
.
Replace
(
newTitle
,
str
,
"[图片]"
);
}
catch
{
newTitle
=
item
.
Title
;
}
try
{
newTitle
=
Regex
.
Replace
(
newTitle
,
@"<iframe\s*[^>]*>"
,
"[音频"
,
RegexOptions
.
IgnoreCase
);
newTitle
=
Regex
.
Replace
(
newTitle
,
@"</iframe>"
,
"]"
,
RegexOptions
.
IgnoreCase
);
}
...
...
@@ -207,22 +201,33 @@ namespace Edu.WebApi.Controllers.Course
{
newTitle
=
item
.
Title
;
}
resultList
.
Add
(
new
var
obj
=
new
{
Number
=(
pageModel
.
PageIndex
-
1
)*
pageModel
.
PageSize
+
index
,
Number
=
(
pageModel
.
PageIndex
-
1
)
*
pageModel
.
PageSize
+
index
,
item
.
QuestionId
,
item
.
CourseId
,
Title
=
newTitle
,
Title
=
newTitle
,
item
.
QuestionTypeId
,
item
.
QuestionTypeKey
,
QuestionTypeName
=
item
.
QuestionTypeKey
!=
"single-number"
?
item
.
QuestionTypeName
:
"选择题"
,
QuestionTypeName
=
item
.
QuestionTypeKey
!=
"single-number"
?
item
.
QuestionTypeName
:
"选择题"
,
item
.
CreateByName
,
item
.
CreateTimeStr
,
item
.
DifficultyType
,
item
.
CategoryName
,
DifficultyTypeName
=
item
.
DifficultyType
.
ToName
(),
item
.
LevelTypeName
});
;
item
.
LevelTypeName
,
QuestionContent
=
query
.
IsShowAllQuestion
==
1
?
item
.
QuestionContent
:
""
,
AnswerParse
=
query
.
IsShowAllQuestion
==
1
?
item
.
AnswerParse
:
""
,
Knowledge
=
query
.
IsShowAllQuestion
==
1
?
item
.
Knowledge
:
""
,
IsUpdateJobExam
=
query
.
IsShowAllQuestion
==
1
?
item
.
IsUpdateJobExam
:
0
,
Answer
=
query
.
IsShowAllQuestion
==
1
?
item
.
Answer
:
""
,
IsMutex
=
query
.
IsShowAllQuestion
==
1
?
item
.
IsMutex
:
0
,
Category
=
query
.
IsShowAllQuestion
==
1
?
item
.
Category
:
0
,
LevelType
=
query
.
IsShowAllQuestion
==
1
?
item
.
LevelType
:
0
,
BankId
=
query
.
IsShowAllQuestion
==
1
?
item
.
BankId
:
0
,
};
resultList
.
Add
(
obj
);
index
++;
}
pageModel
.
Count
=
rowsCount
;
...
...
@@ -244,7 +249,7 @@ namespace Edu.WebApi.Controllers.Course
Title
=
base
.
ParmJObj
.
GetStringValue
(
"Title"
),
PointName
=
base
.
ParmJObj
.
GetStringValue
(
"PointName"
),
BankId
=
base
.
ParmJObj
.
GetInt
(
"BankId"
),
QBankIds
=
base
.
ParmJObj
.
GetStringValue
(
"QBankIds"
),
QBankIds
=
base
.
ParmJObj
.
GetStringValue
(
"QBankIds"
),
};
var
data
=
questionModule
.
GetQuestionCategoryListModule
(
query
);
return
ApiResult
.
Success
(
data
:
data
);
...
...
@@ -329,9 +334,9 @@ namespace Edu.WebApi.Controllers.Course
QuestionTypeKey
=
base
.
ParmJObj
.
GetStringValue
(
"QuestionTypeKey"
),
SortNum
=
base
.
ParmJObj
.
GetInt
(
"SortNum"
),
Title
=
base
.
ParmJObj
.
GetStringValue
(
"Title"
),
Category
=
(
QuestionCategoryEnum
)
base
.
ParmJObj
.
GetInt
(
"Category"
),
LevelType
=
(
LevelTypeEnum
)
base
.
ParmJObj
.
GetInt
(
"LevelType"
),
BankId
=
base
.
ParmJObj
.
GetInt
(
"BankId"
)
Category
=
(
QuestionCategoryEnum
)
base
.
ParmJObj
.
GetInt
(
"Category"
),
LevelType
=
(
LevelTypeEnum
)
base
.
ParmJObj
.
GetInt
(
"LevelType"
),
BankId
=
base
.
ParmJObj
.
GetInt
(
"BankId"
)
};
if
(
string
.
IsNullOrEmpty
(
extModel
.
Title
))
{
...
...
@@ -575,7 +580,7 @@ namespace Edu.WebApi.Controllers.Course
else
if
(
extModel
.
QuestionTypeKey
==
"sharing-choose"
)
{
var
shareList
=
Common
.
Plugin
.
JsonHelper
.
DeserializeObject
<
List
<
List
<
matchingItem
>>>(
extModel
.
QuestionContent
);
if
(
shareList
!=
null
&&
shareList
.
Count
==
2
)
if
(
shareList
!=
null
&&
shareList
.
Count
==
2
)
{
if
(
shareList
[
0
].
Where
(
qitem
=>
string
.
IsNullOrEmpty
(
qitem
.
Content
)).
Count
()
>
0
)
{
...
...
@@ -600,7 +605,7 @@ namespace Edu.WebApi.Controllers.Course
{
return
ApiResult
.
Failed
(
message
:
string
.
Format
(
"请设置题干的正确选项!"
));
}
}
}
else
{
return
ApiResult
.
Failed
(
message
:
"请添加选项!"
);
...
...
@@ -626,7 +631,7 @@ namespace Edu.WebApi.Controllers.Course
var
flag
=
questionModule
.
SetBatchQuestionLevelModule
(
LevelType
,
questionIds
);
return
flag
?
ApiResult
.
Success
()
:
ApiResult
.
Failed
();
}
/// <summary>
/// 选择题验证
/// </summary>
...
...
@@ -690,7 +695,7 @@ namespace Edu.WebApi.Controllers.Course
string
message
=
""
;
if
(
string
.
IsNullOrEmpty
(
answer
))
{
message
=
"请填写简答题答案!"
;
message
=
"请填写简答题答案!"
;
}
return
message
;
}
...
...
@@ -704,7 +709,7 @@ namespace Edu.WebApi.Controllers.Course
{
var
QuestionId
=
base
.
ParmJObj
.
GetInt
(
"QuestionId"
,
0
);
int
isReplaceClozeTitle
=
base
.
ParmJObj
.
GetInt
(
"isReplaceClozeTitle"
,
0
);
var
extModel
=
questionModule
.
GetQuestionModule
(
QuestionId
,
isReplaceClozeTitle
:
isReplaceClozeTitle
);
var
extModel
=
questionModule
.
GetQuestionModule
(
QuestionId
,
isReplaceClozeTitle
:
isReplaceClozeTitle
);
return
ApiResult
.
Success
(
data
:
extModel
);
}
...
...
@@ -715,7 +720,7 @@ namespace Edu.WebApi.Controllers.Course
[
HttpPost
]
public
ApiResult
SetQuestionBeatch
()
{
bool
flag
=
false
;
bool
flag
=
false
;
var
list
=
Common
.
Plugin
.
JsonHelper
.
DeserializeObject
<
List
<
RB_Question_ViewModel
>>(
RequestParm
.
Msg
.
ToString
());
if
(
list
!=
null
&&
list
.
Count
>
0
)
{
...
...
@@ -865,7 +870,7 @@ namespace Edu.WebApi.Controllers.Course
/// 导入Excel问题
/// </summary>
/// <returns></returns>
public
ApiResult
ImportExcelQuestion
(
string
filePath
,
int
CourseId
,
int
Uid
)
public
ApiResult
ImportExcelQuestion
(
string
filePath
,
int
CourseId
,
int
Uid
)
{
var
userInfo
=
base
.
GetUserInfo
(
Uid
);
var
resultList
=
new
List
<
RB_Question_ViewModel
>();
...
...
@@ -885,7 +890,7 @@ namespace Edu.WebApi.Controllers.Course
}
}
System
.
IO
.
File
.
Delete
(
filePath
);
return
ApiResult
.
Success
(
data
:
resultList
);
return
ApiResult
.
Success
(
data
:
resultList
);
}
/// <summary>
...
...
@@ -978,8 +983,8 @@ namespace Edu.WebApi.Controllers.Course
AnswerParse
=
item
.
AnswerAnalysis
,
QuestionTypeId
=
questionTypeModel
?.
QId
??
0
,
QuestionTypeKey
=
questionTypeModel
?.
Key
??
""
,
QuestionTypeName
=
questionTypeModel
?.
Name
??
""
,
Category
=
Category
QuestionTypeName
=
questionTypeModel
?.
Name
??
""
,
Category
=
Category
};
Int32
.
TryParse
(
item
.
ChooseOptionCount
,
out
int
ChooseOptionCount
);
switch
(
item
.
QuestionTypeName
)
...
...
@@ -1285,23 +1290,23 @@ namespace Edu.WebApi.Controllers.Course
case
"阅读理解"
:
List
<
readingComprehensioItem
>
readingList
=
new
List
<
readingComprehensioItem
>();
foreach
(
var
subItem
in
item
.
SubQuestionList
)
{
foreach
(
var
subItem
in
item
.
SubQuestionList
)
{
Int32
.
TryParse
(
subItem
.
ChooseOptionCount
,
out
int
subChooseCount
);
List
<
optionItem
>
singleList
=
new
List
<
optionItem
>();
switch
(
subItem
.
QuestionTypeName
)
{
//单选题
case
"单选题"
:
{
//单选题
case
"单选题"
:
readingComprehensioItem
readingModel
=
new
readingComprehensioItem
()
{
QuestionKey
=
"single"
,
QuestionName
=
"单选题"
,
QuestionType
=
1
,
SubTitle
=
subItem
.
QuestionTitle
,
SubAnwser
=
new
object
()
SubAnwser
=
new
object
()
};
for
(
var
i
=
0
;
i
<
subChooseCount
;
i
++)
{
var
singleModel
=
new
optionItem
()
...
...
@@ -1344,14 +1349,14 @@ namespace Edu.WebApi.Controllers.Course
SubTitle
=
subItem
.
QuestionTitle
,
SubAnwser
=
new
object
()
};
for
(
var
i
=
0
;
i
<
subChooseCount
;
i
++)
{
var
singleModel
=
new
optionItem
()
{
Name
=
(
i
+
1
).
ToString
(),
Name
=
(
i
+
1
).
ToString
(),
Content
=
""
,
IsAnswer
=
subItem
.
QuestionAnswer
.
Trim
()
==(
i
+
1
).
ToString
()
IsAnswer
=
subItem
.
QuestionAnswer
.
Trim
()
==
(
i
+
1
).
ToString
()
};
if
(
i
==
0
)
{
...
...
@@ -1378,8 +1383,8 @@ namespace Edu.WebApi.Controllers.Course
readingModel2
.
SubAnwser
=
singleList
;
readingList
.
Add
(
readingModel2
);
break
;
}
}
}
model
.
QuestionContent
=
Common
.
Plugin
.
JsonHelper
.
Serialize
(
readingList
);
if
(
model
.
QuestionTypeId
==
0
)
{
...
...
@@ -1390,7 +1395,7 @@ namespace Edu.WebApi.Controllers.Course
break
;
case
"单选题(数字)"
:
AnalysisSingle
(
ChooseOptionCount
,
item
,
model
,
questionTypeList
,
isNumChoose
:
true
);
AnalysisSingle
(
ChooseOptionCount
,
item
,
model
,
questionTypeList
,
isNumChoose
:
true
);
break
;
}
model
.
QuestionContentObj
=
questionModule
.
ParsingQuestionModule
(
model
.
QuestionTypeKey
,
model
.
QuestionContent
);
...
...
@@ -1405,7 +1410,7 @@ namespace Edu.WebApi.Controllers.Course
/// <param name="model"></param>
/// <param name="questionTypeList"></param>
/// <param name="isNumChoose">是否数字选择题</param>
private
void
AnalysisSingle
(
int
ChooseOptionCount
,
ImportModel
item
,
RB_Question_ViewModel
model
,
List
<
RB_Question_Type_ViewModel
>
questionTypeList
,
bool
isNumChoose
=
false
)
private
void
AnalysisSingle
(
int
ChooseOptionCount
,
ImportModel
item
,
RB_Question_ViewModel
model
,
List
<
RB_Question_Type_ViewModel
>
questionTypeList
,
bool
isNumChoose
=
false
)
{
if
(
ChooseOptionCount
>
0
)
{
...
...
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