Диплом: Автоматизация процесса контроля знаний учащихся ГОУ СОШ

Внимание! Если размещение файла нарушает Ваши авторские права, то обязательно сообщите нам
75
throw Exception("");
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
}
return 0;
}
//---------------------------------------------------------------------------
UProfile.h
//---------------------------------------------------------------------------
#ifndef UProfileH
#define UProfileH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ExtCtrls.hpp>
#include <stdio.h>
#include "UTest.h"
//---------------------------------------------------------------------------
class TProfileForm : public TForm
{
__published: // IDE-managed Components
TListBox *ProfileListBox;
TButton *SelectBt;
TEdit *AddEd;
TButton *AddBt;
76
TPanel *MainPnl;
TLabel *Label1;
TGroupBox *InfoGB;
TLabel *Label2;
TLabel *Label3;
TLabel *Label4;
TPanel *BestPnl;
TPanel *QtyPnl;
TPanel *MiddlePnl;
TButton *DelBt;
TGroupBox *GroupBox1;
TGroupBox *GroupBox2;
void __fastcall FormCreate(TObject *Sender);
void __fastcall AddBtClick(TObject *Sender);
void __fastcall DelBtClick(TObject *Sender);
void __fastcall ProfileListBoxEnter(TObject *Sender);
void __fastcall SelectBtClick(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TProfileForm(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TProfileForm *ProfileForm;
extern String currentProfile;
extern int* openProfile(String name, int &n);
extern void saveProfile(String name, int* mas, int n);
//---------------------------------------------------------------------------
#endif
UProfile.cpp
//---------------------------------------------------------------------------
77
#include <vcl.h>
#pragma hdrstop
#include "UProfile.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TProfileForm *ProfileForm;
String currentProfile;
//---------------------------------------------------------------------------
__fastcall TProfileForm::TProfileForm(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void findProfiles()
{
TSearchRec tsch_r;
String str;
if(FindFirst("profiles/*.prof", faAnyFile, tsch_r) == 0)
{
do
{
str = tsch_r.Name;
str.Delete(str.Pos(".prof"), 5);
ProfileForm->ProfileListBox->Items->Add(str);
}
while(FindNext(tsch_r) == 0);
}
FindClose(tsch_r);
78
}
//---------------------------------------------------------------------------
int* openProfile(String name, int &n)
{
FILE *file;
int *mas;
if((file = fopen(("profiles/" + name + ".prof").c_str(), "r")) != NULL)
{
fread(&n, sizeof(int), 1, file);
mas = new int[n];
for ( int i = 0; i < n; i++ )
{
fread(&mas[i], sizeof(int), 1, file);
}
}
fclose(file);
return mas;
}
//---------------------------------------------------------------------------
void saveProfile(String name, int* mas, int n)
{
FILE *file;
if((file = fopen(("profiles/" + name + ".prof").c_str(), "w")) != NULL)
{
fwrite(&n, sizeof(int), 1, file);
for ( int i = 0; i < n; i++ )
{
int a = mas[i];
79
fwrite(&a, sizeof(int), 1, file);
}
}
fclose(file);
}
//---------------------------------------------------------------------------
void __fastcall TProfileForm::FormCreate(TObject *Sender)
{
findProfiles();
if ( ProfileListBox->Count )
{
ProfileListBox->ItemIndex = 0;
DelBt->Enabled = true;
SelectBt->Enabled = true;
}
}
//---------------------------------------------------------------------------
void __fastcall TProfileForm::AddBtClick(TObject *Sender)
{
if(AddEd->Text != "")
{
if(ProfileListBox->Items->IndexOf(AddEd->Text) == -1 )
{
int *mas = NULL;
saveProfile(AddEd->Text, mas, 0);
ProfileListBox->Items->Add(AddEd->Text);
DelBt->Enabled = true;
SelectBt->Enabled = true;
ProfileListBox->ItemIndex = ProfileListBox->Count - 1;
}
else
{
80
ShowMessage("Профиль с таким именем уже существует");
}
}
else
{
ShowMessage("Нельзя создать профиль с пустым именем!");
}
}
//---------------------------------------------------------------------------
void __fastcall TProfileForm::DelBtClick(TObject *Sender)
{
remove(("profiles/" + ProfileListBox->Items->operator [](ProfileListBox-
>ItemIndex) + ".prof").c_str());
ProfileListBox->Items->Delete(ProfileListBox->ItemIndex);
QtyPnl->Caption = "";
BestPnl->Caption = "";
MiddlePnl->Caption = "";
if ( !ProfileListBox->Count )
{
DelBt->Enabled = false;
SelectBt->Enabled = false;
}
else
{
ProfileListBox->ItemIndex = 0;
}
}
//---------------------------------------------------------------------------
void __fastcall TProfileForm::ProfileListBoxEnter(TObject *Sender)
{
if ( ProfileListBox->Count )
{
81
int n;
int *mas = openProfile(ProfileListBox->Items->operator [](ProfileListBox-
>ItemIndex), n);
int max = 0;
int sum = 0;
for ( int i = 0; i < n; i++ )
{
if ( max < mas[i] )
{
max = mas[i];
}
sum += mas[i];
}
QtyPnl->Caption = IntToStr(n);
BestPnl->Caption = IntToStr(max);
MiddlePnl->Caption = IntToStr(n ? sum / n : 0);
}
}
//---------------------------------------------------------------------------
void __fastcall TProfileForm::SelectBtClick(TObject *Sender)
{
currentProfile = ProfileListBox->Items->operator [](ProfileListBox-
>ItemIndex);
Hide();
TestForm->Show();
}
//---------------------------------------------------------------------------
UTest.h
//---------------------------------------------------------------------------
82
#ifndef UTestH
#define UTestH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ExtCtrls.hpp>
#include <stdio.h>
#include "UResult.h"
//---------------------------------------------------------------------------
class TTestForm : public TForm
{
__published: // IDE-managed Components
TGroupBox *QuestionGB;
TGroupBox *AnswerGB;
TPanel *MainPanel;
TMemo *QuestionMemo;
TMemo *AnswerMemo1;
TMemo *AnswerMemo2;
TMemo *AnswerMemo3;
TMemo *AnswerMemo4;
TRadioButton *RadioButton1;
TRadioButton *RadioButton2;
TRadioButton *RadioButton3;
TRadioButton *RadioButton4;
TButton *OkBt;
void __fastcall FormShow(TObject *Sender);
void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
void __fastcall OkBtClick(TObject *Sender);
private: // User declarations
public: // User declarations
83
__fastcall TTestForm(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TTestForm *TestForm;
extern int trueAnswer;
extern int qty;
extern int qtyTrue;
//---------------------------------------------------------------------------
#endif
UTest.cpp
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
//---------------------------------------------------------------------------
USEFORM("UProfile.cpp", ProfileForm);
USEFORM("UTest.cpp", TestForm);
USEFORM("UResult.cpp", ResultForm);
//---------------------------------------------------------------------------
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
try
{
Application->Initialize();
Application->Title = "Тестирование знаний";
Application->CreateForm(__classid(TProfileForm), &ProfileForm);
Application->CreateForm(__classid(TTestForm), &TestForm);
Application->CreateForm(__classid(TResultForm), &ResultForm);
Application->Run();
}
catch (Exception &exception)
84
{
Application->ShowException(&exception);
}
catch (...)
{
try
{
throw Exception("");
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
}
return 0;
}
//---------------------------------------------------------------------------
UResult.h
//---------------------------------------------------------------------------
#ifndef UResultH
#define UResultH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ExtCtrls.hpp>
#include "UProfile.h"
//---------------------------------------------------------------------------
class TResultForm : public TForm

Смотрите также:

"Автоматизация обработки заявок ООО "Проектно-Строительная Компания"
"Автоматизация процесса аттестации персонала для ООО "Нэт Бай Нэт Холдинг"
"Анализ интернет-активности конкурентов ( на примере конкурентов "Газпром нефть")
"Бухгалтерский учёт и аудит расчётов с подотчётними лицами в организации на примере ООО "ЛОЦ 10""
«Психологическое сопровождение персонала в организации на примере ООО «Крокус»
Cовершенствование деловой оценки персонала в организации (на примере ООО "Даймонд кейтеринг развитие")
IPO - инструмент финансирования деятельности организации. На примере ПАО «Нефтяная компания «Лукойл»
PR как средство продвижения организации (на примере ПАО "Тамбовский завод "Комсомолец им. Н.С. Артемова")
PR-коммуникации в сфере общественного питания (на примере кафе-кондитерской «Cream Cheese»)
SMM как средство повышения эффективности работы учреждений социокультурной сферы (на примере Малого театра)