zebraxxl

Untitled

Dec 19th, 2011
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 4.06 KB | None | 0 0
  1. procedure ReadQuestion();
  2. var Ini:TIniFile;
  3.     count, i:integer;
  4.     sect, img:string;
  5. begin
  6.   Ini:=TIniFile.Create(ExtractFilePath(Application.ExeName) + 'Triggers.cof');
  7.   count:=Ini.ReadInteger('main', 'count', 0);
  8.   if (count > 0) then begin
  9.     i:=Random(count) + 1;
  10.  
  11.     str(i, sect);
  12.     QuestionText:=Ini.ReadString(sect, 'text', '');
  13.     AnswerText:='1) ' + Ini.ReadString(sect, 'a1', '') + #13 +
  14.                 '2) ' + Ini.ReadString(sect, 'a2', '') + #13 +
  15.                 '3) ' + Ini.ReadString(sect, 'a3', '') + #13 +
  16.                 '4) ' + Ini.ReadString(sect, 'a4', '');
  17.     answer:=Ini.ReadInteger(sect, 'a', 0) and $0F;
  18.     img:=Ini.ReadString(sect, 'img', '');
  19.  
  20.     Form1.RichEdit1.Text := QuestionText;
  21.     Form1.RichEdit2.Text := AnswerText;
  22.     if (img <> '') then
  23.       Form1.Image1.Picture.LoadFromFile(ExtractFilePath(Application.ExeName) + 'img\\' + img);
  24.   end;
  25. end;
  26.  
  27. {$R *.DFM}
  28.  
  29. procedure TForm1.Button1Click(Sender: TObject);
  30. Var enter:char;
  31.     mark:integer;
  32. begin
  33.  If (not(form1.RadioButton1.Checked)) and (not(form1.RadioButton2.Checked))and
  34.     (not(form1.RadioButton3.Checked)) and (not(form1.RadioButton4.Checked))
  35.     Then Application.MessageBox('Выберите какой-нибудь ответ.', 'Будьте внимательнее...' ,mb_ok)
  36.  Else
  37.   Begin
  38.    If (form1.RadioButton1.Checked) and (form1.RadioButton1.Tag = answer) Then bal:=bal+1;
  39.    If (form1.RadioButton2.Checked) and (form1.RadioButton2.Tag = answer) Then bal:=bal+1;
  40.    If (form1.RadioButton3.Checked) and (form1.RadioButton3.Tag = answer) Then bal:=bal+1;
  41.    If (form1.RadioButton4.Checked) and (form1.RadioButton4.Tag = answer) Then bal:=bal+1;
  42.    Inc(i);
  43.    if i<=qcount then
  44.     begin
  45.       ReadQuestion();
  46.     end else begin
  47.       mark:=2;
  48.       If bal>=_3 Then mark:=3;
  49.       If bal>=_4 Then mark:=4;
  50.       If bal>=_5 Then mark:=5;
  51.  
  52.       str(mark,c);
  53.       Form1.RichEdit1.Visible:=False;
  54.       Form1.RichEdit2.Visible:=False;
  55.       Form1.Image1.Visible:=False;
  56.       Form1.Timer1.Enabled:=False;
  57.       Form1.Button1.Visible:=False;
  58.       Form1.GroupBox1.Visible:=False;
  59.       Form1.label1.Visible:=true;
  60.       Form1.label1.Caption:='Ваша оценка '+c + #13 + 'Позовите преподавателя';
  61.       If FileExists('Statist.txt') Then Form1.Memo1.Lines.LoadFromFile('Statist.txt');
  62.       Form1.Memo1.Lines.Text:=Form1.Memo1.Lines.Text+DateToStr(Date)+' '+Form1.Edit1.Text+' '+Form1.Edit2.Text+' '+'Oценка '+c;
  63.       enter:=Chr(23);
  64.       i:=Form1.Memo1.Lines.Add(enter);
  65.       Form1.Memo1.Lines.Move(i,i+1);
  66.       Form1.Memo1.Lines.SaveToFile('Statist.txt');
  67.       i:=1;
  68.       Min:=0;
  69.       Sec:=0;
  70.       Bal:=0;
  71.     end;
  72.   End;
  73. end;
  74.  
  75. procedure TForm1.FormCreate(Sender: TObject);
  76. var Ini:TIniFile;
  77. begin
  78.      StatusBar1.SimpleText:=StatusBar1.SimpleText+'  '+DateToStr(Date);
  79.         Case DayOfWeek(Date) Of
  80.         1: StatusBar1.SimpleText:=StatusBar1.SimpleText+'  '+', Воскресенье';
  81.         2: StatusBar1.SimpleText:=StatusBar1.SimpleText+'  '+', Понедельник';
  82.         3: StatusBar1.SimpleText:=StatusBar1.SimpleText+'  '+', Вторник';
  83.         4: StatusBar1.SimpleText:=StatusBar1.SimpleText+'  '+', Среда';
  84.         5: StatusBar1.SimpleText:=StatusBar1.SimpleText+'  '+', Четверг';
  85.         6: StatusBar1.SimpleText:=StatusBar1.SimpleText+'  '+', Пятница';
  86.         7: StatusBar1.SimpleText:=StatusBar1.SimpleText+'  '+', Суббота';
  87.         End;                              
  88.      Ini:=TIniFile.Create(ExtractFilePath(Application.ExeName) + 'Triggers.cof');
  89.      _min:=Ini.ReadInteger('main', 'min', 5);
  90.      _sec:=Ini.ReadInteger('main', 'sec', 0);
  91.      Label2.Caption:=IntToStr(_min) + ':' + IntToStr(_sec);
  92.  
  93.      qcount:=Ini.ReadInteger('main', 'qcount', 5);
  94.      _3:=Ini.ReadInteger('main', '3', 3);
  95.      _4:=Ini.ReadInteger('main', '3', 4);
  96.      _5:=Ini.ReadInteger('main', '3', 5);
  97.  
  98.      Form1.Edit1.Text:='';
  99.      Form1.Edit2.Text:='';
  100.      Form1.RichEdit1.Text:='';      
  101.      Form1.RichEdit1.Text:='';
  102.      randomize;
  103.      i:=1;
  104. end;
Advertisement
Add Comment
Please, Sign In to add comment