public compare(List <exerL> ell1, V_tea_course vcc1, param p) { ell = ell1; vcc = vcc1; pp = p; InitializeComponent(); }
// V_tea_course vc = null; public EditTestPaper(param p, exerL el1, V_tea_course vcc1) { pp = p; el = el1; vcc = vcc1; InitializeComponent(); }
////////////////////////// private void exportsum(classinfo cl1, View_class_exp vst1, V_tea_course vcourse, int poscol) { String dirsave = null; List <View_class_student> lstwei = new List <View_class_student>(); // List<View_class_student> lstall = null; saveFileDialog2.DefaultExt = ".xlsx"; saveFileDialog2.Filter = "EXCEL file|*.xlsx"; if (saveFileDialog2.ShowDialog() == DialogResult.OK) { string localFilePath = saveFileDialog2.FileName.ToString(); // dirsave = localFilePath.Substring(0, localFilePath.LastIndexOf("\\")); dirsave = localFilePath; } //////////////////////excel Spire.Xls.Workbook wb = new Spire.Xls.Workbook(); //清除默认的工作表 wb.Worksheets.Clear(); //添加一个工作表并指定表名 Worksheet sheet = wb.Worksheets.Add("score"); sheet.Range[2, 2].Text = "序号"; sheet.Range[3, 2].Text = "分值"; sheet.Range[4, 2].Text = "指标"; sheet.Range[5, 1].Text = "学号"; sheet.Range[5, 2].Text = "姓名"; int intobjective = vcourse.numobjective; String expobjective = vst1.objective; String[] strexpobj = expobjective.Split('|'); for (int i = 1; i <= intobjective + 1; i++) { if (i < intobjective + 1) { sheet.Range[4, poscol + i - 1].Text = i.ToString(); } else { sheet.Range[4, poscol + i - 1].Text = "已交"; } } int irow = 6; int icol = poscol; var questionQuery1 = from o in pp.context.View_class_student where o.classid == cl1.classid orderby o.classno select o; List <View_class_student> lstall = null; if (questionQuery1.Count <View_class_student>() > 0) { lstall = questionQuery1.ToList <View_class_student>(); } /// /// if (lstall != null) { foreach (View_class_student itvst in lstall) { sheet.Range[irow, 1].Text = itvst.studentid; sheet.Range[irow, 2].Text = itvst.name; var questionQuery2 = from o in pp.context.studreport where o.classid == cl1.classid && o.expid == vst1.expid && o.stid == itvst.studentid select o; studreport isturep = null; if (questionQuery2.Count <studreport>() > 0) { isturep = questionQuery2.First <studreport>(); String strmarks = isturep.score; String[] strmark = strmarks.Split('|'); for (int i = 1; i <= intobjective + 1; i++) { if (i < intobjective + 1) { sheet.Range[irow, poscol + i - 1].Value2 = 0; for (int j = 1; j < strexpobj.Length; j++) { if (i == int.Parse(strexpobj[j])) { sheet.Range[irow, poscol + i - 1].Value2 = int.Parse(strmark[j]); } } } // else // sheet.Range[irow, poscol + i - 1].Text = "NO"; } } else { for (int i = 1; i <= intobjective + 1; i++) { if (i < intobjective + 1) { sheet.Range[irow, poscol + i - 1].Value2 = 0; } else { sheet.Range[irow, poscol + i - 1].Text = "NO"; } } } irow = irow + 1; } //foreach (View_class_stu } /// end if( lstall !=null) /// sheet.AllocatedRange.AutoFitColumns(); wb.SaveToFile(dirsave, ExcelVersion.Version2013); MessageBox.Show("excel生成好了"); }
///// private void addexerdetail(V_tea_course vcc, List <exerL> ell1, List <int> obctivep, List <int> comp, List <int> typenum, List <int> typescore, int totalscore) { List <List <featurehelp> > testpaper = new List <List <featurehelp> > (); int countell = ell1.Count(); foreach (exerL eel in ell1) { List <featurehelp> paperf = new List <ServiceReference1.featurehelp>(); testpaper.Add(paperf); } List <List <featurehelp> > qlist = new List <List <featurehelp> >(); /* * for (int i = 0; i < 5; i++) * for (int j = 0; j < obctivep.Count(); j++) * { * var q1 = from o in pp.context.featurehelp * where o.type1 == i && o.objective == j + 1 && o.courseid == vcc.couseid * select o; * List<featurehelp> fp = null; * fp = q1.ToList(); * qlist.Add(fp); * * }*/ for (int j = 0; j < obctivep.Count(); j++) { var q1 = from o in pp.context.featurehelp where o.objective == j + 1 && o.courseid == vcc.couseid select o; List <featurehelp> fp = null; fp = q1.ToList(); qlist.Add(fp); } // int totalscore = 0; // for (int i = 0; i < typenum.Count(); i++) // totalscore = totalscore + typenum[i] * typescore[i]; List <int> scoreofobj = new List <int>(); for (int i = 0; i < obctivep.Count(); i++) { scoreofobj.Add((int)obctivep[i] * totalscore / 100); } // totalscore = totalscore + typenum[i] * typescore[i]; List <int> scoreofcon = new List <int>(); for (int i = 0; i < comp.Count(); i++) { scoreofcon.Add((int)comp[i] * totalscore / 100); } /////////////////////////////////////随机化各类目标 List <List <featurehelp> > qlist2 = new List <List <featurehelp> >(); for (int i = 0; i < qlist.Count(); i++) { List <featurehelp> tfp; tfp = RandomSortList <featurehelp>(qlist[i]); qlist2.Add(tfp); } ///////////////////////////////// // List<featurehelp> templ; // templ= GetRandomQue((List<featurehelp>)qlist[0],2); ////////////////////////////// //List < List<featurehelp>> allqustion=new List<List<featurehelp>>() ; ///////产生问题 for (int i = qlist2.Count() - 1; i >= 0; i--) { // int sumss = 0; // int jj = 0; List <bool> lflag = new List <bool> (countell); for (int k = 0; k < lflag.Capacity; k++) { lflag.Add(false); } for (int j = 0; j < qlist2[i].Count(); j++) { int numel = j % countell; /* if (numel == 0 && sumss / countell >= scoreofobj[i]) break; * testpaper[numel].Add(qlist2[i][j]); * sumss = sumss + getscore(qlist2[i][j], typescore);*/ // if (isobjectiveok(testpaper[numel], scoreofobj, i, typescore) ) if (isobjectiveok(testpaper[numel], scoreofobj, i, typescore) && isconok(testpaper[numel], scoreofcon, (int)qlist2[i][j].con, i, typescore)) { testpaper[numel].Add(qlist2[i][j]); } else { lflag[numel] = true; } // ??????if (!lflag.Exists(o=>o==false)) break; /* bool flag2 = true; * foreach (bool bl in lflag) * if (!bl) flag2 = bl; * if(flag2) break;*/ } //MessageBox.Show(i.ToString()); } ////////////////////////////// int kk = 0; foreach (exerL el in ell1) { toexerl(el, testpaper[kk], typescore); kk++; } }