开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
捐赠
捐赠前请先登录
扫描微信二维码支付
取消
支付完成
支付提示
将跳转至支付宝完成支付
确定
取消
1 Star 0 Fork 319

凤凰智能/视频学习+在线考试+题库+直播

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
master
分支 (1)
标签 (8)
master
2.3
2.1.1.21041
2.0.8627
2.0.8499
2.0.8460
2.0.8384
2.0.8355
2.0Beta
master
分支 (1)
标签 (8)
master
2.3
2.1.1.21041
2.0.8627
2.0.8499
2.0.8460
2.0.8384
2.0.8355
2.0Beta
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
master
分支 (1)
标签 (8)
master
2.3
2.1.1.21041
2.0.8627
2.0.8499
2.0.8460
2.0.8384
2.0.8355
2.0Beta
StudentCom.cs 19.43 KB
一键复制 编辑 原始数据 按行查看 历史
宋_微厦科技 提交于 2024年08月12日 22:03 +08:00 . 编写学员组的导出
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WeiSha.Core;
using WeiSha.Data;
using Song.Entities;
using Song.ServiceInterfaces;
namespace Song.DataQuery.SQLite
{
public class StudentCom
{
/// <summary>
/// 高频错题
/// </summary>
/// <param name="couid">课程ID</param>
/// <param name="type">题型</param>
/// <param name="count">取多少条</param>
/// <returns></returns>
public Questions[] QuesOftenwrong(long couid, int type, int count)
{
string sql = @"
select {top} sq.count as Qus_Errornum,c.*
from ""Questions"" as c
inner join
(
SELECT ""Qus_ID"",COUNT(*) as count
FROM ""Student_Ques""
where {couid} and {type} group by ""Qus_ID""
) as sq on c.""Qus_ID"" = sq.""Qus_ID""
order by sq.count desc ";
sql = sql.Replace("{couid}", couid > 0 ? @"""Cou_ID""=" + couid : "1=1");
sql = sql.Replace("{type}", type > 0 ? @"""Qus_Type""=" + type : "1=1");
if (count > 0) sql += "limit " + count + " offset 0";
return Gateway.Default.FromSql(sql).ToArray<Questions>();
}
/// <summary>
/// 登录日志的统计信息
/// </summary>
/// <param name="orgid"></param>
/// <param name="start"></param>
/// <param name="end"></param>
/// <param name="province"></param>
/// <param name="city"></param>
/// <returns>返回三列,area:行政区划名称,code:区划编码,count:登录人次</returns>
public DataTable LoginLogsSummary(int orgid, DateTime? start, DateTime? end, string province, string city)
{
//支持Posgresql
string sql = @"SELECT
CASE
WHEN ""{{field}}"" = ''
THEN 'Other'
ELSE COALESCE(""{{field}}"", 'Other')
END AS area
,MAX(""Lso_Code"") as code
,count(*) as count
FROM ""LogForStudentOnline""
WHERE {{orgid}} and {{start}} and {{end}} and {{parent}}='{{area}}'
GROUP BY area order by count desc";
sql = sql.Replace("{{orgid}}", orgid > 0 ? @"""Org_ID""=" + orgid : "1=1");
sql = sql.Replace("{{start}}", start == null ? "1=1" : @"""Lso_LoginTime"">='" + ((DateTime)start).ToString("yyyy-MM-dd HH:mm:ss") + "'");
sql = sql.Replace("{{end}}", end == null ? "1=1" : @"""Lso_LoginTime""<'" + ((DateTime)end).ToString("yyyy-MM-dd HH:mm:ss") + "'");
if (string.IsNullOrWhiteSpace(province) && string.IsNullOrWhiteSpace(city))
{
sql = sql.Replace("{{field}}", "Lso_Province");
sql = sql.Replace("{{parent}}", "''");
sql = sql.Replace("{{area}}", "");
}
else if (!string.IsNullOrWhiteSpace(province))
{
sql = sql.Replace("{{field}}", "Lso_City");
sql = sql.Replace("{{parent}}", @"""Lso_Province""");
sql = sql.Replace("{{area}}", province);
}
else if (!string.IsNullOrWhiteSpace(city))
{
sql = sql.Replace("{{field}}", "Lso_District");
sql = sql.Replace("{{parent}}", @"""Lso_City""");
sql = sql.Replace("{{area}}", city);
}
DataSet ds = Gateway.Default.FromSql(sql).ToDataSet();
return ds.Tables[0];
}
/// <summary>
/// 错题所属的课程
/// </summary>
/// <param name="stid">学员id</param>
/// <param name="couname">课程名称,可模糊查询</param>
/// <param name="size"></param>
/// <param name="index"></param>
/// <param name="countSum"></param>
/// <returns></returns>
public Course[] QuesForCourse(int stid, string couname, int size, int index, out int countSum)
{
//计算满足条件的数量
string sumSql = @"select COUNT(*) from ""Course"" as c inner join
(select ""Cou_ID"" from ""Student_Ques"" where ""Ac_ID"" = {stid} group by ""Cou_ID"") as q
on c.""Cou_ID"" = q.""Cou_ID"" where {course}";
sumSql = sumSql.Replace("{stid}", stid.ToString());
sumSql = sumSql.Replace("{course}", string.IsNullOrWhiteSpace(couname) ? "1=1" : @"""Cou_Name"" LIKE '%" + couname + "%'");
countSum = Convert.ToInt32(Gateway.Default.FromSql(sumSql).ToScalar());
//分页获取数据
string sql = @"select cou.*,sq.count from ""Course"" as cou inner join
(select ""Cou_ID"", max(""Squs_ID"") as sid, COUNT(*) as count from ""Student_Ques"" where ""Ac_ID"" = {stid} group by ""Cou_ID"") as sq
on cou.""Cou_ID"" = sq.""Cou_ID"" where {course} ORDER BY sq.count desc
LIMIT {{size}} OFFSET {{index}}";
sql = sql.Replace("{stid}", stid.ToString());
sql = sql.Replace("{course}", string.IsNullOrWhiteSpace(couname) ? "1=1" : @"""Cou_Name"" LIKE '%" + couname + "%'");
//分页
sql = sql.Replace("{{size}}", size.ToString());
sql = sql.Replace("{{index}}", ((index - 1) * size).ToString());
return Gateway.Default.FromSql(sql).ToArray<Course>();
}
/// <summary>
/// 购买的课程的学员,不重复
/// </summary>
/// <param name="orgid"></param>
/// <param name="stsid"></param>
/// <param name="couid"></param>
/// <param name="acc"></param>
/// <param name="name"></param>
/// <param name="idcard"></param>
/// <param name="mobi"></param>
/// <param name="start"></param>
/// <param name="end"></param>
/// <param name="size"></param>
/// <param name="index"></param>
/// <param name="countSum"></param>
/// <returns>Ac_CurrCourse列为学员选修的课程数</returns>
public List<Accounts> PurchasePager(int orgid, long stsid, long couid,
string acc, string name, string idcard, string mobi,
DateTime? start, DateTime? end, int size, int index, out int countSum)
{
//支持Sqlite
//计算总数的脚本
string sqlsum = @"select COUNT(*) as total from
(select ""Ac_ID"",count(""Ac_ID"") as count from
(select * from ""Student_Course"" where {{where4sc}} and ({{start}} and {{end}}) ) as ss group by ""Ac_ID""
) as sc inner join
""Accounts"" as a on sc.""Ac_ID"" = a.""Ac_ID"" {{where4acc}}"; ;
//购买记录的条件
string where4sc = "{{orgid}} and {{couid}} and {{stsid}}";
where4sc = where4sc.Replace("{{orgid}}", orgid > 0 ? @"""Student_Course"".""Org_ID"" =" + orgid.ToString() : "1=1");
where4sc = where4sc.Replace("{{couid}}", couid > 0 ? @"""Student_Course"".""Cou_ID"" =" + couid.ToString() : "1=1");
where4sc = where4sc.Replace("{{stsid}}", stsid > 0 ? @"""Student_Course"".""Sts_ID"" =" + stsid.ToString() : "1=1");
//学员查询条件
string where4acc = "where {{acc}} and {{name}} and {{idcard}} and {{mobi}}";
where4acc = where4acc.Replace("{{acc}}", string.IsNullOrWhiteSpace(acc) ? "1=1" : @"a.""Ac_AccName"" LIKE '%" + acc + "%'");
where4acc = where4acc.Replace("{{name}}", string.IsNullOrWhiteSpace(name) ? "1=1" : @"a.""Ac_Name"" LIKE '%" + name + "%'");
where4acc = where4acc.Replace("{{idcard}}", string.IsNullOrWhiteSpace(idcard) ? "1=1" : @"a.""Ac_IDCardNumber"" LIKE '%" + idcard + "%'");
where4acc = where4acc.Replace("{{mobi}}", string.IsNullOrWhiteSpace(mobi) ? "1=1" : @"a.""Ac_MobiTel1"" LIKE '%" + mobi + "%'");
//计算满足条件的记录总数
sqlsum = sqlsum.Replace("{{start}}", start == null ? "1=1" : @"""Stc_StartTime"">='" + ((DateTime)start).ToString("yyyy-MM-dd HH:mm:ss") + "'");
sqlsum = sqlsum.Replace("{{end}}", end == null ? "1=1" : @"""Stc_StartTime""<'" + ((DateTime)end).ToString("yyyy-MM-dd HH:mm:ss") + "'");
sqlsum = sqlsum.Replace("{{where4acc}}", where4acc);
sqlsum = sqlsum.Replace("{{where4sc}}", where4sc);
object o = Gateway.Default.FromSql(sqlsum).ToScalar();
countSum = Convert.ToInt32(o);
//分页查询的脚本
string sqljquery = @"
select a.""Ac_ID"",sc.count as Ac_CurrCourse,""Ac_AccName"",""Ac_Name"",""Ac_IDCardNumber"",""Ac_Age"",""Ac_Photo"",
""Ac_Money"",""Ac_Point"",""Ac_Coupon"",""Org_ID"",""Sts_ID"",""Sts_Name"",""Ac_Sex"",""Ac_MobiTel1"",""Ac_MobiTel2""
from
(
select * from
(select ""Ac_ID"", count(""Ac_ID"") as count from
(select * from ""Student_Course"" {{where4acc}} and({{start}} and {{end}})) as ss group by ""Ac_ID""
) order by count desc
) as sc
inner join
""Accounts"" as a on sc.""Ac_ID"" = a.""Ac_ID"" {{where4acc}}
LIMIT {{size}} OFFSET {{index}}
";
sqljquery = sqljquery.Replace("{{start}}", start == null ? "1=1" : @"""Stc_StartTime"">='" + ((DateTime)start).ToString("yyyy-MM-dd HH:mm:ss") + "'");
sqljquery = sqljquery.Replace("{{end}}", end == null ? "1=1" : @"""Stc_StartTime""<'" + ((DateTime)end).ToString("yyyy-MM-dd HH:mm:ss") + "'");
sqljquery = sqljquery.Replace("{{where4acc}}", where4acc);
sqljquery = sqljquery.Replace("{{where4sc}}", where4sc);
//分页
sqljquery = sqljquery.Replace("{{size}}", size.ToString());
sqljquery = sqljquery.Replace("{{index}}", ((index - 1) * size).ToString());
return Gateway.Default.FromSql(sqljquery).ToList<Accounts>();
}
/// <summary>
/// 学员的活跃情况
/// </summary>
/// <param name="orgid">机构id</param>
/// <param name="stsid">学员组id</param>
/// <param name="acc">账号</param>
/// <param name="name">姓名</param>
/// <param name="mobi">手机号</param>
/// <param name="idcard">身份证号</param>
/// <param name="code">学号</param>
/// <param name="orderby">排序字段</param>
/// <param name="orderpattr">排序方式,asc或desc</param>
/// <returns></returns>
public DataTable Activation(int orgid, long stsid, string acc, string name, string mobi, string idcard, string code,
string orderby, string orderpattr,
int size, int index, out int countSum)
{
string sql = @"
select acc.""Ac_ID"",""Ac_Name"",""Ac_AccName"",""Ac_Sex"",""Ac_Photo"",""Ac_IDCardNumber"",""Ac_MobiTel1"",""Ac_LastTime"",""Sts_ID"",""Sts_Name"",""Ac_Money""
,logincount,logintime
,coursecount,rechargecount,lastrecharge,laststudy,lastexrcise,lasttest,lastexam
from ""Accounts"" as acc
left join --登录次数与最后登录时间
(select ""Ac_ID"", COUNT(0) as logincount, max(""Lso_CrtTime"") as logintime from ""LogForStudentOnline"" group by ""Ac_ID"") as ol
on acc.""Ac_ID"" = ol.""Ac_ID""
left join --课程购买个数
(select ""Ac_ID"", COUNT(0) as coursecount from ""Student_Course"" group by ""Ac_ID"") as buy
on acc.""Ac_ID"" = buy.""Ac_ID""
left join ----资金动向
(select ""Ac_ID"", COUNT(*) as rechargecount, max(""Ma_CrtTime"") as lastrecharge from ""MoneyAccount"" where ""Ma_Type"" = 2 group by ""Ac_ID"") as recharge
on acc.""Ac_ID"" = recharge.""Ac_ID""
left join --视频学习记录
(select ""Ac_ID"", max(""Lss_LastTime"") as laststudy from ""LogForStudentStudy"" group by ""Ac_ID"") as video
on acc.""Ac_ID"" = video.""Ac_ID""
left join --试题练习记录
(select ""Ac_ID"", max(""Lse_LastTime"") as lastexrcise from ""LogForStudentExercise"" group by ""Ac_ID"") as ques
on acc.""Ac_ID"" = ques.""Ac_ID""
left join --测试成绩
(select ""Ac_ID"", max(""Tr_CrtTime"") as lasttest from ""TestResults"" group by ""Ac_ID"") as test
on acc.""Ac_ID"" = test.""Ac_ID""
left join --考试成绩
(select ""Ac_ID"", max(""Exr_CrtTime"") as lastexam from ""ExamResults"" group by ""Ac_ID"") as exam
on acc.""Ac_ID"" = exam.""Ac_ID""
--查询条件
where {{where}}
ORDER BY ""{{orderby}}"" {{orderpattr}}
LIMIT {{size}} OFFSET {{index}}";
//查询条件
string wheresql = @" {{orgid}} and {{stsid}} and {{acc}} and {{name}} and {{mobi}} and {{idcard}} and {{code}}";
wheresql = wheresql.Replace("{{orgid}}", orgid <= 0 ? "1=1" : @"""Org_ID""=" + orgid);
wheresql = wheresql.Replace("{{stsid}}", stsid <= 0 ? "1=1" : @"""Sts_ID""=" + stsid);
wheresql = wheresql.Replace("{{acc}}", string.IsNullOrWhiteSpace(acc) ? "1=1" : @"""Ac_AccName"" LIKE '%" + acc + "%'");
wheresql = wheresql.Replace("{{name}}", string.IsNullOrWhiteSpace(name) ? "1=1" : @"""Ac_Name"" LIKE '%" + name + "%'");
wheresql = wheresql.Replace("{{mobi}}", string.IsNullOrWhiteSpace(mobi) ? "1=1" : @"""Ac_MobiTel1"" LIKE '%" + mobi + "%'");
wheresql = wheresql.Replace("{{idcard}}", string.IsNullOrWhiteSpace(idcard) ? "1=1" : @"""Ac_IDCardNumber"" LIKE '%" + idcard + "%'");
wheresql = wheresql.Replace("{{code}}", string.IsNullOrWhiteSpace(code) ? "1=1" : @"""Ac_CodeNumber"" LIKE '%" + code + "%'");
//获取记录总数
string sumSql = @"select COUNT(*) from ""Accounts"" where " + wheresql;
countSum = Convert.ToInt32(Gateway.Default.FromSql(sumSql).ToScalar());
//查询
sql = sql.Replace("{{where}}", wheresql);
//排序条件与方式
sql = sql.Replace("{{orderby}}", string.IsNullOrWhiteSpace(orderby) ? "Ac_LastTime" : orderby);
sql = sql.Replace("{{orderpattr}}", "asc".Equals(orderpattr, StringComparison.OrdinalIgnoreCase) ? "ASC" : "DESC");
//分页
sql = sql.Replace("{{size}}", size.ToString());
sql = sql.Replace("{{index}}", ((index - 1) * size).ToString());
DataSet ds = Gateway.Default.FromSql(sql).ToDataSet();
return ds.Tables[0];
}
/// <summary>
/// 学员的学习记录
/// </summary>
/// <param name="acid">学员id</param>
/// <returns>datatable中,LastTime:最后学习时间; studyTime:累计学习时间,complete:完成度百分比</returns>
public DataTable StudentStudyCourseLog(int acid)
{
Accounts student = Gateway.Default.From<Accounts>().Where(Accounts._.Ac_ID == acid).ToFirst<Accounts>();
if (student == null) throw new Exception("当前学员不存在!");
Organization org = Gateway.Default.From<Organization>().Where(Organization._.Org_ID == student.Org_ID).ToFirst<Organization>();
if (org == null) throw new Exception("学员所在的机构不存在!");
WeiSha.Core.CustomConfig config = CustomConfig.Load(org.Org_Config);
//容差,例如完成度小于5%,则默认100%
int tolerance = config["VideoTolerance"].Value.Int32 ?? 5;
string sql = @"
select ""Cou_ID"",""Cou_Name"",""Sbj_ID"",lastTime,studyTime,complete from ""Course"" as c inner join
(select s.couid, max(lastTime) as lastTime, sum(studyTime) as studyTime,
sum(case when complete >= 100 then 100 else complete end) as complete
from
(SELECT ""Ol_ID"", MAX(""Cou_ID"") as couid, MAX(""Lss_LastTime"") as lastTime,
sum(""Lss_StudyTime"") as studyTime, MAX(""Lss_Duration"") as totalTime, MAX(""Lss_PlayTime"") as playTime,
(case when max(""Lss_Duration"") > 0 then
CAST((1000 * (CAST(sum(""Lss_StudyTime"") AS float) / sum(""Lss_Duration""))) AS float) * 100
else 0 end
) as complete
FROM ""LogForStudentStudy"" where {{acid}} group by ""Ol_ID""
) as s where s.totalTime > 0 group by s.couid
) as tm on c.""Cou_ID"" = tm.couid ";
sql = sql.Replace("{{acid}}", acid > 0 ? @"""Ac_ID"" = " + acid : "1=1");
try
{
DataSet ds = Gateway.Default.FromSql(sql).ToDataSet();
DataTable dt = ds.Tables[0];
if (dt.Rows.Count > 0)
{
///* 不要删除
//*****如果没有购买的,则去除
//购买的课程(含概试用的)
int count = 0;
List<Song.Entities.Course> cous = Business.Do<ICourse>().CourseForStudent(acid, null, 0, null, null);
for (int i = 0; i < dt.Rows.Count; i++)
{
bool isExist = false;
for (int j = 0; j < cous.Count; j++)
{
if (dt.Rows[i]["Cou_ID"].ToString() == cous[j].Cou_ID.ToString())
{
isExist = true;
break;
}
}
if (!isExist)
{
dt.Rows.RemoveAt(i);
i--;
}
}
// * */
//计算完成度
foreach (DataRow dr in dt.Rows)
{
//课程的累计完成度
double complete = Convert.ToDouble(dr["complete"].ToString());
//课程id
long couid = Convert.ToInt64(dr["Cou_ID"].ToString());
int olnum = Business.Do<IOutline>().OutlineOfCount(couid, -1, true, true, true, null);
//完成度
double peracent = Math.Floor(complete / olnum * 100) / 100;
dr["complete"] = peracent >= (100 - tolerance) ? 100 : peracent;
}
}
return dt;
}
catch
{
return null;
}
}
}
}
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

社区版完全免费,功能完整。直播、视频学习、试题练习、测试、考试、学习证明、成绩打印,实现"学、练、考"一体。适用于在线教育、知识付费、企业内训、员工考评、企业商学院等。
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/PhoenixGroup/LearningSystem.git
git@gitee.com:PhoenixGroup/LearningSystem.git
PhoenixGroup
LearningSystem
视频学习+在线考试+题库+直播
master
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /