例如,标准答案为“ABE”,则对应得分表如下所示。
学生答案 | ABE | AB | AE | BE | A | B | E | AC | ...... |
字符串 | 11001 | 11000 | 10001 | 01001 | 10000 | 01000 | 00001 | 10100 | ...... |
十进制数(x) | 25 | 24 | 17 | 9 | 16 | 8 | 1 | 20 | ...... |
ans(x) | 2 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 0 |
小温依据上述描述设计了“多选题阅卷”的VB程序,实现如下功能:在文本框Text1中输入标准答案(大写字母),先单击“初始化”按钮Command1,在数组ans中生成所有答案组合对应的分值,然后单击“阅卷”按钮Command2,从数据库中读取学生的答案并进行阅卷,在列表框List1中显示得分结果。程序运行界面如图所示。
Dim ans(0 To 31) As Integer
Private Sub Command1_Click()
Dim b(0 To 4) As Integer
Dim s As String, c As String, sum As Integer, k As Integer
'初始化数组ans和数组b,各元素的初始值均为0。代码略
s = Text1.Text:k = Len(s)
For i = 1 To k
c = Mid(s, i, 1)
b(Asc(c) - 65) = 2 ^ (69 - Asc(c))
Next i
For i = 0 To 4
If b(i) <> 0 Then
ans(b(i)) = 1
sum = ①
End If
Next i
ans(sum) = 2
'当标准答案含3个及以上选项时,学生答案选其中2个选项可得1分
i = 0
Do While k >= 3 And i <= 4
For j = i + 1 To 4
If b(i) * b(j) <> 0 Then ans(b(i) + b(j)) = 1
Next j
i = i + 1
Loop
i = 0
Do While k >= 4 And i <= 4
For j = i + 1 To 4
If b(i) * b(j) = 0 Or k = 5 Then ②
Next j
i = i + 1
Loop
'当标准答案含5个选项时,学生答案选其中4个选项可得1分。代码略
End Sub
Private Sub Command2_Click()
Dim xh(1 To 1000) As String, answer(1 To 1000) As String
'从数据库中读取学生学号和答案的数据分别存储在数组xh和answer中
'记录总数存储在变量n中,代码略
List1.Clear
For i = 1 To n
List1.AddItem xh(i) + " " + answer(i) + " " + Str(ans(f(answer(i))))
Next i
End Sub
Function f(s As String) As Integer
Dim i As Integer, x As Integer
x = 0
For i = 1 To Len(s)
x = ③
Next i
f = x
End Function
① ② ③