unit
Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm2 =
class
(TForm)
Panel1: TPanel;
Edit1: TEdit;
Edit2: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
ComboBox1: TComboBox;
Button1: TButton;
Memo1: TMemo;
Memo2: TMemo;
ListBox1: TListBox;
RadioGroup1: TRadioGroup;
ComboBox2: TComboBox;
Label4: TLabel;
Button2: TButton;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
procedure
Button1Click(Sender: TObject);
procedure
FormActivate(Sender: TObject);
procedure
ComboBox1Change(Sender: TObject);
procedure
ListBox1Click(Sender: TObject);
procedure
Button2Click(Sender: TObject);
private
public
end
;
var
Form2: TForm2;
group,fio,pred,tst:
string
;
Nach,Kon,ver,never,kolvop:
integer
;
implementation
uses
Unit1;
{$R *.dfm}
procedure
TForm2
.
Button1Click(Sender: TObject);
var
i:
Integer
;
begin
if
Edit1
.
Text<>
''
then
begin
if
Edit2
.
Text<>
''
then
begin
if
ComboBox2
.
ItemIndex=
0
then
begin
fio:=Edit1
.
Text;
group:=Edit2
.
Text;
pred:=ComboBox2
.
Items[ComboBox2
.
ItemIndex];
Panel1
.
Visible:=
false
;
Form2
.
Caption:=
'Òåìà:'
+pred;
Memo1
.
Lines
.
LoadFromFile(ServerDir+ComboBox1
.
Items[ComboBox1
.
Itemindex]+'\Òåñòû\'+
pred+
'.txt'
);
for
i:=
0
to
Memo1
.
Lines
.
Count -
1
do
begin
if
Pos(
'¹'
,Memo1
.
Lines[i])<>
0
then
begin
ListBox1
.
Items
.
Add(
'Âîïðîñ '
+inttostr(Listbox1
.
Items
.
Count+
1
));
end
;
if
i=Memo1
.
Lines
.
Count -
1
then
begin
Memo1
.
Lines
.
Add(
'¹'
+inttostr(Listbox1
.
Items
.
Count+
1
));
end
;
end
;
end
else
begin
ShowMessage(
'Óêàæèòå òåìó'
);
end
;
end
else
begin
ShowMessage(
'Óêàæèòå ãðóïïó'
);
end
;
end
else
begin
ShowMessage(
'Çàïîëíèòå ïîëå Ô.È.Î.'
);
end
;
end
;
procedure
TForm2
.
FormActivate(Sender: TObject);
var
papki:TSearchRec;
begin
if
FindFirst(ServerDir+
'*'
,faDirectory,papki) =
0
then
begin
repeat
if
(papki
.
Attr
and
faDirectory)=faDirectory
then
begin
if
(papki
.
Name<>
'.'
)
and
(papki
.
Name<>
'..'
)
then
begin
ComboBox1
.
Items
.
Add(papki
.
Name);
end
;
end
;
until
FindNext(papki) <>
0
;
FindClose(papki);
end
;
end
;
procedure
TForm2
.
ComboBox1Change(Sender: TObject);
var
tema:TSearchRec;
begin
ComboBox2
.
Items
.
Clear;
if
FindFirst(ServerDir+ComboBox1
.
Items[ComboBox1
.
Itemindex]+
'\Òåñòû\*.txt'
,faAnyFile,tema) =
0
then
begin
repeat
if
(tema
.
Name<>
'.'
)
and
(tema
.
Name<>
'..'
)
then
begin
Delete(tema
.
Name,Pos(
'.txt'
,tema
.
Name),Length(tema
.
Name));
ComboBox2
.
Items
.
Add(tema
.
Name);
end
;
until
FindNext(tema) <>
0
;
FindClose(tema);
end
;
end
;
procedure
TForm2
.
ListBox1Click(Sender: TObject);
var
vopN,vopk,vr,vb:
string
;
i,j,z:
integer
;
begin
Memo2
.
Clear;
RadioGroup1
.
Items
.
Clear;
vopN:=
'¹'
+inttostr(ListBox1
.
ItemIndex+
1
);
vopk:=
'¹'
+inttostr(ListBox1
.
ItemIndex+
2
);
for
i:=
0
to
memo1
.
Lines
.
count-
1
do
begin
if
Pos(vopN,Memo1
.
Lines[i])<>
0
then
begin
Nach:=i;
end
;
if
Pos(vopk,Memo1
.
Lines[i])<>
0
then
begin
kon:=i;
end
;
end
;
for
j:=Nach
to
Kon-
1
do
begin
if
Pos(
'@'
,memo1
.
Lines[j])<>
0
then
begin
vr:=memo1
.
Lines[j];
Delete(vr,
1
,
1
);
RadioGroup1
.
Items
.
Add(vr);
end
else
begin
Memo2
.
Lines
.
Add(Memo1
.
Lines[j]);
end
;
end
;
for
z:=
0
to
RadioGroup1
.
Items
.
Count-
1
do
begin
if
Pos(
'`'
,RadioGroup1
.
Items[z])<>
0
then
begin
vb:= RadioGroup1
.
Items[z];
Delete(vb,Pos(
'`'
,vb),
1
);
RadioGroup1
.
Items[z]:=vb;
end
;
end
;
end
;
procedure
TForm2
.
Button2Click(Sender: TObject);
var
otv:
string
;
begin
kolvop:=kolvop-
1
;
otv:=RadioGroup1
.
Items[RadioGroup1
.
ItemIndex];
otv:=
'@'
+otv+
'`'
;
if
Memo1
.
Lines[Nach+memo2
.
Lines
.
Count+RadioGroup1
.
ItemIndex]=otv
then
Ver:=ver+
1
else
Never:=never+
1
;
label6
.
Caption:=
'Íåâåðíî:'
+inttostr(never);
label5
.
Caption:=
'Âåðíî:'
+inttostr(ver);
label7
.
Caption:=
'Îñòàëîñü:'
+inttostr(kolvop)+
' âïîðîñîâ'
;
end
;
end
.