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
79d1fbb7
Commit
79d1fbb7
authored
Jan 11, 2021
by
黄奎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
页面修改
parent
16097b7d
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
95 additions
and
7 deletions
+95
-7
XlsQuestionHelper.cs
Edu.Common/Data/XlsQuestionHelper.cs
+1
-1
RB_Question.cs
Edu.Model/Entity/Question/RB_Question.cs
+5
-0
RB_Question_ViewModel.cs
Edu.Model/ViewModel/Question/RB_Question_ViewModel.cs
+1
-1
AnalysisQuestionTypeModule.cs
Edu.Module.Question/AnalysisQuestionTypeModule.cs
+8
-1
QuestionModule.cs
Edu.Module.Question/QuestionModule.cs
+3
-1
QuestionController.cs
Edu.WebApi/Controllers/Course/QuestionController.cs
+62
-0
UploadController.cs
Edu.WebApi/Controllers/Upload/UploadController.cs
+15
-3
No files found.
Edu.Common/Data/XlsQuestionHelper.cs
View file @
79d1fbb7
...
...
@@ -7,7 +7,7 @@ namespace Edu.Common.Data
{
public
class
XlsQuestionHelper
{
public
List
<
XlsItem
>
GetXlsQuestionData
(
string
filePath
)
public
static
List
<
XlsItem
>
GetXlsQuestionData
(
string
filePath
)
{
List
<
XlsItem
>
xlsItems
=
new
List
<
XlsItem
>();
var
dt
=
Common
.
Plugin
.
NPOIHelper
.
ImportExcelToDatatable
(
filePath
,
0
,
0
,
true
);
...
...
Edu.Model/Entity/Question/RB_Question.cs
View file @
79d1fbb7
...
...
@@ -27,6 +27,11 @@ namespace Edu.Model.Entity.Question
/// </summary>
public
string
Title
{
get
;
set
;
}
/// <summary>
/// 问题内容
/// </summary>
public
string
QuestionContent
{
get
;
set
;
}
/// <summary>
/// 难易程度(1-易,2-中,3-难)
/// </summary>
...
...
Edu.Model/ViewModel/Question/RB_Question_ViewModel.cs
View file @
79d1fbb7
...
...
@@ -57,7 +57,7 @@ namespace Edu.Model.ViewModel.Question
/// <summary>
/// 选项
/// </summary>
public
object
Answer
Obj
{
get
;
set
;
}
public
object
QuestionContent
Obj
{
get
;
set
;
}
/// <summary>
/// 知识点名称
...
...
Edu.Module.Question/AnalysisQuestionTypeModule.cs
View file @
79d1fbb7
...
...
@@ -31,7 +31,14 @@ namespace Edu.Module.Question
break
;
//填空题
case
"fill-in"
:
obj
=
Common
.
Plugin
.
JsonHelper
.
DeserializeObject
<
List
<
fillInItem
>>(
data
);
if
(!
string
.
IsNullOrEmpty
(
data
))
{
obj
=
Common
.
Plugin
.
JsonHelper
.
DeserializeObject
<
List
<
fillInItem
>>(
data
);
}
else
{
obj
=
null
;
}
break
;
//判断题
case
"judge"
:
...
...
Edu.Module.Question/QuestionModule.cs
View file @
79d1fbb7
...
...
@@ -80,6 +80,7 @@ namespace Edu.Module.Question
Dictionary
<
string
,
object
>
fileds
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Question_ViewModel
.
Title
),
model
.
Title
},
{
nameof
(
RB_Question_ViewModel
.
QuestionContent
),(!
string
.
IsNullOrEmpty
(
model
.
QuestionContent
)?
model
.
QuestionContent
:
""
)
},
{
nameof
(
RB_Question_ViewModel
.
DifficultyType
),(
int
)
model
.
DifficultyType
},
{
nameof
(
RB_Question_ViewModel
.
AnswerParse
),
model
.
AnswerParse
},
{
nameof
(
RB_Question_ViewModel
.
QuestionTypeId
),
model
.
QuestionTypeId
},
...
...
@@ -151,7 +152,8 @@ namespace Edu.Module.Question
var
extModel
=
questionRepository
.
GetEntity
<
RB_Question_ViewModel
>(
QuestionId
);
if
(
extModel
!=
null
)
{
extModel
.
AnswerObj
=
analysisQuestion
.
ParsingQuestion
(
extModel
.
QuestionTypeKey
,
extModel
.
Answer
);
extModel
.
QuestionContentObj
=
analysisQuestion
.
ParsingQuestion
(
extModel
.
QuestionTypeKey
,
extModel
.
QuestionContent
);
if
(!
string
.
IsNullOrEmpty
(
extModel
.
Knowledge
))
{
extModel
.
QuestionPointList
=
GetPointListModule
(
new
RB_Question_Point_ViewModel
()
{
QPointIds
=
extModel
.
Knowledge
});
...
...
Edu.WebApi/Controllers/Course/QuestionController.cs
View file @
79d1fbb7
using
Edu.Cache.User
;
using
Edu.Common.API
;
using
Edu.Common.Data
;
using
Edu.Common.Enum.Question
;
using
Edu.Common.Plugin
;
using
Edu.Model.ViewModel.Question
;
...
...
@@ -9,6 +10,7 @@ using Microsoft.AspNetCore.Cors;
using
Microsoft.AspNetCore.Mvc
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
namespace
Edu.WebApi.Controllers.Course
{
...
...
@@ -271,5 +273,65 @@ namespace Edu.WebApi.Controllers.Course
return
flag
?
ApiResult
.
Success
()
:
ApiResult
.
Failed
();
}
#
endregion
/// <summary>
/// 导入Excel问题
/// </summary>
/// <returns></returns>
public
ApiResult
ImportExcelQuestion
(
string
filePath
,
int
CourseId
)
{
var
list
=
Common
.
Data
.
XlsQuestionHelper
.
GetXlsQuestionData
(
filePath
);
if
(
list
!=
null
&&
list
.
Count
>
0
)
{
var
difficultyList
=
Common
.
Plugin
.
EnumHelper
.
EnumToList
(
typeof
(
DifficultyTypeEnum
));
var
questionTypeList
=
questionModule
.
GetQuestionTypeListModule
(
new
RB_Question_Type_ViewModel
());
foreach
(
var
item
in
list
)
{
var
model
=
GetQuestionModel
(
item
,
difficultyList
,
questionTypeList
);
model
.
CourseId
=
CourseId
;
}
}
return
ApiResult
.
Success
();
}
private
RB_Question_ViewModel
GetQuestionModel
(
XlsItem
item
,
List
<
EnumItem
>
difficultyList
,
List
<
RB_Question_Type_ViewModel
>
questionTypeList
)
{
var
DifficultyType
=
DifficultyTypeEnum
.
Easy
;
if
(
item
.
EasyType
==
"中"
)
{
DifficultyType
=
DifficultyTypeEnum
.
Middle
;
}
if
(
item
.
EasyType
==
"难"
)
{
DifficultyType
=
DifficultyTypeEnum
.
Difficult
;
}
RB_Question_ViewModel
model
=
new
RB_Question_ViewModel
{
Title
=
item
.
QuestionTitle
,
DifficultyType
=
DifficultyType
,
AnswerParse
=
item
.
AnswerAnalysis
};
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
;
}
break
;
}
return
model
;
}
}
}
\ No newline at end of file
Edu.WebApi/Controllers/Upload/UploadController.cs
View file @
79d1fbb7
...
...
@@ -5,11 +5,13 @@ using System.Linq;
using
System.Threading.Tasks
;
using
Edu.Common.API
;
using
Edu.Common.Plugin
;
using
Edu.WebApi.Controllers.Course
;
using
Edu.WebApi.Filter
;
using
Microsoft.AspNetCore.Authorization
;
using
Microsoft.AspNetCore.Cors
;
using
Microsoft.AspNetCore.Http
;
using
Microsoft.AspNetCore.Mvc
;
using
Newtonsoft.Json.Linq
;
namespace
Edu.WebApi.Controllers.Upload
{
...
...
@@ -26,7 +28,7 @@ namespace Edu.WebApi.Controllers.Upload
/// <returns></returns>
[
HttpPost
]
[
AllowAnonymous
]
public
ApiResult
Upload
ExcelQuestion
()
public
ApiResult
Upload
File
()
{
try
{
...
...
@@ -35,6 +37,10 @@ namespace Edu.WebApi.Controllers.Upload
{
return
new
ApiResult
{
Code
=
(
int
)
ResultCode
.
Fail
,
Message
=
"未选择文件"
,
Data
=
""
};
}
var
json
=
!
string
.
IsNullOrEmpty
(
Request
.
Form
[
"params"
])
?
JObject
.
Parse
(
Request
.
Form
[
"params"
].
ToString
())
:
null
;
Int32
.
TryParse
(
json
[
"Analysis"
].
ToString
(),
out
int
Analysis
);
Int32
.
TryParse
(
json
[
"Excel"
].
ToString
(),
out
int
Excel
);
Int32
.
TryParse
(
json
[
"CourseId"
].
ToString
(),
out
int
CourseId
);
string
filename
=
files
[
0
].
FileName
;
string
fileExtention
=
System
.
IO
.
Path
.
GetExtension
(
files
[
0
].
FileName
);
...
...
@@ -42,7 +48,8 @@ namespace Edu.WebApi.Controllers.Upload
List
<
string
>
ExtList
=
new
List
<
string
>()
{
".xls"
,
".xlsx"
,
".csv"
".doc"
,
".docx"
};
if
(!
ExtList
.
Contains
(
fileExtention
))
{
...
...
@@ -59,7 +66,12 @@ namespace Edu.WebApi.Controllers.Upload
{
files
[
0
].
CopyTo
(
fstream
);
}
//导入Excel文件
if
(
Analysis
==
1
&&
Excel
==
1
&&
CourseId
>
0
)
{
return
new
QuestionController
().
ImportExcelQuestion
(
path_server
,
CourseId
);
}
return
ApiResult
.
Success
(
""
,
new
{
Name
=
filename
,
Path
=
path_server
});
}
catch
(
Exception
ex
)
...
...
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