以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]报错原因?  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=50075)

--  作者:lpedu_jks
--  发布时间:2014/4/28 23:33:00
--  [求助]报错原因?

Dim r As Integer = Tables(Km & "小题分析").Cols("难度").Index
Dim q As Integer = Tables(Km & "小题分析").Cols("区分度").Index

ElseIf 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)
Else
End If

当代码执行ElseIf Lx = "单项填空"  Then时报错,其它“完形填空”、“阅读理解”等就没问题。是怎么回事?请指教。谢谢! 


图片点击可在新窗口打开查看此主题相关图片如下:报错.jpg
图片点击可在新窗口打开查看
[此贴子已经被作者于2014-4-28 23:32:55编辑过]

--  作者:Bin
--  发布时间:2014/4/29 8:28:00
--  
Aggregate 的参数有问题,表没有57行吧
--  作者:有点甜
--  发布时间:2014/4/29 9:06:00
--  
 数据表的行数不足够。
--  作者:lpedu_jks
--  发布时间:2014/4/29 9:50:00
--  
总行数62行,取值是r列的1-15行(0-14),q列的1-15行 (0-14) ,索引没超出范围、非负值并小于集合。
只要删除dr("难度") = Tables(Km & "小题分析").Aggregate(AggregateEnum.Average, 0, r, 14, r)
           dr("区分度") = Tables(Km & "小题分析").Aggregate(AggregateEnum.Average, 0, q, 14, q)
就没问题了,但这是计算当Lx = "单项填空"  即类型=“单项填空”时的难度(Km & "小题分析"表中r列1-15行)和区分度(Km & "小题分析"表中q列1-15行)。不知怎么回事?请指教。谢谢!

--  作者:有点甜
--  发布时间:2014/4/29 9:56:00
--  
 回复4楼,不可能有这种问题,做个小例子发上来。
--  作者:lpedu_jks
--  发布时间:2014/4/29 10:08:00
--  
文件上传。
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:复印高中试卷难度区分度分析.rar


--  作者:Bin
--  发布时间:2014/4/29 10:18:00
--  
明明就只有一行数据.. 当然会报错.
--  作者:lpedu_jks
--  发布时间:2014/4/29 10:34:00
--  
将代码:ElseIf Lx = "单项填空"  Then
               dr("难度") = Tables(Km & "小题分析").Aggregate(AggregateEnum.Average, 0, r, 14, r)
               dr("区分度") = Tables(Km & "小题分析").Aggregate(AggregateEnum.Average, 0, q, 14, q)
删除后,执行就没问题。好像问题就出在这里。
[此贴子已经被作者于2014-4-29 10:35:02编辑过]

--  作者:有点甜
--  发布时间:2014/4/29 12:01:00
--  

 完全理解不了楼主的意图啊,是不是这样?图片点击可在新窗口打开查看

 

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编辑过]

--  作者:lpedu_jks
--  发布时间:2014/4/29 13:24:00
--  

是这样。谢谢!

应该在For Each Th As String In DataTables("答案设置").GetValues( "题号","科目 = \'"& Km &"\'")
下的代码执行后才能再给条件:

        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
执行后面的代码。是这样理解的吧?