随着互联网的发展,尤其是移动互联网的进一步深入,各行各业在享受信息化便利同时也受到信息变革的冲击。淘宝网实现了人人皆商,威客网实现了人力资源交换,而网络学习则实现了知识共享,学习的同时且又可以“人人为师”,实现知识的P2P模式。正是基于这样的思路构想,我们着手规划并设计《在线学习云服务平台》
该平台是云服务平台,其角色分为:超级管理员、机构管理员、教师、学员。
超级管理员主要是针对机构的管理。机构管理员是针对自身机构的管理,例如教师审核、新闻发布等。教师可以发布课程、考试等。该文档对上述四种角色的用户操作都具有针对性的详细讲解。
平台的主要功能可以理解为在线“学习与测评”。它的主要功能也集中在两点,一是学习培训;二是考试。在学习培训部分,首先是老师编排课程,然后学生选择相应课程学习。考试部分,则由老师录入试题,随机生成试卷,学生参加考试。通过记录学员在线上参加的课程培训、考试竞赛、试题练习、调查问卷和培训交流等情况,实现对学员学习情况的全程跟踪管理和对员工学习培训需求的全面掌握。
该平台作为一个云服务平台,不仅可以满足我们自身的使用,还可以提供更多服务与其它机构、学校或公司。当前系统作为多机构版,可以实现某一个培训学校或公司在系统中注册生成一个自己专属的培训考试服务平台,且拥有二级域名、能更换界面风格,完全可以看成一个独立的系统。
主要功能描述如下:
教师发布课程,管理员可以对其审核(或设置直接通过),课程支持图文介绍、视频播放、课件展示等。学生登录后可以选择学习相应课程,并与教师进行相应交流。
试题支持单选题、多选题、判断题、填空题、简答题。支持图文混排、批量导入、录入验证、试题讲解、知识库关联。
考试支持在线随机出题、断网异常处理、自动评分、成绩统计等。可以设定考试时间、考试时长(答卷时间)。
实现学员与教师之间的交流,例如留言、论坛等形式。
管理员可以包括若干,不同管理员通过权限设置实现不同的工作分配,例如甲管理员专职课程审核、乙管理员负责发布新闻与通知。
基于Android平台,实现在线学习、在线练习、成绩查询等功能。采用二维码技术,实现客户端智能安装、信息自动识别与获取等功能。
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Data;
-
- using WeiSha.Common;
- using Song.Entities;
-
- using WeiSha.Data;
- using Song.ServiceInterfaces;
- using System.Data.Common;
- using System.Xml;
-
-
-
- namespace Song.ServiceImpls
- {
- public class ExaminationCom : IExamination
- {
-
- public int ExamAdd(Examination entity)
- {
- entity.Exam_CrtTime = DateTime.Now;
- //当前考试的创建人
- entity.Th_ID = Extend.LoginState.Teacher.CurrentUser.Th_ID;
- entity.Th_Name = Extend.LoginState.Teacher.CurrentUser.Th_Name;
- //
- Song.Entities.Organization org = Business.Do
().OrganCurrent(); - if (org != null)
- {
- entity.Org_ID = org.Org_ID;
- entity.Org_Name = org.Org_Name;
- }
- return Gateway.Default.Save
(entity); - }
-
- public void ExamAdd(Examination theme, List
items, List groups ) - {
- Song.Entities.Organization org = Business.Do
().OrganCurrent(); - if (org != null)
- {
- theme.Org_ID = org.Org_ID;
- theme.Org_Name = org.Org_Name;
- }
- theme.Exam_CrtTime = DateTime.Now;
- //当前考试的创建人
- if (Extend.LoginState.Teacher.CurrentUser != null)
- {
- theme.Th_ID = Extend.LoginState.Teacher.CurrentUser.Th_ID;
- theme.Th_Name = Extend.LoginState.Teacher.CurrentUser.Th_Name;
- }
- //考试时间
- if (items != null && items.Count > 0)
- {
- theme.Exam_Date = items[0].Exam_Date;
- }
- using (DbTrans tran = Gateway.Default.BeginTrans())
- {
- try
- {
- tran.Save
(theme); - if (items != null)
- {
- foreach (Song.Entities.Examination it in items)
- {
- if (it.Sbj_ID < 1) continue;
- it.Exam_CrtTime = DateTime.Now;
- it.Exam_Name = theme.Exam_Name;
- it.Exam_GroupType = theme.Exam_GroupType;
- it.Exam_IsUse = theme.Exam_IsUse;
- tran.Save
(it); - }
- }
- if (groups != null)
- {
- foreach (Song.Entities.ExamGroup g in groups)
- {
- g.Org_ID = org.Org_ID;
- g.Org_Name = org.Org_Name;
- tran.Save
(g); - }
- }
- tran.Commit();
- }
- catch (Exception ex)
- {
- tran.Rollback();
- throw ex;
-
- }
- finally
- {
- tran.Close();
- }
- }
- }
-
- public void ExamSave(Examination entity)
- {
- using (DbTrans tran = Gateway.Default.BeginTrans())
- {
- try
- {
- tran.Save
(entity); - tran.Update
(new Field[] { Examination._.Exam_IsUse }, new object[] { entity.Exam_IsUse }, Examination._.Exam_UID == entity.Exam_UID); - tran.Commit();
- }
- catch (Exception ex)
- {
- tran.Rollback();
- throw ex;
- }
- finally
- {
- tran.Close();
- }
- }
- }
-
- public void ExamSave(Examination theme, List
items, List groups ) - {
-
- //考试时间
- if (items != null && items.Count > 0)
- theme.Exam_Date = items[0].Exam_Date;
- using (DbTrans tran = Gateway.Default.BeginTrans())
- {
- try
- {
- tran.Save
(theme); - //场次
- if (items != null)
- {
- foreach (Song.Entities.Examination it in items)
- {
- if (it.Sbj_ID < 1)
- {
- Gateway.Default.Delete
(it); - }
- else
- {
- it.Exam_Name = theme.Exam_Name;
- it.Exam_GroupType = theme.Exam_GroupType;
- it.Exam_IsUse = theme.Exam_IsUse;
- tran.Save
(it); - }
- }
- }
- //参考人员范围
- tran.Delete
(ExamGroup._.Exam_UID == theme.Exam_UID); - if (groups != null)
- {
- foreach (Song.Entities.ExamGroup g in groups)
- {
- tran.Save
(g); - }
- }
- tran.Commit();
- }
- catch (Exception ex)
- {
- tran.Rollback();
- throw ex;
- }
- finally
- {
- tran.Close();
- }
- }
- }
- public void ExamDelete(int identify)
- {
- Song.Entities.Examination exam = this.ExamSingle(identify);
- using (DbTrans tran = Gateway.Default.BeginTrans())
- {
- try
- {
- tran.Delete
(Examination._.Exam_ID == identify); - tran.Delete
(Examination._.Exam_UID == exam.Exam_UID && Examination._.Exam_IsTheme == false); - tran.Delete
(ExamGroup._.Exam_UID == exam.Exam_UID); - tran.Commit();
- }
- catch (Exception ex)
- {
- tran.Rollback();
- throw ex;
-
- }
- finally
- {
- tran.Close();
- }
- }
- }
-
- public Examination ExamSingle(int identify)
- {
- return Gateway.Default.From
().Where(Examination._.Exam_ID == identify).ToFirst(); - }
-
- public Examination ExamSingle(string uid)
- {
- return Gateway.Default.From
().Where(Examination._.Exam_UID == uid && Examination._.Exam_IsTheme == true).ToFirst(); - }
-
- public ExamResults ResultClacScore(ExamResults resu)
- {
- return _ClacScore(resu);
- }
- public Examination[] ExamItem(string uid)
- {
- return Gateway.Default.From
() - .Where(Examination._.Exam_UID == uid && Examination._.Exam_IsTheme == false)
- .OrderBy(Examination._.Exam_CrtTime.Asc).ToArray
(); - }
-
- public Examination[] ExamItem(int id)
- {
- Song.Entities.Examination exam = this.ExamSingle(id);
- if (exam == null) return null;
- return this.ExamItem(exam.Exam_UID);
- }
-
- ///
- /// 当前考试主题关联的学员分类
- ///
- ///
- ///
- public StudentSort[] GroupForStudentSort(string uid)
- {
- //所在班组的考试
- Song.Entities.StudentSort[] sts = Gateway.Default.From
().InnerJoin(ExamGroup._.Sts_ID == StudentSort._.Sts_ID) - .Where(ExamGroup._.Exam_UID == uid && ExamGroup._.Eg_Type == 2).ToArray
(); - return sts;
- }
-
- public List
ExamCount(int orgid, bool? isUse, int count) - {
- WhereClip wc = Examination._.Org_ID == orgid && Examination._.Exam_IsTheme == true;
- if (isUse != null) wc.And(Examination._.Exam_IsUse == (bool)isUse);
- count = count > 0 ? count : int.MaxValue;
- Song.Entities.Examination[] all = Gateway.Default.From
().Where(wc).OrderBy(Examination._.Exam_Date.Desc).ToArray(count); - List
exams = new List(); - foreach (Song.Entities.Examination t in all)
- _GetSelfExam_Add(exams, t);
- return exams;
- }
- public List
GetSelfExam(int stid, DateTime? start, DateTime? end) - {
- int accid = stid;
- //查询条件
- WhereClip wc = new WhereClip();
- wc.And(Examination._.Exam_IsTheme == false && Examination._.Exam_IsUse == true);
- if (start != null) wc.And(Examination._.Exam_Date >= (DateTime)start);
- if (end != null) wc.And(Examination._.Exam_Date < (DateTime)end);
- //全员参加的考试
- Song.Entities.Examination[] all = Gateway.Default.From
().Where(wc && Examination._.Exam_GroupType == 1).ToArray(); - //所在部门的考试
- Song.Entities.EmpAccount acc = Gateway.Default.From
().Where(EmpAccount._.Acc_Id == accid).ToFirst(); -
- //合并到一起
- List
exams = new List(); - foreach (Song.Entities.Examination t in all)
- _GetSelfExam_Add(exams, t);
- //排序
- for (int i = 0; i < exams.Count; i++)
- {
- for (int j = i; j < exams.Count; j++)
- {
- if (exams[i].Exam_Date < exams[j].Exam_Date)
- {
- Song.Entities.Examination temp = exams[i];
- exams[i] = exams[j];
- exams[j] = temp;
- }
- }
- }
- return exams;
- }
- public List
GetCountExam(int stid, DateTime? start, DateTime? end, bool? isUse, int count) - {
- //查询条件
- WhereClip wc = Examination._.Exam_IsTheme == false && Examination._.Exam_IsUse == true;
- if (isUse != null) wc.And(Examination._.Exam_IsUse == (bool)isUse);
- if (start != null) wc.And(Examination._.Exam_Date >= (DateTime)start);
- if (end != null) wc.And(Examination._.Exam_Date < (DateTime)end);
- count = count > 0 ? count : int.MaxValue;
- //全员参加的考试
- Song.Entities.Examination[] all = Gateway.Default.From
().Where(wc).ToArray(); - List
exams = new List(); - foreach (Song.Entities.Examination t in all)
- _GetSelfExam_Add(exams, t);
- //排序
- for (int i = 0; i < exams.Count; i++)
- {
- for (int j = i; j < exams.Count; j++)
- {
- if (exams[i].Exam_Date > exams[j].Exam_Date)
- {
- Song.Entities.Examination temp = exams[i];
- exams[i] = exams[j];
- exams[j] = temp;
- }
- }
- }
- return exams;
- }
- public List
_GetSelfExam_Add(List list, Examination exam) - {
- foreach (Song.Entities.Examination t in list)
- {
- if (t.Exam_ID == exam.Exam_ID) return list;
- }
- list.Add(exam);
- return list;
- }
- public Examination[] GetPager(int orgid, DateTime? start, DateTime? end, bool? isUse, string searName, int size, int index, out int countSum)
- {
- WhereClip wc = Examination._.Org_ID == orgid && Examination._.Exam_IsTheme == true;
- if (isUse != null) wc.And(Examination._.Exam_IsUse == (bool)isUse);
- if (searName != null && searName != "") wc.And(Examination._.Exam_Name.Like("%" + searName + "%"));
- if (start != null) wc.And(Examination._.Exam_Date >= (DateTime)start);
- if (end != null) wc.And(Examination._.Exam_Date < (DateTime)end);
- countSum = Gateway.Default.Count
(wc); - return Gateway.Default.From
().Where(wc).OrderBy(Examination._.Exam_Date.Desc).ToArray(size, (index - 1) * size); - }
- public ExamResults[] GetAttendPager(int accid, int sbjid,string sear, int size, int index, out int countSum)
- {
- WhereClip wc = ExamResults._.Acc_Id == accid;
- if (sbjid > 0) wc.And(ExamResults._.Sbj_ID == sbjid);
- if (sear != null && sear != "") wc.And(ExamResults._.Exam_Name.Like("%" + sear + "%"));
- countSum = Gateway.Default.Count
(wc); - ExamResults[] exr = Gateway.Default.From
().Where(wc).OrderBy(ExamResults._.Exr_CrtTime.Desc).ToArray(size, (index - 1) * size); - for (int i = 0; i < exr.Length; i++)
- {
- if (exr[i].Exr_Score < 0)
- exr[i] = _ClacScore(exr[i]);
- }
- return exr;
- }
- #region
- ///
- /// 添加考试答题信息
- ///
- ///
- public void ResultAdd(ExamResults result)
- {
- WhereClip wc = ExamResults._.Exam_ID == result.Exam_ID && ExamResults._.Tp_Id == result.Tp_Id && ExamResults._.Acc_Id == result.Acc_Id;
- Song.Entities.ExamResults exr = Gateway.Default.From
().Where(wc).ToFirst(); - if (exr == null)
- exr = result;
- else
- if (exr.Exr_Results == result.Exr_Results) return;
-
- exr.Exr_Results = result.Exr_Results;
- exr.Exr_IP = result.Exr_IP;
- exr.Exr_Mac = result.Exr_Mac;
- exr.Exam_ID = result.Exam_ID;
- exr.Sbj_ID = result.Sbj_ID;
- exr.Tp_Id = result.Tp_Id;
- exr.Acc_Id = result.Acc_Id;
- exr.Exr_CrtTime = DateTime.Now;
- exr.Exr_Score = -1;
- //考试主题
- Examination tm = this.ExamSingle((int)exr.Exam_ID);
- if (tm != null)
- {
- exr.Exam_Name = tm.Exam_Name;
- exr.Exam_UID = tm.Exam_UID;
- }
- //专业名称
- Subject sub = Gateway.Default.From
().Where(Subject._.Sbj_ID == exr.Sbj_ID).ToFirst(); - if (sub != null) exr.Sbj_Name = sub.Sbj_Name;
- //考试生姓名
- EmpAccount acc = Gateway.Default.From
().Where(EmpAccount._.Acc_Id == exr.Acc_Id).ToFirst(); - if (acc != null)
- {
- exr.Acc_Name = acc.Acc_Name;
- exr.Dep_Id = acc.Dep_Id;
- exr.Team_ID = acc.Team_ID;
- }
- Gateway.Default.Save
(exr); -
- //生成临时记录
- Song.Entities.ExamResultsTemp tmp = new ExamResultsTemp();
- tmp.Exr_Results = result.Exr_Results;
- tmp.Exr_IP = result.Exr_IP;
- tmp.Exr_Mac = result.Exr_Mac;
- tmp.Exam_ID = result.Exam_ID;
- tmp.Sbj_ID = result.Sbj_ID;
- tmp.Tp_Id = result.Tp_Id;
- tmp.Acc_Id = result.Acc_Id;
- tmp.Exr_CrtTime = DateTime.Now;
- Gateway.Default.Save
(tmp); - }
- ///
- /// 保存考试答题信息
- ///
- ///
- public void ResultSave(ExamResults result)
- {
- Gateway.Default.Save
(result); - }
- ///
- /// 删除考试成绩
- ///
- ///
- public void ResultDelete(int id)
- {
- Gateway.Default.Delete
(ExamResults._.Exr_ID == id); - }
- ///
- /// 删除某个员工的某个考试的成绩
- ///
- ///
- ///
- public void ResultDelete(int accid, int examid)
- {
- WhereClip wc = new WhereClip();
- if (accid > -1) wc.And(ExamResults._.Acc_Id == accid);
- if (examid > -1) wc.And(ExamResults._.Exam_ID == examid);
- Gateway.Default.Delete
(wc); - }
- ///
- /// 获取最新的答题信息(临时信息)
- ///
- /// 考试id
- /// 试卷id
- /// 考生id
- ///
- public ExamResultsTemp ExamResultsTempSingle(int examid, int tpid, int accid)
- {
- WhereClip wc = ExamResultsTemp._.Exam_ID == examid && ExamResultsTemp._.Tp_Id == tpid && ExamResultsTemp._.Acc_Id == accid;
- Song.Entities.ExamResultsTemp exr = Gateway.Default.From
().Where(wc).ToFirst(); - return exr;
- }
- ///
- /// 获取最新的答题信息(正式答题信息)
- ///
- /// 考试id
- /// 试卷id
- /// 考生id
- ///
- public ExamResults ResultSingle(int examid, int tpid, int accid)
- {
- WhereClip wc = new WhereClip();
- if (examid > -1) wc.And(ExamResults._.Exam_ID == examid);
- if (tpid > -1) wc.And(ExamResults._.Tp_Id == tpid);
- if (accid > -1) wc.And(ExamResults._.Acc_Id == accid);
- Song.Entities.ExamResults exr = Gateway.Default.From
().Where(wc).OrderBy(ExamResults._.Exr_CrtTime.Desc).ToFirst(); - return exr;
- }
-
- public ExamResults ResultSingle(int exrid)
- {
- return Gateway.Default.From
().Where(ExamResults._.Exr_ID == exrid).ToFirst(); - }
- ///
- /// 根据答题信息,获取试题(针对答题过程中死机,又上线时)
- ///
- ///
- public List
QuesForResults(string results) - {
- XmlDocument resXml = new XmlDocument();
- resXml.LoadXml(results);
- XmlNodeList nodeList = resXml.SelectSingleNode("results").ChildNodes;
- string ids = "";
- for (int i = 0; i < nodeList.Count;i++ )
- {
- ids += nodeList[i].Attributes["id"].Value;
- if (i < nodeList.Count - 1) ids += ",";
- }
- string[] s = ids.Split(',');
- List
quesList = new List(); - //取数据库中的题
- for (int i = 0; i < s.Length; i++)
- {
- if (s[i].Trim() == "") continue;
- int id = Convert.ToInt32(s[i]);
- Song.Entities.Questions q = Gateway.Default.From
().Where(Questions._.Qus_ID == id).ToFirst(); - if (q == null) continue;
- quesList.Add(q);
- }
- //设置该题分数
- foreach (Song.Entities.Questions q in quesList)
- {
- for (int i = 0; i < nodeList.Count; i++)
- {
- double num= Convert.ToDouble(nodeList[i].Attributes["num"].Value);
- int id = Convert.ToInt32(nodeList[i].Attributes["id"].Value);
- if (q.Qus_ID == id)
- {
- q.Qus_Number = (float)num;
- break;
- }
- }
- }
- return quesList;
- }
- #endregion
-
-
- #region 私有方法
- ///
- /// 计算当前考试成绩
- ///
- ///
- ///
- private Song.Entities.ExamResults _ClacScore(ExamResults result)
- {
- result.Exr_Score = _ClacScore(result.Exr_Results);
- //考试得分,加绘图得分,加综合评分
- result.Exr_ScoreFinal = result.Exr_Score + result.Exr_Draw + result.Exr_Colligate;
- Gateway.Default.Save
(result); - return result;
- }
- ///
- /// 通过答题的XML信息,计算成绩
- ///
- ///
- ///
- public static float _ClacScore(string resultXML)
- {
- XmlDocument resXml = new XmlDocument();
- resXml.LoadXml(resultXML);
- XmlNode root = resXml.LastChild;
- //学员Id、学科
- int stid = Convert.ToInt32(root.Attributes["accid"].Value);
- int sbjid = Convert.ToInt32(root.Attributes["sbjid"].Value);
- XmlNodeList nodeList = resXml.SelectSingleNode("results").ChildNodes;
- #region 计算成绩
- //得分记录
- double score = 0;
- for (int i = 0; i < nodeList.Count; i++)
- {
- //试题的Id
- int id = Convert.ToInt32(nodeList[i].Attributes["id"].Value);
- //试题的类型
- int type = Convert.ToInt32(nodeList[i].Attributes["type"].Value);
- //试题的分数
- double num = Convert.ToDouble(nodeList[i].Attributes["num"].Value);
- //答案
- string ansid = nodeList[i].Attributes["ansid"].Value;
- //是否正确
- bool isSucess = false;
- if (type == 1 || type == 2 || type == 3)
- {
- if (ansid.Trim() == "" || ansid.Trim() == "undefined") continue;
- if (ansid.Split(',').Length < 1) continue;
- ansid = ansid.Substring(0, ansid.LastIndexOf(","));
- }
- Questions qus = Gateway.Default.From
().Where(Questions._.Qus_ID == id).ToFirst(); - if (qus == null) continue;
- #region 单选题
- if (type == 1)
- {
- QuesAnswer[] ans1 = Gateway.Default.From
().Where(QuesAnswer._.Qus_UID == qus.Qus_UID && QuesAnswer._.Ans_IsCorrect == true).ToArray(); - if (ans1.Length < 1) continue;
- foreach (string s in ansid.Split(','))
- {
- if (Convert.ToInt32(s) == ans1[0].Ans_ID)
- {
- score += num;
- isSucess = true;
- break;
- }
- }
- }
- #endregion
- #region 多选题
- if (type == 2)
- {
- QuesAnswer[] ans2 = Gateway.Default.From
().Where(QuesAnswer._.Qus_UID == qus.Qus_UID && QuesAnswer._.Ans_IsCorrect == true).ToArray(); - if (ans2.Length < 1) continue;
- string[] ansArr = ansid.Split(',');
- if (ansArr.Length != ans2.Length) continue;
- int tm = ansArr.Length;
- foreach (string s in ansArr)
- {
- foreach (QuesAnswer qa in ans2)
- {
- if (Convert.ToInt32(s) == qa.Ans_ID)
- {
- tm--;
- break;
- }
- }
- }
- if (tm == 0)
- {
- score += num;
- isSucess = true;
- }
- }
- #endregion
- #region 判断题
- if (type == 3)
- {
- if (Convert.ToInt32(ansid) == 0 && qus.Qus_IsCorrect == true) isSucess = true;
- if (Convert.ToInt32(ansid) == 1 && qus.Qus_IsCorrect == false) isSucess = true;
- if (isSucess) score += num;
- }
- #endregion
- #region 如果是简答题,跳过
- if (type == 4)
- {
- //试题得分
- double shortscore = 0;
- if (nodeList[i].Attributes["score"] != null)
- shortscore = Convert.ToDouble(nodeList[i].Attributes["score"].Value);
- score += shortscore;
- }
- #endregion
- #region 填空题
- if (type == 5)
- {
- QuesAnswer[] ans5 = Gateway.Default.From
().Where(QuesAnswer._.Qus_UID == qus.Qus_UID).ToArray(); - string[] ansText = nodeList[i].InnerText.Split(',');
- int corrNum = 0;
- for (int j = 0; j < ansText.Length; j++)
- {
- if (ansText[j].Trim() == "") continue;
- if (ans5.Length <= j || ans5[j] == null) continue;
- string corentTxt = ans5[j].Ans_Context;
- foreach (string tm in corentTxt.Split(','))
- {
- if (tm == string.Empty || tm.Trim() == "") continue;
- if (tm.Trim() == ansText[j].Trim())
- {
- corrNum++;
- break;
- }
- }
- }
- if (corrNum == ans5.Length) isSucess = true;
- if (isSucess) score += num;
- }
- #endregion
-
- //如果错了,则记录为错题,以方便复习
- if (!isSucess)
- {
- Song.Entities.Student_Ques sq = new Student_Ques();
- //学员Id
- sq.St_ID = stid;
- //试题id与类型
- sq.Qus_ID = id;
- sq.Qus_Type = type;
- //学科
- sq.Sbj_ID = sbjid;
- //难度
- sq.Qus_Diff = qus.Qus_Diff;
- Business.Do
().QuesAdd(sq); - }
-
- }
- #endregion
- return (float)score;
- }
- #endregion
- ///
- /// 考试主题下的所有参考人员成绩
- ///
- ///
- ///
- public DataTable Result4Theme(int id)
- {
- Examination theme = this.ExamSingle(id);
- Examination[] exams = this.ExamItem(theme.Exam_UID);
- DataTable dt = new DataTable("DataBase");
- //人员id与姓名
- dt.Columns.Add(new DataColumn("Acc_Id", Type.GetType("System.Int32")));
- dt.Columns.Add(new DataColumn("姓名", Type.GetType("System.String")));
- foreach (Examination ex in exams)
- dt.Columns.Add(new DataColumn(ex.Sbj_Name, Type.GetType("System.String")));
- //取出所有的成绩
- ExamResults[] results = Gateway.Default.From
().Where(ExamResults._.Exam_UID == theme.Exam_UID).ToArray(); - //计算成绩
- for (int i = 0; i < results.Length; i++)
- {
- if (results[i].Exr_Score < 0)
- results[i] = _ClacScore(results[i]);
-
- }
- foreach (ExamResults er in results)
- {
- bool isHav = false;
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- int accid = Convert.ToInt32(dt.Rows[i]["Acc_Id"]);
- if (er.Acc_Id == accid)
- {
- isHav = true;
- break;
- }
- }
- if (isHav == false)
- {
- DataRow dr = dt.NewRow();
- dr["Acc_Id"] = er.Acc_Id;
- dr["姓名"] = er.Acc_Name;
- dt.Rows.Add(dr);
- }
- }
- foreach (Examination ex in exams)
- {
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- int accid = Convert.ToInt32(dt.Rows[i]["Acc_Id"]);
- foreach (ExamResults er in results)
- {
- if (er.Acc_Id == accid && er.Sbj_Name==ex.Sbj_Name)
- {
- dt.Rows[i][ex.Sbj_Name] = er.Exr_Score;
- break;
- }
- }
- }
- }
- DataView dv = dt.DefaultView;
- dv.Sort = "姓名 Asc";
- return dv.ToTable();
- }
- /
- / 统计各部门在某个考试中的平均分
- /
- / "id">
- /
- //public DataTable Analysis4Depart(int id)
- //{
- // Examination theme = this.ExamSingle(id);
- // Examination[] exams = this.ExamItem(theme.Exam_UID);
- // DataTable dt = new DataTable("DataBase");
- // //部门id与名称
- // dt.Columns.Add(new DataColumn("Dep_Id", Type.GetType("System.Int32")));
- // dt.Columns.Add(new DataColumn("部门", Type.GetType("System.String")));
- // foreach (Examination ex in exams)
- // dt.Columns.Add(new DataColumn(ex.Sbj_Name, Type.GetType("System.String")));
- // //取出所有的成绩
- // ExamResults[] results = Gateway.Default.From
().Where(ExamResults._.Exam_UID == theme.Exam_UID).ToArray(); - // for (int i = 0; i < results.Length; i++)
- // {
- // if (results[i].Exr_Score < 0)
- // results[i] = _ClacScore(results[i]);
- // }
- // Song.Entities.Depart[] deps = this.GroupForDepart(theme.Exam_UID);
- // if (deps.Length < 1) deps = Gateway.Default.From
().OrderBy(Depart._.Dep_Tax.Asc).ToArray(); - // foreach (Depart dep in deps)
- // {
- // DataRow dr = dt.NewRow();
- // dr["Dep_Id"] = dep.Dep_Id;
- // dr["部门"] = dep.Dep_CnName;
- // dt.Rows.Add(dr);
- // }
- // foreach (Examination ex in exams)
- // {
- // for (int i = 0; i < dt.Rows.Count; i++)
- // {
- // int depid = Convert.ToInt32(dt.Rows[i]["Dep_Id"]);
- // double score = 0;
- // int tmNum = 0;
- // foreach (ExamResults er in results)
- // {
- // if (er.Dep_Id == depid && er.Sbj_Name == ex.Sbj_Name)
- // {
- // score += (float)er.Exr_Score;
- // tmNum++;
- // break;
- // }
- // }
- // double avg = tmNum == 0 ? 0 : score / tmNum;
- // avg = Math.Round(avg * 100) / 100;
- // dt.Rows[i][ex.Sbj_Name] = avg.ToString();
- // }
- // }
- // return dt;
- //}
- /
- / 统计各班组在某个考试中的平均分
- /
- / "id">
- /
- //public DataTable Analysis4Team(int id)
- //{
- // Examination theme = this.ExamSingle(id);
- // Examination[] exams = this.ExamItem(theme.Exam_UID);
- // DataTable dt = new DataTable("DataBase");
- // //部门id与名称
- // dt.Columns.Add(new DataColumn("Team_ID", Type.GetType("System.Int32")));
- // dt.Columns.Add(new DataColumn("班组", Type.GetType("System.String")));
- // foreach (Examination ex in exams)
- // dt.Columns.Add(new DataColumn(ex.Sbj_Name, Type.GetType("System.String")));
- // //取出所有的成绩
- // ExamResults[] results = Gateway.Default.From
().Where(ExamResults._.Exam_UID == theme.Exam_UID).ToArray(); - // for (int i = 0; i < results.Length; i++)
- // {
- // if (results[i].Exr_Score < 0)
- // results[i] = _ClacScore(results[i]);
- // }
- // Song.Entities.Team[] teams = this.GroupForTeam(theme.Exam_UID);
- // foreach (Team team in teams)
- // {
- // DataRow dr = dt.NewRow();
- // dr["Team_ID"] = team.Team_ID;
- // dr["班组"] = team.Team_Name;
- // dt.Rows.Add(dr);
- // }
- // foreach (Examination ex in exams)
- // {
- // for (int i = 0; i < dt.Rows.Count; i++)
- // {
- // int tmid = Convert.ToInt32(dt.Rows[i]["Team_ID"]);
- // double score = 0;
- // int tmNum = 0;
- // foreach (ExamResults er in results)
- // {
- // if (er.Team_ID == tmid && er.Sbj_Name == ex.Sbj_Name)
- // {
- // score += (float)er.Exr_Score;
- // tmNum++;
- // break;
- // }
- // }
- // double avg = tmNum == 0 ? 0 : score / tmNum;
- // avg = Math.Round(avg * 100) / 100;
- // dt.Rows[i][ex.Sbj_Name] = avg.ToString();
- // }
- // }
- // return dt;
- //}
- ///
- /// 计算某个考试主题的及格率
- ///
- ///
- ///
- public double PassRate4Theme(string uid)
- {
- Examination[] exam = this.ExamItem(uid);
- double rate = 0;
- foreach (Examination ex in exam)
- {
- rate += this.PassRate4Exam(ex);
- }
- return rate / exam.Length;
- }
- ///
- /// 计算某场考试的及极率
- ///
- ///
- ///
- public double PassRate4Exam(Examination exam)
- {
- int sum = Gateway.Default.Count
(ExamResults._.Exam_ID == exam.Exam_ID && ExamResults._.Exr_Score >= 0); - if (sum < 1) return 0;
- TestPaper tp = Gateway.Default.From
().Where(TestPaper._.Tp_Id == exam.Tp_Id).ToFirst(); - int pass = Gateway.Default.Count
(ExamResults._.Exam_ID == exam.Exam_ID && ExamResults._.Exr_Score >= tp.Tp_Total * 0.6); - double s = (double)sum;
- double p = (double)pass;
- double rate = Math.Round(p / s * 10000) / 100;
- return rate;
- }
- ///
- /// 计算某个考试主题的平均分
- ///
- ///
- ///
- public double Avg4Theme(string uid)
- {
- Examination[] exam = this.ExamItem(uid);
- double avg = 0;
- foreach (Examination ex in exam)
- {
- avg += this.Avg4Exam(ex);
- }
- return avg / exam.Length;
- }
- ///
- /// 计算某场考试的平均分
- ///
- ///
- ///
- public double Avg4Exam(Examination exam)
- {
- object obj = Gateway.Default.Avg
(ExamResults._.Exr_Score, ExamResults._.Exam_ID == exam.Exam_ID); - System.Type type = obj.GetType();
- if (type.FullName == "System.DBNull") return 0;
- double tm = obj is DBNull ? 0 : Convert.ToDouble(obj);
- return tm;
- }
- public ExamResults[] Results(int examid, int size, int index, out int countSum)
- {
- WhereClip wc = ExamResults._.Exam_ID == examid;
- countSum = Gateway.Default.Count
(wc); - ExamResults[] exr = Gateway.Default.From
().Where(wc).OrderBy(ExamResults._.Exr_CrtTime.Desc).ToArray(size, (index - 1) * size); - for (int i = 0; i < exr.Length; i++)
- {
- if (exr[i].Exr_Score < 0)
- exr[i] = _ClacScore(exr[i]);
- }
- return exr;
- }
-
- public ExamResults[] Results(string examuid, int size, int index, out int countSum)
- {
- WhereClip wc = ExamResults._.Exam_UID == examuid;
- countSum = Gateway.Default.Count
(wc); - ExamResults[] exr = Gateway.Default.From
().Where(wc).OrderBy(ExamResults._.Exr_CrtTime.Desc).ToArray(size, (index - 1) * size); - for (int i = 0; i < exr.Length; i++)
- {
- if (exr[i].Exr_Score < 0)
- exr[i] = _ClacScore(exr[i]);
- }
- return exr;
- }
- }
- }