Рефераты. Информационная система обучения по курсу "Компьютерные сети"

Label2: TLabel;

Label3: TLabel;

Label4: TLabel;

// радиокнопки выбора ответа

RadioButton1: TRadioButton;

RadioButton2: TRadioButton;

RadioButton3: TRadioButton;

RadioButton4: TRadioButton;

Image1: TImage; // область вывода иллюстрации

Button1: TButton;

Panel1: TPanel;

RadioButton5: TRadioButton;

Gauge1: TGauge;

Timer1: TTimer;

procedure FormActivate(Sender: TObject);

procedure Button1Click(Sender: TObject);

procedure RadioButtonClick(Sender: TObject);

// Эти объявления вставлены сюда вручную

procedure Info;

procedure VoprosToScr;

procedure ShowPicture; // выводит иллюстрацию

procedure ResetForm; // "очистка" формы перед выводом очередного вопроса

procedure Itog;

procedure FormCreate(Sender: TObject);

procedure Timer1Timer(Sender: TObject);

procedure FormClose(Sender: TObject; var Action: TCloseAction);

procedure FormShow(Sender: TObject); // результат тестирования

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form1: TForm1; // форма

implementation

uses Unit19, Unit1, Unit44;

{$R *.DFM}

const

N_LEV=4; // четыре уровня оценки

N_ANS=4; // четыре варианта ответов

var

f,fil1:TextFile;

fn:string; // имя файла вопросов

level:array[1..N_LEV] of integer; // сумма, соответствующая уровню

mes:array[1..N_LEV] of string; // сообщение, соответствующее уровню

score:array[1..N_ANS] of integer; // оценка за выбор ответа

summa:integer; // набрано очков

vopros:integer; // номер текущего вопроса

otv:integer; // номер выбранного ответа

// вывод информации о тесте

procedure Tform1.Info;

var

s,buf:string;

begin

readln(f,s);

Form1.Caption := s;

buf:='';

repeat

readln(f,s);

if s[1] <> '.'

then buf := buf +s + #13;

until s[1] ='.';

Label5.caption:=buf;

end;

// прочитать информацию об оценках за тест

Procedure GetLevel;

var

i:integer;

buf:string;

begin

i:=1;

repeat

readln(f,buf);

if buf[1] <> '.' then begin

mes[i]:=buf; // сообщение

readln(f,level[i]); // оценка

i:=i+1;

end;

until buf[1]='.';

end;

// масштабирование иллюстрации

Procedure TForm1.ShowPicture;

var

w,h: integer; // максимально возможные размеры картинки

begin

// вычислить допустимые размеры картинки

w:=ClientWidth-10;

h:=ClientHeight

- Panel1.Height -10

- Label5.Top

- Label5.Height - 10;

// вопросы

if Label1.Caption <> ''

then h:=h-Label1.Height-10;

if Label2.Caption <> ''

then h:=h-Label2.Height-10;

if Label3.Caption <> ''

then h:=h-Label3.Height-10;

if Label4.Caption <> ''

then h:=h-Label4.Height-10;

// если размер картинки меньше w на h,

// то она не масштабируется

Image1.Top:=Form1.Label5.Top+Label5.Height+10;

if Image1.Picture.Bitmap.Height > h

then Image1.Height:=h

else Image1.Height:= Image1.Picture.Height;

if Image1.Picture.Bitmap.Width > w

then Image1.Width:=w

else Image1.Width:=Image1.Picture.Width;

Image1.Visible := True;

end;

// вывести вопрос

Procedure TForm1.VoprosToScr;

var

i:integer;

s,buf:string;

ifn:string; // файл иллюстрации

begin

vopros:=vopros+1;

caption:='Вопрос ' + IntToStr(vopros);

// прочитать вопрос

buf:='';

repeat

readln(f,s);

if (s[1] <> '.') and (s[1] <> '\')

then buf:=buf+s+' ';

until (s[1] ='.') or (s[1] ='\');

Label5.caption:=buf; // вывести вопрос

{Иллюстрацию прочитаем, но выведем только после того, как прочитаем альтернативные ответы и определим максимально возможный размер области формы, который можно использовать для ее вывода.}

if s[1] <> '\'

then Image1.Tag:=0 // к вопросу нет иллюстрации

else // к вопросу есть иллюстрация

begin

Image1.Tag:=1;

ifn:=copy(s,2,length(s));

try

Image1.Picture.LoadFromFile(ifn);

except

on E:EFOpenError do

Image1.Tag:=0;

end;

end;

// Читаем варианты ответов

i:=1;

repeat

buf:='';

repeat // читаем текст варианта ответа

readln(f,s);

if (s[1]<>'.') and (s[1] <> ',')

then buf:=buf+s+' ';

until (s[1]=',')or(s[1]='.');

// прочитан альтернативный ответ

score[i]:= StrToInt(s[2]);

case i of

1: Label1.caption:=buf;

2: Label2.caption:=buf;

3: Label3.caption:=buf;

4: Label4.caption:=buf;

end;

i:=i+1;

until s[1]='.';

// здесь прочитана иллюстрация и альтернативные ответы

// текст вопроса уже выведен

if Image1.Tag =1 // есть иллюстрация к вопросу

then ShowPicture;

// вывод альтернативных ответов

if Form1.Label1.Caption <> ''

then begin

if Form1.Image1.Tag =1

then Label1.top:=Image1.Top+Image1.Height+10

else Label1.top:=Label5.Top+Label5.Height+10;

RadioButton1.top:=Label1.top;

Label1.visible:=TRUE;

RadioButton1.visible:=TRUE;

end;

if Form1.Label2.Caption <> ''

then begin

Label2.top:=Label1.top+ Label1.height+10;

RadioButton2.top:=Label2.top;

Label2.visible:=TRUE;

RadioButton2.visible:=TRUE;

end;

if Form1.Label3.Caption <> ''

then begin

Label3.top:=Label2.top+ Label2.height+10;

RadioButton3.top:=Label3.top;

Label3.visible:=TRUE;

RadioButton3.visible:=TRUE;

end;

if Form1.Label4.Caption <> ''

then begin

Label4.top:=Label3.top+ Label3.height+10;

RadioButton4.top:=Label4.top;

Label4.visible:=TRUE;

RadioButton4.visible:=TRUE;

end;

end;

Procedure TForm1.ResetForm;

begin // сделать невидимыми все метки и радиокнопки

Label1.Visible:=FALSE;

Label1.caption:='';

Label1.width:=ClientWidth-Label1.left-5;

RadioButton1.Visible:=FALSE;

Label2.Visible:=FALSE;

Label2.caption:='';

Label2.width:=ClientWidth-Label2.left-5;

RadioButton2.Visible:=FALSE;

Label3.Visible:=FALSE;

Label3.caption:='';

Label3.width:=ClientWidth-Label3.left-5;

RadioButton3.Visible:=FALSE;

Label4.Visible:=FALSE;

Label4.caption:='';

Label4.width:=ClientWidth-Label4.left-5;

RadioButton4.Visible:=FALSE;

Label5.width:=ClientWidth-Label5.left-5;

Image1.Visible:=FALSE;

end;

// определение достигнутого уровня

procedure TForm1.Itog;

var

i:integer;

buf:string;

begin

buf:='';

buf:='Результаты тестирования'+ #13

+'Всего баллов: '+ IntToStr(summa);

i:=1;

while (summa < level[i]) and (i<N_LEV) do

i:=i+1;

buf:=buf+ #13+mes[i];

Label5.Top:=20;

Label5.caption:=buf;

end;

procedure TForm1.FormActivate(Sender: TObject);

begin

end;

// щелчок на кнопке Button1

procedure TForm1.Button1Click(Sender: TObject);

var s,s2,s1,s3,s4,s5,s6,s7,k,tim1:string;i,j,l,l1,l2:integer;tim:integer;

begin

case Button1.tag of

0: begin

Button1.caption:='Дальше';

Button1.tag:=1;

RadioButton5.Checked:=TRUE;

// вывод первого вопроса

Timer1.Enabled:=true;

Gauge1.Visible:=true;

Button1.Enabled:=False;

ResetForm;

VoprosToScr;

end;

1: begin // вывод остальных вопросов

summa:=summa+score[otv];

RadioButton5.Checked:=TRUE;

Button1.Enabled:=False;

ResetForm;

if not eof(f)

then VoprosToScr

else

begin

summa:=summa+score[otv];

closefile(f);

Button1.caption:='Ok';

Form1.caption:='Результат';

Button1.tag:=2;

Button1.Enabled:=TRUE;

Itog; // вывести результат

end;

end;

2: begin // завершение работы

Timer1.Enabled:=false;

s:='';

assignfile(fil1,'bd\result.txt');

reset(fil1);

s:='';

while not eof(fil1) do

begin

readln(fil1,s2);

s:=s+s2;

end;

closefile(fil1);

s1:='';

for i:=1 to length(s) do begin

if (s[i] = '*') then begin

if s1=zagl.Edit1.Text then begin

j:=i+1;

s3:='';

while s[j]<>'#' do begin

if s[j]='&' then begin

tim:=time1+StrToInt(s3);

delete(s,i+1,j-1-i-1);

tim1:=FloatToStr(tim);

insert(tim1,s,i+1);

s3:='';

end;

if s[j]='$' then begin

if summa>=7 then begin

l:=StrToInt(s[j-1])+1;

delete(s,j-1,1);

s7:=IntToStr(l);

insert(s7,s,j-1);

s3:='';

end

else l:=StrToInt(s[j-1]);

if summa>=7 then begin

s5:=s[j+1]+s[j+2];

l2:=StrToInt(s5);

delete(s,j+1,2);

l2:=l2+summa;

s6:=IntToStr(l2);

if length(s6)=1 then s6:=' '+s6;

insert(s6,s,j+1);

end;

end;

s3:=s3+s[j];

j:=j+1;

end;

end;

end;

s1:=s1+s[i];

if (s[i]='#') then s1:='';

end;

rewrite(fil1);

s4:='';

for i:=1 to length(s) do

begin

s4:=s4+s[i];

if s[i]='#' then begin

writeln(fil1,s4);

s4:='';

end;

end;

closefile(fil1);

assignfile(fil1,'bd\result1.txt');

reset(fil1);

s:='';

while not eof(fil1) do

begin

readln(fil1,s2);

s:=s+s2;

end;

closefile(fil1);

s1:='';

for i:=1 to length(s) do begin

if (s[i] = '*') then begin

//showmessage(s1);

if s1=zagl.Edit1.Text then begin

j:=i+1;

s3:='';

while s[j]<>'~' do begin

if (s[j]='!')and(l=1)and(summa>StrToInt(s[j-1])) then begin

delete(s,j-1,1);

s6:=IntToStr(summa);

insert(s6,s,j-1);

end;

if (s[j]='$')and(l=2)and(summa>StrToInt(s[j-1])) then begin

delete(s,j-1,1);

s6:=IntToStr(summa);

insert(s6,s,j-1);

end;

if (s[j]='#')and(l=3)and(summa>StrToInt(s[j-1])) then begin

delete(s,j-1,1);

s6:=IntToStr(summa);

insert(s6,s,j-1);

end;

if (s[j]='%')and(l=4)and(summa>StrToInt(s[j-1])) then begin

delete(s,j-1,1);

s6:=IntToStr(summa);

insert(s6,s,j-1);

end;

if (s[j]='^')and(l=5)and(summa>StrToInt(s[j-1])) then begin

delete(s,j-1,1);

s6:=IntToStr(summa);

insert(s6,s,j-1);

end;

if (s[j]='@')and(l=6)and(summa>StrToInt(s[j-1])) then begin

delete(s,j-1,1);

s6:=IntToStr(summa);

insert(s6,s,j-1);

end;

if (s[j]='~')and(l=7)and(summa>StrToInt(s[j-1])) then begin

delete(s,j-1,1);

s6:=IntToStr(summa);

insert(s6,s,j-1);

end;

s3:=s3+s[j];

j:=j+1;

end;

end;

end;

s1:=s1+s[i];

if (s[i]='~') then s1:='';

end;

rewrite(fil1);

s4:='';

for i:=1 to length(s) do

begin

s4:=s4+s[i];

if s[i]='~' then begin

writeln(fil1,s4);

s4:='';

end;

end;

closefile(fil1);

Form1.Close;

ElektKursInf.Button1.Enabled:=true;

end;

end;

end;

// Процедура обработки события OnClick

// для компонентов RadioButton1-RadioButton4

procedure TForm1.RadioButtonClick(Sender: TObject);

begin

if sender = RadioButton1

then otv:=1

else if sender = RadioButton1

then otv:=2

else if sender = RadioButton3

then otv:=3

else otv:=4;

Button1.enabled:=TRUE;

end;

// обеспечивает настройку компонентов

procedure TForm1.FormCreate(Sender: TObject);

begin

Image1.AutoSize := False;

Image1.Proportional := True;

RadioButton1.Visible := False;

end;

procedure TForm1.Timer1Timer(Sender: TObject);

begin

Gauge1.Progress:=Gauge1.Progress+1;

if Gauge1.Progress=100 then begin

ResetForm;

summa:=summa+score[otv];

Button1.caption:='Ok';

Form1.caption:='Результат';

Button1.tag:=2;

Button1.Enabled:=TRUE;

Itog; // вывести результат

Timer1.Enabled:=false;

end;

end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);

begin

ElektKursInf.Button1.Enabled:=true;

end;

procedure TForm1.FormShow(Sender: TObject);

var z:integer;s0:string;

begin

assignfile(fil,'bd\path1.txt');

reset(fil);

s0:='';

while not eof(fil) do

begin

readln(fil,s0);

break;

end;

closefile(fil);

randomize;

ResetForm;

z:=random(4)+1;

fn:=copy(s0,9,length(s0))+IntToStr(ElektKursInf.ListBox1.ItemIndex+1)+IntToStr(z)+'.txt';

assignfile(f,fn);

try

reset(f);

except

on EFOpenError do

begin

ShowMessage('Файл теста '+fn+' не найден.');

Button1.caption:='Ok';

Button1.tag:=2;

Button1.Enabled:=TRUE;

exit;

end;

end;

Info; // прочитать и вывести информацию о тесте

GetLevel; // прочитать информацию об уровнях оценок

end;

end.

Страницы: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12



2012 © Все права защищены
При использовании материалов активная ссылка на источник обязательна.