Архитектура Аудит Военная наука Иностранные языки Медицина Металлургия Метрология
Образование Политология Производство Психология Стандартизация Технологии


ДОДАТОК Б. МОДУЛЬ ТЕСТУВАННЯ



program Project1;

uses

Forms,

Unit1 in 'Unit1.pas' {Form1};

 

{$R *.res}

 

begin

Application.Initialize;

Application.CreateForm(TForm1, Form1);

Application.Run;

end.

 

unit Unit1;

interface

 

uses

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

Dialogs, ExtCtrls, StdCtrls, DB, ADODB, jpeg, Grids, DBGrids;

 

type

TForm1 = class(TForm)

Stard: TButton;

Image1: TImage;

Button1: TButton;

Button2: TButton;

Button3: TButton;

Button4: TButton;

Button5: TButton;

Button6: TButton;

Button7: TButton;

 Button8: TButton;

Button9: TButton;

Button10: TButton;

Button11: TButton;

Button12: TButton;

Button13: TButton;

Button14: TButton;

Button15: TButton;

Button16: TButton;

Button17: TButton;

Button18: TButton;

Button19: TButton;

Button20: TButton;

Button21: TButton;

vremya: TLabel;

Timer1: TTimer;

max_bilet: TADOQuery;

base: TADOConnection;

max_biletmaxx: TIntegerField;

Label1: TLabel;

RadioButton1: TRadioButton;

RadioButton2: TRadioButton;

RadioButton3: TRadioButton;

RadioButton4: TRadioButton;

RadioButton5: TRadioButton;

bilety: TADOQuery;

biletyid_bileta: TAutoIncField;

biletyname: TIntegerField;

vopros: TADOQuery;

bilety_: TDataSource;

voprosid_bileta: TIntegerField;

voprosnomer: TIntegerField;

voprosotvet: TMemoField;

voprospravilniy: TBooleanField;

vopros_: TDataSource;

Button22: TButton;

voprosvopros: TMemoField;

voprosimage: TWideStringField;

Label2: TLabel;

procedure StardClick(Sender: TObject);

procedure Timer1Timer(Sender: TObject);

procedure FormCreate(Sender: TObject);

 procedure Button21Click(Sender: TObject);

procedure Button1Click(Sender: TObject);

procedure Button22Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

min, sec: integer;

bilet_nomer: integer;

activniy_vopros: integer;

pravilniy_otvet: array[1..20] of Boolean;

nomer_otveta: array[1..20] of integer;

  end;

 

var

Form1: TForm1;

 

implementation

 

{$R *.dfm}

 

procedure TForm1.StardClick(Sender: TObject);

var i: integer;

begin

 activniy_vopros: =1;

 

 image1.Picture.LoadFromFile('C: \Deeplom\image\null.jpg');

 for i: =1 to 22 do

 TButton(FindComponent('Button'+IntToStr(i))).visible: =true;

 for i: =1 to 5 do

 TRadioButton(FindComponent('RadioButton'+IntToStr(i))).visible: =true;

 Image1.Visible: =true;

 sec: =30; min: =1;                   // Задаємо годину

 max_bilet.close;     // Пiдраховуємо кiлькiсть бiлетiв

 max_bilet.Open;                   // Виконати запит

 Randomize;           // Активизиємо генерацiю випадкового значення

 bilet_nomer: =StrToInt(floatToStr(random(max_biletmaxx.Value+1)));

                                         // № бiлета отримуємо з бази даних

 bilety.close; bilety.Open;

 for i: =1 to bilet_nomer do // Переходиться до потрiбного квитку зсувом

 bilety.Next;                    // щоб не обирати номери видалених бiлетiв

Label1.Caption: ='Билет №'+IntToStr(biletyname.AsInteger);

                             // Номер бiлету отримуємо з поля name бази даних

 Timer1.Enabled: =true;          // Включити обратний вiдлiк

 Stard.Enabled: =false;           // Вімкнути кнопку старт

 for i: =1 to 20 do

 begin

 pravilniy_otvet[i]: =false;      //Зануляємо всi вiдповiдi

 TButton(FindComponent('Button'+IntToStr(i))).Font.Style: =[];

 end;

   // Вибираємо питання за номером

   vopros.Close;

   vopros.Parameters[1].Value: =1;

   vopros.Open;

   label2.Caption: =voprosvopros.AsString;

   if voprosimage.AsString< > '' then

   BEGIN

    try

    image1.Picture.LoadFromFile(voprosimage.AsString)

    except

    image1.Picture.LoadFromFile('C: \Deeplom\image\null.jpg');

    end;

   END

   ELSE

   image1.Picture.LoadFromFile('C: \Deeplom\image\null.jpg');

   // Заповнюємо варiанти вiдповiдей

   for i: =1 to vopros.RecordCount do

    Begin

   TRadioButton(FindComponent('RadioButton'+IntToStr(i))).Visible: =true;

  TRadioButton(FindComponent('RadioButton'+IntToStr(i))).Caption: = voprosotvet.AsString;

    vopros.Next;

    End;

   i: =vopros.RecordCount;

   while i< 5 do

   begin

    i: =i+1;

    TRadioButton(FindComponent('RadioButton'+IntToStr(i))).Visible: =false;

   end;

   // Для визначення на яке питання відповідаємо використовуємо маркер

    Button1.Font.Style: =[fsBold];

end;

function OdinToDva(x: integer): string;

begin

 if Length(IntToStr(x))=1 then

OdinToDva: ='0'+IntToStr(x)

 else

OdinToDva: =IntToStr(x)

end;

 

procedure TForm1.Timer1Timer(Sender: TObject);

var i, prav_otvetov: integer;

begin

vremya.Caption: =OdinToDva(min)+': '+OdinToDva(sec);

if sec=0 then

begin

if(min=0) then

   begin

    Timer1.Enabled: =false;

           prav_otvetov: =0;

           for i: =1 to 20 do

           begin

           TButton(FindComponent('Button'+IntToStr(i))).Enabled: =True;

           if pravilniy_otvet[i]=true then

           begin

           prav_otvetov: =prav_otvetov+1;

           TButton(FindComponent('Button'+IntToStr(i))).Font.Style: =[];

           end

           else

           TButton(FindComponent('Button'+IntToStr(i))).Font.Style: =[fsBold];

          end;

           TButton(FindComponent('Button'+IntToStr(i))).Enabled: =True;

           Application.MessageBox('Тестування завершене! ', 'Вышло час.', 0);

           Application.MessageBox(Pchar('Правильних відповідей: '+IntToStr(prav_otvetov)), '', 0);

           Button21.Enabled: =false;

           Button22.Enabled: =false;

    Abort;

   end;

   sec: =60;

   min: =min-1;

end;

sec: =sec-1;

end;

procedure TForm1.FormCreate(Sender: TObject);

var i: integer;

begin

image1.Picture.LoadFromFile('C: \Deeplom\image\null.jpg');

for i: =1 to 22 do

TButton(FindComponent('Button'+IntToStr(i))).visible: =false;

for i: =1 to 5 do

TRadioButton(FindComponent('RadioButton'+IntToStr(i))).visible: =false;

Image1.Visible: =false;

end;

procedure TForm1.Button21Click(Sender: TObject);

var i, j, not_chaket: integer;

radio_otvet: string;

begin

not_chaket: =0;

for i: =1 to 5 do

 if TRadioButton(FindComponent('RadioButton'+IntToStr(i))).Checked then

 not_chaket: =1;

if not_chaket=0 then // Not chaket

Application.MessageBox('Вибіріте відповідь! ', '', 0)

else

   begin // Not chaket

    //Знайдемо вiдповiдь вказану користувачем:

    for i: =1 to vopros.RecordCount do

    if TRadioButton(FindComponent('RadioButton'+IntToStr(i))).Checked

    then

    begin        

radio_otvet: =

TRadioButton(FindComponent('RadioButton'+IntToStr(i))).Caption;

    nomer_otveta[activniy_vopros]: =i;

    end;

            //Знайдемо у БД правильний вiн чи нi

    vopros.First;

    for i: =1 to vopros.RecordCount do // Пройти по всiм питанням

    BEGIN

    if radio_otvet=voprosotvet.AsString then

     if voprospravilniy.AsBoolean=true then

      begin

      pravilniy_otvet[activniy_vopros]: =True;

      Application.MessageBox('Правiльна', '', 0);

      end;

    vopros.Next;

   END;

   // Перебрати питання на яке ще не відповідали - відповідаємо

   i: =activniy_vopros;

   while (i=activniy_vopros) and (i< =20) do

    begin

    i: =i+1;

    if nomer_otveta[i]=0 then // наступне питання стає активним

    begin                         // на яке ще не відповіли

    activniy_vopros: =i;

    TButton(FindComponent('Button'+IntToStr(i))).Font.Style: =[fsBold];

    TButton(FindComponent('Button'+IntToStr(i))).Click;

     i: =21; // Виходимо з циклу

    end;

   end;

    end; // not chaket

 // Відключити питання на яке вже відповіли

 for j: =1 to 20 do

 if nomer_otveta[j]> 0 then

 TButton(FindComponent('Button'+IntToStr(j))).Enabled: =false

 else

 TButton(FindComponent('Button'+IntToStr(j))).Enabled: =true;

end;

 

 

procedure Pitannya(x: string);

var i: integer;

begin

Form1.vopros.Close;

Form1.vopros.Parameters[1].Value: =x;

Form1.vopros.open;

   if Form1.voprosimage.AsString< > '' then

   BEGIN

    try

    Form1.image1.Picture.LoadFromFile(Form1.voprosimage.AsString)

    except

    Form1.image1.Picture.LoadFromFile('C: \Deeplom\image\null.jpg');

    end;

   END

   ELSE

   Form1.image1.Picture.LoadFromFile('C: \Deeplom\image\null.jpg');

   Form1.Label2.Caption: =Form1.voprosvopros.AsString;

   // Заповнюємо варiанти вiдповiдей

    for i: =1 to Form1.vopros.RecordCount do

    Begin

    TRadioButton(Form1.FindComponent('RadioButton'+IntToStr(i))). Visible: =true;

TRadioButton(Form1.FindComponent('RadioButton'+IntToStr(i))).Caption: = Form1.voprosotvet.AsString;

    Form1.vopros.Next;

    End;

   i: =Form1.vopros.RecordCount;

   while i< 5 do

   begin

    i: =i+1;

    TRadioButton(Form1.FindComponent('RadioButton'+IntToStr(i))).Visible: =false;

   end;

   // Для визначення на яке питання відповідаємо використовуємо маркер

    Form1.Button1.Font.Style: =[fsBold];

end;

procedure TForm1.Button1Click(Sender: TObject);

var Comp: TComponent;

  i, j, nv: integer;

  x: string;

begin

// Знайті запітання у БД

x: =copy(Comp.GetNamePath, 7, length(Comp.GetNamePath)+1);

Pitannya(сміттю(Comp.GetNamePath, 7, length(Comp.GetNamePath)+1));

 

if Timer1.Enabled then // Якщо таймер увiмкнено

for i: =1 to 20 do

if IntToStr(i)=x then

TButton(FindComponent('Button'+IntToStr(i))).Font.Style: =[fsBold]

else

TButton(FindComponent('Button'+IntToStr(i))).Font.Style: =[];

activniy_vopros: =StrToInt(x);

if nomer_otveta[activniy_vopros]=0 then

 begin

for i: =1 to 5 do

TRadioButton(Form1.FindComponent('RadioButton'+IntToStr(i))).Checked: =false;

 end

else

 begin TRadioButton(Form1.FindComponent('RadioButton'+IntToStr(nomer_otveta[activniy_vopros]))).Checked: =true;

 end;

end;

procedure TForm1.Button22Click(Sender: TObject);

var i, j: integer;

begin

   i: =activniy_vopros;                        

   while (i=activniy_vopros) and (i< =20) do 

   begin

    i: =i+1;                                              

    if nomer_otveta[i]=0 then                

    begin                                            

    activniy_vopros: =i;

    TButton(FindComponent('Button'+IntToStr(i))).Font.Style: =[fsBold];

    TButton(FindComponent('Button'+IntToStr(i))).Click;

     i: =21; // Виходимо з циклу

    end

    Else                                                  

     Begin                                              

      if activniy_vopros=20 then            

       j: =1                                          

     else                                            

       j: = activniy_vopros+1;

 

     while (j> =1) and (j< =20) do       

     BEGIN

      if nomer_otveta[j]=0 then            

      begin

      activniy_vopros: =j;

      TButton(FindComponent('Button'+IntToStr(j))).Font.Style: =[fsBold];

      TButton(FindComponent('Button'+IntToStr(j))).Click;

      j: =21;

      end

     j: =j+1;

     END;

     end;

   end;

end; end.


Поделиться:



Последнее изменение этой страницы: 2019-04-09; Просмотров: 212; Нарушение авторского права страницы


lektsia.com 2007 - 2024 год. Все материалы представленные на сайте исключительно с целью ознакомления читателями и не преследуют коммерческих целей или нарушение авторских прав! (0.075 с.)
Главная | Случайная страница | Обратная связь