- •1. Взаимосвязь задач в системе «программа«экзаменатор» 4
- •1.1. Основные цели создания подсистемы «Программа«Экзаменатор» 4
- •2. Разработка задачи “тестирование или экзамен по вопросам” 6
- •Введение
- •1. Взаимосвязь задач в системе «программа«экзаменатор»
- •1.1. Основные цели создания подсистемы «Программа«Экзаменатор»
- •1.2. Описание системы программного обеспечения
- •2.2.4. Математическая постановка задачи
- •2.2.5. Специальные требования к техническому обеспечению
- •2.2.6. Требования к характеристикам качества программного средства
- •1.3. Описание технологического процесса сбора данных
- •1.4. Описание технологического процесса обработки данных.
- •2.3. Описание подзадачи наполнения информационной базы билетов
- •2.3.1. Назначение и характеристика подзадачи
- •2.3.2. Используемая информация
- •2.3.3. Результаты решения
- •2.3.4. Математическое описание
- •2.5.3. Результаты расчета
- •2.5.4. Результаты испытания программы
- •3. Качество программного средства
- •Заключение
- •Список литературы
- •Текст модуля project1.Dpr
- •Текст модуля unit1.Pas
- •Текст модуля unit2.Pas
- •Текст модуля unit3.Pas
- •Текст модуля Unit3.Pas
- •Экран программы
- •1. Назначение программы
- •2. Условия применения программы
- •3. Характеристики программы
- •4. Обращение к программе
- •5. Сообщения
Список литературы
П.Дарахвелидзе, Е.Марков. Delphi – среда визуального программирования. С.-Пб.:BHV–Санкт-Петербург, 1996.
Правила дорожного движения. М., 1994.
Приложение 1
С
ХЕМA
ПРОГРАММЫ
PDDPROJECT
Рис. П1.1
Продолжение рис. П1.1
Приложение 2
ТЕКСТЫ И РЕЗУЛЬТАТЫ РАБОТЫ ПРОГРАММЫ
Текст модуля project1.Dpr
program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1},
Unit2 in 'Unit2.pas' {OKBottomDlg},
Unit3 in 'Unit3.pas' {OKRightDlg},
Unit4 in 'Unit4.pas' {Form4};
{$R *.RES}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.CreateForm(TOKBottomDlg, OKBottomDlg);
Application.CreateForm(TOKRightDlg, OKRightDlg);
Application.CreateForm(TForm4, Form4);
Application.Run;
end.
Текст модуля unit1.Pas
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Menus, ComCtrls, ExtCtrls, StdCtrls, Grids, Buttons;
type
TForm1 = class(TForm)
StatusBar1: TStatusBar;
OpenDialog1: TOpenDialog;
MainMenu1: TMainMenu;
File1: TMenuItem;
Exit1: TMenuItem;
Open1: TMenuItem;
Help1: TMenuItem;
About1: TMenuItem;
Contents1: TMenuItem;
N1: TMenuItem;
Timer1: TTimer;
StaticText1: TStaticText;
Edit1: TEdit;
StaticText2: TStaticText;
Bevel1: TBevel;
StringGrid1: TStringGrid;
StaticText3: TStaticText;
StaticText4: TStaticText;
StaticText5: TStaticText;
StaticText6: TStaticText;
Close1: TMenuItem;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
StaticText7: TStaticText;
StaticText8: TStaticText;
StaticText9: TStaticText;
StaticText10: TStaticText;
SpeedButton4: TSpeedButton;
Variant1: TMenuItem;
procedure Exit1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure About1Click(Sender: TObject);
procedure Contents1Click(Sender: TObject);
procedure Open1Click(Sender: TObject);
procedure Titl;
procedure Results;
procedure Stop;
procedure Opn;
procedure MU(r : longint);
procedure Close1Click(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
procedure SpeedButton2Click(Sender: TObject);
procedure StringGrid1SelectCell(Sender: TObject; Col, Row: Integer;
var CanSelect: Boolean);
procedure StringGrid1DblClick(Sender: TObject);
procedure StringGrid1KeyPress(Sender: TObject; var Key: Char);
procedure SpeedButton4Click(Sender: TObject);
procedure Variant1Click(Sender: TObject);
{ Private declarations }
public
{ Public declarations }
end;
type Ta = array[0..65535] of byte;
var
Form1 : TForm1;
fd,tt : TextFile;
i,n,sel : longint;
ans,pans : ^Ta;
implementation
uses Unit2, Unit3, Unit4;
{$R *.DFM}
procedure TForm1.Exit1Click(Sender: TObject);
begin
if StaticText4.Caption<>'' then CloseFile(fd);
FreeMem(ans,n);
FreeMem(pans,n);
Close ;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Randomize;
Form1.Left:=Screen.Width div 2-Form1.Width div 2;
Form1.Top:=Screen.Height div 2-Form1.Height div 2;
StatusBar1.Panels[0].width:=Form1.Width-60;
StaticText1.Left:=Form1.Width div 2-StaticText1.Width div 2;
StaticText2.Left:=Form1.Width div 2-(StaticText2.Width+Edit1.Width)div 2;
StaticText3.Left:=StaticText2.Left;
StaticText4.Left:=StaticText3.Left+StaticText2.Width+25;
StaticText5.Left:=StaticText2.Left+StaticText3.Width+10;
Edit1.Left:=StaticText2.Left+StaticText2.Width+3;
Bevel1.Width:=Form1.Width-70;
Bevel1.Left:=(Form1.Width-Bevel1.Width) div 2;
StringGrid1.DefaultColWidth:=StringGrid1.Width;
Titl;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
StatusBar1.Panels[1].Text:=TimeToStr(Time);
end;
procedure TForm1.About1Click(Sender: TObject);
begin
OkBottomDlg.Left:=Form1.Left+Form1.Width div 2-OkBottomDlg.Width div 2;
OkBottomDlg.Top:=Form1.Top+Form1.Height div 2-OkBottomDlg.Height div 2;
OkBottomDlg.ShowModal;
end;
procedure TForm1.Contents1Click(Sender: TObject);
begin
OkRightDlg.Left:=Form1.Left+Form1.Width div 2-OkRightDlg.Width div 2;
OkRightDlg.Top:=Form1.Top+Form1.Height div 2-OkRightDlg.Height div 2;
OkRightDlg.ShowModal;
end;
procedure TForm1.Titl;
begin
StaticText3.Left:=Form1.Width div 2-
(StaticText3.Width+StaticText4.Width+
StaticText5.Width+StaticText6.Width+10)div 2;
StaticText4.Left:=StaticText3.Left+StaticText3.Width+0;
StaticText5.Left:=StaticText4.Left+StaticText4.Width+10;
StaticText6.Left:=StaticText5.Left+StaticText5.Width+0;
end;
procedure TForm1.Opn;
var k,a : longint;
s,s1 : string[127];
begin
If OpenDialog1.Execute then
begin
Stop;
if StaticText4.Caption<>'' then CloseFile(fd);
StaticText4.Caption:='';
StaticText6.Caption:='';
Edit1.Enabled:=False;
SpeedButton2.Visible:=False;
SpeedButton4.Visible:=False;
Titl;
Try
begin
AssignFile(fd,OpenDialog1.FileName);
Reset(fd);
end
Except
begin
MessageDlg('Ошибка открытия файла.',mtWarning,[mbOK],0);
exit;
end;
end;
Try
Readln(fd,n);
Except
begin
MessageDlg('Ошибка при чтении из файла.',mtWarning,[mbOK],0);
exit;
end;
end;
getmem(ans,n);
getmem(pans,n);
FillChar(ans^,succ(n),0);
FillChar(pans^,succ(n),0);
s:=ExtractFileName(OpenDialog1.FileName);
try
AssignFile(tt,'ANS_'+s[6]+'.txt');
reset(tt);
except
begin
MessageDlg('Ошибка открытия файла '+'ANS_'+s[6]+
'.txt',mtWarning,[mbOK],0);
exit;
end;
end;
for k:=1 to n do
Try
Readln(tt,a,pans^[k]);
if (a<>k) then
begin
str(k,s1);
MessageDlg('Ошибка в структуре файла '+'ANS_'+s[6]+
'.txt'+' в строке '+s1+'.',mtWarning,[mbOK],0);
closefile(fd);
closefile(tt);
exit;
end;
Except
begin
str(k,s1);
MessageDlg('Ошибка при чтении файла '+'ANS_'+s[6]+
'.txt'+' в строке '+s1+'.',mtWarning,[mbOK],0);
closefile(fd);
closefile(tt);
exit;
end;
end;
CloseFile(tt);
str(n,s);
StaticText6.Caption:=s;
StaticText4.Caption:=ExtractFileName(OpenDialog1.FileName);
Titl;
Edit1.Enabled:=True;
Edit1.SetFocus;
end;
end;
procedure TForm1.Open1Click(Sender: TObject);
begin
Opn;
end;
procedure TForm1.SpeedButton3Click(Sender: TObject);
begin
Opn;
end;
procedure TForm1.Close1Click(Sender: TObject);
begin
Stop;
if StaticText4.Caption<>'' then closefile(fd);
Edit1.Enabled:=False;
SpeedButton2.Visible:=False;
SpeedButton4.Visible:=False;
StaticText4.Caption:='';
StaticText6.Caption:='';
Titl;
end;
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
if StaticText4.Caption<>'' then CloseFile(fd);
FreeMem(ans,n);
FreeMem(pans,n);
Close ;
end;
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if (key=#13)and(Edit1.Text<>'') then
begin
SpeedButton2.Visible:=True;
SpeedButton4.Visible:=True;
StaticText7.Caption:='Тихо! Идет экзамен.';
Edit1.Enabled:=false;
StringGrid1.Enabled:=True;
StringGrid1.SetFocus;
i:=1;
MU(0);
end;
end;
procedure Tform1.Results;
var k,b,p : longint;
begin
b:=0; p:=0;
dec(i);
for k:=1 to i do
if ans^[k]=pans^[k] then inc(b) else
if ans^[k]=0 then inc(p);
fillchar(ans^,succ(n),0);
AssignFile(tt,Edit1.Text+'.txt');
Rewrite(tt);
Writeln(tt,'Экзамен сдавал(а) : ',Edit1.Text);
Writeln(tt,'Было предложено ',i,' вопрос(а,ов),');
Writeln(tt,'из них на ',b,' вопрос(а,ов) дан правильный ответ,');
Writeln(tt,p,' вопрос(а,ов) было пропущен(о).');
k:=round(b/i*100);
Writeln(tt,'Итог : ',k,'% правильных ответов');
Write(tt,'Ваша оценка за экзамен :');
if k>=85 then k:=5 else
if k>=60 then k:=4 else
if k>=45 then k:=3 else k:=2;
Writeln(tt,k,' балла(ов)');
CloseFile(tt);
MessageDlg('Результаты Вашего экзамена в файле '+Edit1.Text+'.txt'
,mtInformation,[mbOK],0);
Edit1.Clear;
end;
procedure Tform1.stop;
begin
SpeedButton2.Visible:=False;
SpeedButton4.Visible:=False;
StaticText7.Caption:='';
Edit1.Enabled:=True;
Edit1.SetFocus;
StringGrid1.Enabled:=False;
StringGrid1.DefaultRowHeight:=0;
StringGrid1.RowCount:=1;
StaticText8.Caption:='';
StaticText9.Caption:='';
StaticText10.Caption:='';
if StaticText4.Caption<>'' then
begin
Reset(fd);
readln(fd);
end;
end;
procedure Tform1.mu(r : longint);
Const mes = 'Ошибка в структуре файла вопросов';
var a,b,c,x : longint;
s : string;
m : array[1..10] of string[127];
begin
str(i,s);
StaticText8.Caption:='Вопрос №'+s;
StaticText8.Left:=Form1.Width div 2-StaticText8.Width div 2;
StaticText9.Caption:='';
StaticText10.Caption:='';
if (StringGrid1.Cells[0,sel]<>'')and(r=0) then
begin
repeat
val(StringGrid1.Cells[0,sel][1],c,x);
if x<>0 then dec(sel);
until x=0;
ans^[i-1]:=c;
end;
if (not eof(fd))and(i<=n) then readln(fd,s)
else
begin
reset(fd);
results;
stop;
exit;
end ;
if (s<>'') then
if not(s[1] in ['0'..'9']) then
StaticText9.Caption:=s
else
begin
MessageDlg(mes,mtWarning,[mbOK],0);
StaticText9.Caption:='';
StaticText10.Caption:='';
exit;
end
else
begin
StaticText9.Caption:='';
Exit;
end;
if not eof(fd) then readln(fd,s);
if (s<>'') then
if not(s[1] in ['0'..'9']) then StaticText10.Caption:=s
else
begin
StaticText10.Caption:='';
end
else
begin
StaticText10.Caption:='';
Exit;
end;
if StaticText10.Caption<>'' then a:=0
else
begin
m[1]:=s; a:=1
end;
repeat
inc(a);
readln(fd,m[a]);
until m[a]='';
dec(a);
StringGrid1.DefaultRowHeight:=
Pred((StringGrid1.Height-2) div a);
StringGrid1.RowCount:=a;
for b:=0 to a-1 do StringGrid1.Cells[0,b]:=m[b+1];
inc(i);
end;
procedure TForm1.SpeedButton2Click(Sender: TObject);
begin
Stop;
end;
procedure TForm1.StringGrid1SelectCell(Sender: TObject; Col, Row: Integer;
var CanSelect: Boolean);
begin
sel:=row;
end;
procedure TForm1.StringGrid1DblClick(Sender: TObject);
begin
MU(0);
end;
procedure TForm1.StringGrid1KeyPress(Sender: TObject; var Key: Char);
begin
MU(0);
end;
procedure TForm1.SpeedButton4Click(Sender: TObject);
begin
MU(1);
end;
procedure TForm1.Variant1Click(Sender: TObject);
var s : string;
begin
If OpenDialog1.Execute then
begin
Stop;
if StaticText4.Caption<>'' then CloseFile(fd);
StaticText4.Caption:='';
StaticText6.Caption:='';
Edit1.Enabled:=False;
SpeedButton2.Visible:=False;
SpeedButton4.Visible:=False;
Titl;
Try
begin
AssignFile(fd,OpenDialog1.FileName);
Reset(fd);
end
Except
begin
MessageDlg('Ошибка открытия файла.',mtWarning,[mbOK],0);
exit;
end;
end;
Try
Readln(fd,n);
Except
begin
MessageDlg('Ошибка при чтении из файла.',mtWarning,[mbOK],0);
closefile(fd);
exit;
end;
end;
s:=ExtractFileName(OpenDialog1.FileName);
try
AssignFile(tt,'ANS_'+s[6]+'.txt');
reset(tt);
except
begin
MessageDlg('Ошибка открытия файла '+'ANS_'+s[6]+
'.txt',mtWarning,[mbOK],0);
exit;
end;
end;
Form4.Left:=Form1.Left+Form1.Width div 2-Form4.Width div 2;
Form4.Top:=Form1.Top+Form1.Height div 2-Form4.Height div 2;
Form4.showmodal;
closefile(fd); closefile(tt);
end;end;
end.
