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
9e9b119f
Commit
9e9b119f
authored
Jan 11, 2021
by
黄奎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
页面修改
parent
79d1fbb7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
322 additions
and
14 deletions
+322
-14
XlsQuestionHelper.cs
Edu.Common/Data/XlsQuestionHelper.cs
+9
-1
ConvertHelper.cs
Edu.Common/Plugin/ConvertHelper.cs
+15
-0
RB_AccountRepository.cs
Edu.Repository/User/RB_AccountRepository.cs
+2
-1
QuestionController.cs
Edu.WebApi/Controllers/Course/QuestionController.cs
+296
-12
No files found.
Edu.Common/Data/XlsQuestionHelper.cs
View file @
9e9b119f
...
...
@@ -5,8 +5,16 @@ using System.Text;
namespace
Edu.Common.Data
{
public
class
XlsQuestionHelper
/// <summary>
/// 导入问题帮助类
/// </summary>
public
class
QuestionHelper
{
/// <summary>
/// 根据Excel文件获取问题列表
/// </summary>
/// <param name="filePath"></param>
/// <returns></returns>
public
static
List
<
XlsItem
>
GetXlsQuestionData
(
string
filePath
)
{
List
<
XlsItem
>
xlsItems
=
new
List
<
XlsItem
>();
...
...
Edu.Common/Plugin/ConvertHelper.cs
View file @
9e9b119f
...
...
@@ -198,6 +198,21 @@ namespace Edu.Common
{
return
Regex
.
IsMatch
(
StrSource
,
@"^((20|21|22|23|[0-1]?\d):[0-5]?\d:[0-5]?\d)$"
);
}
/// <summary>
/// 获取英文字母
/// </summary>
/// <param name="index"></param>
/// <returns></returns>
public
static
string
GetEnChar
(
int
index
)
{
string
[]
tempArray
=
{
"A"
,
"B"
,
"C"
,
"D"
,
"E"
,
"F"
,
"G"
,
"H"
,
"I"
,
"J"
,
"K"
,
"L"
,
"M"
,
"N"
,
"O"
,
"P"
,
"Q"
,
"R"
,
"S"
,
"T"
,
"U"
,
"V"
,
"W"
,
"X"
,
"Y"
,
"Z"
};
if
(
index
<
tempArray
.
Length
)
{
return
tempArray
[
index
];
}
return
""
;
}
}
}
\ No newline at end of file
Edu.Repository/User/RB_AccountRepository.cs
View file @
9e9b119f
...
...
@@ -215,6 +215,7 @@ WHERE 1=1 {1}
StringBuilder
wheremanager
=
new
StringBuilder
();
StringBuilder
whereteacher
=
new
StringBuilder
();
StringBuilder
whereassist
=
new
StringBuilder
();
where
.
AppendFormat
(
" AND A.{0}={1} "
,
nameof
(
Employee_ViewModel
.
Status
),
(
int
)
DateStateEnum
.
Normal
);
if
(
query
!=
null
)
{
if
(
query
.
Group_Id
>
0
)
...
...
@@ -346,7 +347,7 @@ FROM
,b.School_Id,IFNULL(B.AssistName,'') AS EmployeeName,B.AssistIcon AS UserIcon,B.Dept_Id,B.Post_Id,B.IDCard
,B.Sex,B.Education,B.EntryTime,B.Address,B.BirthDate
,B.LeaveStatus,B.LeaveTime,B.AssistTel AS EmployeeTel,IFNULL(B.Email,'') AS Email
FROM rb_assist AS B LEFT JOIN rb_account AS A ON A.AccountId=B.AId AND A.AccountType=3
FROM rb_assist AS B LEFT JOIN rb_account AS A ON A.AccountId=B.AId AND A.AccountType=3
WHERE 1=1 {0} {3}
) AS A LEFT JOIN rb_group AS g ON A.Group_Id=g.GId
LEFT JOIN rb_school AS s ON A.School_Id=s.SId
...
...
Edu.WebApi/Controllers/Course/QuestionController.cs
View file @
9e9b119f
...
...
@@ -280,7 +280,8 @@ namespace Edu.WebApi.Controllers.Course
/// <returns></returns>
public
ApiResult
ImportExcelQuestion
(
string
filePath
,
int
CourseId
)
{
var
list
=
Common
.
Data
.
XlsQuestionHelper
.
GetXlsQuestionData
(
filePath
);
var
resultList
=
new
List
<
RB_Question_ViewModel
>();
var
list
=
Common
.
Data
.
QuestionHelper
.
GetXlsQuestionData
(
filePath
);
if
(
list
!=
null
&&
list
.
Count
>
0
)
{
var
difficultyList
=
Common
.
Plugin
.
EnumHelper
.
EnumToList
(
typeof
(
DifficultyTypeEnum
));
...
...
@@ -289,6 +290,7 @@ namespace Edu.WebApi.Controllers.Course
{
var
model
=
GetQuestionModel
(
item
,
difficultyList
,
questionTypeList
);
model
.
CourseId
=
CourseId
;
resultList
.
Add
(
model
);
}
}
return
ApiResult
.
Success
();
...
...
@@ -305,27 +307,309 @@ namespace Edu.WebApi.Controllers.Course
{
DifficultyType
=
DifficultyTypeEnum
.
Difficult
;
}
var
questionTypeModel
=
questionTypeList
?.
Where
(
qitem
=>
qitem
.
Name
==
item
.
QuestionTypeName
)?.
FirstOrDefault
();
RB_Question_ViewModel
model
=
new
RB_Question_ViewModel
{
Title
=
item
.
QuestionTitle
,
DifficultyType
=
DifficultyType
,
AnswerParse
=
item
.
AnswerAnalysis
DifficultyType
=
DifficultyType
,
AnswerParse
=
item
.
AnswerAnalysis
,
QuestionTypeId
=
questionTypeModel
?.
QId
??
0
,
QuestionTypeKey
=
questionTypeModel
?.
Key
??
""
,
};
Int32
.
TryParse
(
item
.
ChooseOptionCount
,
out
int
ChooseOptionCount
);
switch
(
item
.
QuestionTypeName
)
{
case
"单选题"
:
Int32
.
TryParse
(
item
.
ChooseOptionCount
,
out
int
ChooseOptionCount
);
if
(
ChooseOptionCount
>
0
)
{
List
<
optionItem
>
singleList
=
new
List
<
optionItem
>();
//for (var i = 0; i < ChooseOptionCount; i++)
//{
// singleList.Add(new optionItem() {
// Name=
// })
//}
model
.
QuestionContentObj
=
singleList
;
for
(
var
i
=
0
;
i
<
ChooseOptionCount
;
i
++)
{
var
singleModel
=
new
optionItem
()
{
Name
=
Common
.
ConvertHelper
.
GetEnChar
(
i
),
Content
=
""
,
IsAnswer
=
item
.
QuestionAnswer
.
Contains
(
Common
.
ConvertHelper
.
GetEnChar
(
i
))
};
if
(
i
==
0
)
{
singleModel
.
Content
=
item
.
OptionA
;
}
if
(
i
==
1
)
{
singleModel
.
Content
=
item
.
OptionB
;
}
if
(
i
==
2
)
{
singleModel
.
Content
=
item
.
OptionC
;
}
if
(
i
==
3
)
{
singleModel
.
Content
=
item
.
OptionD
;
}
if
(
i
==
4
)
{
singleModel
.
Content
=
item
.
OptionE
;
}
if
(
i
==
5
)
{
singleModel
.
Content
=
item
.
OptionF
;
}
if
(
i
==
6
)
{
singleModel
.
Content
=
item
.
OptionG
;
}
if
(
i
==
7
)
{
singleModel
.
Content
=
item
.
OptionH
;
}
if
(
singleModel
.
IsAnswer
)
{
model
.
Answer
=
singleModel
.
Name
;
}
singleList
.
Add
(
singleModel
);
}
model
.
QuestionContent
=
Common
.
Plugin
.
JsonHelper
.
Serialize
(
singleList
);
}
if
(
model
.
QuestionTypeId
==
0
)
{
var
tempModel
=
questionTypeList
.
Where
(
qitem
=>
qitem
.
Key
==
"single"
)?.
FirstOrDefault
();
model
.
QuestionTypeId
=
tempModel
?.
QId
??
0
;
model
.
QuestionTypeKey
=
tempModel
?.
Key
??
""
;
}
break
;
case
"多选题"
:
if
(
ChooseOptionCount
>
0
)
{
List
<
optionItem
>
multipleList
=
new
List
<
optionItem
>();
string
answer
=
""
;
for
(
var
i
=
0
;
i
<
ChooseOptionCount
;
i
++)
{
var
singleModel
=
new
optionItem
()
{
Name
=
Common
.
ConvertHelper
.
GetEnChar
(
i
),
Content
=
""
,
IsAnswer
=
item
.
QuestionAnswer
.
Contains
(
Common
.
ConvertHelper
.
GetEnChar
(
i
))
};
if
(
i
==
0
)
{
singleModel
.
Content
=
item
.
OptionA
;
}
if
(
i
==
1
)
{
singleModel
.
Content
=
item
.
OptionB
;
}
if
(
i
==
2
)
{
singleModel
.
Content
=
item
.
OptionC
;
}
if
(
i
==
3
)
{
singleModel
.
Content
=
item
.
OptionD
;
}
if
(
i
==
4
)
{
singleModel
.
Content
=
item
.
OptionE
;
}
if
(
i
==
5
)
{
singleModel
.
Content
=
item
.
OptionF
;
}
if
(
i
==
6
)
{
singleModel
.
Content
=
item
.
OptionG
;
}
if
(
i
==
7
)
{
singleModel
.
Content
=
item
.
OptionH
;
}
if
(
singleModel
.
IsAnswer
)
{
answer
+=
","
+
singleModel
.
Name
;
}
multipleList
.
Add
(
singleModel
);
}
if
(!
string
.
IsNullOrEmpty
(
answer
))
{
answer
=
answer
.
Substring
(
1
);
}
model
.
Answer
=
answer
;
model
.
QuestionContent
=
Common
.
Plugin
.
JsonHelper
.
Serialize
(
multipleList
);
}
if
(
model
.
QuestionTypeId
==
0
)
{
var
tempModel
=
questionTypeList
.
Where
(
qitem
=>
qitem
.
Key
==
"multiple"
)?.
FirstOrDefault
();
model
.
QuestionTypeId
=
tempModel
?.
QId
??
0
;
model
.
QuestionTypeKey
=
tempModel
?.
Key
??
""
;
}
break
;
case
"填空题"
:
if
(
ChooseOptionCount
>
0
)
{
List
<
fillInItem
>
fillInList
=
new
List
<
fillInItem
>();
string
answer
=
""
;
for
(
var
i
=
0
;
i
<
ChooseOptionCount
;
i
++)
{
var
singleModel
=
new
fillInItem
()
{
Content
=
""
,
};
if
(
i
==
0
)
{
singleModel
.
Content
=
item
.
OptionA
;
}
if
(
i
==
1
)
{
singleModel
.
Content
=
item
.
OptionB
;
}
if
(
i
==
2
)
{
singleModel
.
Content
=
item
.
OptionC
;
}
if
(
i
==
3
)
{
singleModel
.
Content
=
item
.
OptionD
;
}
if
(
i
==
4
)
{
singleModel
.
Content
=
item
.
OptionE
;
}
if
(
i
==
5
)
{
singleModel
.
Content
=
item
.
OptionF
;
}
if
(
i
==
6
)
{
singleModel
.
Content
=
item
.
OptionG
;
}
if
(
i
==
7
)
{
singleModel
.
Content
=
item
.
OptionH
;
}
fillInList
.
Add
(
singleModel
);
}
if
(!
string
.
IsNullOrEmpty
(
answer
))
{
answer
=
answer
.
Substring
(
1
);
}
model
.
Answer
=
answer
;
model
.
QuestionContent
=
Common
.
Plugin
.
JsonHelper
.
Serialize
(
fillInList
);
}
if
(
model
.
QuestionTypeId
==
0
)
{
var
tempModel
=
questionTypeList
.
Where
(
qitem
=>
qitem
.
Key
==
"fill-in"
)?.
FirstOrDefault
();
model
.
QuestionTypeId
=
tempModel
?.
QId
??
0
;
model
.
QuestionTypeKey
=
tempModel
?.
Key
??
""
;
}
break
;
case
"判断题"
:
if
(
ChooseOptionCount
>
0
)
{
List
<
optionItem
>
judgeList
=
new
List
<
optionItem
>();
for
(
var
i
=
0
;
i
<
ChooseOptionCount
;
i
++)
{
var
singleModel
=
new
optionItem
()
{
Name
=
Common
.
ConvertHelper
.
GetEnChar
(
i
),
Content
=
""
,
IsAnswer
=
item
.
QuestionAnswer
.
Contains
(
Common
.
ConvertHelper
.
GetEnChar
(
i
))
};
if
(
i
==
0
)
{
singleModel
.
Content
=
item
.
OptionA
;
}
if
(
i
==
1
)
{
singleModel
.
Content
=
item
.
OptionB
;
}
if
(
i
==
2
)
{
singleModel
.
Content
=
item
.
OptionC
;
}
if
(
i
==
3
)
{
singleModel
.
Content
=
item
.
OptionD
;
}
if
(
i
==
4
)
{
singleModel
.
Content
=
item
.
OptionE
;
}
if
(
i
==
5
)
{
singleModel
.
Content
=
item
.
OptionF
;
}
if
(
i
==
6
)
{
singleModel
.
Content
=
item
.
OptionG
;
}
if
(
i
==
7
)
{
singleModel
.
Content
=
item
.
OptionH
;
}
if
(
singleModel
.
IsAnswer
)
{
model
.
Answer
=
singleModel
.
Name
;
}
judgeList
.
Add
(
singleModel
);
}
model
.
QuestionContent
=
Common
.
Plugin
.
JsonHelper
.
Serialize
(
judgeList
);
}
if
(
model
.
QuestionTypeId
==
0
)
{
var
tempModel
=
questionTypeList
.
Where
(
qitem
=>
qitem
.
Key
==
"judge"
)?.
FirstOrDefault
();
model
.
QuestionTypeId
=
tempModel
?.
QId
??
0
;
model
.
QuestionTypeKey
=
tempModel
?.
Key
??
""
;
}
break
;
case
"简答题"
:
if
(
ChooseOptionCount
>
0
)
{
for
(
var
i
=
0
;
i
<
ChooseOptionCount
;
i
++)
{
if
(
i
==
0
)
{
model
.
QuestionContent
=
item
.
OptionA
;
}
if
(
i
==
1
)
{
model
.
QuestionContent
=
item
.
OptionB
;
}
if
(
i
==
2
)
{
model
.
QuestionContent
=
item
.
OptionC
;
}
if
(
i
==
3
)
{
model
.
QuestionContent
=
item
.
OptionD
;
}
if
(
i
==
4
)
{
model
.
QuestionContent
=
item
.
OptionE
;
}
if
(
i
==
5
)
{
model
.
QuestionContent
=
item
.
OptionF
;
}
if
(
i
==
6
)
{
model
.
QuestionContent
=
item
.
OptionG
;
}
if
(
i
==
7
)
{
model
.
QuestionContent
=
item
.
OptionH
;
}
}
}
if
(
model
.
QuestionTypeId
==
0
)
{
var
tempModel
=
questionTypeList
.
Where
(
qitem
=>
qitem
.
Key
==
"short-answer"
)?.
FirstOrDefault
();
model
.
QuestionTypeId
=
tempModel
?.
QId
??
0
;
model
.
QuestionTypeKey
=
tempModel
?.
Key
??
""
;
}
break
;
...
...
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