Commit 04b0d22a authored by 黄奎's avatar 黄奎

新增导入类

parent ca1904a4
using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
namespace Edu.Common.Data
{
/// <summary>
/// 课程章节处理类
/// </summary>
public class CourseChapterHelper
{
/// <summary>
/// 根据Excel文件获取问题列表
/// </summary>
/// <param name="filePath"></param>
/// <returns></returns>
public static List<CourseChapterModel> GetXlsCourseChapterData(string filePath)
{
List<CourseChapterModel> xlsItems = new List<CourseChapterModel>();
var dt = Common.Plugin.NPOIHelper.ImportExcelToDatatable(filePath, 0, 0, true);
if (dt != null && dt.Rows.Count > 0)
{
foreach (DataRow item in dt.Rows)
{
xlsItems.Add(DataRowToModel(item));
}
}
return xlsItems;
}
/// <summary>
/// DataRow转实体
/// </summary>
/// <param name="dr"></param>
/// <returns></returns>
private static CourseChapterModel DataRowToModel(DataRow dr)
{
CourseChapterModel model = new CourseChapterModel();
if (dr != null)
{
if (dr.Table.Columns.Contains("第~次课") && !string.IsNullOrEmpty(dr["第~次课"].ToString()))
{
model.ChapterName = dr["第~次课"].ToString();
}
if (dr.Table.Columns.Contains("对应章节") && !string.IsNullOrEmpty(dr["对应章节"].ToString()))
{
model.ChapterName += " "+dr["对应章节"].ToString();
}
if (dr.Table.Columns.Contains("内容") && !string.IsNullOrEmpty(dr["内容"].ToString()))
{
model.ChapterContent = dr["内容"].ToString();
}
if (dr.Table.Columns.Contains("时长") && !string.IsNullOrEmpty(dr["时长"].ToString()))
{
model.StudyHours = 2;
model.StudyMinutes = 90;
}
}
return model;
}
}
/// <summary>
/// 课程章节导入实体
/// </summary>
public class CourseChapterModel
{
/// <summary>
/// 章节名称
/// </summary>
public string ChapterName { get; set; }
/// <summary>
/// 章节编号
/// </summary>
public string ChapterNo { get; set; }
/// <summary>
/// 章节内容
/// </summary>
public string ChapterContent { get; set; }
/// <summary>
/// 学习课时
/// </summary>
public double StudyHours { get; set; }
/// <summary>
/// 学习分钟
/// </summary>
public double StudyMinutes { get; set; }
}
}
...@@ -9,6 +9,7 @@ using Edu.Common.Enum.Exam; ...@@ -9,6 +9,7 @@ using Edu.Common.Enum.Exam;
using Edu.Common.Enum.Question; using Edu.Common.Enum.Question;
using Edu.Common.Enum.Sale; using Edu.Common.Enum.Sale;
using Edu.Common.Plugin; using Edu.Common.Plugin;
using Edu.Model.ViewModel.Course;
using Edu.Model.ViewModel.Exam; using Edu.Model.ViewModel.Exam;
using Edu.Model.ViewModel.Grade; using Edu.Model.ViewModel.Grade;
using Edu.Model.ViewModel.LearningGarden; using Edu.Model.ViewModel.LearningGarden;
...@@ -615,8 +616,11 @@ namespace Edu.WebApi.Controllers.Applet ...@@ -615,8 +616,11 @@ namespace Edu.WebApi.Controllers.Applet
//查询章节列表 + 完成度 + 单词测试得分 //查询章节列表 + 完成度 + 单词测试得分
var MaxChapterNo = planList.Any() ? planList.Max(x => x.LessonPlanNum) : 0; var MaxChapterNo = planList.Any() ? planList.Max(x => x.LessonPlanNum) : 0;
//查询所有的章节 //查询所有的章节
var chapterTreeList = courseModule.GetChapterTreeListModule_V2(new Model.ViewModel.Course.RB_Course_Chapter_ViewModel() { Group_Id = appletUserInfo.Group_Id, CourseId = CourseId }); var chapterTreeList = courseModule.GetChapterTreeListModule_V2(new RB_Course_Chapter_ViewModel() { Group_Id = appletUserInfo.Group_Id, CourseId = CourseId });
var ctList = chapterTreeList.Where(x => Convert.ToInt32(x.ChapterNo) <= MaxChapterNo).OrderByDescending(qitem => Convert.ToInt32(qitem.ChapterNo)).ToList(); var ctList = new List<ChapterTree_ViewModel>();
//ctList = chapterTreeList.Where(x => Convert.ToInt32(x.ChapterNo) <= MaxChapterNo).OrderByDescending(qitem => Convert.ToInt32(qitem.ChapterNo)).ToList();
ctList = chapterTreeList.OrderByDescending(qitem => Convert.ToInt32(qitem.ChapterNo)).ToList();
//章节单词得分 //章节单词得分
var prepWordsList = courseExamModule.GetStuWordsPrepListModule(new RB_StuWords_Prep_Extend() var prepWordsList = courseExamModule.GetStuWordsPrepListModule(new RB_StuWords_Prep_Extend()
{ {
......
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