辽宁省信息技术优秀科研成果选编(二)
上QQ阅读APP看本书,新人免费读10天
设备和账号都新为新人

五、系统主要功能实现

1.后台用户登录实现

后台用户登录界面如图1-2所示,提示输入用户名、密码,当输入正确后单击“登录”按钮就可以进入系统主界面,如图1-3所示。

图1-2 用户登录界面

图1-3 系统主界面

部分主要代码实现及说明如下:

      //检测登录
      function actionCheck(){
          $userobj=new User();
          if($info=$userobj->find(array('username'=>$_GET['username'],
  'password'=>md5($_GET['password'])))){
            $_SESSION['uname20111214']=$_GET['username'];
            $_SESSION['urole20111214']=$info['g_en_name'];
            $result=array(
                'status'=>1, // 成功标志
                'message'=>’欢迎您使用efing在线考试系统!', // 提示信息
            );
        }else{
          $result=array(
            'status'=>0, // 失败标志
            'message'=>’用户名或密码输入有误!', // 提示信息
          );
      }
      echo json_encode($result); // 返回(显示)Json结构
    }

2.用户角色管理的实现

用户角色管理界面如图1-4所示,其角色权限设置管理界面如图1-5所示。

图1-4 用户角色管理界面

图1-5 用户角色权限设置管理界面

部分主要代码实现及说明如下:

    //权限设置页面
      function actionAclPage(){
          $groupsObj=new Groups();
          $aclObj=new Acl();

          $this->id=isset($_GET['id'])? $_GET['id']:"";

          $this->acllist1=$aclObj->query("select * from my_user_acl where
  mygroup like ’用户管理中心’ and g_en_name='G_ADMIN' order by AID asc");
          $this->acllist2=$aclObj->query("select * from my_user_acl where
  mygroup like ’基础数据中心’ and g_en_name='G_ADMIN'  order by AID asc");
          $this->acllist3=$aclObj->query("select * from my_user_acl where
  mygroup like ’试题管理中心’ and g_en_name='G_ADMIN'  order by AID asc");
          $this->acllist4=$aclObj->query("select * from my_user_acl where
  mygroup like ’考试管理中心’ and g_en_name='G_ADMIN'  order by AID asc");
          $this->acllist5=$aclObj->query("select * from my_user_acl where
  mygroup like ’学员管理中心’ and g_en_name='G_ADMIN'  order by AID asc");
          $this->acllist6=$aclObj->query("select * from my_user_acl where
  mygroup like ’数据统计中心’ and g_en_name='G_ADMIN'  order by AID asc");

          $info=$groupsObj->find(array('GID'=>(isset($_GET['id'])?
  $_GET['id']:"")));
          $this->acllist=explode(', ', $info['aclstr']);

          $this->display("admin/groups/acl.html");
      }

3.试卷管理的实现

试卷管理的列表界面如图1-6所示,其新增试卷的界面如图1-7所示。

图1-6 试卷管理的列表界面

图1-7 新增试卷的界面

部分主要代码实现及说明如下:

      //预览试卷
      function actionShowPaper(){
          $PaperBaseObj=new PaperBase();
          $radioObj=new Radio();
          $judgeObj=new Judge();
          $multiselectObj=new MultiSelect();
          $blankObj=new Blank();
          $shortObj=new Short();

          $id=isset($_GET['id'])? $_GET['id']:'';
          $this->id=$id;
          $paperinfo=$PaperBaseObj->find(array('TPBID'=>$id));
          $this->paperinfo=$paperinfo;

          $data= json_decode($paperinfo['content'], true);
          $this->radioinfo=$data[0];
          $this->judgeinfo=$data[1];
          $this->multiselectinfo=$data[2];
          $this->blankinfo=$data[3];
          $this->shortinfo=$data[4];
          //手动选题
          if($paperinfo['is_fixed']==0){
            //单选
            if($data[0]['shitistr']){
                $radio=$radioObj->query("select a.*, b.CCID from my_test_
  radio a, my_test_main b  where a.TQID=b.TQID and b.CCID='".$paperinfo
    ['CCID']."' and  a.TQID in(".$data[0]['shitistr']."0)");
                  foreach($radio as $k=>$v){
                    $iteminfo_tmp1[$k]['item']=json_decode($v['Item'],
    true);
                    $iteminfo_tmp1[$k]['TQID']=$v['TQID'];
                  }
                  $this->iteminfo1=$iteminfo_tmp1;
                  shuffle($radio);
                  $this->radiodata=$radio;
              }else{
                  $this->radiodata="";
              }
              //print_r($iteminfo_tmp1);
              //判断
              if($data[1]['shitistr']){
                  $judge=$judgeObj->query("select a.*, b.CCID from my_test_
    judge a, my_test_main b where a.TQID=b.TQID and b.CCID='".$paperinfo
    ['CCID']."' and a.TQID in(".$data[1]['shitistr']."0)");
                  shuffle($judge);
                  $this->judgedata=$judge;
              }else{
                  $this->judgedata="";
              }
              //多选
              if($data[2]['shitistr']){
                  $multiselect=$multiselectObj->query("select   a.*, b.CCID
    from  my_test_multiselect  a, my_test_main  b  where  a.TQID=b.TQID  and
    b.CCID='".$paperinfo['CCID']."'and  a.TQID in(".$data[2]['shitistr'].
    "0)");
                  foreach($multiselect as $k=>$v){
                    $iteminfo_tmp3[$k]['item']=json_decode($v['Item'],
    true);
                    $iteminfo_tmp3[$k]['TQID']=$v['TQID'];
                    $iteminfo_tmp3[$k]['answer']=explode('、', $v['answer']);
                  }
                  $this->iteminfo3=$iteminfo_tmp3;
                  shuffle($multiselect);
                  $this->multiselectdata=$multiselect;
              }else{
                  $this->multiselectdata="";
              }
              //填空
              if($data[3]['shitistr']){
                $blank=$blankObj->query("select a.*, b.CCID from my_test_
  blank a, my_test_main b where a.TQID=b.TQID and b.CCID='".$paperinfo
  ['CCID']."' and a.TQID in(".$data[3]['shitistr']."0)");
                foreach($blank as $k=>$v){
                    //$iteminfo_tmp4[$k]['item']=json_decode($v['Item'],
  true);
                    $iteminfo_tmp4[$k]['TQID']=$v['TQID'];
                    $iteminfo_tmp4[$k]['answer']=json_decode
  ($v['answer'], true);
                }
                $this->iteminfo4=$iteminfo_tmp4;
                shuffle($blank);
                $this->blankdata=$blank;
              }else{
                $this->blankdata="";
              }
              //简答
              if($data[4]['shitistr']){
                $short=$shortObj->query("select a.*, b.CCID from my_test_
  short a, my_test_main b where a.TQID=b.TQID and b.CCID='".$paperinfo
  ['CCID']."' and a.TQID in(".$data[4]['shitistr']."0)");
                shuffle($short);
                $this->shortdata=$short;
              }else{
                $this->shortdata="";
              }
          }else{//随机选题
              //单选
              if($data[0]['num']>0){
                $radiodata=$radioObj->query("select TQID from my_test_main
  where ttype=1 and CCID='".$paperinfo['CCID']."'");
                $radioarray=array();
                foreach($radiodata as $k=>$v){
                    $radioarray[$v['TQID']]=$v['TQID'];
                }
                $radio_tmp=array_rand($radioarray, $data[0]['num']);
                $radio=$radioObj->query("select a.*, b.CCID from my_test_
  radio a, my_test_main b  where a.TQID=b.TQID and b.CCID='".$paperinfo
  ['CCID']."' and  a.TQID in(".implode(', ', $radio_tmp).")");
                foreach($radio as $k=>$v){
                    $iteminfo_tmp1[$k]['item']=json_decode($v['Item'],
  true);
                    $iteminfo_tmp1[$k]['TQID']=$v['TQID'];
                }
                $this->iteminfo1=$iteminfo_tmp1;
                shuffle($radio);
                $this->radiodata=$radio;
              }else{
                $this->radiodata="";
              }
              //echo $paperinfo['CCID'];
              //print_r($iteminfo_tmp1);
              //判断
              if($data[1]['num']>0){
                $judgedata=$judgeObj->query("select TQID from my_test_main
  where ttype=2 and CCID='".$paperinfo['CCID']."'");
                $judgearray=array();
                foreach($judgedata as $k=>$v){
                    $judgearray[$v['TQID']]=$v['TQID'];
                }
                $judge_tmp=array_rand($judgearray, $data[1]['num']);
                $judge=$judgeObj->query("select a.*, b.CCID from my_test_
  judge a, my_test_main b where a.TQID=b.TQID and b.CCID='".$paperinfo
  ['CCID']."' and a.TQID in(".implode(', ', $judge_tmp).")");
                shuffle($judge);
                $this->judgedata=$judge;
              }else{
                $this->judgedata="";
              }
              //多选
              if($data[2]['num']>0){
                $multiselectdata=$multiselectObj->query("select TQID from
  my_test_main where ttype=3 and CCID='".$paperinfo['CCID']."'");
                $multiselectarray=array();
                foreach($multiselectdata as $k=>$v){
                    $multiselectarray[$v['TQID']]=$v['TQID'];
                }
                $multiselect_tmp=array_rand($multiselectarray, $data[2]
  ['num']);
                $multiselect=$multiselectObj->query("select   a.*, b.CCID
  from  my_test_multiselect  a, my_test_main  b  where  a.TQID=b.TQID  and
  b.CCID='".$paperinfo['CCID']."' and a.TQID in(".implode(', ', $multiselect_
  tmp).")");
                //print_r($multiselectarray);
                foreach($multiselect as $k=>$v){
                    $iteminfo_tmp3[$k]['item']=json_decode($v['Item'],
  true);
                    $iteminfo_tmp3[$k]['TQID']=$v['TQID'];
                    $iteminfo_tmp3[$k]['answer']=explode('、', $v['answer']);
                }
                $this->iteminfo3=$iteminfo_tmp3;
                shuffle($multiselect);
                $this->multiselectdata=$multiselect;
              }else{
                $this->multiselectdata="";
              }
              //填空
              if($data[3]['num']>0){
                $blankdata=$blankObj->query("select TQID from my_test_main
  where ttype=4 and CCID='".$paperinfo['CCID']."'");
                $blankarray=array();
                foreach($blankdata as $k=>$v){
                    $blankarray[$v['TQID']]=$v['TQID'];
                }
                $blank_tmp=array_rand($blankarray, $data[3]['num']);
                $blank=$blankObj->query("select a.*, b.CCID from my_test_
  blank a, my_test_main b where a.TQID=b.TQID and b.CCID='".$paperinfo
  ['CCID']."' and a.TQID in(".implode(', ', $blank_tmp).")");
                foreach($blank as $k=>$v){
                    //$iteminfo_tmp4[$k]['item']=json_decode($v['Item'],
  true);
                    $iteminfo_tmp4[$k]['TQID']=$v['TQID'];
                    $iteminfo_tmp4[$k]['answer']=json_decode
  ($v['answer'], true);
                }
                $this->iteminfo4=$iteminfo_tmp4;
                shuffle($blank);
                $this->blankdata=$blank;
              }else{
                $this->blankdata="";
              }
              //简答
              if($data[4]['num']>0){
                $shortdata=$shortObj->query("select TQID from my_test_main
    where ttype=5 and CCID='".$paperinfo['CCID']."'");
                  $shortarray=array();
                  foreach($shortdata as $k=>$v){
                    $shortarray[$v['TQID']]=$v['TQID'];
                  }
                  $short_tmp=array_rand($shortarray, $data[4]['num']);
                  if($data[4]['num']>1){
                    $short=$shortObj->query("select a.*, b.CCID from my_test_
    short a, my_test_main b where a.TQID=b.TQID and b.CCID='".$paperinfo
    ['CCID']."' and a.TQID in(".implode(', ', $short_tmp).")");
                  }else{
                    $short=$shortObj->query("select  a.*, b.CCID  from  my_
    test_short a, my_test_main b where a.TQID=b.TQID and b.CCID='".$paperinfo
    ['CCID']."' and a.TQID='".$short_tmp."'");
                  }
                  shuffle($short);
                  $this->shortdata=$short;
              }else{
                  $this->shortdata="";
              }
              //print_r($short);
          }

          $this->a0=1;
          $this->b0=1;
          $this->c0=1;
          $this->d0=1;
          $this->e0=1;

          $this->a1=1;
          $this->b1=1;
          $this->c1=1;
          $this->d1=1;
          $this->e1=1;
          //$this->p

          //echo $data[0]['shitistr'];
          //print_r($iteminfo_tmp1);
          $this->display('admin/PaperBase/show.html');
        }

4.考场管理的实现

考场管理的列表界面如图1-8所示,其新增考场的操作界面如图1-9所示。

图1-8 考场管理的列表界面

图1-9 新增考场的操作界面

部分主要代码实现及说明如下:

        //添加
        function actionAddDo(){
            $RoomObj=new Room();
            $CourseClassObj=new CourseClass();
            $ccinfo=$CourseClassObj->find(array('cc_name'=>isset
    ($_POST['cc_name'])? $_POST['cc_name']:""));

            $room_user=isset($_POST['room_user'])? $_POST['room_user']:"";
          if(strstr($room_user, ', ')){
              $room_user=str_replace(', ', ', ', $room_user);
          }

          $data=array(
              "room_title"=>isset($_POST['room_title'])? $_POST['room_
    title']:"",
              "room_content"=>isset($_POST['room_content'])? $_POST['room_
    content']:"",
              "room_startdate"=>isset($_POST['room_startdate'])? ($_
    POST['room_startdate']=='0000-00-00 00:00:00'? null:$_POST['room_
    startdate']):"",
              "room_enddate"=>isset($_POST['room_enddate'])?
    ($_POST['room_enddate']=='0000-00-00 00:00:00'? null:$_POST['room_
    enddate']):"",
              "CCID"=>$ccinfo['CCID'],
              "room_user"=>$room_user
          );

          //print_r($data);
          if(count($data)>=5){
              if($info=$RoomObj->find(array("room_title"=>$data
    ["room_title"]))==false)
              {
                $RoomObj->create($data);
                echo  "<script>layer.msg(’ 操 作 完 成 !', function(){window.
    location.assign('room_list.html'); }); </script>";
              }else{
                echo  "<script>layer.msg(’ 您 输 入 的 考 场 名 称 已 经 存 在 !',
    function(){
          layer.msg(json.message, {icon:5}); $('#cc_name').focus(); });
    </script>";
              }

          }else{
              echo "<script>layer.msg(’请您根据条件填写进行正确的输入!',
    function(){
          layer.msg(json.message, {icon:5}); $('#cc_name').focus(); });
    </script>";
          }

      }

5.成绩统计的实现

成绩统计的列表界面如图1-10所示。

图1-10 成绩统计的列表界面

部分主要代码实现及说明:

        function actionList(){
            $askObj=new Ask();
            $departmentObj=new Department();
            $this->dInfo=$departmentObj->query("select d_name, DID from my_user_
    department group by d_name");
            $PostObj=new Post();
            $this->pInfo=$PostObj->query("select p_name, PID from my_user_
    post group by p_name");
            $keyword1=isset($_GET["key1"])? $_GET['key1']:"";
            $keyword2=isset($_GET["key2"])? $_GET['key2']:"";
            $keyword3=isset($_GET["key3"])? $_GET['key3']:"";
            $keyword4=isset($_GET["key4"])? $_GET['key4']:"";
            $keyword5=isset($_GET["key5"])? $_GET['key5']:"";
            $keyword6=isset($_GET["key6"])? $_GET['key6']:"";
            $this->keyword1=$keyword1;
            $this->keyword2=$keyword2;
            $this->keyword3=$keyword3;
            $this->keyword4=$keyword4;
            $this->keyword5=$keyword5;
            $this->keyword6=$keyword6;
            if($keyword6! ==''){
              $keyword2=" and f.room_title like '%".$keyword2."%' ";
            }
          if($keyword5! ==''){
              $keyword5=" and a.room_id=".$keyword5." ";
          }
          if(! empty($keyword1)){
              $dinfo=$departmentObj->find(array('d_name'=>$keyword1));
              $keyword1="and b.DID='".$dinfo['DID']."'";
          }
          if(! empty($keyword2)){
              $pinfo=$PostObj->find(array('P_name'=>$keyword2));
              $keyword2="and b.PID='".$pinfo['PID']."'";
          }
          if(! empty($keyword3)){
              $keyword3="and b.name like '%".$keyword3."%'";
          }
          if(! empty($keyword4)){
              $keyword4="and b.username like '%".$keyword4."%'";
          }
          $page=isset($_GET["page"])? $_GET['page']:1;
          $sql="select a.*, TIMESTAMPDIFF(MINUTE, a.user_start_ask_time,
    a.user_ endtime)as usertime, b.username, b.name, b.sex, b.email, b.phone,
    b.status, b.p_name, b.d_name, f.room_title, f.cc_name from my_exam_user a
    left join(select c.*, d.d_name, e.p_name from my_student
    c, my_user_department d, my_user_post e where c.DID=d.DID and
    c.PID=e.PID)b on a.SID=b.SID left join(select h.*, i.cc_name from
    my_exam_room h left join my_course_class i on h.CCID=i.CCID)f on
    a.room_id=f.room_id where a.user_examstatus='2' $keyword1 $keyword2
    $keyword3 $keyword4 $keyword5 $keyword6 order by a.room_id, b.SID";
          $data=$askObj->findsql($sql, array($page,15));
          foreach($data as $k=>$v){
              $json=(array)json_decode($v['user_askstring'], true);
              $tmjson=(array)json_decode($v['user_exampaper'], true);

              $fen1=0;
              $fen2=0;
              $fen3=0;
              $fen4=0;
              $fen5=0;

              $t1=0;
              $t2=0;
              $t3=0;
              $t4=0;
              $t5=0;
          foreach($json as $k1=>$v1){

            if($v1['type']=='1'){
                $fen1=$fen1+$v1['defen'];
                $t1=$tmjson[0]['radio'];
            }
            if($v1['type']=='2'){
                $fen2=$fen2+$v1['defen'];
                $t2=$tmjson[1]['judge'];
            }
            if($v1['type']=='3'){
                $fen3=$fen3+$v1['defen'];
                $t3=$tmjson[2]['multiselect'];
            }
            if($v1['type']=='4'){
                $fen4=$fen4+$v1['defen'];
                $t4=$tmjson[3]['blank'];
            }
            if($v1['type']=='5'){
                $fen5=$fen5+$v1['defen'];
                $t5=$tmjson[4]['short'];
            }
          }
          $data[$k]['defen1']=$fen1;
          $data[$k]['defen2']=$fen2;
          $data[$k]['defen3']=$fen3;
          $data[$k]['defen4']=$fen4;
          $data[$k]['defen5']=$fen5;

          $data[$k]['t1']=$t1;
          $data[$k]['t2']=$t2;
          $data[$k]['t3']=$t3;
          $data[$k]['t4']=$t4;
          $data[$k]['t5']=$t5;
      }
      $this->data=$data;
      $this->page=$askObj->page;
      $this->display("admin/statistics/list.html");
    }