• 在线学习云服务平台


     背景

    随着互联网的发展,尤其是移动互联网的进一步深入,各行各业在享受信息化便利同时也受到信息变革的冲击。淘宝网实现了人人皆商,威客网实现了人力资源交换,而网络学习则实现了知识共享,学习的同时且又可以“人人为师”,实现知识的P2P模式。正是基于这样的思路构想,我们着手规划并设计《在线学习云服务平台》

    目标读者

    该平台是云服务平台,其角色分为:超级管理员、机构管理员、教师、学员。

    超级管理员主要是针对机构的管理。机构管理员是针对自身机构的管理,例如教师审核、新闻发布等。教师可以发布课程、考试等。该文档对上述四种角色的用户操作都具有针对性的详细讲解。

    主要功能

    平台的主要功能可以理解为在线“学习与测评”。它的主要功能也集中在两点,一是学习培训;二是考试。在学习培训部分,首先是老师编排课程,然后学生选择相应课程学习。考试部分,则由老师录入试题,随机生成试卷,学生参加考试。通过记录学员在线上参加的课程培训、考试竞赛、试题练习、调查问卷和培训交流等情况,实现对学员学习情况的全程跟踪管理和对员工学习培训需求的全面掌握。

    该平台作为一个云服务平台,不仅可以满足我们自身的使用,还可以提供更多服务与其它机构、学校或公司。当前系统作为多机构版,可以实现某一个培训学校或公司在系统中注册生成一个自己专属的培训考试服务平台,且拥有二级域名、能更换界面风格,完全可以看成一个独立的系统。

    主要功能描述如下:

    课程管理

    教师发布课程,管理员可以对其审核(或设置直接通过),课程支持图文介绍、视频播放、课件展示等。学生登录后可以选择学习相应课程,并与教师进行相应交流。

    试题库管理

    试题支持单选题、多选题、判断题、填空题、简答题。支持图文混排、批量导入、录入验证、试题讲解、知识库关联。

    考试管理

    考试支持在线随机出题、断网异常处理、自动评分、成绩统计等。可以设定考试时间、考试时长(答卷时间)。

    交流互动

    实现学员与教师之间的交流,例如留言、论坛等形式。

    用户权限

    管理员可以包括若干,不同管理员通过权限设置实现不同的工作分配,例如甲管理员专职课程审核、乙管理员负责发布新闻与通知。

    智能手机客户端

    基于Android平台,实现在线学习、在线练习、成绩查询等功能。采用二维码技术,实现客户端智能安装、信息自动识别与获取等功能。

    课程管理代码

    1. using System;
    2. using System.Collections.Generic;
    3. using System.Text;
    4. using System.Data;
    5. using WeiSha.Common;
    6. using Song.Entities;
    7. using WeiSha.Data;
    8. using Song.ServiceInterfaces;
    9. using System.Data.Common;
    10. using System.Xml;
    11. namespace Song.ServiceImpls
    12. {
    13. public class ExaminationCom : IExamination
    14. {
    15. public int ExamAdd(Examination entity)
    16. {
    17. entity.Exam_CrtTime = DateTime.Now;
    18. //当前考试的创建人
    19. entity.Th_ID = Extend.LoginState.Teacher.CurrentUser.Th_ID;
    20. entity.Th_Name = Extend.LoginState.Teacher.CurrentUser.Th_Name;
    21. //
    22. Song.Entities.Organization org = Business.Do().OrganCurrent();
    23. if (org != null)
    24. {
    25. entity.Org_ID = org.Org_ID;
    26. entity.Org_Name = org.Org_Name;
    27. }
    28. return Gateway.Default.Save(entity);
    29. }
    30. public void ExamAdd(Examination theme, List items, List groups)
    31. {
    32. Song.Entities.Organization org = Business.Do().OrganCurrent();
    33. if (org != null)
    34. {
    35. theme.Org_ID = org.Org_ID;
    36. theme.Org_Name = org.Org_Name;
    37. }
    38. theme.Exam_CrtTime = DateTime.Now;
    39. //当前考试的创建人
    40. if (Extend.LoginState.Teacher.CurrentUser != null)
    41. {
    42. theme.Th_ID = Extend.LoginState.Teacher.CurrentUser.Th_ID;
    43. theme.Th_Name = Extend.LoginState.Teacher.CurrentUser.Th_Name;
    44. }
    45. //考试时间
    46. if (items != null && items.Count > 0)
    47. {
    48. theme.Exam_Date = items[0].Exam_Date;
    49. }
    50. using (DbTrans tran = Gateway.Default.BeginTrans())
    51. {
    52. try
    53. {
    54. tran.Save(theme);
    55. if (items != null)
    56. {
    57. foreach (Song.Entities.Examination it in items)
    58. {
    59. if (it.Sbj_ID < 1) continue;
    60. it.Exam_CrtTime = DateTime.Now;
    61. it.Exam_Name = theme.Exam_Name;
    62. it.Exam_GroupType = theme.Exam_GroupType;
    63. it.Exam_IsUse = theme.Exam_IsUse;
    64. tran.Save(it);
    65. }
    66. }
    67. if (groups != null)
    68. {
    69. foreach (Song.Entities.ExamGroup g in groups)
    70. {
    71. g.Org_ID = org.Org_ID;
    72. g.Org_Name = org.Org_Name;
    73. tran.Save(g);
    74. }
    75. }
    76. tran.Commit();
    77. }
    78. catch (Exception ex)
    79. {
    80. tran.Rollback();
    81. throw ex;
    82. }
    83. finally
    84. {
    85. tran.Close();
    86. }
    87. }
    88. }
    89. public void ExamSave(Examination entity)
    90. {
    91. using (DbTrans tran = Gateway.Default.BeginTrans())
    92. {
    93. try
    94. {
    95. tran.Save(entity);
    96. tran.Update(new Field[] { Examination._.Exam_IsUse }, new object[] { entity.Exam_IsUse }, Examination._.Exam_UID == entity.Exam_UID);
    97. tran.Commit();
    98. }
    99. catch (Exception ex)
    100. {
    101. tran.Rollback();
    102. throw ex;
    103. }
    104. finally
    105. {
    106. tran.Close();
    107. }
    108. }
    109. }
    110. public void ExamSave(Examination theme, List items, List groups)
    111. {
    112. //考试时间
    113. if (items != null && items.Count > 0)
    114. theme.Exam_Date = items[0].Exam_Date;
    115. using (DbTrans tran = Gateway.Default.BeginTrans())
    116. {
    117. try
    118. {
    119. tran.Save(theme);
    120. //场次
    121. if (items != null)
    122. {
    123. foreach (Song.Entities.Examination it in items)
    124. {
    125. if (it.Sbj_ID < 1)
    126. {
    127. Gateway.Default.Delete(it);
    128. }
    129. else
    130. {
    131. it.Exam_Name = theme.Exam_Name;
    132. it.Exam_GroupType = theme.Exam_GroupType;
    133. it.Exam_IsUse = theme.Exam_IsUse;
    134. tran.Save(it);
    135. }
    136. }
    137. }
    138. //参考人员范围
    139. tran.Delete(ExamGroup._.Exam_UID == theme.Exam_UID);
    140. if (groups != null)
    141. {
    142. foreach (Song.Entities.ExamGroup g in groups)
    143. {
    144. tran.Save(g);
    145. }
    146. }
    147. tran.Commit();
    148. }
    149. catch (Exception ex)
    150. {
    151. tran.Rollback();
    152. throw ex;
    153. }
    154. finally
    155. {
    156. tran.Close();
    157. }
    158. }
    159. }
    160. public void ExamDelete(int identify)
    161. {
    162. Song.Entities.Examination exam = this.ExamSingle(identify);
    163. using (DbTrans tran = Gateway.Default.BeginTrans())
    164. {
    165. try
    166. {
    167. tran.Delete(Examination._.Exam_ID == identify);
    168. tran.Delete(Examination._.Exam_UID == exam.Exam_UID && Examination._.Exam_IsTheme == false);
    169. tran.Delete(ExamGroup._.Exam_UID == exam.Exam_UID);
    170. tran.Commit();
    171. }
    172. catch (Exception ex)
    173. {
    174. tran.Rollback();
    175. throw ex;
    176. }
    177. finally
    178. {
    179. tran.Close();
    180. }
    181. }
    182. }
    183. public Examination ExamSingle(int identify)
    184. {
    185. return Gateway.Default.From().Where(Examination._.Exam_ID == identify).ToFirst();
    186. }
    187. public Examination ExamSingle(string uid)
    188. {
    189. return Gateway.Default.From().Where(Examination._.Exam_UID == uid && Examination._.Exam_IsTheme == true).ToFirst();
    190. }
    191. public ExamResults ResultClacScore(ExamResults resu)
    192. {
    193. return _ClacScore(resu);
    194. }
    195. public Examination[] ExamItem(string uid)
    196. {
    197. return Gateway.Default.From()
    198. .Where(Examination._.Exam_UID == uid && Examination._.Exam_IsTheme == false)
    199. .OrderBy(Examination._.Exam_CrtTime.Asc).ToArray();
    200. }
    201. public Examination[] ExamItem(int id)
    202. {
    203. Song.Entities.Examination exam = this.ExamSingle(id);
    204. if (exam == null) return null;
    205. return this.ExamItem(exam.Exam_UID);
    206. }
    207. ///
    208. /// 当前考试主题关联的学员分类
    209. ///
    210. ///
    211. ///
    212. public StudentSort[] GroupForStudentSort(string uid)
    213. {
    214. //所在班组的考试
    215. Song.Entities.StudentSort[] sts = Gateway.Default.From().InnerJoin(ExamGroup._.Sts_ID == StudentSort._.Sts_ID)
    216. .Where(ExamGroup._.Exam_UID == uid && ExamGroup._.Eg_Type == 2).ToArray();
    217. return sts;
    218. }
    219. public List ExamCount(int orgid, bool? isUse, int count)
    220. {
    221. WhereClip wc = Examination._.Org_ID == orgid && Examination._.Exam_IsTheme == true;
    222. if (isUse != null) wc.And(Examination._.Exam_IsUse == (bool)isUse);
    223. count = count > 0 ? count : int.MaxValue;
    224. Song.Entities.Examination[] all = Gateway.Default.From().Where(wc).OrderBy(Examination._.Exam_Date.Desc).ToArray(count);
    225. List exams = new List();
    226. foreach (Song.Entities.Examination t in all)
    227. _GetSelfExam_Add(exams, t);
    228. return exams;
    229. }
    230. public List GetSelfExam(int stid, DateTime? start, DateTime? end)
    231. {
    232. int accid = stid;
    233. //查询条件
    234. WhereClip wc = new WhereClip();
    235. wc.And(Examination._.Exam_IsTheme == false && Examination._.Exam_IsUse == true);
    236. if (start != null) wc.And(Examination._.Exam_Date >= (DateTime)start);
    237. if (end != null) wc.And(Examination._.Exam_Date < (DateTime)end);
    238. //全员参加的考试
    239. Song.Entities.Examination[] all = Gateway.Default.From().Where(wc && Examination._.Exam_GroupType == 1).ToArray();
    240. //所在部门的考试
    241. Song.Entities.EmpAccount acc = Gateway.Default.From().Where(EmpAccount._.Acc_Id == accid).ToFirst();
    242. //合并到一起
    243. List exams = new List();
    244. foreach (Song.Entities.Examination t in all)
    245. _GetSelfExam_Add(exams, t);
    246. //排序
    247. for (int i = 0; i < exams.Count; i++)
    248. {
    249. for (int j = i; j < exams.Count; j++)
    250. {
    251. if (exams[i].Exam_Date < exams[j].Exam_Date)
    252. {
    253. Song.Entities.Examination temp = exams[i];
    254. exams[i] = exams[j];
    255. exams[j] = temp;
    256. }
    257. }
    258. }
    259. return exams;
    260. }
    261. public List GetCountExam(int stid, DateTime? start, DateTime? end, bool? isUse, int count)
    262. {
    263. //查询条件
    264. WhereClip wc = Examination._.Exam_IsTheme == false && Examination._.Exam_IsUse == true;
    265. if (isUse != null) wc.And(Examination._.Exam_IsUse == (bool)isUse);
    266. if (start != null) wc.And(Examination._.Exam_Date >= (DateTime)start);
    267. if (end != null) wc.And(Examination._.Exam_Date < (DateTime)end);
    268. count = count > 0 ? count : int.MaxValue;
    269. //全员参加的考试
    270. Song.Entities.Examination[] all = Gateway.Default.From().Where(wc).ToArray();
    271. List exams = new List();
    272. foreach (Song.Entities.Examination t in all)
    273. _GetSelfExam_Add(exams, t);
    274. //排序
    275. for (int i = 0; i < exams.Count; i++)
    276. {
    277. for (int j = i; j < exams.Count; j++)
    278. {
    279. if (exams[i].Exam_Date > exams[j].Exam_Date)
    280. {
    281. Song.Entities.Examination temp = exams[i];
    282. exams[i] = exams[j];
    283. exams[j] = temp;
    284. }
    285. }
    286. }
    287. return exams;
    288. }
    289. public List _GetSelfExam_Add(List list, Examination exam)
    290. {
    291. foreach (Song.Entities.Examination t in list)
    292. {
    293. if (t.Exam_ID == exam.Exam_ID) return list;
    294. }
    295. list.Add(exam);
    296. return list;
    297. }
    298. public Examination[] GetPager(int orgid, DateTime? start, DateTime? end, bool? isUse, string searName, int size, int index, out int countSum)
    299. {
    300. WhereClip wc = Examination._.Org_ID == orgid && Examination._.Exam_IsTheme == true;
    301. if (isUse != null) wc.And(Examination._.Exam_IsUse == (bool)isUse);
    302. if (searName != null && searName != "") wc.And(Examination._.Exam_Name.Like("%" + searName + "%"));
    303. if (start != null) wc.And(Examination._.Exam_Date >= (DateTime)start);
    304. if (end != null) wc.And(Examination._.Exam_Date < (DateTime)end);
    305. countSum = Gateway.Default.Count(wc);
    306. return Gateway.Default.From().Where(wc).OrderBy(Examination._.Exam_Date.Desc).ToArray(size, (index - 1) * size);
    307. }
    308. public ExamResults[] GetAttendPager(int accid, int sbjid,string sear, int size, int index, out int countSum)
    309. {
    310. WhereClip wc = ExamResults._.Acc_Id == accid;
    311. if (sbjid > 0) wc.And(ExamResults._.Sbj_ID == sbjid);
    312. if (sear != null && sear != "") wc.And(ExamResults._.Exam_Name.Like("%" + sear + "%"));
    313. countSum = Gateway.Default.Count(wc);
    314. ExamResults[] exr = Gateway.Default.From().Where(wc).OrderBy(ExamResults._.Exr_CrtTime.Desc).ToArray(size, (index - 1) * size);
    315. for (int i = 0; i < exr.Length; i++)
    316. {
    317. if (exr[i].Exr_Score < 0)
    318. exr[i] = _ClacScore(exr[i]);
    319. }
    320. return exr;
    321. }
    322. #region
    323. ///
    324. /// 添加考试答题信息
    325. ///
    326. ///
    327. public void ResultAdd(ExamResults result)
    328. {
    329. WhereClip wc = ExamResults._.Exam_ID == result.Exam_ID && ExamResults._.Tp_Id == result.Tp_Id && ExamResults._.Acc_Id == result.Acc_Id;
    330. Song.Entities.ExamResults exr = Gateway.Default.From().Where(wc).ToFirst();
    331. if (exr == null)
    332. exr = result;
    333. else
    334. if (exr.Exr_Results == result.Exr_Results) return;
    335. exr.Exr_Results = result.Exr_Results;
    336. exr.Exr_IP = result.Exr_IP;
    337. exr.Exr_Mac = result.Exr_Mac;
    338. exr.Exam_ID = result.Exam_ID;
    339. exr.Sbj_ID = result.Sbj_ID;
    340. exr.Tp_Id = result.Tp_Id;
    341. exr.Acc_Id = result.Acc_Id;
    342. exr.Exr_CrtTime = DateTime.Now;
    343. exr.Exr_Score = -1;
    344. //考试主题
    345. Examination tm = this.ExamSingle((int)exr.Exam_ID);
    346. if (tm != null)
    347. {
    348. exr.Exam_Name = tm.Exam_Name;
    349. exr.Exam_UID = tm.Exam_UID;
    350. }
    351. //专业名称
    352. Subject sub = Gateway.Default.From().Where(Subject._.Sbj_ID == exr.Sbj_ID).ToFirst();
    353. if (sub != null) exr.Sbj_Name = sub.Sbj_Name;
    354. //考试生姓名
    355. EmpAccount acc = Gateway.Default.From().Where(EmpAccount._.Acc_Id == exr.Acc_Id).ToFirst();
    356. if (acc != null)
    357. {
    358. exr.Acc_Name = acc.Acc_Name;
    359. exr.Dep_Id = acc.Dep_Id;
    360. exr.Team_ID = acc.Team_ID;
    361. }
    362. Gateway.Default.Save(exr);
    363. //生成临时记录
    364. Song.Entities.ExamResultsTemp tmp = new ExamResultsTemp();
    365. tmp.Exr_Results = result.Exr_Results;
    366. tmp.Exr_IP = result.Exr_IP;
    367. tmp.Exr_Mac = result.Exr_Mac;
    368. tmp.Exam_ID = result.Exam_ID;
    369. tmp.Sbj_ID = result.Sbj_ID;
    370. tmp.Tp_Id = result.Tp_Id;
    371. tmp.Acc_Id = result.Acc_Id;
    372. tmp.Exr_CrtTime = DateTime.Now;
    373. Gateway.Default.Save(tmp);
    374. }
    375. ///
    376. /// 保存考试答题信息
    377. ///
    378. ///
    379. public void ResultSave(ExamResults result)
    380. {
    381. Gateway.Default.Save(result);
    382. }
    383. ///
    384. /// 删除考试成绩
    385. ///
    386. ///
    387. public void ResultDelete(int id)
    388. {
    389. Gateway.Default.Delete(ExamResults._.Exr_ID == id);
    390. }
    391. ///
    392. /// 删除某个员工的某个考试的成绩
    393. ///
    394. ///
    395. ///
    396. public void ResultDelete(int accid, int examid)
    397. {
    398. WhereClip wc = new WhereClip();
    399. if (accid > -1) wc.And(ExamResults._.Acc_Id == accid);
    400. if (examid > -1) wc.And(ExamResults._.Exam_ID == examid);
    401. Gateway.Default.Delete(wc);
    402. }
    403. ///
    404. /// 获取最新的答题信息(临时信息)
    405. ///
    406. /// 考试id
    407. /// 试卷id
    408. /// 考生id
    409. ///
    410. public ExamResultsTemp ExamResultsTempSingle(int examid, int tpid, int accid)
    411. {
    412. WhereClip wc = ExamResultsTemp._.Exam_ID == examid && ExamResultsTemp._.Tp_Id == tpid && ExamResultsTemp._.Acc_Id == accid;
    413. Song.Entities.ExamResultsTemp exr = Gateway.Default.From().Where(wc).ToFirst();
    414. return exr;
    415. }
    416. ///
    417. /// 获取最新的答题信息(正式答题信息)
    418. ///
    419. /// 考试id
    420. /// 试卷id
    421. /// 考生id
    422. ///
    423. public ExamResults ResultSingle(int examid, int tpid, int accid)
    424. {
    425. WhereClip wc = new WhereClip();
    426. if (examid > -1) wc.And(ExamResults._.Exam_ID == examid);
    427. if (tpid > -1) wc.And(ExamResults._.Tp_Id == tpid);
    428. if (accid > -1) wc.And(ExamResults._.Acc_Id == accid);
    429. Song.Entities.ExamResults exr = Gateway.Default.From().Where(wc).OrderBy(ExamResults._.Exr_CrtTime.Desc).ToFirst();
    430. return exr;
    431. }
    432. public ExamResults ResultSingle(int exrid)
    433. {
    434. return Gateway.Default.From().Where(ExamResults._.Exr_ID == exrid).ToFirst();
    435. }
    436. ///
    437. /// 根据答题信息,获取试题(针对答题过程中死机,又上线时)
    438. ///
    439. ///
    440. public List QuesForResults(string results)
    441. {
    442. XmlDocument resXml = new XmlDocument();
    443. resXml.LoadXml(results);
    444. XmlNodeList nodeList = resXml.SelectSingleNode("results").ChildNodes;
    445. string ids = "";
    446. for (int i = 0; i < nodeList.Count;i++ )
    447. {
    448. ids += nodeList[i].Attributes["id"].Value;
    449. if (i < nodeList.Count - 1) ids += ",";
    450. }
    451. string[] s = ids.Split(',');
    452. List quesList = new List();
    453. //取数据库中的题
    454. for (int i = 0; i < s.Length; i++)
    455. {
    456. if (s[i].Trim() == "") continue;
    457. int id = Convert.ToInt32(s[i]);
    458. Song.Entities.Questions q = Gateway.Default.From().Where(Questions._.Qus_ID == id).ToFirst();
    459. if (q == null) continue;
    460. quesList.Add(q);
    461. }
    462. //设置该题分数
    463. foreach (Song.Entities.Questions q in quesList)
    464. {
    465. for (int i = 0; i < nodeList.Count; i++)
    466. {
    467. double num= Convert.ToDouble(nodeList[i].Attributes["num"].Value);
    468. int id = Convert.ToInt32(nodeList[i].Attributes["id"].Value);
    469. if (q.Qus_ID == id)
    470. {
    471. q.Qus_Number = (float)num;
    472. break;
    473. }
    474. }
    475. }
    476. return quesList;
    477. }
    478. #endregion
    479. #region 私有方法
    480. ///
    481. /// 计算当前考试成绩
    482. ///
    483. ///
    484. ///
    485. private Song.Entities.ExamResults _ClacScore(ExamResults result)
    486. {
    487. result.Exr_Score = _ClacScore(result.Exr_Results);
    488. //考试得分,加绘图得分,加综合评分
    489. result.Exr_ScoreFinal = result.Exr_Score + result.Exr_Draw + result.Exr_Colligate;
    490. Gateway.Default.Save(result);
    491. return result;
    492. }
    493. ///
    494. /// 通过答题的XML信息,计算成绩
    495. ///
    496. ///
    497. ///
    498. public static float _ClacScore(string resultXML)
    499. {
    500. XmlDocument resXml = new XmlDocument();
    501. resXml.LoadXml(resultXML);
    502. XmlNode root = resXml.LastChild;
    503. //学员Id、学科
    504. int stid = Convert.ToInt32(root.Attributes["accid"].Value);
    505. int sbjid = Convert.ToInt32(root.Attributes["sbjid"].Value);
    506. XmlNodeList nodeList = resXml.SelectSingleNode("results").ChildNodes;
    507. #region 计算成绩
    508. //得分记录
    509. double score = 0;
    510. for (int i = 0; i < nodeList.Count; i++)
    511. {
    512. //试题的Id
    513. int id = Convert.ToInt32(nodeList[i].Attributes["id"].Value);
    514. //试题的类型
    515. int type = Convert.ToInt32(nodeList[i].Attributes["type"].Value);
    516. //试题的分数
    517. double num = Convert.ToDouble(nodeList[i].Attributes["num"].Value);
    518. //答案
    519. string ansid = nodeList[i].Attributes["ansid"].Value;
    520. //是否正确
    521. bool isSucess = false;
    522. if (type == 1 || type == 2 || type == 3)
    523. {
    524. if (ansid.Trim() == "" || ansid.Trim() == "undefined") continue;
    525. if (ansid.Split(',').Length < 1) continue;
    526. ansid = ansid.Substring(0, ansid.LastIndexOf(","));
    527. }
    528. Questions qus = Gateway.Default.From().Where(Questions._.Qus_ID == id).ToFirst();
    529. if (qus == null) continue;
    530. #region 单选题
    531. if (type == 1)
    532. {
    533. QuesAnswer[] ans1 = Gateway.Default.From().Where(QuesAnswer._.Qus_UID == qus.Qus_UID && QuesAnswer._.Ans_IsCorrect == true).ToArray();
    534. if (ans1.Length < 1) continue;
    535. foreach (string s in ansid.Split(','))
    536. {
    537. if (Convert.ToInt32(s) == ans1[0].Ans_ID)
    538. {
    539. score += num;
    540. isSucess = true;
    541. break;
    542. }
    543. }
    544. }
    545. #endregion
    546. #region 多选题
    547. if (type == 2)
    548. {
    549. QuesAnswer[] ans2 = Gateway.Default.From().Where(QuesAnswer._.Qus_UID == qus.Qus_UID && QuesAnswer._.Ans_IsCorrect == true).ToArray();
    550. if (ans2.Length < 1) continue;
    551. string[] ansArr = ansid.Split(',');
    552. if (ansArr.Length != ans2.Length) continue;
    553. int tm = ansArr.Length;
    554. foreach (string s in ansArr)
    555. {
    556. foreach (QuesAnswer qa in ans2)
    557. {
    558. if (Convert.ToInt32(s) == qa.Ans_ID)
    559. {
    560. tm--;
    561. break;
    562. }
    563. }
    564. }
    565. if (tm == 0)
    566. {
    567. score += num;
    568. isSucess = true;
    569. }
    570. }
    571. #endregion
    572. #region 判断题
    573. if (type == 3)
    574. {
    575. if (Convert.ToInt32(ansid) == 0 && qus.Qus_IsCorrect == true) isSucess = true;
    576. if (Convert.ToInt32(ansid) == 1 && qus.Qus_IsCorrect == false) isSucess = true;
    577. if (isSucess) score += num;
    578. }
    579. #endregion
    580. #region 如果是简答题,跳过
    581. if (type == 4)
    582. {
    583. //试题得分
    584. double shortscore = 0;
    585. if (nodeList[i].Attributes["score"] != null)
    586. shortscore = Convert.ToDouble(nodeList[i].Attributes["score"].Value);
    587. score += shortscore;
    588. }
    589. #endregion
    590. #region 填空题
    591. if (type == 5)
    592. {
    593. QuesAnswer[] ans5 = Gateway.Default.From().Where(QuesAnswer._.Qus_UID == qus.Qus_UID).ToArray();
    594. string[] ansText = nodeList[i].InnerText.Split(',');
    595. int corrNum = 0;
    596. for (int j = 0; j < ansText.Length; j++)
    597. {
    598. if (ansText[j].Trim() == "") continue;
    599. if (ans5.Length <= j || ans5[j] == null) continue;
    600. string corentTxt = ans5[j].Ans_Context;
    601. foreach (string tm in corentTxt.Split(','))
    602. {
    603. if (tm == string.Empty || tm.Trim() == "") continue;
    604. if (tm.Trim() == ansText[j].Trim())
    605. {
    606. corrNum++;
    607. break;
    608. }
    609. }
    610. }
    611. if (corrNum == ans5.Length) isSucess = true;
    612. if (isSucess) score += num;
    613. }
    614. #endregion
    615. //如果错了,则记录为错题,以方便复习
    616. if (!isSucess)
    617. {
    618. Song.Entities.Student_Ques sq = new Student_Ques();
    619. //学员Id
    620. sq.St_ID = stid;
    621. //试题id与类型
    622. sq.Qus_ID = id;
    623. sq.Qus_Type = type;
    624. //学科
    625. sq.Sbj_ID = sbjid;
    626. //难度
    627. sq.Qus_Diff = qus.Qus_Diff;
    628. Business.Do().QuesAdd(sq);
    629. }
    630. }
    631. #endregion
    632. return (float)score;
    633. }
    634. #endregion
    635. ///
    636. /// 考试主题下的所有参考人员成绩
    637. ///
    638. ///
    639. ///
    640. public DataTable Result4Theme(int id)
    641. {
    642. Examination theme = this.ExamSingle(id);
    643. Examination[] exams = this.ExamItem(theme.Exam_UID);
    644. DataTable dt = new DataTable("DataBase");
    645. //人员id与姓名
    646. dt.Columns.Add(new DataColumn("Acc_Id", Type.GetType("System.Int32")));
    647. dt.Columns.Add(new DataColumn("姓名", Type.GetType("System.String")));
    648. foreach (Examination ex in exams)
    649. dt.Columns.Add(new DataColumn(ex.Sbj_Name, Type.GetType("System.String")));
    650. //取出所有的成绩
    651. ExamResults[] results = Gateway.Default.From().Where(ExamResults._.Exam_UID == theme.Exam_UID).ToArray();
    652. //计算成绩
    653. for (int i = 0; i < results.Length; i++)
    654. {
    655. if (results[i].Exr_Score < 0)
    656. results[i] = _ClacScore(results[i]);
    657. }
    658. foreach (ExamResults er in results)
    659. {
    660. bool isHav = false;
    661. for (int i = 0; i < dt.Rows.Count; i++)
    662. {
    663. int accid = Convert.ToInt32(dt.Rows[i]["Acc_Id"]);
    664. if (er.Acc_Id == accid)
    665. {
    666. isHav = true;
    667. break;
    668. }
    669. }
    670. if (isHav == false)
    671. {
    672. DataRow dr = dt.NewRow();
    673. dr["Acc_Id"] = er.Acc_Id;
    674. dr["姓名"] = er.Acc_Name;
    675. dt.Rows.Add(dr);
    676. }
    677. }
    678. foreach (Examination ex in exams)
    679. {
    680. for (int i = 0; i < dt.Rows.Count; i++)
    681. {
    682. int accid = Convert.ToInt32(dt.Rows[i]["Acc_Id"]);
    683. foreach (ExamResults er in results)
    684. {
    685. if (er.Acc_Id == accid && er.Sbj_Name==ex.Sbj_Name)
    686. {
    687. dt.Rows[i][ex.Sbj_Name] = er.Exr_Score;
    688. break;
    689. }
    690. }
    691. }
    692. }
    693. DataView dv = dt.DefaultView;
    694. dv.Sort = "姓名 Asc";
    695. return dv.ToTable();
    696. }
    697. /
    698. / 统计各部门在某个考试中的平均分
    699. /
    700. / "id">
    701. /
    702. //public DataTable Analysis4Depart(int id)
    703. //{
    704. // Examination theme = this.ExamSingle(id);
    705. // Examination[] exams = this.ExamItem(theme.Exam_UID);
    706. // DataTable dt = new DataTable("DataBase");
    707. // //部门id与名称
    708. // dt.Columns.Add(new DataColumn("Dep_Id", Type.GetType("System.Int32")));
    709. // dt.Columns.Add(new DataColumn("部门", Type.GetType("System.String")));
    710. // foreach (Examination ex in exams)
    711. // dt.Columns.Add(new DataColumn(ex.Sbj_Name, Type.GetType("System.String")));
    712. // //取出所有的成绩
    713. // ExamResults[] results = Gateway.Default.From().Where(ExamResults._.Exam_UID == theme.Exam_UID).ToArray();
    714. // for (int i = 0; i < results.Length; i++)
    715. // {
    716. // if (results[i].Exr_Score < 0)
    717. // results[i] = _ClacScore(results[i]);
    718. // }
    719. // Song.Entities.Depart[] deps = this.GroupForDepart(theme.Exam_UID);
    720. // if (deps.Length < 1) deps = Gateway.Default.From().OrderBy(Depart._.Dep_Tax.Asc).ToArray();
    721. // foreach (Depart dep in deps)
    722. // {
    723. // DataRow dr = dt.NewRow();
    724. // dr["Dep_Id"] = dep.Dep_Id;
    725. // dr["部门"] = dep.Dep_CnName;
    726. // dt.Rows.Add(dr);
    727. // }
    728. // foreach (Examination ex in exams)
    729. // {
    730. // for (int i = 0; i < dt.Rows.Count; i++)
    731. // {
    732. // int depid = Convert.ToInt32(dt.Rows[i]["Dep_Id"]);
    733. // double score = 0;
    734. // int tmNum = 0;
    735. // foreach (ExamResults er in results)
    736. // {
    737. // if (er.Dep_Id == depid && er.Sbj_Name == ex.Sbj_Name)
    738. // {
    739. // score += (float)er.Exr_Score;
    740. // tmNum++;
    741. // break;
    742. // }
    743. // }
    744. // double avg = tmNum == 0 ? 0 : score / tmNum;
    745. // avg = Math.Round(avg * 100) / 100;
    746. // dt.Rows[i][ex.Sbj_Name] = avg.ToString();
    747. // }
    748. // }
    749. // return dt;
    750. //}
    751. /
    752. / 统计各班组在某个考试中的平均分
    753. /
    754. / "id">
    755. /
    756. //public DataTable Analysis4Team(int id)
    757. //{
    758. // Examination theme = this.ExamSingle(id);
    759. // Examination[] exams = this.ExamItem(theme.Exam_UID);
    760. // DataTable dt = new DataTable("DataBase");
    761. // //部门id与名称
    762. // dt.Columns.Add(new DataColumn("Team_ID", Type.GetType("System.Int32")));
    763. // dt.Columns.Add(new DataColumn("班组", Type.GetType("System.String")));
    764. // foreach (Examination ex in exams)
    765. // dt.Columns.Add(new DataColumn(ex.Sbj_Name, Type.GetType("System.String")));
    766. // //取出所有的成绩
    767. // ExamResults[] results = Gateway.Default.From().Where(ExamResults._.Exam_UID == theme.Exam_UID).ToArray();
    768. // for (int i = 0; i < results.Length; i++)
    769. // {
    770. // if (results[i].Exr_Score < 0)
    771. // results[i] = _ClacScore(results[i]);
    772. // }
    773. // Song.Entities.Team[] teams = this.GroupForTeam(theme.Exam_UID);
    774. // foreach (Team team in teams)
    775. // {
    776. // DataRow dr = dt.NewRow();
    777. // dr["Team_ID"] = team.Team_ID;
    778. // dr["班组"] = team.Team_Name;
    779. // dt.Rows.Add(dr);
    780. // }
    781. // foreach (Examination ex in exams)
    782. // {
    783. // for (int i = 0; i < dt.Rows.Count; i++)
    784. // {
    785. // int tmid = Convert.ToInt32(dt.Rows[i]["Team_ID"]);
    786. // double score = 0;
    787. // int tmNum = 0;
    788. // foreach (ExamResults er in results)
    789. // {
    790. // if (er.Team_ID == tmid && er.Sbj_Name == ex.Sbj_Name)
    791. // {
    792. // score += (float)er.Exr_Score;
    793. // tmNum++;
    794. // break;
    795. // }
    796. // }
    797. // double avg = tmNum == 0 ? 0 : score / tmNum;
    798. // avg = Math.Round(avg * 100) / 100;
    799. // dt.Rows[i][ex.Sbj_Name] = avg.ToString();
    800. // }
    801. // }
    802. // return dt;
    803. //}
    804. ///
    805. /// 计算某个考试主题的及格率
    806. ///
    807. ///
    808. ///
    809. public double PassRate4Theme(string uid)
    810. {
    811. Examination[] exam = this.ExamItem(uid);
    812. double rate = 0;
    813. foreach (Examination ex in exam)
    814. {
    815. rate += this.PassRate4Exam(ex);
    816. }
    817. return rate / exam.Length;
    818. }
    819. ///
    820. /// 计算某场考试的及极率
    821. ///
    822. ///
    823. ///
    824. public double PassRate4Exam(Examination exam)
    825. {
    826. int sum = Gateway.Default.Count(ExamResults._.Exam_ID == exam.Exam_ID && ExamResults._.Exr_Score >= 0);
    827. if (sum < 1) return 0;
    828. TestPaper tp = Gateway.Default.From().Where(TestPaper._.Tp_Id == exam.Tp_Id).ToFirst();
    829. int pass = Gateway.Default.Count(ExamResults._.Exam_ID == exam.Exam_ID && ExamResults._.Exr_Score >= tp.Tp_Total * 0.6);
    830. double s = (double)sum;
    831. double p = (double)pass;
    832. double rate = Math.Round(p / s * 10000) / 100;
    833. return rate;
    834. }
    835. ///
    836. /// 计算某个考试主题的平均分
    837. ///
    838. ///
    839. ///
    840. public double Avg4Theme(string uid)
    841. {
    842. Examination[] exam = this.ExamItem(uid);
    843. double avg = 0;
    844. foreach (Examination ex in exam)
    845. {
    846. avg += this.Avg4Exam(ex);
    847. }
    848. return avg / exam.Length;
    849. }
    850. ///
    851. /// 计算某场考试的平均分
    852. ///
    853. ///
    854. ///
    855. public double Avg4Exam(Examination exam)
    856. {
    857. object obj = Gateway.Default.Avg(ExamResults._.Exr_Score, ExamResults._.Exam_ID == exam.Exam_ID);
    858. System.Type type = obj.GetType();
    859. if (type.FullName == "System.DBNull") return 0;
    860. double tm = obj is DBNull ? 0 : Convert.ToDouble(obj);
    861. return tm;
    862. }
    863. public ExamResults[] Results(int examid, int size, int index, out int countSum)
    864. {
    865. WhereClip wc = ExamResults._.Exam_ID == examid;
    866. countSum = Gateway.Default.Count(wc);
    867. ExamResults[] exr = Gateway.Default.From().Where(wc).OrderBy(ExamResults._.Exr_CrtTime.Desc).ToArray(size, (index - 1) * size);
    868. for (int i = 0; i < exr.Length; i++)
    869. {
    870. if (exr[i].Exr_Score < 0)
    871. exr[i] = _ClacScore(exr[i]);
    872. }
    873. return exr;
    874. }
    875. public ExamResults[] Results(string examuid, int size, int index, out int countSum)
    876. {
    877. WhereClip wc = ExamResults._.Exam_UID == examuid;
    878. countSum = Gateway.Default.Count(wc);
    879. ExamResults[] exr = Gateway.Default.From().Where(wc).OrderBy(ExamResults._.Exr_CrtTime.Desc).ToArray(size, (index - 1) * size);
    880. for (int i = 0; i < exr.Length; i++)
    881. {
    882. if (exr[i].Exr_Score < 0)
    883. exr[i] = _ClacScore(exr[i]);
    884. }
    885. return exr;
    886. }
    887. }
    888. }

  • 相关阅读:
    Scala---元组
    centos安装git
    Verilog语句
    WaterAngle题解Contest806div4
    java计算机毕业设计小小银动漫网站源码+系统+数据库+lw文档+mybatis+运行部署
    【入门Flink】- 02Flink经典案例-WordCount
    QT实现多线程两种方式案例详解
    C++中引用类型做做右值
    【Spring源码】18. factory-method创建对象关键函数详解:instantiateUsingFactoryMethod()
    手机号的正则表达式
  • 原文地址:https://blog.csdn.net/xdpcxq/article/details/128196290