uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, Buttons, DB, DBTables;
type
TForm6 = class(TForm)
Panel1: TPanel;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
Label1: TLabel;
Edit1: TEdit;
Label2: TLabel;
Edit2: TEdit;
Label3: TLabel;
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form6: TForm6;
implementation
uses Unit1;
{$R *.dfm}
procedure TForm6.BitBtn1Click(Sender: TObject);
begin
ModalResult:=mrNo;
end;
procedure TForm6.BitBtn2Click(Sender: TObject);
var
Comm:TStringList;
begin
try
with Form1.Table1 do begin
Active := False;
DatabaseName := 'Olymp';
TableType := ttParadox;
TableName := Edit1.Text;
if not Form1.Table1.Exists then begin
with FieldDefs do begin
Clear;
with AddFieldDef do begin
Name := 'Counter';
DataType := ftInteger;
Required := True;
end;
with AddFieldDef do begin
Name := 'FIO';
DataType := ftString;
Size := 25;
end;
with AddFieldDef do begin
Name := 'MARK1';
DataType := ftFloat;
Required := True;
end;
with AddFieldDef do begin
Name := 'MARK2';
DataType := ftFloat;
Required := True;
end;
with AddFieldDef do begin
Name := 'MARK3';
DataType := ftFloat;
Required := True;
end;
with AddFieldDef do begin
Name := 'MARK4';
DataType := ftFloat;
Required := True;
end;
with AddFieldDef do begin
Name := 'MARK5';
DataType := ftFloat;
Required := True;
end;
with AddFieldDef do begin
Name := 'MARK6';
DataType := ftFloat;
Required := True;
end;
with AddFieldDef do begin
Name := 'SUMMARK';
DataType := ftFloat;
Required := True;
end;
with AddFieldDef do begin
Name := 'SCHOOL';
DataType := ftString;
Size := 35;
end;
with AddFieldDef do begin
Name := 'PARAM1';
DataType := ftFloat;
Required:=False;
end;
with AddFieldDef do begin
Name := 'PARAM2';
DataType := ftFloat;
Required:=False;
end;
with AddFieldDef do begin
Name := 'PARAM3';
DataType := ftFloat;
Required:=False;
end;
with AddFieldDef do begin
Name := 'PLACE';
DataType := ftInteger;
Required:=False;
end;
end;
with IndexDefs do begin
Clear;
with AddIndexDef do begin
Name := '';
Fields := 'COUNTER';
Options := [ixPrimary];
end;
with AddIndexDef do begin
Name := 'VAL1';
Fields := 'PARAM1';
Options := [ixDescending];
end;
with AddIndexDef do begin
Name := 'VAL2';
Fields := 'PARAM2';
Options := [ixDescending];
end;
with AddIndexDef do begin
Name := 'VAL3';
Fields := 'PARAM3';
Options := [ixDescending];
end;
end;
CreateTable;
Application.MessageBox('Локальная база данных успешно создана!','Сообщение',mb_OK+mb_IconAsterisk);
end
else Application.MessageBox('Локальная база данных уже существует и открыта!','Сообщение',mb_OK+mb_IconAsterisk);
end;
except
Application.MessageBox('Ошибка создания базы данных!','Внимание',mb_OK+mb_IconHand);
Exit;
end;
Form1.Table1.Active:=True;
Form1.dsOlymp.DataSet:=Form1.Table1;
Form1.DBGrid1.DataSource:=Form1.dsOlymp;
Comm:=TStringList.Create;
Comm.Clear;
Comm.Add(Edit2.Text);
Comm.SaveToFile('Bases\'+Edit1.Text+'.olp');
Comm.Free;
Form1.Label1.Caption:='ОписаниеБД: '+Edit2.Text;
ModalResult:=mrNo;
end;
end.
Модуль 6.
Этот модуль отвечает за весь процесс оценки качества заданий. В нем рассчитываются все параметры, и строятся необходимые диаграммы.
unit Unit7;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, Buttons, Grids, DBGrids, TeEngine, Series,
TeeProcs, Chart, DB, DBTables, INIFiles;
type
TForm7 = class(TForm)
Panel1: TPanel;
BitBtn1: TBitBtn;
Chart1: TChart;
Series1: TBarSeries;
DataSource1: TDataSource;
Query1: TQuery;
GroupBox1: TGroupBox;
Label1: TLabel;
Label2: TLabel;
Label4: TLabel;
Label5: TLabel;
Chart2: TChart;
Series2: TBarSeries;
Chart3: TChart;
Series3: TLineSeries;
Series4: TBarSeries;
Series5: TBarSeries;
Label3: TLabel;
Series6: TLineSeries;
procedure BitBtn1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form7: TForm7;
Cf1:TIniFile;
implementation
uses Unit1, Unit5, foxsoft;
{$R *.dfm}
procedure TForm7.BitBtn1Click(Sender: TObject);
begin
ModalResult:=mrOk;
end;
procedure TForm7.FormShow(Sender: TObject);
var
i,j,NumI,kl,kz,nz,gr:integer;
ind,per,block1,block2,block3,coun,coun1,coun2,coun3,n1,n2,n3,k:double;
p1,p2,p3:array [1..50] of double;
GrPar, GrPercent, parm:array[1..200] of double;
MCon, Default,maxb:string;
sbl1,sbl2,sbl3:double;
kn, kp:array[1..3] of double;
srbl1,srbl2,srbl3,sdxq1,sdxq2,sdxq3:double;
dx1,dx2,dx3,sigm1,sigm2,sigm3,m:double;
begin
try
with Query1 do
begin
Active:=False;
SQL.Clear;
SQL.Add('Select * from "'+Form1.Table1.TableName+'"');
ExecSQL;
end;
Query1.Active:=True;
Chart1.Enabled:=True;
except
Application.MessageBox('ОшибкаинициализацииБД. Возможно не установлен BDE, или база не открыта.','Ошибка',mb_Ok+MB_ICONHAND);
Chart1.Enabled:=False;
Exit;
end;
if Query1.RecordCount=0 then
begin
Application.MessageBox('ВБДнетниоднойзаписи.','Сообщение',mb_Ok+MB_ICONASTERISK);
Exit;
end;
Cf1:=TIniFile.Create(GetCurrentDir+'\Config.ini');
try
with Cf1 do
begin
MCon:=ReadString('MARK_CONFIG','MARKS_TYPE',Default);
if MCon='ONE_IN_ONE' then
begin
maxb:=ReadString('MARK_CONFIG','MARKS_VALUE',Default);
end;
MCon:=ReadString('BLOCK_CONFIG','NUM_BLOCKS',Default);
end;
NumI:=StrToInt(maxb);
Cf1.Free;
except
Application.MessageBox('Ошибкачтенияиз INI-файла. Проверьтеконфигурацию.','Ошибка',mb_Ok+mb_IconHand);
Exit;
end;
for i:=0 to 200 do
begin
GrPar[i]:=0;
GrPercent[i]:=0;
parm[i]:=0;
end;
per:=0;
ind:=0;
Query1.First;
for j:=1 to Query1.RecordCount do
begin
parm[j]:=Query1.FieldValues['SUMMARK'];
Query1.Next;
end;
ind:=0;
for i:=1 to 6*NumI+1 do
begin
for j:=1 to Query1.RecordCount do
begin
if ind=parm[j] then per:=per+1;
end;
GrPar[i]:=ind;
GrPercent[i]:=per/Query1.RecordCount;
per:=0;
ind:=ind+1;
end;
Series1.Clear;
Chart1.BottomAxis.Title.Caption:='Суммарныйбалл';
Chart1.BottomAxis.Minimum:=0*NumMarks;
Chart1.BottomAxis.Maximum:=ind-1;
For i:=0 to 6*NumI+1 do
begin
Series1.AddXY(GrPar[i],GrPercent[i]);
end;
if MCon='2' then
begin
with Query1 do
begin
Series2.Clear;
Chart2.BottomAxis.Maximum:=RecordCount;
Chart2.BottomAxis.Minimum:=0;
n1:=0;
k:=1;
coun:=0;
First;
for i:=1 to RecordCount do
begin
block1:=FieldValues['MARK1']+FieldValues['MARK2']+FieldValues['MARK3'];
block2:=FieldValues['MARK4']+FieldValues['MARK5']+FieldValues['MARK6'];
Series2.AddXY(k,block1-block2);
if block1-block2>=0 then coun:=coun+1;
Next;
k:=k+1;
end;
end;
n1:=coun/Query1.RecordCount;
Label1.Caption:='Надежностьреализации - '+FloatToStr(n1*100)+'%.';
end;
if MCon='3' then
begin
with Query1 do
begin
Series2.Clear;
Series4.Clear;
Series5.Clear;
Chart2.BottomAxis.Maximum:=RecordCount+10;
Chart2.BottomAxis.Minimum:=0;
n1:=0; n2:=0; n3:=0;
k:=1;
coun:=0; coun2:=0; coun3:=0;
First;
for i:=1 to RecordCount do
begin
block1:=FieldValues['MARK1']+FieldValues['MARK2'];
block2:=FieldValues['MARK3']+FieldValues['MARK4'];
block3:=FieldValues['MARK5']+FieldValues['MARK6'];
Series2.AddXY(k,block1-block2);
Series4.AddXY(k,block2-block3);
Series5.AddXY(k,block1-block3);
if block1-block2>=0 then coun1:=coun1+1;
if block2-block3>=0 then coun2:=coun2+1;
if block1-block3>=0 then coun3:=coun3+1;
Next;
k:=k+1;
end;
end;
n1:=coun1/Query1.RecordCount;
n2:=coun2/Query1.RecordCount;
n3:=coun3/Query1.RecordCount;
Label1.Caption:='Надежностьреализации - '+FloatToStr(Okrugl(n1*100,2))+'%, '+FloatToStr(Okrugl(n2*100,2))+'%, '+FloatToStr(Okrugl(n3*100,2))+'%.';
end;
if MCon='1' then
begin
Series2.Clear;
Series4.Clear;
Series5.Clear;
Label1.Caption:='Параметр не имеет смысла с 1 блоком.';
end;
Label3.Caption:='Количество блоков задач - '+Mcon;
Label5.Caption:='Обшее количество участников '+IntToStr(Query1.RecordCount)+'.';
Label4.Caption:='Максимальный балл равен '+IntToStr(NumI)+'.';
if MCon<>'1' then
begin
Query1.First;
for i:=1 to Query1.RecordCount do
begin
p1[i]:=Query1.FieldValues['PARAM1'];
p2[i]:=Query1.FieldValues['PARAM2'];
p3[i]:=Query1.FieldValues['PARAM3'];
Query1.Next;
end;
kl:=0;
j:=1;
kz:=Query1.RecordCount;
nz:=0;
gr:=0;
for i:=1 to kz do
begin
with Query1 do
begin
Active:=False;
SQL.Clear;
SQL.Add('Select * from "'+Form1.Table1.TableName+'"');
SQL.Add('where (PARAM1='+FloatToStr(p1[j])+') and (PARAM2='+FloatToStr(p2[j])+') and (PARAM3='+FloatToStr(p3[j])+')');
ExecSQL;
Active:=True;
kl:=Query1.RecordCount;
if kl=1 then j:=j+1;
if kl>1 then
begin
j:=j+kl;
nz:=nz+kl;
gr:=gr+1;
end;
end;
end;
Label2.Caption:='Коэффициентмест - '+FloatToStr(Okrugl((kz-nz+gr)/kz,2))+'.';
end
else Label2.Caption:='Для одного блока не рассчитывается.';
//This is a demo-code for KN & KP
try
with Query1 do
begin
Active:=False;
SQL.Clear;
SQL.Add('Select * from "'+Form1.Table1.TableName+'"');
ExecSQL;
end;
Query1.Active:=True;
Chart1.Enabled:=True;
except
Application.MessageBox('ОшибкаинициализацииБД. Возможно не установлен BDE, или база не открыта.','Ошибка',mb_Ok+MB_ICONHAND);
Chart1.Enabled:=False;
Exit;
end;
sbl1:=0; srbl1:=0;
sbl2:=0; srbl2:=0;
sbl3:=0; srbl3:=0;
dx1:=0; dx2:=0; dx3:=0;
sdxq1:=0; sdxq2:=0; sdxq3:=0;
sigm1:=0; sigm2:=0; sigm3:=0;
Query1.First;
if MCon='2' then
begin
for i:=1 to Query1.RecordCount do
begin
block1:=Query1.FieldValues['MARK1']+Query1.FieldValues['MARK2']+Query1.FieldValues['MARK3'];
block2:=Query1.FieldValues['MARK4']+Query1.FieldValues['MARK5']+Query1.FieldValues['MARK6'];
sbl1:=sbl1+block1;
sbl2:=sbl2+block2;
Query1.Next;
end;
srbl1:=sbl1/Query1.RecordCount;
srbl2:=sbl2/Query1.RecordCount;
Query1.First;
for i:=1 to Query1.RecordCount do
begin
block1:=Query1.FieldValues['MARK1']+Query1.FieldValues['MARK2']+Query1.FieldValues['MARK3'];
block2:=Query1.FieldValues['MARK4']+Query1.FieldValues['MARK5']+Query1.FieldValues['MARK6'];
dx1:=dx1+sqr(block1-srbl1);
dx2:=dx2+sqr(block2-srbl2);
Query1.Next;
end;
sdxq1:=dx1/Query1.RecordCount;
sdxq2:=dx2/Query1.RecordCount;
sigm1:=sqrt(sdxq1);
sigm2:=sqrt(sdxq2);
m:=StrToFloat(maxb);
kn[1]:=((m-srbl1)*((m-srbl1)*srbl1-sqr(sigm1))/(m*sqr(sigm1)-(m-srbl1)*srbl1))-1;
kp[1]:=1-((srbl1*((m-srbl1)*srbl1-sqr(sigm1)))/(m*sqr(sigm1)-(m-srbl1)*srbl1));
kn[2]:=((m-srbl2)*((m-srbl2)*srbl2-sqr(sigm2))/(m*sqr(sigm2)-(m-srbl2)*srbl2))-1;
kp[2]:=1-((srbl2*((m-srbl2)*srbl2-sqr(sigm2)))/(m*sqr(sigm2)-(m-srbl2)*srbl2));
Series3.Clear;
for i:=1 to 2 do
Series3.AddXY(kn[i],kp[i]);
end;
if MCon='1' then
begin
for i:=1 to Query1.RecordCount do
begin
block1:=Query1.FieldValues['SUMMARK'];
sbl1:=sbl1+block1;
Query1.Next;
end;
srbl1:=sbl1/Query1.RecordCount;
Query1.First;
for i:=1 to Query1.RecordCount do
begin
block1:=Query1.FieldValues['SUMMARK'];
dx1:=dx1+sqr(block1-srbl1);
Query1.Next;
end;
sdxq1:=dx1/Query1.RecordCount;
sigm1:=sqrt(sdxq1);
m:=StrToFloat(maxb);
kn[1]:=((m-srbl1)*((m-srbl1)*srbl1-sqr(sigm1))/(m*sqr(sigm1)-(m-srbl1)*srbl1))-1;
kp[1]:=1-((srbl1*((m-srbl1)*srbl1-sqr(sigm1)))/(m*sqr(sigm1)-(m-srbl1)*srbl1));
Series3.AddXY(kn[1],kp[1]);
end;
if MCon='3' then
begin
for i:=1 to Query1.RecordCount do
begin
block1:=Query1.FieldValues['MARK1']+Query1.FieldValues['MARK2'];
block2:=Query1.FieldValues['MARK3']+Query1.FieldValues['MARK4'];
block3:=Query1.FieldValues['MARK5']+Query1.FieldValues['MARK6'];
sbl1:=sbl1+block1;
sbl2:=sbl2+block2;
sbl3:=sbl3+block3;
Query1.Next;
end;
srbl1:=sbl1/Query1.RecordCount;
srbl2:=sbl2/Query1.RecordCount;
srbl3:=sbl3/Query1.RecordCount;
Query1.First;
for i:=1 to Query1.RecordCount do
begin
block1:=Query1.FieldValues['MARK1']+Query1.FieldValues['MARK2'];
block2:=Query1.FieldValues['MARK3']+Query1.FieldValues['MARK4'];
block3:=Query1.FieldValues['MARK5']+Query1.FieldValues['MARK6'];
dx1:=dx1+sqr(block1-srbl1);
dx2:=dx2+sqr(block2-srbl2);
dx3:=dx3+sqr(block3-srbl3);
Query1.Next;
end;
sdxq1:=dx1/Query1.RecordCount;
sdxq2:=dx2/Query1.RecordCount;
sdxq3:=dx3/Query1.RecordCount;
sigm1:=sqrt(sdxq1);
sigm2:=sqrt(sdxq2);
sigm3:=sqrt(sdxq3);
m:=StrToFloat(maxb);
kn[1]:=((m-srbl1)*((m-srbl1)*srbl1-sqr(sigm1))/(m*sqr(sigm1)-(m-srbl1)*srbl1))-1;
kp[1]:=1-((srbl1*((m-srbl1)*srbl1-sqr(sigm1)))/(m*sqr(sigm1)-(m-srbl1)*srbl1));
kn[2]:=((m-srbl2)*((m-srbl2)*srbl2-sqr(sigm2))/(m*sqr(sigm2)-(m-srbl2)*srbl2))-1;
kp[2]:=1-((srbl2*((m-srbl2)*srbl2-sqr(sigm2)))/(m*sqr(sigm2)-(m-srbl2)*srbl2));
kn[3]:=((m-srbl3)*((m-srbl3)*srbl3-sqr(sigm3))/(m*sqr(sigm3)-(m-srbl3)*srbl3))-1;
kp[3]:=1-((srbl3*((m-srbl3)*srbl3-sqr(sigm3)))/(m*sqr(sigm3)-(m-srbl3)*srbl3));