p align="left">if Image1.Tag =1 // есть иллюстрация к вопросу then ShowPicture; // вывод альтернативных ответов if Form1.Label1.Caption <> '' then begin if Form1.Image1.Tag =1 then Label1.top:=Image1.Top+Image1.Height+10 else Label1.top:=Label5.Top+Label5.Height+10; RadioButton1.top:=Label1.top; Label1.visible:=TRUE; RadioButton1.visible:=TRUE; end; if Form1.Label2.Caption <> '' then begin Label2.top:=Label1.top+ Label1.height+10; RadioButton2.top:=Label2.top; Label2.visible:=TRUE; RadioButton2.visible:=TRUE; end; if Form1.Label3.Caption <> '' then begin Label3.top:=Label2.top+ Label2.height+10; RadioButton3.top:=Label3.top; Label3.visible:=TRUE; RadioButton3.visible:=TRUE; end; if Form1.Label4.Caption <> '' then begin Label4.top:=Label3.top+ Label3.height+10; RadioButton4.top:=Label4.top; Label4.visible:=TRUE; RadioButton4.visible:=TRUE; end; end; Procedure TForm1.ResetForm; begin // сделать невидимыми все метки и радиокнопки Label1.Visible:=FALSE; Label1.caption:=''; Label1.width:=ClientWidth-Label1.left-5; RadioButton1.Visible:=FALSE; Label2.Visible:=FALSE; Label2.caption:=''; Label2.width:=ClientWidth-Label2.left-5; RadioButton2.Visible:=FALSE; Label3.Visible:=FALSE; Label3.caption:=''; Label3.width:=ClientWidth-Label3.left-5; RadioButton3.Visible:=FALSE; Label4.Visible:=FALSE; Label4.caption:=''; Label4.width:=ClientWidth-Label4.left-5; RadioButton4.Visible:=FALSE; Label5.width:=ClientWidth-Label5.left-5; Image1.Visible:=FALSE; end; // определение достигнутого уровня procedure TForm1.Itog; var i:integer; buf:string; begin buf:=''; buf:='Результаты тестирования'+ #13 +'Всего баллов: '+ IntToStr(summa); i:=1; while (summa < level[i]) and (i<N_LEV) do i:=i+1; buf:=buf+ #13+mes[i]; Label5.Top:=20; Label5.caption:=buf; end; procedure TForm1.FormActivate(Sender: TObject); begin end; // щелчок на кнопке Button1 procedure TForm1.Button1Click(Sender: TObject); var s,s2,s1,s3,s4,s5,s6,s7,k,tim1:string;i,j,l,l1,l2:integer;tim:integer; begin case Button1.tag of 0: begin Button1.caption:='Дальше'; Button1.tag:=1; RadioButton5.Checked:=TRUE; // вывод первого вопроса Timer1.Enabled:=true; Gauge1.Visible:=true; Button1.Enabled:=False; ResetForm; VoprosToScr; end; 1: begin // вывод остальных вопросов summa:=summa+score[otv]; RadioButton5.Checked:=TRUE; Button1.Enabled:=False; ResetForm; if not eof(f) then VoprosToScr else begin summa:=summa+score[otv]; closefile(f); Button1.caption:='Ok'; Form1.caption:='Результат'; Button1.tag:=2; Button1.Enabled:=TRUE; Itog; // вывести результат end; end; 2: begin // завершение работы Timer1.Enabled:=false; s:=''; assignfile(fil1,'bd\result.txt'); reset(fil1); s:=''; while not eof(fil1) do begin readln(fil1,s2); s:=s+s2; end; closefile(fil1); s1:=''; for i:=1 to length(s) do begin if (s[i] = '*') then begin if s1=zagl.Edit1.Text then begin j:=i+1; s3:=''; while s[j]<>'#' do begin if s[j]='&' then begin tim:=time1+StrToInt(s3); delete(s,i+1,j-1-i-1); tim1:=FloatToStr(tim); insert(tim1,s,i+1); s3:=''; end; if s[j]='$' then begin if summa>=7 then begin l:=StrToInt(s[j-1])+1; delete(s,j-1,1); s7:=IntToStr(l); insert(s7,s,j-1); s3:=''; end else l:=StrToInt(s[j-1]); if summa>=7 then begin s5:=s[j+1]+s[j+2]; l2:=StrToInt(s5); delete(s,j+1,2); l2:=l2+summa; s6:=IntToStr(l2); if length(s6)=1 then s6:=' '+s6; insert(s6,s,j+1); end; end; s3:=s3+s[j]; j:=j+1; end; end; end; s1:=s1+s[i]; if (s[i]='#') then s1:=''; end; rewrite(fil1); s4:=''; for i:=1 to length(s) do begin s4:=s4+s[i]; if s[i]='#' then begin writeln(fil1,s4); s4:=''; end; end; closefile(fil1); assignfile(fil1,'bd\result1.txt'); reset(fil1); s:=''; while not eof(fil1) do begin readln(fil1,s2); s:=s+s2; end; closefile(fil1); s1:=''; for i:=1 to length(s) do begin if (s[i] = '*') then begin //showmessage(s1); if s1=zagl.Edit1.Text then begin j:=i+1; s3:=''; while s[j]<>'~' do begin if (s[j]='!')and(l=1)and(summa>StrToInt(s[j-1])) then begin delete(s,j-1,1); s6:=IntToStr(summa); insert(s6,s,j-1); end; if (s[j]='$')and(l=2)and(summa>StrToInt(s[j-1])) then begin delete(s,j-1,1); s6:=IntToStr(summa); insert(s6,s,j-1); end; if (s[j]='#')and(l=3)and(summa>StrToInt(s[j-1])) then begin delete(s,j-1,1); s6:=IntToStr(summa); insert(s6,s,j-1); end; if (s[j]='%')and(l=4)and(summa>StrToInt(s[j-1])) then begin delete(s,j-1,1); s6:=IntToStr(summa); insert(s6,s,j-1); end; if (s[j]='^')and(l=5)and(summa>StrToInt(s[j-1])) then begin delete(s,j-1,1); s6:=IntToStr(summa); insert(s6,s,j-1); end; if (s[j]='@')and(l=6)and(summa>StrToInt(s[j-1])) then begin delete(s,j-1,1); s6:=IntToStr(summa); insert(s6,s,j-1); end; if (s[j]='~')and(l=7)and(summa>StrToInt(s[j-1])) then begin delete(s,j-1,1); s6:=IntToStr(summa); insert(s6,s,j-1); end; s3:=s3+s[j]; j:=j+1; end; end; end; s1:=s1+s[i]; if (s[i]='~') then s1:=''; end; rewrite(fil1); s4:=''; for i:=1 to length(s) do begin s4:=s4+s[i]; if s[i]='~' then begin writeln(fil1,s4); s4:=''; end; end; closefile(fil1); Form1.Close; ElektKursInf.Button1.Enabled:=true; end; end; end; // Процедура обработки события OnClick // для компонентов RadioButton1-RadioButton4 procedure TForm1.RadioButtonClick(Sender: TObject); begin if sender = RadioButton1 then otv:=1 else if sender = RadioButton1 then otv:=2 else if sender = RadioButton3 then otv:=3 else otv:=4; Button1.enabled:=TRUE; end; // обеспечивает настройку компонентов procedure TForm1.FormCreate(Sender: TObject); begin Image1.AutoSize := False; Image1.Proportional := True; RadioButton1.Visible := False; end; procedure TForm1.Timer1Timer(Sender: TObject); begin Gauge1.Progress:=Gauge1.Progress+1; if Gauge1.Progress=100 then begin ResetForm; summa:=summa+score[otv]; Button1.caption:='Ok'; Form1.caption:='Результат'; Button1.tag:=2; Button1.Enabled:=TRUE; Itog; // вывести результат Timer1.Enabled:=false; end; end; procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); begin ElektKursInf.Button1.Enabled:=true; end; procedure TForm1.FormShow(Sender: TObject); var z:integer;s0:string; begin assignfile(fil,'bd\path1.txt'); reset(fil); s0:=''; while not eof(fil) do begin readln(fil,s0); break; end; closefile(fil); randomize; ResetForm; z:=random(4)+1; fn:=copy(s0,9,length(s0))+IntToStr(ElektKursInf.ListBox1.ItemIndex+1)+IntToStr(z)+'.txt'; assignfile(f,fn); try reset(f); except on EFOpenError do begin ShowMessage('Файл теста '+fn+' не найден.'); Button1.caption:='Ok'; Button1.tag:=2; Button1.Enabled:=TRUE; exit; end; end; Info; // прочитать и вывести информацию о тесте GetLevel; // прочитать информацию об уровнях оценок end; end.
Страницы: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
|