079.
w,h:
integer
;
// максимально допустимые размеры картинки
080.
scaleX:
real
;
// коэф. масштабирования по X
081.
scaleY:
real
;
// коэф. масштабирования по Y
082.
scale:
real
;
// общий коэф. масштабирования
083.
begin
084.
// вычислить максимально допустимые размеры картинки
085.
w:=Forml
.
ClientWidth-
10
;
086.
hi=Forml
.
ClientHeight
087.
Forml
.
Panell
.
Height -
5
088.
Forml
.
LabelS
.
Top
089.
Forml
.
Label5
.
Height -
5
;
090.
if
Forml
.
Labell
.
Caption <> "
091.
then
h:=h-Forml
.
Labell
.
Height-
5
;
092.
if
Forml
.
Label2
.
Caption о "
093.
then
h:=h-FOrml
.
Label2
.
Height-
5
;
094.
if
Forml
.
Label3
.
Caption <>
''
095.
then
h:=h-Forml
.
Label3
.
Height-
5
;
096.
if
Forml
.
Label4
.
Caption о
''
097.
then
h:=h-Forml
.
Label4
.
Height-
5
;
098.
// определить масштаб
099.
if
wMmagel
.
Picture
.
Bitmap
.
Width
100.
then
scaleX:=l
101.
else
scaleX:=w/Imagel
.
Picture
.
Bitmap
.
Width;
102.
if
h>Imagel
.
Picture
.
Bitmap
.
Height
103.
then
scaleY:=l
104.
else
scaleY:=h/Imagel
.
Picture
.
Bitmap
.
Height;
105.
if
ScaleYOcaleX
106.
then
scale:=scaleY
107.
else
scale:=scaleX;
108.
// здесь масштаб определен
109.
Imagel
.
Top:-Forml
.
Labels
.
Top+Forml
.
Labels
.
Height+
5
;
110.
Imagel
.
Width:=Round(Imagel
.
Picture
.
Bitmap
.
Width'scale);
111.
Imagel
.
Height:=Round(Imagel
.
Picture
.
Bitmap
.
Height'scale);
112.
end
;
113.
// вывод вопроса на экран
114.
Procedure VoprosToScr(
var
f:TextFile;frm:TForml;
var
vopros:
integer
);
115.
var
116.
i:
integer
;
117.
code:
integer
;
118.
s,buf:
string
;
119.
ifn:
string
;
// файл иллюстрации
120.
begin
121.
vopros:=vopros+l;
122.
str(vopros:
3
,s);
123.
frm
.
caption:=
'Bonpoc'
+ s;
124.
//выведем текст вопроса
125.
buf :=
' '
;
126.
repeat
127.
readlnlf,s);
128.
if
(s[l] <>
'.'
)
and
(s[l] <> ' V )
129.
then
buf:=buf+s+
' '
;
130.
until
(s[l] =
' . '
)
or
|s[l] = ' V ) ;
131.
frm. Labels
.
caption:=buf;
132.
if
s l l ] <> 'V
133.
then
Forml
.
Imagel
.
Tag:=
0
134.
else
// к вопросу есть иллюстрация
135.
begin
136.
Forml
.
Imagel
.
Tag:=
1
;
137.
ifn:=copy(s,
2
,length(s));
138.
try
139.
Forml
.
Imagel
.
Picture
.
LoadFromFile(ifn);
140.
except
141.
on
E:EFOpenError
do
142.
frm. tag:=
0
;
143.
end
;
// try
144.
end
;
145.
// читаем варианты ответов
146.
i:=lj
147.
repeat
148.
buf:=
''
;
149.
repeat
// читаем текст варианта ответа
150.
readlnff,s] ;
151.
if
. ( s [ l ] < >
' . '
)
and
(ts[l] <>
', '
)
then
bufr=buf4s+
' '
;
152.
until
(s[l]-r ,
' ) o r ( s [ l ] = '
. ' ) ;
153.
// прочитан альтернативный ответ
154.
val
(s[
2
],score,code);
155.
case
i
of
156.
1
: frm
.
Label1
.
caption:=buf;
157.
2
: frm
.
Label2
.
caption:=buf;
158.
3
: frm
.
Label3
.
caption:=buf;
159.
4
: frm
.
Label4
.
caption:=buf;;
160.
end
;
161.
inc(i);
162.
until
s=
' . '
;
163.
// здесь прочитана иллюстрация и альтернативные ответы
164.
// текст вопроса уже выведен
165.
if
Forml
.
Imagel
.
Tag =
1
// есть иллюстрация к вопросу
166.
then
begin
167.
Scalelmage(Form1
.
Image1);
168.
Form1
.
Image1
.
Visible:=TRUE;
169.
end
;
170.
// вывод альтернатинных ответов
171.
if
Forml
.
Labell
.
Caption <> "
172.
then
begin
173.
if
Forml
.
Imagel
.
Tag =
1
174.
then
frm
.
Label!.top:=frm
.
Imagel
.
Top+frm
.
Imagel
.
Height+
5
175.
else
frm
.
Labell,top:=frm
.
Labels
.
Top+frm
.
Labels
.
Height+
5
;
176.
frm
.
RadioButtonl
.
top:=frm
.
Labell
.
top;
177.
frm
.
Labell
.
visible:=TRUE;
178.
frm
.
RadioButtonl
.
visible:=TRU£;
179.
end
;
180.
if
Forml
.
Label2
.
Caption о
''
181.
then
begin
182.
frm. Label2
.
top:=frm
.
Labell
.
top* f rm
.
Labell
.
height+
5
;
183.
frm
.
RadioButton2
.
top:=frm
.
Label2
.
top;
184.
frm
.
Label2
.
visible:=TROE;
185.
frm
.
RadioButton2
.
visible:-TRUE;
186.
end
;
187.
if
Forml
.
Label3
.
Caption <>
''
188.
then
begin
189.
frm. LabelB
.
top:-frm
.
Label2
.
top+ frm
.
Label2
.
height+
5
;
190.
frm
.
RadioButton3
.
top:-frm
.
LabelS
.
top;
191.
f rrn. Label3. visible: =TRUE;
192.
f rrn. RadioButtonS. visible: =TRUE;
193.
end
;
194.
if
Forml
.
Label4
.
Caption О
''
195.
then
begin
196.
frm. Label4
.
top:=frm
.
Label3
.
top+ frm
.
Labels
.
height+
5
;
197.
frm
.
RadioButton4
.
top:-frm
.
Label4
.
top;
198.
fan
.
Label4
.
visible:=TRUE;
199.
frm
.
RadioButton4
.
visible:=TRUE;
200.
end
;
201.
end
;
202.
Procedure ResetForm(frm:TForml);
203.
begin
204.
// сделать невидимыми see метки и переключатели
205.
frm
.
Labell
.
Visible:=FALSE;
206.
frm
.
Labell
.
caption:^
''
;
207.
frm
.
Labell
.
width:=frm
.
ClientWidth-frm
.
Labell
.
left-
5
;
208.
frm
.
RadioButtonl
.
Visible:=FALSE;
209.
fnn
.
Label2
.
Visible:-FALSE;
210.
fnn
.
Label2
.
caption:=
''
;
211.
fcm
.
Label2
.
width:=frm
.
ClientWidth-frm
.
Label2
.
left-
5
,•
212.
fcm
.
RadioButton2
.
Visible:=FALSE;
213.
frm
.
LabelS
.
Visible:=FALSE;
214.
fnn
.
Label3
.
caption:=
''
;
215.
f rm
.
Label3
.
width:=frm
.
ClientWidth-frm
.
LabelS
.
left-
5
,•
216.
frm
.
RadioButton3
.
Visible:=FALSE;
217.
fm
.
Label4
.
Visible:=FALSE;
218.
fnn
.
Label4
.
caption:-
1
';
219.
f nn
.
Labe!
4.
width:=frm
.
ClientWidth-frm
.
Labels
.
left-
5
,•
220.
frm
.
RadioButton4
.
Visible:=FALSE;
221.
frm
.
LabelS
.
width:=fm
.
ClientWidth-frm
.
Labels
.
left-
5
;
222.
frm. Imagel
.
Visible:-FALSE;
223.
end
;
224.
// определение достигнутого
225.
procedure
ltog(summa:
integer
;frm:TFormll
226.
var
227.
i:
integer
;
228.
buf:
string
;
229.
begin
230.
buf:=
' '
;
231.
str (summa:
5
,buf] ;
232.
buf :=
' Результаты тестирования '
+chr (
13
)
233.
+
'Всего баллов: '
-t-buf;
234.
i:=l;
235.
while
(sunraa < level |
and
|i
236.
i:=i+lj
237.
buf:=buf+chr(
13
)+mes;
238.
f rm. Labels. caption :=buf ;
239.
end
;
240.
(SR *.DFM}
241.
procedure
TForml
.
FormActivatelSender: TObject);
242.
begin
243.
ResetForm(Forml) ;
244.
if
ParamCount =
0
245.
then
begin
246.
Labels. caption := 'He задан файл вопросов теста.
1
;
247.
Buttonl . caption : =
' Ok '
;
248.
Buttonl
.
tag:=
2
;
249.
Buttonl . Enabled : =TROE
250.
end
251.
else
begin
252.
fn := ParamStr (
1
) ;
253.
assignfile (f , fn) ;
254.
{
$I
-}
255.
reset (f ) ;
256.
{
$I
+}
257.
if
IOResult=
0
then
258.
begin
259.
Info(f, LabelS) ;
// прочитать и вывести информацию о тесте
260.
GetLevel (f ) ;
// прочитать информацию об уровнях оценок
261.
end
;
262.
end
;
263.
end
;
264.
procedure
TFormI .ButtonlClick (Sender : TObject);
265.
begin
266.
саsе Buttonl
.
tag
of
267.
0
:
begin
268.
Buttonl
.
caption: = 'Дальше
1
;
269.
Buttonl
.
tag:=
1
;
270.
RadioButtonS. Checked: =TRUE ;
271.
// вывод первого вопроса
272.
Buttonl
.
Enabled:=False;
273.
ResetForm(Formll ;
274.
VoprosToScr(f,Forml,vopros]
275.
end
;
276.
1
:
begin
// вывод остальных вопросов
277.
summa:=summa+5core[otv] ;
278.
RadioButtonS
.
Checked:=TRUE;
279.
Suttonl
.
Enabled:=False;
280.
ResetForm(Forml) ,-
281.
if
not
eof(f)
282.
then
VoprosToScr(f,Forml,vopros]
283.
else
284.
begin
285.
sumraa:=suinma+score[otv] ;
286.
closefile[f);
287.
Buttonl
.
caption:=
'Ok'
;
288.
Forml
.
caption:='Результат
1
;
289.
Buttonl
.
tag:=
2
;
290.
Buttonl
.
Enabled:-TRUE;
291.
Itog Isurnma, Forml} ;
292.
end
;
293.
end
;
294.
2
:
begin
// завершение работы
295.
Forml
.
Close;
296.
end
;
297.
end
;
298.
end
;
299.
procedure
TForml
.
RadioButtonclick(Sender: TObject);
300.
begin
301.
if
sender = RadioButtonl
302.
then
otv:=
1
303.
else
if
sender = RadioButtonl
304.
then
otv:=
2
305.
else
if
sender = RadioButton3
306.
then
otv:=
3
307.
else
otv:=
4
;
308.
Buttonl
.
enabled:=TRUE;
309.
End;
end
.