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 系統流程設計

|