⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 系统程序文挡1.txt

📁 试卷生成系统 delphi 试卷生成系统 试卷生成系统
💻 TXT
📖 第 1 页 / 共 4 页
字号:
begin
showmessage('对不起!您输入了非法的字符!');
key:=#13;
xs.Text:='';
end;
end;

procedure TForm7.tsKeyPress(Sender: TObject; var Key: Char);
begin
if not ((key>=#48) and (key<=#57)  ) then
begin
showmessage('对不起!您输入了非法的字符!');
key:=#13;
ts.Text:='';
end;
end;

procedure TForm7.Timer1Timer(Sender: TObject);
var
xk,tk:string;
xks,tks:integer;
begin
if timer1.tag=0 then
begin
if xuanke.selke.tag =0 then
begin
xk:='线性代数选择题库';
tk:='线性代数填空题库';
end
else
begin
xk:='外语选择题库';
tk:='外语填空题库';
end;
xianshu.SQL.Clear ;
xianshu.SQL.Add('select * from '+xk);
xianshu.Open;
xzs.Max :=xianshu.RecordCount ; //使得用户选择试题树目不至于超出试题总数
xianshu.SQL.Clear ;
xianshu.SQL.Add('select * from '+tk);
xianshu.Open;
tians.Max :=xianshu.RecordCount ;//使得用户选择试题树目不至于超出试题总数
timer1.Tag:=1;
end;
end;

procedure TForm7.FormActivate(Sender: TObject);
begin
form7.Tag:=1;//标志是采用的半自动方式生成试卷
tj.SetFocus ;
end;

procedure TForm7.tiansClick(Sender: TObject; Button: TUDBtnType);
begin
if tians.Position=tians.Max then
showmessage('已达到填空题库中试题总数!');
end;

procedure TForm7.xzsClick(Sender: TObject; Button: TUDBtnType);
begin
if xzs.Position=xzs.Max then
showmessage('已达到选择题库中试题总数!');
end;

end.

var
  Form8: TForm8; //教师自主出题对话框

implementation
uses unit6,unit5, Unit3, Unit7, Unit4;
{$R *.dfm}
procedure kongshu6(); //根据填空数目来设定4个填空框的隐现
begin
case strtoint(form6.kongshu.Text) of
 1:begin form6.lk2.Visible :=false;form6.k2.Visible :=false;
   form6.lk3.Visible :=false;form6.k3.Visible :=false;
   form6.lk4.Visible:=false;form6.k4.Visible :=false;end;
 2:begin form6.lk3.Visible :=false;form6.k3.Visible :=false;
   form6.lk4.Visible:=false;form6.k4.Visible :=false;end;
 3:begin form6.lk4.Visible:=false;form6.k4.Visible :=false;end;
end;
end;
procedure kongshu1(); //根据填空数目来设定4个填空框的隐现
begin
case strtoint(form8.kongshu.Text) of
 1:begin form8.lk2.Visible :=false;form8.k2.Visible :=false;
   form8.lk3.Visible :=false;form8.k3.Visible :=false;
   form8.lk4.Visible:=false;form8.k4.Visible :=false;end;
 2:begin form8.lk3.Visible :=false;form8.k3.Visible :=false;
   form8.lk4.Visible:=false;form8.k4.Visible :=false;end;
 3:begin form8.lk4.Visible:=false;form8.k4.Visible :=false;end;
end;
end;
procedure huifu(); //使四个填空项全部显现出来
begin
  form8.lk2.Visible :=true;form8.k2.Visible :=true;
  form8.lk3.Visible :=true;form8.k3.Visible :=true;
  form8.lk4.Visible :=true;form8.k4.Visible :=true;
end;
procedure TForm8.BitBtn4Click(Sender: TObject); //到上一题
begin
xuanti.Prior ;

  if strtoint(tino.Caption ) >1 then
     tino.Caption:= inttostr(strtoint( tino.Caption) -1);
end;

procedure TForm8.nexttiClick(Sender: TObject); //到下一题且可循环
begin
xuanti.next ;

 if strtoint(tino.Caption ) <xuanti.RecordCount  then
   tino.Caption:= inttostr(strtoint( tino.Caption) +1)
 else
  begin
   tino.Caption:='1';
   xuanti.Close;
   xuanti.Open;
  end;
end;

procedure TForm8.BitBtn1Click(Sender: TObject);
begin //到上一题
 huifu();
 xuantitian.Prior ;
 kongshu1();
  if strtoint(tino1.Caption ) >1 then
    tino1.Caption:= inttostr(strtoint( tino1.Caption) -1);
  
end;

procedure TForm8.BitBtn3Click(Sender: TObject); //到下一题
begin
huifu();
  xuantitian.next ;
  kongshu1();
  if strtoint(tino1.Caption ) <xuantitian.RecordCount  then
     tino1.Caption:= inttostr(strtoint( tino1.Caption) +1)
  else
  begin
   tino1.Caption:='1';
   xuantitian.Close;
   xuantitian.Open;
   kongshu1(); 
  end;
end;

procedure TForm8.tkClick(Sender: TObject);
begin //选择填空题
 xuantitian.SQL.Clear ;
 xuantitian.SQL.Add('select * from '+form5.tk.Text );
 xuantitian.Open;
 shumu1.Caption :=inttostr(xuantitian.RecordCount );
 xuanze.Visible :=false;
 tiankong.Visible :=true;
 kongshu1(); 
 showmessage('请您先选择本题型分数否则您没有选择填空试题的权利!');
end;

procedure TForm8.xzClick(Sender: TObject);
begin //选择选择题
 xuanti.SQL.Clear ;
 xuanti.SQL.Add('select * from '+form5.xk.Text );
 xuanti.Open;
 shumu.Caption :=inttostr(xuanti.RecordCount );
 xuanze.Visible :=true;
 tiankong.Visible :=false;
end;

procedure TForm8.BitBtn2Click(Sender: TObject);
var
juanno:integer;

begin
 inssjk.SQL.Clear ;
 inssjk.SQL.Add('delete from 考卷试题库');
 inssjk.ExecSQL ;
 xuanti.Next ;
 xuanti.Close ;
 xuanti.Open;
 if not xuantitian.IsEmpty then //更新选择题库
 begin
   xuantitian.Next ;
   xuantitian.Close;
   xuantitian.Open;
 end;
 inssjk.SQL.Clear ;
 inssjk.SQL.Add('insert into 考卷试题库(题号,题型,题目,选项A,选项B,选项C,选项D,正确答案,所属课程) select 题号,题型,题目,选项A,选项B,选项C,选项D,正确答案,所属课程 from  '+form5.xk.Text+' where 是否选中='+''''+'true'+'''');
 inssjk.ExecSQL ;  //向试卷中插入选择题
 inssjk.SQL.Clear;
 inssjk.SQL.Add('insert into 考卷试题库(题号,题型,题目,选项A,选项B,选项C,选项D,填空数目,所属课程) select 题号,题型,题目,空1,空2,空3,空4,填空数目,所属课程 from '+form5.tk.Text+' where 是否选中='+''''+'true'+'''');
 inssjk.ExecSQL ; //向试卷中插入填空题
 //以试卷的形式表现出来
  form5.chuansong.SQL.Clear ;
  form5.chuansong.SQL.Add('select * from 考卷试题库');
  form5.chuansong.Open;

if not form5.chuansong.IsEmpty then //展示试卷
  begin 

   form6.show;
   inssjk.SQL.Clear ;
   inssjk.SQL.Add('select * from 考卷试题库 where 题型='+''''+'选择题'+'''');
   inssjk.Open;
   if not inssjk.IsEmpty then
   form6.query1.ParamByName('tixing').AsString :='选择题'
   else
   begin
      form6.query1.ParamByName('tixing').AsString :='填空';
      
   end;
   form6.query1.open;
   form6.shumu1.Caption :=inttostr(form6.Query1.RecordCount );
   form6.shumu.Caption :=inttostr(form6.Query1.RecordCount );
   form6.cunjuan.Visible:=true;
   
   if form5.panel1.tag=0 then
   begin
   while form5.button3.tag=0 do //随机产生试卷号
    begin
     form5.seljuanno.Close;
     juanno:=trunc(random(200))+1;
     form5.seljuanno.ParamByName('no').AsString :=inttostr(juanno);
     form5.seljuanno.Open;
     if  form5.seljuanno.IsEmpty then
        begin
          form6.juanno.Caption:=form6.juanno.Caption +': '+inttostr(juanno);
          form5.button3.Tag:=1;
        end;
    end;
    form5.panel1.Tag:=1;
    form6.kecheng.Caption:=form6.kecheng.Caption  +': '+teacher.ke.Text;
    end;
end;
 //展示结束
  inssjk.SQL.Clear ;
  inssjk.SQL.Add('select * from 考卷试题库 where 题型='+''''+'选择题'+'''');
  inssjk.Open;
  if  inssjk.IsEmpty  then //试卷中无选择题
 begin

   form6.xuanze.Visible :=false;
   form6.tiankong.Visible :=true;
   form6.xz.Visible :=false;
   form6.tk.Visible :=false;
   kongshu6();
 end;
  inssjk.SQL.Clear ;
  inssjk.SQL.Add('select * from 考卷试题库 where 题型='+''''+'填空'+'''');
  inssjk.Open;
 if inssjk.IsEmpty  then //试卷中无填空题
 begin
   form6.xuanze.Visible :=true;
   form6.tiankong.Visible :=false;
   form6.xz.Visible :=false;
   form6.tk.Visible :=false;
 end;
 form7.tag:=2;

end;

procedure TForm8.FormActivate(Sender: TObject);
begin

showmessage('请您先选择本题型分数否则您没有选择试题的权利!');
end;

procedure TForm8.xuanzeClick(Sender: TObject);
begin //到下一题
Form8.nexttiClick(Sender);
end;

procedure TForm8.tiankongClick(Sender: TObject);
begin //到下一题
Form8.BitBtn3Click(Sender);
end;

procedure TForm8.xzfChange(Sender: TObject); //限制用户必须首先选择分值
begin
if xzf.Text <>'0' then
  isxuan.Enabled :=true
else
  isxuan.Enabled :=false;
end;

procedure TForm8.tzfChange(Sender: TObject);//限制用户必须首先选择分值
begin
if tzf.Text <>'0' then
  istian.Enabled :=true
else
  istian.Enabled :=false;
end;


var
  Form6: TForm6; //考试系统窗体

implementation

uses Unit5,unit3, Unit1, Unit2, Unit4, Unit7, Unit8, Unit9, Unit10, Unit13,
  Unit15, Unit16;

{$R *.dfm}
procedure kongshu1(); //根据填空数目来设定4个填空框的隐现
begin
form6.k1.SetFocus ;
form6.k1.SelectAll ;
case strtoint(form6.kongshu.Text) of
1:begin form6.lk2.Visible :=false;form6.k2.Visible :=false;
  form6.lk3.Visible :=false;form6.k3.Visible :=false;
  form6.lk4.Visible:=false;form6.k4.Visible :=false;end;
2:begin form6.lk3.Visible :=false;form6.k3.Visible :=false;
  form6.lk4.Visible:=false;form6.k4.Visible :=false;end;
3:begin form6.lk4.Visible:=false;form6.k4.Visible :=false;end;
end;
end;
procedure huifu(); //使得四个填空项全部显现
begin
  form6.lk2.Visible :=true;form6.k2.Visible :=true;
  form6.lk3.Visible :=true;form6.k3.Visible :=true;
  form6.lk4.Visible :=true;form6.k4.Visible :=true;

end;
procedure TForm6.BitBtn1Click(Sender: TObject); //到上一题
begin
  huifu();
  query1.Prior ;
  kongshu1();
  if strtoint(tino1.Caption ) >1 then
    tino1.Caption:= inttostr(strtoint( tino1.Caption) -1);
end;

procedure TForm6.BitBtn3Click(Sender: TObject); 防止选项为空否则会出现系统错误
begin
  if k1.Text ='' then
   k1.text:=' ';
  if k2.Text ='' then
   k2.text:=' ';
  if k3.Text ='' then
   k3.text:=' ';
  if k4.Text ='' then
   k4.text:=' ';
  query1.Edit;
  huifu();
  query1.next ;  //到下一题且可循环

  kongshu1();
  if strtoint(tino1.Caption ) <query1.RecordCount  then
     tino1.Caption:= inttostr(strtoint( tino1.Caption) +1)
  else
   begin
   tino1.Caption :='1';
   query1.Close;
   query1.Open;
   query1.Edit;
   huifu();
   kongshu1();
   end;
end;

procedure TForm6.BitBtn4Click(Sender: TObject);
begin
 //初始化四选项
 a.Checked :=false;
 b.Checked :=false;
 c.Checked :=false;
 d.Checked :=false;
  query1.Prior ;


  if strtoint(tino.Caption ) >1 then  //将考生选择题答案插入考题库
   begin
    tino.Caption:= inttostr(strtoint( tino.Caption) -1);
    updatedaan.SQL.Clear;
    updatedaan.SQL.Add('select 考生答案 from 考卷试题库 where 题号=:no');
    updatedaan.ParamByName('no').AsString :=dbedit1.Text ;
    updatedaan.Open;
    daan.Text :=updatedaan.Fields.Fields[0].AsString ;


    end;
end;

procedure TForm6.nexttiClick(Sender: TObject);
begin
  query1.next ; 
  a.Checked :=false; //将四选项置空
  b.Checked :=false;
  c.Checked :=false;
  d.Checked :=false;


 if strtoint(tino.Caption ) <query1.RecordCount  then //插入考生答案到考题库
 begin
   tino.Caption:= inttostr(strtoint( tino.Caption) +1);
   updatedaan.SQL.Clear;
   updatedaan.SQL.Add('select 考生答案 from 考卷试题库 where 题号=:no');
   updatedaan.ParamByName('no').AsString :=dbedit1.Text ;
   updatedaan.Open;
   daan.Text :=updatedaan.Fields.Fields[0].AsString ;
 end
 else
   begin
   tino.Caption :='1';
   query1.Close;
   query1.Open;
   updatedaan.SQL.Clear;
   updatedaan.SQL.Add('select 考生答案 from 考卷试题库 where 题号=:no');
   updatedaan.ParamByName('no').AsString :=dbedit1.Text ;
   updatedaan.Open;
   daan.Text :=updatedaan.Fields.Fields[0].AsString ;
   end;
end;

procedure TForm6.tkClick(Sender: TObject); //进入填空题答题
begin
  query1.Next ;
  query1.Close;
  query1.ParamByName('tixing').AsString :='填空';
  query1.Open;
  shumu1.Caption :=inttostr(query1.RecordCount); 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -