你好,欢迎来到电脑编程技巧与维护杂志社! 杂志社简介广告服务读者反馈编程社区  
合订本订阅
 
 
您的位置:杂志经典 / 编程语言
C++Builder下基于CppWebBrowser的“考试系统”设计与实现(二)
 

2.2  数据结构设计

“专业技术理论考试系统”采用试卷管理类实现了试题题型、单题数据、大题数据、用户输入信息等内容的统一管理,系统结构清晰,层次分明。

1) 试题类型结构

struct  TQuestionType

{

    int type_id;            //题型ID

    AnsiString type_name;   //题型名称

};

2) 试题类型管理类

class TQuestionTypeManager

{

    public:

        TList * QuestionTypes;  //试题类型列表

        int     GetTypesNum()

        {

            return QuestionTypes->Count;

        };

 //加入新题型

        void    AddQuestionType(AnsiString type_name,int type_id)

        {

            TQuestionType * curType = new TQuestionType();

            curType->type_id = type_id;

            curType->type_name = type_name;

            QuestionTypes->Add(curType);

        };

 

        TQuestionTypeManager() { QuestionTypes = new TList();};

            //析构时释放题型对象实例

        ~TQuestionTypeManager()

        {

            for(int i=QuestionTypes->Count-1;i>=0;i--)

                delete (TQuestionType *)QuestionTypes->Items[i];

            delete QuestionTypes;

        };

};

3) 试题对象类

试题对象类用来描述试卷上的每一道试题对象,包括试题的题干、答案、选项等内容。

//试题对象描述类

class TQuestion                   

{

    public:

    AnsiString    Body;         //题干内容

    TStringList*  SelectItems;      //试题选项

    TStringList*  UserAnswerItems;  //用户填空题输入内容

    AnsiString    Answers;          //试题原答案

    AnsiString    UserAnswers;      //用户选择、判断题输入内容

 

    TQuestion()

    {

        SelectItems = new TStringList();

        UserAnswerItems = new TStringList();

        UserAnswerCheck = new TStringList();

    };

    ~TQuestion()

    {

        delete SelectItems;

        delete UserAnswerCheck;

        delete UserAnswerItems;

    };

 

};

4) 试题集合类

试题集合类用来管理一个大题内的所有试题,同时存储本类大题的题型和每题分值信息。

class TQuestionUnits  //试题集合类

{

    public:

        TQuestionType* questionType;    //题型

        float          questionScore;   //每题分值

       

        TList*        Questions;

        TQuestionUnits()

        {

           Questions = new TList();

        };

        ~TQuestionUnits()

        {

           for(int i=Questions->Count-1;i>=0;i--)

               delete (TQuestion *)Questions->Items[i];

           delete Questions;

        };

};

 

5 HTML试卷管理类

HTML试卷管理类用来实现对一次考试的全部信息进行管理,包括设定的考试时间、用户姓名和单位、HTML试卷题头以及试卷包含的大题等内容。

//HTML试卷管理类

class THTMLPaper

{

    public:

        TList*     QuestionUnits;   //试题集合列表(试卷大题列表)

        int        ExamTimes;       //考试时长

        long long  ExamStartTime;   //考试开始时间

        long long  ExamEndTime;     //考试结束时间

        float      UserScores;      //用户成绩

        float      PaperTotalScore;     //卷面总分

        AnsiString  UserName;  //用户名

        AnsiString  UserCompany;    //用户单位

        bool        AllowMakePaper;     //允许生成试卷标志

        AnsiString  PaperTitle;    //试卷标题题头

        float       SimilitudeValue; //答案相似度

                                         //当相似度大于该值时得分

        //清空试卷数据

        void Clear()

        {

            UserScores - 0;

            PaperTotalScore = 0;

            for(int i=QuestionUnits->Count-1;i>=0;i--)

                delete (TQuestionUnits *)QuestionUnits->Items[i];

            QuestionUnits->Clear();

        };

        THTMLPaper()

        {

            QuestionUnits = new TList();

        };

        ~THTMLPaper()

        {

            for(int i=QuestionUnits->Count-1;i>=0;i--)

                delete (TQuestionUnits *)QuestionUnits->Items[i];

            delete QuestionUnits;

        };

};

 

2.3  系统流程设计


  推荐精品文章

·2024年2月目录 
·2024年1月目录
·2023年12月目录
·2023年11月目录
·2023年10月目录
·2023年9月目录 
·2023年8月目录 
·2023年7月目录
·2023年6月目录 
·2023年5月目录
·2023年4月目录 
·2023年3月目录 
·2023年2月目录 
·2023年1月目录 

  联系方式
TEL:010-82561037
Fax: 010-82561614
QQ: 100164630
Mail:gaojian@comprg.com.cn

  友情链接
 
Copyright 2001-2010, www.comprg.com.cn, All Rights Reserved
京ICP备14022230号-1,电话/传真:010-82561037 82561614 ,Mail:gaojian@comprg.com.cn
地址:北京市海淀区远大路20号宝蓝大厦E座704,邮编:100089