//權限設置頁面
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');
}