APP下载

基于CSV格式的考试系统研究

2015-12-21丁亚涛

电脑知识与技术 2015年27期

丁亚涛

摘要:该文研究利用CSV数据格式存储考试相关数据。作为Excel标准数据格式,在面向普通教师方面比专业的数据库系统更具有实用性。由于考试系统所面对的对象是教师和学生,特别是非计算机专业的用户群,如何使得系统的使用更加方便和高效,必须充分考虑用户的使用体验。基于CSV格式的考试系统降低了软件系统应用门槛,提升了软件的实际用价值。

关键词:CSV;考试系统;数据格式

中图分类号:TP311.13 文献标识码:A 文章编号:1009-3044(2015)28-0070-02

Research on CSV Data Format of Test System

DING Ya-tao

(AHTCM, College of Medical Information Engineering, Hefei 230012, China)

Abstract: In this paper, we use CSV data format to store data. As the standard data format of Excel, it is more practical for ordinary teachers to be more practical than a professional database system. As the user group of the examination system is the teacher and students, especially the non computer professional user group, how to make the system more convenient and efficient, we must consider the user's experience. Examination system based on CSV format reduces the threshold of the application of the software system, and promotes the practical value of the software.

Key words: CSV; test system; data format

考试软件系统中存储数据的格式可以选择数据库,也可以选择其他方式。笔者通过二级Office考试系统的开发与研究发现,基于CSV格式的数据存储尤其很好的数据优势。CSV是Excel导出的一种数据格式,分行按自定义分隔符,评卷时非常方便,数据存储兼容Office,非常适合数据量不大的考试系统软件系统。下面是应用的基本思路。

1 自定义CSV格式

自定义的CSV格式可以有很多种,例如下面的以“,”作为分隔符的格式:

SheetName,3,,,,平均单价,,,1,工作表名错误,没有将“sheet2”工作表命名为“平均单价”,

SheetFormula,2,A4,A4,内容,,001,1,1,插入列错误,没有在“店铺”列左侧插入一个空列,

所对应的分割项目分别是:

函数名称,表编号,开始单元格,结束单元格,原属性,值1, 值2, 值3,分值,错误提示,说明,

2 读取数据

先定义一个函数库或函数串,例如:

FunctionLib =“Name, Formula, PivotTable,Cells_Alignment,Cells_value,……”

编写一个函数用来将函数库或函数串列入数组等集合中,例如:

Public cmdArray(100)

Store "" To cmdArray

cSplitChar=“,”

cString = Alltrim(FunctionLib)

nSplitChar = Occurs(cSplitChar,cString )

If nSplitChar >1

If Left(cString,1)<>cSplitChar

cString = cSplitChar + cString

Endif

For j= 1 To nSplitChar

nleft = At(cSplitChar,cString,j)

nRight = At(cSplitChar,cString,j+1)

If nRight - nleft > 1

cmdArray(j)=Substr(cString,nleft+1,nRight - nleft -1)

Else

cmdArray(j)=""

Endif

Endfor

Endif

得到参数集合cmdArray后,构建评卷程序框架:

nScore = 0

bRight = .F.

If !Empty(cmdArray(1)) And UPPER(cmdArray(1))+"," $ UPPER(CommandLib)

cmdName = Upper(cmdArray(1))

DO Case

Case cmdName = Upper("Cells_Alignment")

LOCAL nTableNumber

nTableNumber =INT(VAL(cmdArray(2)))

bError =.T.

oTable = oWord.Documents(1).Tables(nTableNumber)

TRY

DO case

CASE "中" $ cmdArray(5)

If oTable.rows.Alignment = 1

bRight =.T.

Endif

CASE "中" $ cmdArray(5)

If oTable.rows.Alignment = 1

bRight =.T.

Endif

CASE "中" $ cmdArray(5)

If oTable.rows.Alignment = 1

bRight =.T.

Endif

……

Endcase

bError =.F.

Catch

bError =.T.

Endtry

If !bError

nScore = nScore + Val(cmdArray(8))

Endif

Case …

Endcase

3 定义评卷答案

由于CSV格式是Excel可以识别的标准格式,所以,命卷工作可以直接在Excel中完成,例如下面的命卷:


登录APP查看全文