Delphi tilida test dasturini yaratish texnologiyasi


Download 53.21 Kb.
Sana26.06.2020
Hajmi53.21 Kb.
#121778
Bog'liq
Delphi tilida test dasturini yaratish texnologiyasi


Delphi tilida test dasturini yaratish texnologiyasi

Biz Delphi dasturlash tilida tesdasturini yaratish uchun bizga test dasturi uchun bloknotda sovol tuzib olamiz bunda 1 fanning nomi 2 savollar soni misol uchun 5 ta savol uchun 5 raqam yoziladi 3 vaqt misol uchun 1 minut uchun 1:00 yoziladi savollar ketma-ketligi qatorma-qator yoziladi to’g’ri javobga 1,2,3,4 sonlar qo’yiladi agarda javoblar 4 tadan iborat bo’lsa, savoldan keying 1 qatordagi javob to’g’ri bo’lsa, 1 raqam qo’yiladi va ikkinchi savol boshlanadi va shu ketma-ketlik davom ettiriladi savolning javobini ixtiyoriy qatorga qo’yish mumkin. Rasm 1.



Rasm 1.


Delphida dasturi dizayni quyidagicha berilgan.

Rasm 2.


Fayl bo'limidan testni yuklaymiz rasm 3.

Rasm 3.


Dastur bajarilish dizayni rasm 4.

Rasm 4.


Dasturi kodi quyidagicha
unit Unit1;

interface


uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Menus, ExtCtrls;
type
// vaqt
TPrTime = Record
Min: Byte;
Sec: Byte;
end;
TForm1 = class(TForm)
MainMenu1: TMainMenu;
N11: TMenuItem;
Panel1: TPanel;
Lbl_Last: TLabel;
Lbl_FQuestion: TLabel;
BtnV1: TButton;
BtnV2: TButton;
BtnV3: TButton;
BtnV4: TButton;
MQuestion: TMemo;
MIAbout: TMenuItem;
Timer1: TTimer;
MITest: TMenuItem;
MITBegin: TMenuItem;
MIOpenFile: TMenuItem;
Memo_Temp: TMemo;
MV1: TMemo;
MV2: TMemo;
MV3: TMemo;
MV4: TMemo;
OpenDialog1: TOpenDialog;
GBox: TGroupBox;
MIExit: TMenuItem;
MITEnd: TMenuItem;
LblNameTest: TLabel;
Label1: TLabel;
Label2: TLabel;
PanelButton: TPanel;
Label3: TLabel;
Lbl_NomQuestion: TLabel;
procedure FormCreate(Sender: TObject);
function DecTime(Var aa:TPrTime; Sender: TObject): string;
procedure PrTimeOut(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure MIOpenFileClick(Sender: TObject);
procedure MIAboutClick(Sender: TObject);
procedure PrFillFileds(Sender: TObject);
procedure MITBeginClick(Sender: TObject);
procedure PrClickButton(Sender: TObject);
procedure MIExitClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
PrTimeLast: TPrTime;
PrTimeFull: TPrTime;
//nomer bo’yicha savol
NomQuestion: Byte;
// to’g’ri javoblar bali
PrVAnsverOK: Byte;
//nomer savol bo’yicha massiv
PrOrderQuestion: array [1..255] of byte;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
GBox.Visible:=False;
Timer1.Enabled:=False;
PrTimeLast.Min:=0;
PrTimeLast.Sec:=0;
MITBegin.Enabled:=True;
MITEnd.Enabled:=False;
NomQuestion:=1;
Memo_Temp.Lines.Clear;
PrVAnsverOK:=0;
PanelButton.Visible:=True;
end;
// --- Vaqt nazorati ---
Function PrFormatConvert(aa:TPrTime): String;
begin
if aa.Min<=9 then result:='0'+IntToStr(aa.Min)
else result:=IntToStr(aa.Min);
if aa.Sec<=9 then result:=result+':0'+IntToStr(aa.Sec)
else result:=result+':'+IntToStr(aa.Sec);
end;
// Vaqtni o’zgartiriash
function TForm1.DecTime(Var aa:TPrTime; Sender: TObject): string;
begin
if aa.Sec=0 then
if aa.Min>0 then
begin
dec(aa.Min);
aa.Sec:=59;
end
else PrTimeOut(Sender)
else dec(aa.Sec);
result:=PrFormatConvert(aa);
end;
// Vaqt bo’yicha savollarga javobni nazorat qilish
procedure TForm1.PrTimeOut(Sender: TObject);
begin
// Test variantlarini kiritish
if NomQuestion=StrToInt(copy(Memo_Temp.Lines[1],1,pos(' ',Memo_Temp.Lines[1])-1)) then
begin
Timer1.Enabled:=False;
PanelButton.Visible:=False; // Tugmachani tanlashni to’xtatish.
ShowMessage('Javob (Jami to`g`ri javob):'+#13+#10
+IntToStr(NomQuestion)+'\'+IntToStr(PrVAnsverOK)); //PrStatisticsTest(Sender);
Abort;
end;
{v0103} PrTimeLast.Min:=StrToInt(copy(Memo_Temp.Lines[1],
pos(' ',Memo_Temp.Lines[1])+1,pos(':',Memo_Temp.Lines[1])-pos(' ',Memo_Temp.Lines[1])-1)); {v0103} PrTimeLast.Sec:=StrToInt(copy(Memo_Temp.Lines[1],
pos(':',Memo_Temp.Lines[1])+1,Length(Memo_Temp.Lines[1])-pos(':',Memo_Temp.Lines[1]))); inc(NomQuestion);
PrFillFileds(Sender);
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Lbl_Last.Caption:=DecTime(PrTimeLast,Sender);
end;

procedure TForm1.MIOpenFileClick(Sender: TObject);


begin
FormCreate(Sender);
OpenDialog1.InitialDir:=ExtractFilePath(Application.ExeName);
if OpenDialog1.Execute then
Memo_Temp.Lines.LoadFromFile(OpenDialog1.FileName);
end;
procedure TForm1.MIAboutClick(Sender: TObject);
begin
ShowMessage('Administrator: Tami;'+#13+#10+
' '+#13+#10+
'http:\\www.tami.uz'+#13+#10+#13+#10+
'e-mail: shoydullo@mail.ru; ');
end;
procedure TForm1.PrFillFileds(Sender: TObject);
begin
MQuestion.Clear;
MV1.Clear;
MV2.Clear;
MV3.Clear;
MV4.Clear;

MQuestion.Lines[0]:=Memo_Temp.Lines[2+6*(PrOrderQuestion[NomQuestion]-1)];


MV1.Lines[0]:=Memo_Temp.Lines[3+6*(PrOrderQuestion[NomQuestion]-1)];
MV2.Lines[0]:=Memo_Temp.Lines[4+6*(PrOrderQuestion[NomQuestion]-1)];
MV3.Lines[0]:=Memo_Temp.Lines[5+6*(PrOrderQuestion[NomQuestion]-1)];
MV4.Lines[0]:=Memo_Temp.Lines[6+6*(PrOrderQuestion[NomQuestion]-1)];
Lbl_NomQuestion.Caption:=IntToStr(NomQuestion);
if MQuestion.Lines.Count>=3 then MQuestion.scrollbars:=ssVertical else MQuestion.scrollbars:=ssNone;
if MV1.Lines.Count>=3 then MV1.scrollbars:=ssVertical else MV1.scrollbars:=ssNone;
if MV2.Lines.Count>=3 then MV2.scrollbars:=ssVertical else MV2.scrollbars:=ssNone;
if MV3.Lines.Count>=3 then MV3.scrollbars:=ssVertical else MV3.scrollbars:=ssNone;
if MV4.Lines.Count>=3 then MV4.scrollbars:=ssVertical else MV4.scrollbars:=ssNone;
end;
procedure TForm1.MITBeginClick(Sender: TObject);
Var
Stroka: String;
tempNomQuestion, i: byte;
begin
// Test faylni yuklash
if Memo_Temp.Lines.Count<4 then
begin
ShowMessage('Test faylini yuklang!');
Abort;
end;
Stroka:=Memo_Temp.Lines[1];
PrTimeLast.Min:=StrToInt(copy(Stroka,pos(' ',Stroka)+1,pos(':',Stroka)-pos(' ',Stroka)-1));
PrTimeLast.Sec:=StrToInt(copy(Stroka,pos(':',Stroka)+1,Length(Stroka)-pos(':',Stroka)));
PrTimeFull.Sec:=StrToInt(copy(Stroka,1,pos(' ',Stroka)-1))
*PrTimeLast.Sec mod 60;
PrTimeFull.Min:=StrToInt(copy(Stroka,1,pos(' ',Stroka)-1))
*PrTimeLast.Min + StrToInt(copy(Stroka,1,pos(' ',Stroka)-1))
*PrTimeLast.Sec div 60;
for i:=1 to 255 do
PrOrderQuestion[i]:=0;
tempNomQuestion:=0;
while tempNomQuestionbegin
randomize;
i:=1+random(StrToInt(copy(Memo_Temp.Lines[1],1,pos(' ',Memo_Temp.Lines[1])-1)));
if PrOrderQuestion[i]=0 then
begin
inc(tempNomQuestion);
PrOrderQuestion[i]:=tempNomQuestion;
end;
end;

PrFillFileds(Sender);


LblNameTest.Caption:=Memo_Temp.Lines[0];
Lbl_FQuestion.Caption:=PrFormatConvert(PrTimeFull);
Lbl_Last.Caption:=PrFormatConvert(PrTimeLast);
NomQuestion:=1;
MITBegin.Enabled:=False;
MITEnd.Enabled:=True;
GBox.Visible:=True;
PanelButton.Visible:=True;
Timer1.Enabled:=True;
end;
procedure TForm1.PrClickButton(Sender: TObject);
begin
if StrToInt(Memo_Temp.Lines[7+6*(NomQuestion-1)])=(Sender as TButton).Tag Then
begin
ShowMessage('To`g`ri');
inc(PrVAnsverOK);
end
else ShowMessage('Noto`g`ri');
PrTimeOut(Sender);
end;
procedure TForm1.MIExitClick(Sender: TObject);
begin
Close;
end;
end.
Download 53.21 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling