Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Начинающим";
Текущий архив: 2007.07.08;
Скачать: [xml.tar.bz2];

Вниз

даже не знаю как назвать...   Найти похожие ветки 

 
Bullfrog   (2007-06-11 20:26) [0]

придумал какой-то "ломанный" алгоритм теста, который должен уметь обрабатывать вопросы простого выбора(чекбокс) и вопросы на сопосталение(здесь используется мемо и несколько эдитов)
Запускаем программу, проходим тест один раз(вроде все нормально), пытаемся пройти другой тест, но он уже не работает. Отображается последний вопрос предыдущего теста, а варианты ответа(ни чекбоксы, ни эдиты) вообще не отображаются, хотя им присваивается висибл := тру.
Всю голову уже сломал, меня явно заклинило, помогите, пожалуйста!
Пожалуйста, не бейте сильно за такой вопрос, но я уже не могу.
щас закину коды...


 
Bullfrog   (2007-06-11 20:28) [1]

if TreeView1.Items[6].Selected then// Showmessage("Test1");//test1
Begin WebBrowser1.Hide;
     Button7.Visible := true;
     Button8.Visible := True;
     TreeView1.Enabled := false;
     Button1.Enabled := false;
     Button2.Enabled := false;
     Button3.Enabled := false;
     Button4.Enabled := false;
     Button5.Enabled := false;
     Button6.Enabled := false;
     BtnTest.Enabled := false;
     rq:=0; nq:=0; numtest:=1; buf:="";
//zapolnyaem pervii vopros
//proveryaem kakoi vid voprosa
     renamefile("Test1.tst","test");
     assignfile(f,"test");
     reset(f);
     readln(f,buf);
     if buf = "v" then
     begin readln(f,buf);
           label1.Visible :=true;
           label1.Caption := buf;
           readln(f,buf);
           checkbox1.Visible := true;
           checkbox1.Caption := buf;
           readln(f,buf);
           checkbox2.Visible := true;
           checkbox2.Caption := buf;
           readln(f,buf);
           if buf<>"---" then
           begin checkbox3.Visible := true;
                 checkbox3.Caption := buf; end;
           readln(f,buf);
           if buf<>"---" then
           begin checkbox4.Visible := true;
                 checkbox4.Caption := buf; end;
           readln(f,buf);
           if buf<>"---" then
           begin checkbox5.Visible := true;
                 checkbox5.Caption := buf; end;
           readln(f,buf);
           if buf<>"---" then
           begin checkbox6.Visible := true;
                 checkbox6.Caption := buf; end;
           readln(f,buf);
           if buf<>"---" then
           begin checkbox7.Visible := true;
                 checkbox7.Caption := buf; end;
           readln(f,buf);
           if buf<>"---" then
           begin checkbox8.Visible := true;
                 checkbox8.Caption := buf; end;
           readln(f,buf);
           if buf<>"---" then
           begin checkbox9.Visible := true;
                 checkbox9.Caption := buf; end;
           readln(f,buf);
           if buf<>"---" then
           begin checkbox10.Visible := true;
                 checkbox10.Caption := buf; end;
     end
     else if buf = "s" then
     begin Label1.Visible := True;
           Label2.Visible :=true;
           Label3.Visible :=true;
           Label4.Visible :=true;
           Label5.Visible :=true;
           Label6.Visible :=true;
//            Label7.Visible :=true;
//            Label8.Visible :=true;
//            Label9.Visible :=true;
//            Label10.Visible :=true;
//            Label11.Visible :=true;
           Edit1.Visible := True;
           Edit2.Visible := True;
           Edit3.Visible := True;
           Edit4.Visible := True;
           Edit5.Visible := True;
//            Edit6.Visible := True;
//            Edit7.Visible := True;
//            Edit8.Visible := True;
//            Edit9.Visible := True;
//            Edit10.Visible := True;
           Memo1.Visible := True;
           readln(f,buf);
           label1.Caption := buf;
           for i:=1 to 10 do
           begin readln(f,buf); memo1.Lines.Add(buf); end;
     end;
 end;
эта штука нажимается один раз, для перелистывания вопрос, подсчета баллов и тд написана следующая вещь:


 
Bullfrog   (2007-06-11 20:31) [2]

var st: string; ocenka:integer; Users: UserInfo;
tq: string;              //rq-right question, tq-total question, nq-number question
begin
//prinimaem otvet
   tq:="";
   if checkbox1.Checked then tq:= "1.";
   if checkbox2.Checked then tq:= tq + "2.";
   if checkbox3.Checked then tq:= tq + "3.";
   if checkbox4.Checked then tq:= tq + "4.";
   if checkbox5.Checked then tq:= tq + "5.";
   if checkbox6.Checked then tq:= tq + "6.";
   if checkbox7.Checked then tq:= tq + "7.";
   if checkbox8.Checked then tq:= tq + "8.";
   if checkbox9.Checked then tq:= tq + "9.";
   if checkbox10.Checked then tq:= tq + "10.";
   //esli tq pustoi, znachit bil vopros na sootvetstvie, pinimaem ego
   if tq = "" then begin
   tq:="1"+Edit1.Text+".";
   tq:=tq+"2"+Edit2.Text+".";
   tq:=tq+"3"+Edit3.Text+".";
   tq:=tq+"4"+Edit4.Text+".";
   tq:=tq+"5"+Edit5.Text+".";
   tq:=tq+"6"+Edit6.Text+".";
   tq:=tq+"7"+Edit7.Text+".";
   tq:=tq+"8"+Edit8.Text+".";
   tq:=tq+"9"+Edit9.Text+".";
   tq:=tq+"10"+Edit10.Text+".";
   end;
//vikluchaem formu testa
Memo1.Visible := False;
Label2.Visible := False;
Label3.Visible := False;
Label4.Visible := False;
Label5.Visible := False;
Label6.Visible := False;
Label7.Visible := False;
Label8.Visible := False;
Label9.Visible := False;
Label10.Visible := False;
Label11.Visible := False;
Edit1.Visible := False;
Edit2.Visible := False;
Edit3.Visible := False;
Edit4.Visible := False;
Edit5.Visible := False;
Edit6.Visible := False;
Edit7.Visible := False;
Edit8.Visible := False;
Edit9.Visible := False;
Edit10.Visible := False;
//sbrsivaem editi
Edit1.Text :="";
Edit2.Text :="";
Edit3.Text :="";
Edit4.Text :="";
Edit5.Text :="";
Edit6.Text :="";
Edit7.Text :="";
Edit8.Text :="";
Edit9.Text :="";
Edit10.Text :="";
CheckBox1.Visible := False;
CheckBox2.Visible := False;
CheckBox3.Visible := False;
CheckBox4.Visible := False;
CheckBox5.Visible := False;
CheckBox6.Visible := False;
CheckBox7.Visible := False;
CheckBox8.Visible := False;
CheckBox9.Visible := False;
CheckBox10.Visible := False;
//sbrasivaem checkboxi
  checkbox1.Checked := false;
  checkbox2.Checked := false;
  checkbox3.Checked := false;
  checkbox4.Checked := false;
  checkbox5.Checked := false;
  checkbox6.Checked := false;
  checkbox7.Checked := false;
  checkbox8.Checked := false;
  checkbox9.Checked := false;
  checkbox10.Checked := false;
 inc(nq); buf:="";
 readln(f,buf); if buf = tq then begin inc(rq); end;
 readln(f,buf);
//zapolnyaem sledujushii vopros
if Not Eof(f) then begin
if buf = "v" then begin
 readln(f,buf);
 label1.Visible :=true;
 label1.Caption := buf;
 readln(f,buf);
 checkbox1.Visible := true;
 checkbox1.Caption := buf;
 readln(f,buf);
 checkbox2.Visible := true;
 checkbox2.Caption := buf;
 readln(f,buf);
 if buf<>"---" then begin checkbox3.Visible := true;
 checkbox3.Caption := buf;  end;
 readln(f,buf);
 if buf<>"---" then begin checkbox4.Visible := true;
 checkbox4.Caption := buf;  end;
 readln(f,buf);
 if buf<>"---" then begin checkbox5.Visible := true;
 checkbox5.Caption := buf;  end;
 readln(f,buf);
 if buf<>"---" then begin checkbox6.Visible := true;
 checkbox6.Caption := buf;  end;
 readln(f,buf);
 if buf<>"---" then begin checkbox7.Visible := true;
 checkbox7.Caption := buf;  end;
 readln(f,buf);
 if buf<>"---" then begin checkbox8.Visible := true;
 checkbox8.Caption := buf;  end;
 readln(f,buf);
 if buf<>"---" then begin checkbox9.Visible := true;
 checkbox9.Caption := buf;  end;
 readln(f,buf);
 if buf<>"---" then begin checkbox10.Visible := true;
 checkbox10.Caption := buf;  end;
end
else if buf = "s" then begin
 Label1.Visible := True;
 Label2.Visible :=true;
 Label3.Visible :=true;
 Label4.Visible :=true;
 Label5.Visible :=true;
 Label6.Visible :=true;
 Edit1.Visible := True;
 Edit2.Visible := True;
 Edit3.Visible := True;
 Edit4.Visible := True;
 Edit5.Visible := True;
 Memo1.Visible := True;
 readln(f,buf);
 label1.Caption := buf;
 for i:=1 to 10 do begin readln(f,buf); memo1.Lines.Add(buf); end; end;
end
//zdes budet else
Else begin
 end;

if (rq/nq)<=0.15 then ocenka:=1
 else if (rq/nq)<=0.25 then ocenka:=2
         else if (rq/nq)<=0.5 then ocenka:=3
               else if (rq/nq)<=0.75 then ocenka:=4
                    // else if (rq/nq)<=0.95 then ocenka:=4
                           else ocenka:=5;
rq:=0; flush(f);
closefile(f); buf:="";
renamefile("test","Test"+inttostr(numtest)+".tst");
assignfile(DataFile, "users");
WebBrowser1.Show;
Button7.Visible := false; Button8.Visible := false;
Button1.Enabled := true; Button2.Enabled := true;
Button3.Enabled := true; Button4.Enabled := true;
Button5.Enabled := true; Button6.Enabled := true;
BtnTest.Enabled := true; TreeView1.Enabled :=true;
reset(DataFile);
Seek(DataFile, 0);
case numtest of
1: begin
     while not eof(DataFile) do
     begin
      read(DataFile, Users);
      if (AvtLog = Users.Login) and (AvtPas = Users.Password)
      then With Users do ocenka1:=inttostr(ocenka);
     end;
     write(DataFile,Users);
   end;
2: begin
     while not eof(DataFile) do
     begin
      read(DataFile, Users);
      if (AvtLog = Users.Login) and (AvtPas = Users.Password)
      then With Users do ocenka2:=inttostr(ocenka);
     end;
     Seek(DataFile, FilePos(DataFile)-1);
     write(DataFile,Users);
   end;
3: begin
     while not eof(DataFile) do
     begin
      read(DataFile, Users);
      if (AvtLog = Users.Login) and (AvtPas = Users.Password)
      then With Users do ocenka3:=inttostr(ocenka);
     end;
     Seek(DataFile, FilePos(DataFile)-1);
     write(DataFile,Users);
   end;
4: begin
     while not eof(DataFile) do
     begin
      read(DataFile, Users);
      if (AvtLog = Users.Login) and (AvtPas = Users.Password)
      then With Users do ocenka4:=inttostr(ocenka);
     end;
     Seek(DataFile, FilePos(DataFile)-1);
     write(DataFile,Users);
   end;
 5: begin
     while not eof(DataFile) do
     begin
      read(DataFile, Users);
      if (AvtLog = Users.Login) and (AvtPas = Users.Password)
      then With Users do ocenka5:=inttostr(ocenka);
     end;
     Seek(DataFile, FilePos(DataFile)-1);
     write(DataFile,Users);
   end;
 6: begin
     while not eof(DataFile) do
     begin
      read(DataFile, Users);
      if (AvtLog = Users.Login) and (AvtPas = Users.Password)
      then With Users do ocenka6:=inttostr(ocenka);
     end;
     Seek(DataFile, FilePos(DataFile)-1);
     write(DataFile,Users);
   end;
 7: begin
     while not eof(DataFile) do
     begin
      read(DataFile, Users);
      if (AvtLog = Users.Login) and (AvtPas = Users.Password)
      then With Users do ocenka7:=inttostr(ocenka);
     end;
     Seek(DataFile, FilePos(DataFile)-1);
     write(DataFile,Users);
   end;
  end;
end;

Еще раз прошу прощенья! Буду далгодарен любой посильной помощи


 
Bullfrog   (2007-06-11 21:48) [3]

Каюсь! Каюсь! Каюсь! Меня и правда заклинило,5 часов над этой ерундой сидел, а оказалось формат одного файла не отвечал требованиям. Так как после переделок алгоритма упустил изменение одного файла(теста).
вот я гоню!

Простите меня за такой флуд, надеюсь, подобного не повторится.



Страницы: 1 вся ветка

Форум: "Начинающим";
Текущий архив: 2007.07.08;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.49 MB
Время: 0.032 c
15-1181109052
Игорь Шевченко
2007-06-06 09:50
2007.07.08
Компания Codegear Borland проводит семинары


2-1181845410
sergey_61
2007-06-14 22:23
2007.07.08
Grayscale (Черно-белое изображение)


4-1170351098
kolj
2007-02-01 20:31
2007.07.08
Работа с COM портом


15-1181199412
stone
2007-06-07 10:56
2007.07.08
Нужен программист MS SQL + Delphi


2-1180966360
AlexanderMS
2007-06-04 18:12
2007.07.08
Как поместить ProgressBar на определённую область StatusBar.





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский