Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2007.07.08;
Скачать: CL | DM;

Вниз

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

 
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;
Скачать: CL | DM;

Наверх




Память: 0.5 MB
Время: 0.021 c
15-1181235837
Interior
2007-06-07 21:03
2007.07.08
Умер ноутбук но винт живой


2-1181889608
Баян 555
2007-06-15 10:40
2007.07.08
перевод в читабельный вид


15-1181470440
Kostafey
2007-06-10 14:14
2007.07.08
С днем рождения ! 10 июня


2-1181571361
molotok
2007-06-11 18:16
2007.07.08
что это такое и как с этим бороться?


9-1156193657
Селезин
2006-08-22 00:54
2007.07.08
Расчет координат