Разработка программы психотестирования
Рефераты >> Программирование и компьютеры >> Разработка программы психотестирования

rb2.Enabled:=true;

rb3.Enabled:=true;

rb1.Checked:=false;

rb2.Checked:=false;

rb3.Checked:=false;

if rb3.caption='' then rb3.hide else rb3.Show

end;

procedure TfrmTest.FormActivate(Sender: TObject);

begin

testcount:=0;

defque:=1;

load

end;

procedure TfrmTest.rb1Click(Sender: TObject);

begin

speedbutton1.Enabled:=true;

rb1.Enabled:=false;

rb2.Enabled:=false;

rb3.Enabled:=false;

inc(testcount,test[defque].count[1])

end;

procedure TfrmTest.rb2Click(Sender: TObject);

begin

speedbutton1.Enabled:=true;

rb1.Enabled:=false;

rb2.Enabled:=false;

rb3.Enabled:=false;

inc(testcount,test[defque].count[2])

end;

procedure TfrmTest.rb3Click(Sender: TObject);

begin

speedbutton1.Enabled:=true;

rb1.Enabled:=false;

rb2.Enabled:=false;

rb3.Enabled:=false;

inc(testcount,test[defque].count[3])

end;

procedure TfrmTest.SpeedButton1Click(Sender: TObject);

var f:file of TResult;

r:tresult;

begin

inc(defque);

if defque=testnum then begin

assignfile(f,copy(testfilename,1,length(testfilename)-3)+'rts');

reset(f);

while not eof(f) do begin

read(f,r);

if testcount in [r.min r.max] then begin

frmres.label1.Caption:=r.text;

break

end

end;

closefile(f);

frmtest.hide;

frmres.show;

end;

load

end;

procedure TfrmTest.FormClose(Sender: TObject; var Action: TCloseAction);

begin

frmmain.show;

action:=cahide

end;

end.

unit Resfrm;

interface

uses

Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,

StdCtrls;

type

TfrmRes = class(TForm)

Label1: TLabel;

Button1: TButton;

procedure Button1Click(Sender: TObject);

procedure FormClose(Sender: TObject; var Action: TCloseAction);

private

{ Private declarations }

public

{ Public declarations }

end;

var

frmRes: TfrmRes;

implementation

uses Mainfrm;

{$R *.DFM}

procedure TfrmRes.Button1Click(Sender: TObject);

begin

frmres.hide;

frmmain.show

end;

procedure TfrmRes.FormClose(Sender: TObject; var Action: TCloseAction);

begin

action:=cahide;

frmmain.show

end;

end.

unit TestTypes;

interface

type

TTest=record

text:string[255];

quest:array[1 3] of string[100];

count:array[1 3] of byte;

end;

var

testfilename: string;

test:array[1 100] of ttest;

testnum:byte;

implementation

end.

Листинг программы ТС:

unit Mainfrm;

interface

uses

Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,

StdCtrls, Spin, TestTypes;

type

TfrmMain = class(TForm)

rb1: TRadioButton;

rb2: TRadioButton;

rb3: TRadioButton;

Edit1: TEdit;

Label1: TLabel;

SpinEdit1: TSpinEdit;

Label2: TLabel;

Edit2: TEdit;

Label3: TLabel;

Label4: TLabel;

Button1: TButton;

Button2: TButton;

SaveDialog1: TSaveDialog;

OpenDialog1: TOpenDialog;

StaticText1: TStaticText;

Label5: TLabel;

SpinEdit2: TSpinEdit;

Button3: TButton;

procedure Button2Click(Sender: TObject);

procedure Button1Click(Sender: TObject);

procedure FormCreate(Sender: TObject);

procedure Edit1Change(Sender: TObject);

procedure Edit2Change(Sender: TObject);

procedure rb1Click(Sender: TObject);

procedure rb2Click(Sender: TObject);

procedure rb3Click(Sender: TObject);

procedure SpinEdit1Change(Sender: TObject);

procedure SpinEdit2Change(Sender: TObject);

procedure Button3Click(Sender: TObject);

private

{ Private declarations }

public

variant:^tradiobutton;

nq:byte;

end;

var

frmMain: TfrmMain;

implementation

{$R *.DFM}

procedure TfrmMain.Button2Click(Sender: TObject);

var f:file of TTest;

i:byte;

begin

if savedialog1.execute then begin

assignfile(f,savedialog1.Filename);

rewrite(f);

for i:=1 to testnum do write(f,test[i]);

closefile(f)

end

end;

procedure TfrmMain.Button1Click(Sender: TObject);

var f:file of ttest;

begin

if opendialog1.execute then begin

assignfile(f,opendialog1.Filename);

reset(f);

testnum:=1;

while not eof(f) do begin

read(f,test[testnum]);

inc(testnum)

end;

statictext1.Caption:='Всего вопросов '+inttostr(testnum);

closefile(f);

spinedit1.value:=1;

spinedit1change(sender)

end

end;

procedure TfrmMain.FormCreate(Sender: TObject);

var i:byte;

begin

testnum:=1;

variant:=@rb1;

nq:=1;

for i:=1 to 100 do begin

test[i].quest[1]:='Вариант1';

test[i].quest[2]:='Вариант2';

test[i].quest[3]:='Вариант3';

test[i].count[1]:=0;

test[i].count[2]:=0;

test[i].count[3]:=0;

test[i].text:='Текст вопроса'

end;

end;

procedure TfrmMain.Edit1Change(Sender: TObject);

begin

label2.Caption:=edit1.Text;

test[spinedit1.value].text:=edit1.text

end;

procedure TfrmMain.Edit2Change(Sender: TObject);

begin

variant^.Caption:=edit2.Text;

test[spinedit1.value].quest[nq]:=edit2.text

end;

procedure TfrmMain.rb1Click(Sender: TObject);

begin

variant:=@rb1;

nq:=1;

edit2.Text:=rb1.Caption;

spinedit2.Value:=test[spinedit1.Value].count[1];

edit2.SetFocus

end;

procedure TfrmMain.rb2Click(Sender: TObject);

begin

variant:=@rb2;

nq:=2;

edit2.Text:=rb2.Caption;

spinedit2.Value:=test[spinedit1.Value].count[2];

edit2.SetFocus

end;

procedure TfrmMain.rb3Click(Sender: TObject);

begin

variant:=@rb3;

nq:=3;

edit2.Text:=rb3.Caption;

spinedit2.Value:=test[spinedit1.Value].count[3];

edit2.SetFocus

end;

procedure TfrmMain.SpinEdit1Change(Sender: TObject);

begin

if spinedit1.value>testnum then begin

inc(testnum);

statictext1.caption:='Всего вопросов '+inttostr(testnum)

end;

label2.Caption:=test[spinedit1.value].text;

rb1.Caption:=test[spinedit1.value].quest[1];

rb2.Caption:=test[spinedit1.value].quest[2];

rb3.Caption:=test[spinedit1.value].quest[3];

rb1.Checked:=true;

variant:=@rb1;

edit1.Text:=test[spinedit1.value].text;

edit2.text:=test[spinedit1.value].quest[1];

edit2.setfocus

end;

procedure TfrmMain.SpinEdit2Change(Sender: TObject);

begin

test[spinedit1.value].count[nq]:=spinedit2.value

end;

procedure TfrmMain.Button3Click(Sender: TObject);

var i:byte;

begin

if spinedit1.value=testnum then begin

dec(testnum);

spinedit1.value:=spinedit1.value-1;

exit

end;

if testnum=1 then exit;

for i:=spinedit1.value to testnum-1 do test[i]:=test[i+1];

dec(testnum);

spinedit1change(sender);


Страница: