📄 unit5.~pas
字号:
unit Unit5;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Buttons, DB, DBTables;
type
TForm5 = class(TForm)
Panel1: TPanel;
jiegou: TPanel;
quanzidong: TRadioButton;
banzidong: TRadioButton;
shougong: TRadioButton;
Button1: TButton;
Button2: TButton;
Button3: TButton;
chuansong: TQuery;
cunrnd: TComboBox;
qktk: TQuery;
seljuanno: TQuery;
xk: TEdit;
tk: TEdit;
procedure quanzidongClick(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure banzidongClick(Sender: TObject);
procedure shougongClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form5: TForm5;
implementation
uses unit4, Unit6,unit3, Unit7,unit8;
{$R *.dfm}
//此函数为按数目,范围提供随即数
function qurand(num,range1:integer):integer;
var
i,j,k:integer;
zancun:array[0..100] of integer;
begin
form5.cunrnd.Clear ;
zancun[0]:=trunc(random(range1)+1);
form5.cunrnd.Items.Add(inttostr(trunc(random(range1)+1))) ;
while form5.jiegou.tag<num-1 do
begin
i:=trunc(random(range1)+1);
for j:=0 to form5.Tag do
begin
if i=zancun[j] then
break;
end;
if j>form5.tag then
begin
form5.jiegou.Tag:=form5.jiegou.Tag+1;
form5.Tag:=form5.Tag+1;
zancun[form5.Tag]:=i;
form5.cunrnd.Items.Add(inttostr(i)) ;
end;
end;
form5.cunrnd.Items.Strings[0]:=inttostr(zancun[0]);
form5.Tag:=0;
form5.jiegou.Tag:=0;
end;
procedure TForm5.quanzidongClick(Sender: TObject);
var
k,h,juanno:integer;
begin
button3.Tag:=0;
qktk.ExecSQL ;
if quanzidong.Checked =true then
begin
if xuanke.selke.tag=0 then
begin //将线性代数试题插入试卷库
chuansong.SQL.Add('select * from 线性代数选择题库');
chuansong.Open;
if not chuansong.IsEmpty then
begin
h:=qurand(7,chuansong.RecordCount); //从题库中所有的试题中选择7道题
chuansong.SQL.Clear ;
chuansong.SQL.Add('insert into 考卷试题库 (题号,题型,题目,选项A,选项B,选项C,选项D,正确答案,所属课程) select 题号,题型,题目,选项A,选项B,选项C,选项D,正确答案,所属课程 from 线性代数选择题库 where 题号=:no');
for k:=0 to cunrnd.Items.Count-1 do
begin
chuansong.ParamByName('no').AsString :=cunrnd.items.strings[k];
chuansong.ExecSQL ;
end;
chuansong.SQL.Clear ;
end
else
showmessage('对不起!选择题库中没有试题!');
//插入线性代数填空试题
chuansong.SQL.Clear ;
chuansong.SQL.Add('select * from 线性代数填空题库');
chuansong.Open;
if not chuansong.IsEmpty then
begin
h:=qurand(7,chuansong.RecordCount);
chuansong.SQL.Clear ;
chuansong.SQL.Add('insert into 考卷试题库 (题号,题型,题目,选项A,选项B,选项C,选项D,填空数目,所属课程) select 题号,题型,题目,空1,空2,空3,空4,填空数目,所属课程 from 线性代数填空题库 where 题号=:no');
for k:=0 to cunrnd.Items.Count-1 do
begin
chuansong.ParamByName('no').AsString :=cunrnd.Items.Strings[k];
chuansong.ExecSQL ;
end;
end
else
showmessage('对不起!填空题库中没有试题!');
end
else
begin//将外语试题插入试卷题库
chuansong.SQL.Clear ;
chuansong.SQL.Add('select * from 外语选择题库');
chuansong.Open;
if not chuansong.IsEmpty then
begin
h:=qurand(7,chuansong.RecordCount);
chuansong.SQL.Clear ;
chuansong.SQL.Add('insert into 考卷试题库 (题号,题型,题目,选项A,选项B,选项C,选项D,正确答案,所属课程) select 题号,题型,题目,选项A,选项B,选项C,选项D,正确答案,所属课程 from 外语选择题库 where 题号=:no');
for k:=0 to cunrnd.Items.Count-1 do
begin
chuansong.ParamByName('no').AsString :=cunrnd.items.strings[k];
chuansong.ExecSQL ;
end;
chuansong.SQL.Clear ;
end;
end;
end
else
showmessage('对不起!选择题库中没有试题!');
//插入外语填空试题
chuansong.SQL.Clear ;
chuansong.SQL.Add('select * from 外语填空题库');
chuansong.Open;
if not chuansong.IsEmpty then
begin
h:=qurand(7,chuansong.RecordCount);
chuansong.SQL.Clear ;
if xuanke.selke.tag=1 then
begin
chuansong.SQL.Add('insert into 考卷试题库 (题号,题型,题目,选项A,选项B,选项C,选项D,填空数目,所属课程) select 题号,题型,题目,空1,空2,空3,空4,填空数目,所属课程 from 外语填空题库 where 题号=:no');
for k:=0 to cunrnd.Items.Count-1 do
begin
chuansong.ParamByName('no').AsString :=cunrnd.Items.Strings[k];
chuansong.ExecSQL ;
end;
end;
end
else
showmessage('对不起!填空题库中没有试题!');
chuansong.SQL.Clear ;
chuansong.SQL.Add('select * from 考卷试题库');
chuansong.Open;
if not chuansong.IsEmpty then //用试卷形式展示所选试题
begin
form6.show;
form6.query1.ParamByName('tixing').AsString :='选择题';
form6.query1.open;
form6.shumu.Caption :=inttostr(form6.Query1.RecordCount );
form6.gh.Visible :=true;
form6.cunjuan.Visible:=true;
if panel1.tag=0 then
begin
while button3.tag=0 do //得到唯一的试卷号
begin
seljuanno.Close;
juanno:=trunc(random(200))+1;
seljuanno.ParamByName('no').AsString :=inttostr(juanno);
seljuanno.Open;
if seljuanno.IsEmpty then
begin
form6.juanno.Caption:=form6.juanno.Caption +': '+inttostr(juanno);
button3.Tag:=1;
end;
end;
panel1.Tag:=1;
form6.kecheng.Caption:=form6.kecheng.Caption +': '+teacher.ke.Text;
end;
end;
form5.Close;
end;
procedure TForm5.Button1Click(Sender: TObject);
begin
showmessage('由系统自动完成试卷生成的全部过程,包括(题型,试题数目,各题型分值,试卷内容)');
end;
procedure TForm5.Button2Click(Sender: TObject);
begin
showmessage('由教师选择(题型,试题数目,各题型分值)再由系统完成试卷生成操作!');
end;
procedure TForm5.Button3Click(Sender: TObject);
begin
showmessage('由教师选择("题目",题型,试题数目,各题型分值)再由系统完成试卷生成操作!');
end;
procedure TForm5.FormCreate(Sender: TObject);
begin
randomize();
end;
procedure TForm5.banzidongClick(Sender: TObject);
begin
if banzidong.Checked =true then
begin
form7.show;
banzidong.Tag:=1;
form7.Timer1.Enabled :=true;
form5.Close;
end;
end;
procedure TForm5.shougongClick(Sender: TObject);
begin
form8.show;
form8.xuanze.Visible :=true;
form8.tiankong.Visible :=false;
if xuanke.selke.tag=0 then
begin
xk.Text :='线性代数选择题库';
tk.text:='线性代数填空题库';
end
else
begin
xk.text:='外语选择题库';
tk.text:='外语填空题库';
end;
qktk.SQL.Clear ;
qktk.SQL.Add('update '+form5.xk.Text+ ' set 是否选中='+''''+'false'+'''');
qktk.ExecSQL ;
qktk.SQL.Clear ;
qktk.SQL.Add('update '+form5.tk.Text+ ' set 是否选中='+''''+'false'+'''');
qktk.ExecSQL ;
form8.xuanti.SQL.Add('select * from '+xk.text);
form8.xuanti.Open;
form8.shumu.Caption :=inttostr(form8.xuanti.RecordCount );
form5.Close;
end;
procedure TForm5.FormActivate(Sender: TObject);
begin
form6.N2.Visible :=false;//隐藏试卷提交按扭
form6.zhengque.Visible :=true;
form6.k1.Ctl3D:=false; //将填空题答案以标签的形式表现
form6.k1.BorderStyle :=bsnone;
form6.k1.Color :=form6.xuanze.Color ;
form6.k2.Ctl3D:=false;
form6.k2.BorderStyle :=bsnone;
form6.k2.Color :=form6.xuanze.Color ;
form6.k3.Ctl3D:=false;
form6.k3.BorderStyle :=bsnone;
form6.k3.Color :=form6.xuanze.Color ;
form6.k4.Ctl3D:=false;
form6.k4.BorderStyle :=bsnone;
form6.k4.Color :=form6.xuanze.Color ;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -