Ejemplo n.º 1
0
 private static 考试分析 得到考试分析(List<考生做过的试卷> list, int totalScore, int 间隔值, string departmentName)
 {
     //X轴数据
     List<string> listX = new List<string>();
     //Y轴数据
     List<int> listY = new List<int>();
     int count = 0;
     if (totalScore % 间隔值 == 0)
     {
         count = totalScore / 间隔值;
     }
     else
     {
         count = totalScore / 间隔值 + 1;
     }
     for (int i = 0; i < count; i++)
     {
         string x = string.Empty;
         int y = 0;
         //第一段间隔值
         if (i == 0)
         {
             x = i * 间隔值 + "-" + (i + 1) * 间隔值;
             y = list.Where(a => a.总得分 < (i + 1) * 间隔值 + 1).Count();
         }
         //最后一段间隔值
         else if (i == count - 1)
         {
             x = i * 间隔值 + 1 + "-" + totalScore;
             y = list.Where(a => a.总得分 > i * 间隔值).Count();
         }
         //中间段间隔值
         else
         {
             x = i * 间隔值 + 1 + "-" + (i + 1) * 间隔值;
             y = list.Where(a => a.总得分 > i * 间隔值 && a.总得分 < (i + 1) * 间隔值 + 1).Count();
         }
         listX.Add(x);
         listY.Add(y);
     }
     考试分析 analyse = new 考试分析();
     analyse.部门名 = departmentName;
     analyse.间隔值列表 = listX;
     analyse.人数列表 = listY;
     return analyse;
 }
        /// <summary>
        /// 返回考试分析表格Body
        /// </summary>
        /// <param name="c考试分析">考试分析</param>
        /// <returns></returns>
        public static string Get考试分析表格TBody(考试分析 c考试分析)
        {
            List<int> listY = c考试分析.人数列表;

            if (listY == null || listY.Count == 0)
            {
                return "";
            }

            /* 考生范围数 */
            int Total = 0;
            string sTBody = "";

            #region 人数
            sTBody += "<tr>";
            sTBody += "<td rowSpan=\"2\">" + c考试分析.部门名 + "</td>";
            sTBody += "<td>人</td>";
            for (int i = 0; i < listY.Count; i++)
            {
                sTBody += "<td>" + listY[i] + "</td>";
                Total += listY[i];
            }
            sTBody += "</tr>";
            #endregion

            #region 百分比
            sTBody += "<tr style=\"background:#f1f1f1;\">";
            sTBody += "<td>%</td>";
            for (int i = 0; i < listY.Count; i++)
            {
                sTBody += "<td><font>" + (((double)listY[i] / Total) * 100) + "</font></td>";
            }
            sTBody += "</tr>";
            #endregion

            return sTBody;
        }