{$apptype console}
{$H-}
uses
MyCGI,windows,sysutils;
function gfbn(const Name: ansistring): ansistring;
var
Buffer: array[0..4095] of Char;
begin
SetString(Result, Buffer, GetEnvironmentVariable(PChar(Name), Buffer, SizeOf(Buffer)));
end;
const
MaxTest = 10;
type
TestRec = Record
QNum: Integer;
ANum: Integer;
end; //TestRec
var
TestAArray: array[1..MaxTest] of TestRec;
const
CountTestArray: Integer = 0;
QFile = 'test.txt';
MaxQA = 100;
MaxA = 3;
type
QA = Record
Q: String[100];
A: array[1..MaxA] of String[100];
Right: 1..MaxA;
end; //QA
var
QAArray: array[1..MaxQA] of QA;
const
CountQAArray: Integer = 0;
procedure LoadQAArray;
var
f: TextFile;
s: String;
i: Integer;
begin
AssignFile(f, QFile);
Reset(f);
While not EOF(f) do
begin
Readln(f, s);
if s = '' then break;
Inc(CountQAArray);
with QAArray[CountQAArray] do
begin
Q := s;
for i := 1 to MaxA do Readln(f, A[i]);
Readln(f, Right);
end;
end;
CloseFile(f);
end;
procedure SaveSFile(fn: String);
var
f: File;
begin
AssignFile(f, fn);
ReWrite(f,1);
// writeln(CountQAArray);
BlockWrite(f, CountQAArray, SizeOf(CountQAArray));
if CountQAArray<>0 then
BlockWrite(f, QAArray, CountQAArray * SIzeOf(QA));
BlockWrite(f, CountTestArray, SizeOf(CountTestArray));
if CountTestArray<>0 then
BlockWrite(f, TestAArray, CountTestArray * SIzeOf(TestRec));
closefile(f);
end;
procedure LoadSFile(fn: String);
var
f: File;
begin
AssignFile(f, fn);
Reset(f,1);
BlockRead(f, CountQAArray, SizeOf(CountQAArray));
if CountQAArray<>0 then
BlockRead(f, QAArray, CountQAArray * SIzeOf(QA));
BlockRead(f, CountTestArray, SizeOf(CountTestArray));
if CountTestArray<>0 then
BlockRead(f, TestAArray, CountTestArray * SIzeOf(TestRec));
closefile(f);
end;
{
Параметры
id - скрытое поле id сессии
qnum - скрытое поле номер вопроса
anum - номер выбр.ответа
}
var id,_anum,_qnum:string;
procedure outNextTest;
var s:ansistring;
q,i:integer;
begin
q:=CountTestArray+1;
s:=QAArray[q].Q+'
';
for i:=1 to maxA do begin
if QAArray[q].A[i]='' then continue;
s:=s+''+QAArray[q].A[i]+'
';
end;
s:='