chengkun
2025-04-18 1bb985f32f2efe0f9dd69f3cf29a1c809b1cf96d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
<?php
/*
* $Author :PHPYUN开发团队
*
* 官网: http://www.phpyun.com
*
* 版权所有 2009-2021 宿迁鑫潮信息技术有限公司,并保留所有权利。
*
* 软件声明:未经授权前提下,不得用于商业运营、二次开发以及任何形式的再次发布。
 */
class evaluate_controller extends common{
    function index_action(){
        $evaluateM=$this->MODEL('evaluate');
        
        $where['keyid']            =    array('<>',0);
        //分页链接
        $urlarr['c']         =     $_GET['c']; 
        $urlarr['page']     =     "{{page}}";
        $pageurl            =    Url('wap',$urlarr);
        
        //提取分页
        $pageM            =    $this  -> MODEL('page');
        $pages            =    $pageM -> pageList('evaluate_group',$where,$pageurl,$_GET['page']);
        
        //分页数大于0的情况下 执行列表查询
        if($pages['total'] > 0){
            
            
            $where['orderby']    =    'ctime,desc';
            
            $where['limit']        =    $pages['limit'];
            
            $List                =    $evaluateM->getList($where,array('field'=>'`id`,`pic`,`name`,`description`,`visits`','pic'=>1));
            
            $this->yunset("rows",$List);
        }
        $this->seo("evaluate");
        $this->yunset("headertitle","职业测评");
        $this->yuntpl(array('wap/evaluatelist'));
    }
    function show_action(){
        $evaluateM     =     $this->MODEL('evaluate'); 
        
        $id         =     intval($_GET['id']); 
        $info        =    $evaluateM->getInfo(array('id'=>$id),array('field'=>'`id`,`name`,`description`,`visits`')); 
        $this->yunset('info',$info);
        
        if($info['id']==''){
            $this->ACT_msg_wap(Url("wap",array('c'=>"evaluate")),"没有找到相关测评哦!");
        }
        //题目数
        $questions     =     $evaluateM->getEvaluateNum(array('gid'=>$id));
        $this->yunset('questions',$questions);
        
        $evaluateM->upEvaluateGroup(array('visits'=>array('+',1)),array('id'=>$info['id']));
        
        $data['exampaper']    =    $info['name'];        
        $this->data            =    $data;
        $this->seo('exampaper');
        
        $this->yunset("headertitle","职业测评");
        $this->yuntpl(array('wap/evaluateshow'));
    }
    function exampaper_action(){
        $evaluateM     =     $this->MODEL('evaluate'); 
        $id         =     intval($_GET['id']); 
        $info        =    $evaluateM->getInfo(array('id'=>$id),array('field'=>'`id`,`name`,`description`'));
        $this->yunset('info',$info);
        
        if($info['id']==''){
            $this->ACT_msg_wap(Url("wap",array('c'=>"evaluate")),"没有找到相关测评哦!");
        }
        
        $arr=array();
        $questions     =     $evaluateM->getEvaluateList(array('gid'=>$id),array('letters'=>1));
        $this->yunset('questions',$questions);    
        
        $data['exampaper']    =    $info['name'];        
        $this->data            =    $data;
        $this->seo('exampaper');
        
        $this->yunset("headertitle","职业测评");
        $this->yuntpl(array('wap/evaluatepaper'));
    }
    /*展现得分*/
    function grade_action(){
        
        $evaluateM    =    $this->MODEL('evaluate');
        
        $questions     =     $evaluateM->getEvaluateList(array('gid'=>(int)$_POST['examid']),array('field'=>'`id`,`score`'));
            
        $score        =    $pid    =array();
        foreach($questions as $val){
            $pid[]    =    $val['id'];
            $score['q'.$val['id']]    =     $val['score'];
        }  
        $scores        =    0;
        foreach($pid as $val){  
            $scores    +=    $score['q'.$val][$_POST['q'.$val]]; 
        }
        if($this->uid && $this->username){
            $uid    =    $this->uid;
            $type    =    'uid';
        }else if($_COOKIE['nuid']){ 
            $uid    =    $_COOKIE['nuid']; 
            $type    =    'nuid';
        }else{
            $uid    =    $this->create_uuid();
            $type    =    'nuid';
            $this->cookie->setcookie("nuid",$uid,time()+3600); 
        }
        
        $data=array(
            'examid'    =>    $_POST['examid'],
            'uid'        =>    $uid,
            'type'        =>    $type,
            'hidGid'    =>    $_POST['hidGid'],
            'scores'    =>    $scores,
            'utype'        =>    'wap',
        );
        $return=$evaluateM->addEvaluateLog($data);
        if($return['errcode']==10){
            $this->ACT_msg_wap($return['url'],$return['msg']);
        }else{
            $this->layer_msg($return['msg'],$return['errcode'],0,$return['url'],2);
        }
    }
    function gradeshow_action(){ 
    
        $evaluateM    =    $this->MODEL('evaluate');
        
        $id            =    (int)$_GET['id']; 
        
        if($this->uid &&$this->username){
            
            $where['id']    =    $id;
            $where['uid']    =    $this->uid;
        }else{
            $where['id']    =    $id;
            $where['nuid']    =    $_COOKIE['nuid'];
        }
        //测试结果
        $info        =    $evaluateM->getEvaluateLogInfo($where,array('field'=>'`grade`,`examid`,`id`'));
        $this->yunset('info',$info);
        
        if($info['id']==''){
            $this->ACT_msg_wap(Url("wap",array('c'=>"evaluate")),"试卷不存在哦!");
        }
        $exambase    =    $evaluateM->getInfo(array('id'=>$info['examid']),array('field'=>'`id`,`name`,`toscore`,`fromscore`,`comment`'));
        $this->yunset('exambase',$exambase); 
        //留言
        $mwhere['examid']    =    $info['examid'];
        
        $urlarr['c']         =     $_GET['c']; 
        $urlarr['a']         =     $_GET['a']; 
        $urlarr['id']         =     (int)$_GET['id']; 
        $urlarr['page']     =     "{{page}}";
        $pageurl            =    Url('evaluate',$urlarr);
        
        $pageM                =    $this  -> MODEL('page');
        $pages                =    $pageM -> pageList('evaluate_leave_message',$mwhere,$pageurl,$_GET['page']);
        
        if($pages['total'] > 0){
            
            $mwhere['orderby']    =    'ctime,desc';
            $mwhere['limit']    =    $pages['limit'];
            
            $rows                =    $evaluateM->getMessageList($mwhere);
            $this->yunset("rows",$rows);
        }
        $data['exampaper']    =    $exambase['name'];        
        $this->data            =    $data;
        $this->seo('gradeshow');
        
        $this->yunset("headertitle","职业测评");
        $this->yuntpl(array('wap/evaluategradeshow'));
    }
    function create_uuid($prefix = "yun"){    //可以指定前缀
        $str     =     md5(uniqid(mt_rand(), true));   
        $uuid      =     substr($str,0,12);   
        return $prefix.$uuid; 
    }
    function messages_action(){
        $evaluateM    =    $this->MODEL('evaluate');
        $data        =    array(
            'examid'    =>    (int)$_POST['examid'],
            'message'    =>    trim($_POST['message']),
            'uid'        =>    $this->uid,
            'usertype'    =>    $this->usertype,
            'username'    =>    $this->username,
            'nuid'        =>    $_COOKIE['nuid'],
            
        );
        $return     =    $evaluateM->addMessage($data);
        $this->layer_msg($return['msg'],$return['errcode'],0,$_SERVER['HTTP_REFERER']);
    }
}
?>