public function __construct()
 {
     parent::__construct();
     self::$_db = Fn::db();
     self::$_data = array();
     $this->load->model('cron/report/subject_report/common_model');
 }
Esempio n. 2
0
    /**
     * 按学科ID,父ID,读取信息提取方式列表
     *          
     * @param   int       学科ID
     * @param   int       上级ID
     * @return  array
     */
    public static function get_group_type_list($pid = 0, $subject_id = 0, $relate_num = TRUE, $relate_child = false)
    {
        static $result = array();
        $hash = $subject_id . '-' . $pid;
        if (isset($result[$hash])) {
            return $result[$hash];
        }
        $list = array();
        $sql = <<<EOT
SELECT * FROM rd_group_type WHERE pid = {$pid}
EOT;
        if ($subject_id) {
            $sql .= " AND subject_id = {$subject_id}";
        }
        $rows = Fn::db()->fetchAll($sql);
        foreach ($rows as $row) {
            $list[$row['id']] = $row;
        }
        if ($relate_num) {
            foreach ($list as &$val) {
                $val = self::get_group_type_num($val);
            }
        }
        if ($relate_child) {
            foreach ($list as &$val) {
                $val['childlist'] = array_values(self::get_group_type_list($val['id'], $val['subject_id'], false));
            }
        }
        $result[$hash] = $list;
        return $result[$hash];
    }
Esempio n. 3
0
 protected function beforeAction($action)
 {
     $this->_controller = $action->getController()->getId();
     $this->_action = $action->getId();
     $this->returnurl = Fn::url_login_current();
     $token = FCookie::get("auth");
     $now = time();
     list($uid, $email, $timeout) = explode("\t", FHelper::auth_code($token, 'DECODE', FF_SALT));
     if ($uid) {
         $userInfo = $this->getUserinfo($uid);
         if ($userInfo['user']['id']) {
             if ($token == $userInfo['user']['token']) {
                 if ($now < $timeout) {
                     $this->userInfo = $userInfo['info'];
                     $this->user = $userInfo['user'];
                     if ($timeout - $now < 60 * 2) {
                         $timeout = time() + 60 * 15;
                         $token = FHelper::auth_code("{$uid}\t{$email}\t{$timeout}", 'ENCODE', FF_SALT);
                         FCookie::set('auth', $token, 60 * 15);
                         $attr = array('token' => $token);
                         $user_model = new User();
                         $user_model->updateByPk($uid, $attr);
                     }
                     //                        $timeout =  time()+60 *15;
                     //                        $token = FHelper::auth_code("$uid\t$email\t$timeout", 'ENCODE', FF_SALT);
                     //                        FCookie::set('auth', $token);
                 }
             }
         }
     }
     return true;
 }
Esempio n. 4
0
    public function report($exam_id)
    {
        $sql1 = <<<EOT
SELECT count(1) as 'count' 
from rd_student rs,rd_exam_place_student reps , rd_exam_place rep 
where rep.exam_pid='{$exam_id}' and rep.place_id=reps.place_id and rs.uid=reps.uid
EOT;
        $sql2 = <<<EOT
SELECT rs.exam_ticket,CONCAT(rs.last_name,rs.first_name) as xname 
from rd_student rs,rd_exam_place_student reps , rd_exam_place rep 
where rep.exam_pid='{$exam_id}' and rep.place_id=reps.place_id and rs.uid=reps.uid
EOT;
        $result1 = Fn::db()->fetchRow($sql1);
        // 读取数据
        if ($result1['count'] > 0) {
            $sql3 = "SELECT exam_name FROM rd_exam WHERE exam_id={$exam_id}";
            $row = Fn::db()->fetchRow($sql3);
            $title = $row['exam_name'] . '.xls';
            $data = array();
            $data['list'] = $this->db->query($sql2)->result_array();
            $header = array('准考证号', '姓名');
            $excel_model = new ExcelModel();
            $excel_model->addHeader($header);
            $excel_model->addBody($data['list']);
            $excel_model->download($title);
        } else {
            echo '暂无学生,请先添加学生';
        }
    }
Esempio n. 5
0
    public function schools()
    {
        $schools = array();
        $sql = <<<EOT
SELECT school_id, school_name FROM rd_school
EOT;
        $where = array();
        $bind = array();
        if ($keyword = trim($this->input->post('keyword'))) {
            $where[] = 'school_name LIKE ?';
            $bind[] = '%' . $keyword . '%';
        }
        if ($grade_id = intval($this->input->post('grade_id'))) {
            $grade_period = get_grade_period($grade_id);
            if ($grade_period) {
                $where[] = 'grade_period LIKE ?';
                $bind[] = '%' . $grade_period . '%';
            }
        }
        if ($where) {
            $sql .= ' WHERE ' . implode(' AND ', $where);
        }
        $schools = Fn::db()->fetchAll($sql, $bind);
        echo json_encode($schools);
    }
Esempio n. 6
0
 private static function delarray($dbName, $array, $is_export_student)
 {
     // 处理传入进来的数组
     $tableList = array();
     foreach ($array as $tables) {
         if ($tables == '*') {
             // 所有的表(获得表名时不能按常规方式来组成一个数组)
             $sql = "SELECT table_name, table_type \n                        FROM information_schema.tables \n                        WHERE table_schema = '{$dbName}'";
             $stmt = Fn::db()->query($sql);
             while ($item = $stmt->fetch(PDO_DB::FETCH_ASSOC)) {
                 if (strtolower($item['table_type']) == 'view') {
                     $tableList['view'][] = $item['table_name'];
                 } else {
                     if (!$is_export_student && (is_int(strpos($item['table_name'], 'student')) || is_int(strpos($item['table_name'], 'summary')))) {
                         continue;
                     }
                     $tableList['table'][] = $item['table_name'];
                 }
             }
         } else {
             $tableList['table'] = $array;
             break;
         }
     }
     return $tableList;
 }
Esempio n. 7
0
    /**
     * 考试类型列表
     *          
     * @return  array
     */
    public static function get_type_list()
    {
        $sql = <<<EOT
SELECT * FROM rd_interview_type ORDER BY pid ASC
EOT;
        $rows = Fn::db()->fetchAll($sql);
        $list = array();
        foreach ($rows as $row) {
            if ($row['pid']) {
                $list[$row['pid']]['children'][$row['type_id']] = $row;
            } else {
                $list[$row['type_id']] = $row;
            }
        }
        // 分级排序
        $result = array();
        foreach ($list as $row) {
            $result[$row['type_id']] = $row;
            if (!empty($row['children'])) {
                $result = $result + $row['children'];
                unset($result[$row['type_id']]['children']);
            }
        }
        return $result;
    }
Esempio n. 8
0
 public function getHTML()
 {
     if (Config::get('debug')) {
         return $this->html;
     } else {
         return Fn::minifyHTML($this->html);
     }
 }
Esempio n. 9
0
 /**
  * 获取平均值
  *
  * @param array $param 查询条件
  * @param string $field 查询字段
  * @return array 数据结果集
  */
 public static function get_average($param, $field)
 {
     PDO_DB::build_where($param, $where_sql, $bind);
     $sql = "SELECT AVG({$field}) AS {$field} FROM rd_interview_result";
     if ($where_sql) {
         $sql .= " WHERE {$where_sql}";
     }
     return Fn::db()->fetchRow($sql, $bind);
 }
Esempio n. 10
0
 public static function each($view, $collection, $item = 'item', array $scope = array())
 {
     if (Fn::iterable($collection)) {
         $tmpl = $tmpl = Ant::init()->fromFile($view);
         foreach ($collection as $single) {
             $scope[$item] = $single;
             echo $tmpl->assign($scope)->draw();
         }
     }
 }
Esempio n. 11
0
    /**
     * 获取平均值
     *
     * @param array $param 查询条件
     * @param string $field 查询字段
     * @return array 数据结果集
     */
    public static function get_average($param, $field)
    {
        PDO_DB::build_where($param, $where_sql, $bind);
        $sql = <<<EOT
SELECT AVG({$field}) AS {$field} FROM rd_ruidabei_result
EOT;
        if ($where_sql) {
            $sql .= " WHERE " . $where_sql;
        }
        return Fn::db()->fetchRow($sql, $bind);
    }
 /**
  * 添加 生成考试期次学生的成绩任务
  */
 public function insert($data)
 {
     if (empty($data['exam_pid'])) {
         return false;
     }
     $data['c_time'] = time();
     $data['status'] = 0;
     $exam_ticket_maprule = ExamModel::get_exam($data['exam_pid'], 'exam_ticket_maprule');
     if ($exam_ticket_maprule > 0) {
         $data['status'] = 1;
     }
     return Fn::db()->replace('rd_cron_task_exam_result', $data);
 }
Esempio n. 13
0
    public static function get_admin_log($log_info = '', $item = '*')
    {
        if ($log_info == '') {
            return FALSE;
        }
        $sql = <<<EOT
SELECT {$item} FROM rd_admin_log WHERE log_info = ?
EOT;
        $row = Fn::db()->fetchRow($sql, $log_info);
        if ($item && isset($row[$item])) {
            return $row[$item];
        } else {
            return $row;
        }
    }
Esempio n. 14
0
    /**
     * 读取一个试题
     */
    public static function get_question($id = 0, $item = '*')
    {
        if ($id == 0) {
            return FALSE;
        }
        $sql = <<<EOT
SELECT {$item} FROM rd_interview_question WHERE id = {$id}
EOT;
        $row = Fn::db()->fetchRow($sql);
        if ($item && isset($row[$item])) {
            return $row[$item];
        } else {
            return $row;
        }
    }
Esempio n. 15
0
 /**
  * 控制界面首页
  */
 public function index($exam_pid = 0)
 {
     Fn::ajax_call($this, 'regenerateExamRecord', 'regenerateExamResults', 'endPlaceExam', 'regenerateSummaryReportData', 'regenerateReport', 'removeCronTaskReport');
     $exam_pid = intval($exam_pid);
     $param['exam_pid'] = 0;
     $param['exam_isfree'] = 0;
     $examlist = ExamModel::get_exam_list_all($param);
     $exam = array();
     if ($exam_pid > 0) {
         $exam = ExamModel::get_exam($exam_pid);
     }
     if (!$exam) {
         $exam = current($examlist);
     }
     $db = Fn::db();
     /////////////////////////考试记录是否生成/////////////
     $sql = "SELECT uid_data FROM rd_cron_task_place_student_paper ctps\n                LEFT JOIN rd_exam_place  ep ON ep.place_id = ctps.place_id\n                WHERE ep.exam_pid ={$exam['exam_id']} AND ctps.status=2";
     $uid_arr = $db->fetchCol($sql);
     $paper_count = 0;
     foreach ($uid_arr as $item) {
         $paper_count += count(json_decode($item));
     }
     $sql = "SELECT COUNT(*) FROM rd_exam_place_student eps\n               LEFT JOIN rd_exam_place ep ON ep.place_id = eps.place_id\n               WHERE ep.exam_pid = {$exam['exam_id']}";
     $student_count = $db->fetchOne($sql);
     if ($paper_count == $student_count) {
         $data['paper_status'] = true;
         //考试记录是否完全生成
     } else {
         $data['paper_status'] = false;
     }
     /////////////////////////////////////////
     $sql = "SELECT status FROM rd_cron_task_exam_result \n            WHERE exam_pid = {$exam['exam_id']}";
     $data['cter_status'] = $db->fetchOne($sql);
     //////////////////////////////////////////
     $sql = "SELECT DISTINCT(status) FROM rd_cron_task_report ctr \n                LEFT JOIN rd_evaluate_rule er ON er.id = ctr.rule_id \n                WHERE exam_pid =  {$exam['exam_id']}";
     $data['ctr_status'] = $db->fetchCol($sql);
     ////////////////////////////////////////
     $data['exam'] = $exam;
     $data['demo_exam'] = $this->demo_exam_list();
     $data['examlist'] = $examlist;
     $data['place'] = ExamPlaceModel::get_exam_place($exam_pid, 'MAX(end_time) as end_time');
     $data['crontaskexamresult'] = ReportCommandModel::cronTaskExamResultInfo($exam['exam_id']);
     $data['evaluerulelist'] = ReportCommandModel::cronTaskReportLists($exam['exam_id']);
     $this->load->view('report_command/index', $data);
 }
Esempio n. 16
0
 public static function db_pg()
 {
     if (self::$_db_pg) {
         return self::$_db_pg;
     }
     $dir = dirname(__FILE__);
     include_once $dir . '/PDO/DB.php';
     include $dir . '/../config/config.db.php';
     $cfg = $db['zmoss'];
     $dsn = 'pgsql:host=' . $cfg['hostname'] . ';dbname=' . $cfg['database'];
     if (isset($cfg['port'])) {
         $dsn .= ';port=' . $cfg['port'];
     }
     self::$_db_pg = new PDO_DB($dsn, $cfg['username'], $cfg['password']);
     if (in_array(substr($dsn, 0, 6), array('mysql:', 'pgsql:'))) {
         self::$_db_pg->query("SET NAMES 'utf8'");
     }
     return self::$_db_pg;
 }
Esempio n. 17
0
 /**
  * 读取列表
  * @param   int $subject_id = 0 学科ID,为0表示不限学科
  * @return  map<int, variant>   获取某个学科(或不限学科)的所有技能列表
  */
 public static function get_skills($subject_id = 0)
 {
     static $result = array();
     $hash =& $subject_id;
     if (isset($result[$hash])) {
         return $result[$hash];
     }
     $sql = 'SELECT * FROM rd_skill';
     $list = array();
     if ($subject_id) {
         $sql .= ' WHERE subject_id = ' . $subject_id;
     }
     $rows = Fn::db()->fetchAll($sql);
     foreach ($rows as $row) {
         $list[$row['id']] = $row;
     }
     $result[$hash] = $list;
     return $list;
 }
Esempio n. 18
0
 static function getPayList($orderby = 'order_id', $order = 'DESC', $limit = 30, array $query_conds = array(), &$statinfo = array())
 {
     $where = "AND o.`pay_status`=2";
     if (isset($query_conds['seeall']) && $query_conds['seeall']) {
         $where = "";
     }
     $where_cond = '';
     if (isset($query_conds['target']) && $query_conds['target']) {
         if (is_numeric($query_conds['target'])) {
             $where_cond .= " AND o.`player_id`=" . $query_conds['target'];
         } else {
             $where_cond .= " AND p.`truename` like '%%" . D()->escape_string($query_conds['target']) . "%%'";
         }
     }
     if (isset($query_conds['start_date']) && $query_conds['start_date']) {
         $starttime = strtotime($query_conds['start_date'] . DAY_BEGIN);
         $where_cond .= " AND o.`add_time`>=" . $starttime;
     }
     if (isset($query_conds['end_date']) && $query_conds['end_date']) {
         $endtime = strtotime($query_conds['end_date'] . DAY_END);
         $where_cond .= " AND o.`add_time`<=" . $endtime;
     }
     $where = $where . $where_cond;
     $sql = "SELECT o.*,u.nickname,u.logo,p.truename AS player_name\n\t\t\t\t\t\t\t\tFROM `{order_info}` o INNER JOIN `{member}` u ON o.user_id=u.uid\n\t\t\t\t\t\t\t\t     INNER JOIN `{player}` p ON o.player_id=p.player_id\n\t\t\t\t       WHERE 1 {$where}\n\t\t           ORDER BY `%s` %s";
     $sqlcnt = "SELECT COUNT(o.order_id) AS rcnt FROM {order_info} o INNER JOIN `{player}` p ON o.player_id=p.player_id WHERE 1 {$where}";
     $result = D()->pager_query($sql, $limit, $sqlcnt, 0, $orderby, $order)->fetch_array_all();
     $statinfo = ['total_pay' => 0, 'current_pay' => 0];
     $statinfo['total_pay'] = D()->query("SELECT SUM(o.`goods_amount`) AS total_pay FROM `{order_info}` o INNER JOIN `{player}` p ON o.player_id=p.player_id WHERE o.`pay_status`=2 {$where_cond}")->result();
     if (empty($statinfo['total_pay'])) {
         $statinfo['total_pay'] = 0;
     }
     if (!empty($result)) {
         foreach ($result as &$it) {
             $it['order_status_name'] = Fn::order_status($it['order_status']);
             $it['pay_status_name'] = Fn::pay_status($it['pay_status']);
             if ($it['pay_status'] == PS_PAYED) {
                 $statinfo['current_pay'] += $it['goods_amount'];
             }
         }
     }
     return $result;
 }
 /**
  * 手动给参加考试的学生分配试卷及试题
  *
  * @return void
  */
 public function init_distribution_paper_manual()
 {
     set_time_limit(0);
     $db = Fn::db();
     $this->load->model('cron/cron_place_student_paper_model', 'init_model');
     /* 手动指定考场 */
     /* $places = array(57,58,59,60); */
     $places = array(60);
     $place_list = array();
     /* 获取考场学生 */
     foreach ($places as $key => $value) {
         $sql = "SELECT uid FROM rd_exam_place_student WHERE place_id='{$value}'";
         $place_list[$value]['uids'] = $db->fetchCol($sql);
     }
     $place_uids = array();
     $place_ids = array();
     foreach ($place_list as $place_id => $place) {
         $exam_pid = $place['exam_pid'];
         foreach ($place['uids'] as $uid) {
             //给学生分配试卷
             $result = $this->init_model->init_test_paper($place_id, $uid);
             if ($result) {
                 $place_ids[$exam_pid][$place_id][] = $uid;
             }
         }
     }
     //给考场学生分配试题
     if ($place_ids) {
         foreach ($place_ids as $exam_pid => $place) {
             foreach ($place as $place_id => $uids) {
                 $uids = array_unique($uids);
                 $this->init_model->init_test_question($exam_pid, $place_id, $uids);
             }
         }
     }
 }
 public function __construct()
 {
     parent::__construct();
     self::$_db = Fn::db();
 }
Esempio n. 21
0
 /**
  * 执行考试成绩同步
  */
 public static function initSyncZmossExamResults()
 {
     $db = Fn::db();
     $sql = "SELECT er_examid, er_zmoss_examid FROM t_exam_relate\n                WHERE er_flag > 0 AND er_flag < 3 AND er_exampid > 0 limit 5";
     $list = $db->fetchAll($sql);
     if (!$list) {
         return false;
     }
     foreach ($list as $item) {
         $db->update('t_exam_relate', array('er_flag' => 100), 'er_examid = ? AND er_zmoss_examid = ?', array($item['er_examid'], $item['er_zmoss_examid']));
     }
     foreach ($list as $item) {
         $flag = self::syncZmossExamResults($item['er_examid'], $item['er_zmoss_examid']);
         if ($flag) {
             $bind = array('er_flag' => 3);
         } else {
             $bind = array('er_flag' => 2);
         }
         $db->update('t_exam_relate', $bind, 'er_examid = ? AND er_zmoss_examid = ?', array($item['er_examid'], $item['er_zmoss_examid']));
     }
 }
Esempio n. 22
0
 /**
  * Display an error message
  *
  * @access        public
  * @param        string        the error message
  * @param        string        any "swap" values
  * @param        boolean        whether to localize the message
  * @return        string        sends the application/error_db.php template
  */
 function display_error($error = '', $swap = '', $native = FALSE)
 {
     Fn::core_db_error_handler($error, $swap, $native);
 }
Esempio n. 23
0
 public static function is_action_type_self($segment, $item, $subject_id = 0)
 {
     //return $this->get_action_type_segment($segment, $item) == '1';
     $action = Fn::sess()->userdata('action');
     $is_action_type_self = false;
     foreach ($action as $power) {
         $action_type = @unserialize($power['action_type']);
         if ($subject_id > 0) {
             if ($power['subject_id'] == -1 || in_array($subject_id, explode(',', $power['subject_id']))) {
                 if (!empty($action_type[$segment][$item]) && $action_type[$segment][$item] == 1) {
                     $is_action_type_self = true;
                     break;
                 }
             }
         } else {
             if (!empty($action_type[$segment][$item]) && $action_type[$segment][$item] == 1) {
                 $is_action_type_self = true;
                 break;
             }
         }
     }
     return $is_action_type_self;
 }
Esempio n. 24
0
 /**
  * 清除系统缓存
  */
 public function clean()
 {
     $this->load->driver('cache');
     $this->cache->file->clean();
     Fn::factory('File')->clear('/zmexam/');
     // $this->mc->flush();
     message('清除成功');
 }
Esempio n. 25
0
 /**
  * 获取$profession_id所指定的职业信息,返回结果集
  * @param   mixed   $profession_id
  * @param   array   map<string, variant>
  */
 public static function professionInfo($profession_id)
 {
     if (!$profession_id) {
         return array();
     }
     if (Validate::isInt($profession_id)) {
         $sql = "SELECT * FROM t_profession\n                    WHERE profession_id = ?";
         return Fn::db()->fetchRow($sql, array($profession_id));
     } else {
         if (Validate::isJoinedIntStr($profession_id)) {
             $sql = "SELECT * FROM t_profession\n                    WHERE profession_id IN ({$profession_id})";
             return Fn::db()->fetchAssoc($sql);
         } else {
             return array();
         }
     }
 }
Esempio n. 26
0
 public function __construct()
 {
     parent::__construct();
     self::$_db = Fn::db();
     $this->load->model('cron/report/class_report/class_common_model');
 }
Esempio n. 27
0
 /**
  * 删除学习风格属性信息,成功返回非0,失败返回0
  * @param   int     $lsattr_learnstyleid
  * @param   int     $lsattr_value
  * @return  bool    true|false
  */
 public static function removeLearnStyleAttribute($lsattr_learnstyleid, $lsattr_value)
 {
     if (!Validate::isInt($lsattr_learnstyleid) || $lsattr_learnstyleid <= 0 || !in_array($lsattr_value, array(1, 2))) {
         return false;
     }
     $where = 'lsattr_learnstyleid = ? AND lsattr_value = ?';
     $where_bind[] = $lsattr_learnstyleid;
     $where_bind[] = $lsattr_value;
     return Fn::db()->delete('t_learn_style_attribute', $where, $where_bind);
 }
Esempio n. 28
0
 /**
  * 检查考场名称是否重复
  */
 public static function checkPlaceNameIsRepeat($exam_pid, $place_id = null, $place_name)
 {
     if (!$exam_pid || !$place_name) {
         throw new Exception('考试期次或考场名称不能为空');
     }
     $bind = array($exam_pid, $place_name);
     $sql = "SELECT COUNT(*) FROM rd_exam_place\n                WHERE exam_pid = ? AND place_name = ?";
     if ($place_id > 0) {
         $sql .= " AND place_id <> ?";
         $bind[] = $place_id;
     }
     return Fn::db()->fetchOne($sql, $bind);
 }
Esempio n. 29
0
 /**
  * 获取交易记录
  * @param   string  $tr_no  交易号
  * @return  array   map<string, variant>类型数据
  */
 public static function transactionRecordInfoByTrNo($tr_no, $item = "*")
 {
     if (!$tr_no) {
         return false;
     }
     $item = $item ? $item : '*';
     $sql = "SELECT {$item} FROM t_transaction_record\n                WHERE tr_no = ?";
     return Fn::db()->fetchRow($sql, array($tr_no));
 }
Esempio n. 30
0
 /**
  * 按 考试期次id 获取一个考试信息
  *
  * @param   int     考试期次ID(exam_id)
  * @param   string  字段列表(多个字段用逗号分割,默认取全部字段)
  * @return  mixed   指定单个字段则返回该字段值,否则返回关联数组
  */
 public static function get_exam_by_id($id = 0, $select_items = NULL)
 {
     if ($id == 0) {
         return FALSE;
     }
     if ($select_items) {
         $sql = 'SELECT ' . $select_items;
     } else {
         $sql = 'SELECT *';
     }
     $sql .= " FROM rd_exam WHERE exam_id = {$id} LIMIT 1";
     $row = Fn::db()->fetchRow($sql);
     if (is_string($select_items) && $select_items && isset($row[$select_items])) {
         return $row[$select_items];
     } else {
         return $row;
     }
 }