完全理解不了楼主的意图啊,是不是这样?
For Each Km As String In DataTables("校名设置").GetValues( "科目","单位 = '统计'")
Dim s1() As String = New String() {""& Km &""}
Dim dt As Table = Tables(Km)
Dim c2 As Integer = DataTables(Km).DataRows.count*0.27
Dim c3 As Integer = DataTables(Km).DataRows.count*0.73
Functions.Execute("小题排名",s1,dt)
Dim dtb As New DataTableBuilder(Km & "小题分析")
dtb.AddDef("题号",Gettype(String),8)
dtb.AddDef("序号",Gettype(Double))
dtb.AddDef("答案",Gettype(String),4)
dtb.AddDef("参考人数",Gettype(Double))
dtb.AddDef("最大值",Gettype(Double))
dtb.AddDef("最小值",Gettype(Double))
dtb.AddDef("平均分",Gettype(Double))
dtb.AddDef("标准差",Gettype(Double))
dtb.AddDef("得分人",Gettype(Double),"","得分率_人数")
dtb.AddDef("得分率",Gettype(Double),"","得分率_%")
dtb.AddDef("满分人",Gettype(Double),"","满分率_人数")
dtb.AddDef("满分率",Gettype(Double),"","满分率_%")
dtb.AddDef("零分人",Gettype(Double),"","零分率_人数")
dtb.AddDef("零分率",Gettype(Double),"","零分率_%")
dtb.AddDef("难度",Gettype(Double))
dtb.AddDef("区分度",Gettype(Double))
dtb.Build()
For Each Th As String In DataTables("答案设置").GetValues( "题号","科目 = '"& Km &"'")
For Each Xh As String In DataTables("答案设置").GetValues("序号","题号 = '"& Th &"'")
Dim dr As DataRow = DataTables(Km & "小题分析").AddNew()
Dim dr1 As DataRow = DataTables("答案设置").Find("题号 = '" & Th & "'")
Dim c1 As Double = dr1("目标2")
dr("答案") = dr1("目标1")
dr("题号") = Th
dr("序号") = Xh
Tables(Km & "小题分析").Sort = "序号"
dr("参考人数") = DataTables(Km).Compute("count(单位)")
dr("最大值") = DataTables(Km).Compute("Max(" & dr("题号") & ")")
dr("最小值") = DataTables(Km).Compute("Min(" & dr("题号") & ")")
dr("平均分") = DataTables(Km).Compute("Avg(" & dr("题号") & ")")
Dim p As Integer = Tables(Km).Cols("" & dr("题号") & "").Index
Dim rs As Integer = Tables(Km).Rows.Count -1
dr("标准差") = Tables(Km).Aggregate(AggregateEnum.Std, 0, p, rs, p)
dr("得分人") = DataTables(Km).Compute("count(单位)",""& dr("题号") &" > 0")
dr("得分率") = dr("平均分")/c1*100 '正确率,平均分/满分
dr("满分人") = DataTables(Km).Compute("count(单位)",""& dr("题号") &" = "& dr1("目标2") &"")
dr("满分率") = dr("满分人")/dr("参考人数")*100
dr("零分人") = DataTables(Km).Compute("count(单位)",""& dr("题号") &" = 0")
dr("零分率") = dr("零分人")/dr("参考人数")*100
For Each Lx As String In DataTables("答案设置").GetValues( "类型", "题号 = '" & dr("题号") & "'")
Dim tj As String = Km & "排名"
Dim c4 As Double = DataTables(Km).Compute("count(单位)", ""& dr("题号") &" = " & dr1("目标2") & " and " & tj & " <= '" & c2 & "'")
Dim c5 As Double = DataTables(Km).Compute("count(单位)", ""& dr("题号") &" = " & dr1("目标2") & " and " & tj & " >= '" & c3 & "'")
Dim c6 As Double = DataTables(Km).Compute("Sum("& dr("题号") &")","" & tj & " <= '" & c2 & "'")
Dim c7 As Double = DataTables(Km).Compute("Sum("& dr("题号") &")","" & tj & " >= '" & c3 & "'")
Dim c11 As Double = DataTables(Km).Compute("Avg("& dr("题号") &")","" & tj & " <= '" & c2 & "'")
Dim c12 As Double = DataTables(Km).Compute("Avg("& dr("题号") &")","" & tj & " >= '" & c3 & "'")
If Lx = "客观题" Then
dr("难度") = dr("平均分")/c1 '主观题难度:平均分/满分,也可以满分人/参考人数
dr("区分度") = (c4-c5)/c2 '客观题区分度:高低分组难度值之差,也可以高低分组的平均分之差/满分((c11- c12)/c1)
ElseIf Lx = "主观题" Then
dr("难度") = dr("平均分")/c1 '客观题难度:正确率,也可以平均分/满分
dr("区分度") = (c6-c7)/c2/(dr("最大值")-dr("最小值")) '也可以高低分组的平均分之差/满分((c11- c12)/c1))
End If
Next
Next
Next
For Each dr As DataRow In DataTables(Km & "小题分析").DataRows
Dim r As Integer = Tables(Km & "小题分析").Cols("难度").Index
Dim q As Integer = Tables(Km & "小题分析").Cols("区分度").Index
Dim Lx As String = dr("题号")
If lx = "单项填空" Then
dr("难度") = Tables(Km & "小题分析").Aggregate(AggregateEnum.Average, 0, r, 14, r)
dr("区分度") = Tables(Km & "小题分析").Aggregate(AggregateEnum.Average, 0, q, 14, q)
ElseIf Lx = "完形填空" Then
dr("难度") = Tables(Km & "小题分析").Aggregate(AggregateEnum.Average, 15, r, 34, r)
dr("区分度") = Tables(Km & "小题分析").Aggregate(AggregateEnum.Average, 15, q, 34, q)
ElseIf Lx = "阅读理解" Then
dr("难度") = Tables(Km & "小题分析").Aggregate(AggregateEnum.Average, 35, r, 54, r)
dr("区分度") = Tables(Km & "小题分析").Aggregate(AggregateEnum.Average, 35, q, 54, q)
ElseIf Lx = "写作" Then
dr("难度") = Tables(Km & "小题分析").Aggregate(AggregateEnum.Average, 55, r, 56, r)
dr("区分度") = Tables(Km & "小题分析").Aggregate(AggregateEnum.Average, 55, q, 56, q)
ElseIf Lx = Km Then
dr("难度") = Tables(Km & "小题分析").Aggregate(AggregateEnum.Average, 0, r, 56, r)
dr("区分度") = Tables(Km & "小题分析").Aggregate(AggregateEnum.Average, 0, q, 56, q)
End If
Next
Tables(Km & "小题分析").SetHeaderRowHeight(30,30) '表名的两个标题行的行高
Tables(Km & "小题分析").DefaultRowHeight = 25 '设置默认的行高
Tables(Km & "小题分析").Cols("题号").TextAlign = TextAlignEnum.Center
Tables(Km & "小题分析").Cols("答案").TextAlign = TextAlignEnum.Center
Tables(Km & "小题分析").Cols("参考人数").TextAlign = TextAlignEnum.Center
Tables(Km & "小题分析").Cols("最大值").TextAlign = TextAlignEnum.Center
Tables(Km & "小题分析").Cols("最小值").TextAlign = TextAlignEnum.Center
Tables(Km & "小题分析").SetColVisibleWidth("题号|70|序号|40|答案|40|参考人数|40|最大值|40|最小值|40|平均分|45|标准差|45|得分人|45|得分率|45|满分人|45|满分率|45|零分人|45|零分率|45|难度|45|区分度|45") '批量设置要显示的列及其列宽Dim nms() As String = {"平均分","标准差","得分率","满分率","零分率","难度","区分度"}
Dim nms() As String = {"平均分","标准差","得分率","满分率","零分率","难度","区分度"}
For Each nm As String In nms
For Each dr As DataRow In DataTables(Km & "小题分析").DataRows
If dr.IsNull(nm) = False Then
dr(nm) = Math.Round(dr(nm),3)'确定小数位数
End If
Next
Next
DataTables(Km & "小题分析").Save()
DataTables(Km).ResumeRedraw
Next
[此贴子已经被作者于2014-4-29 12:01:30编辑过]