<?php
//decode by https://www.txee.cn/
include_once '../addons/goouc_fullexam/inc/common/wxapi.php';
include_once '../addons/goouc_fullexam/inc/common/wxpay.php';
include_once '../addons/goouc_fullexam/inc/common/wxBizDataCrypt.php';
include_once '../addons/goouc_fullexam/inc/common/wxconfig.php';
include_once '../addons/goouc_fullexam/inc/phonecode/sendSms.php';
include_once '../addons/goouc_fullexam/inc/common/AliyunVod.php';
class Goouc_fullexamModuleWxapp extends WeModuleWxapp
{
	public $contion = " weid = :weid AND istatus = 1 ";
	public $t_setting = "goouc_fullexam_setting";
	public $t_banner = "goouc_fullexam_banner";
	public $t_notice = "goouc_fullexam_notice";
	public $t_category = "goouc_fullexam_category";
	public $t_test = "goouc_fullexam_test";
	public $t_test_type = "goouc_fullexam_test_type";
	public $t_paper_test = "goouc_fullexam_paper_test";
	public $t_paper = "goouc_fullexam_paper";
	public $t_member = "goouc_fullexam_user_member";
	public $psize = 15;
	public $t_user = "goouc_fullexam_user";
	public $t_user_read = "goouc_fullexam_user_read";
	public $t_user_wrong_praction = "goouc_fullexam_user_wrong_praction";
	public $t_phonecode = "goouc_fullexam_phonecode";
	public $t_order = "goouc_fullexam_order";
	public $t_user_exam_answer = "goouc_fullexam_user_exam_answer";
	public $t_user_doexam = "goouc_fullexam_user_doexam";
	public function dopageLogin()
	{
		global $_W;
		global $_GPC;
		$contion = "";
		$params[":weid"] = $_W["uniacid"];
		$code = $_GPC["code"];
		if (empty($code)) {
			return $this->result(1, "code值获取失败", ["message" => "code值获取失败"]);
		}
		$appid = $_W["account"]["key"];
		$secret = $_W["account"]["secret"];
		$wxapi = new wxapi($appid, $secret);
		$info = $wxapi->code2Session($code);
		if ($info["code"] == 4001) {
			return $this->result(1, "获取用户信息失败", ["message" => $info["message"]]);
		}
		$contion .= " AND openid = :openid ";
		$params[":openid"] = $info["openid"];
		$uinfo = pdo_fetch("select * from " . tablename($this->t_user) . " where " . $this->contion . $contion, $params);
		$info_status = 2;
		if (empty($uinfo)) {
			$encryptedData = $_GPC["encryptedData"];
			$iv = $_GPC["iv"];
			$pc = new WXBizDataCrypt($appid, $info["session_key"]);
			$errCode = $pc->decryptData($encryptedData, $iv, $datas);
			if ($errCode == 0) {
				$a = json_decode($datas, true);
				$data["openid"] = $a["openId"];
				$data["nickname"] = $a["nickName"];
				$data["nativeplace"] = $a["province"] . "," . $a["city"];
				$data["headimg"] = $a["avatarUrl"];
				$data["unionid"] = $a["unionId"];
				$data["createtime"] = time();
			}
			$data["weid"] = $_W["uniacid"];
			$data["last_login_time"] = time();
			try {
				pdo_insert($this->t_user, $data);
			} catch (Exception $e) {
				return $this->result(1, "用户数据插入失败");
			}
			$uid = pdo_insertid();
			if (time() - cache_load('tokentime') > 6800) {
				cache_delete('access_token');
				cache_delete('tokentime');
				$access_token = $wxapi->getAccess_Token();
				cache_write('access_token', $access_token);
				cache_write('tokentime', time());
			} else {
				$access_token = cache_load("access_token");
			}
			$path = "../addons/goouc_fullexam/Qrcode/";
			if (!is_dir($path)) {
				mkdir($path, 511, true);
			}
			$filename = "qrcode_" . $uid . ".jpg";
			try {
				$res = $wxapi->getUnlimited($access_token, $uid, $path, $filename);
				if ($res) {
					$da["qrcode"] = $path . $filename;
					pdo_update($this->t_user, $da, ["id" => $uid]);
				}
			} catch (Exception $e) {
				return $this->result(1, "生成二维码错误了", $e);
			}
		} else {
			if ($uinfo["status"] != 1) {
				return $this->result(1, "您已被禁用,请联系管理员处理~", $uinfo);
			}
			$data["last_login_time"] = time();
			pdo_update($this->t_user, $data, ["weid" => $_W["uniacid"], "id" => $uinfo["id"]]);
			$uid = $uinfo["id"];
			if (!empty($uinfo["phone"])) {
				$info_status = 1;
			}
		}
		return $this->result(0, "登录成功", ["uid" => $uid, "info_status" => $info_status]);
	}
	public function dopageLogin2()
	{
		global $_W;
		global $_GPC;
		$contion = "";
		$params[":weid"] = $_W["uniacid"];
		$code = $_GPC["code"];
		if (empty($code)) {
			return $this->result(1, "code值获取失败", ["message" => "code值获取失败"]);
		}
		$appid = $_W["account"]["key"];
		$secret = $_W["account"]["secret"];
		$wxapi = new wxapi($appid, $secret);
		$info = $wxapi->code2Session($code);
		if ($info["code"] == 4001) {
			return $this->result(1, "获取用户信息失败", ["message" => $info["message"]]);
		}
		$contion .= " AND openid = :openid ";
		$params[":openid"] = $info["openid"];
		$uinfo = pdo_fetch("select * from " . tablename($this->t_user) . " where " . $this->contion . $contion, $params);
		$info_status = 2;
// 		var_dump($info);die;
		$data["openid"] = $info["openid"];
		$data["nickname"] = $_GPC["nickName"];
		$data["nativeplace"] = $_GPC["province"] . "," . $_GPC["city"];
		$data["headimg"] = $_GPC["avatarUrl"];
		$data["unionid"] = $info["unionid"];
		$data["createtime"] = time();
		if (empty($uinfo)) {
// 			$encryptedData = $_GPC["encryptedData"];
// 			$iv = $_GPC["iv"];
// 			$pc = new WXBizDataCrypt($appid, $info["session_key"]);
// 			$errCode = $pc->decryptData($encryptedData, $iv, $datas);
// 			if ($errCode == 0) {
// 				$a = json_decode($datas, true);
// 				$data["openid"] = $a["openId"];
// 				$data["nickname"] = $a["nickName"];
// 				$data["nativeplace"] = $a["province"] . "," . $a["city"];
// 				$data["headimg"] = $a["avatarUrl"];
// 				$data["unionid"] = $a["unionId"];
// 				$data["createtime"] = time();
// 			}
			$data["weid"] = $_W["uniacid"];
			$data["last_login_time"] = time();
			try {
				pdo_insert($this->t_user, $data);
			} catch (Exception $e) {
				return $this->result(1, "用户数据插入失败");
			}
			$uid = pdo_insertid();
			if (time() - cache_load('tokentime') > 6800) {
				cache_delete('access_token');
				cache_delete('tokentime');
				$access_token = $wxapi->getAccess_Token();
				cache_write('access_token', $access_token);
				cache_write('tokentime', time());
			} else {
				$access_token = cache_load("access_token");
			}
			$path = "../addons/goouc_fullexam/Qrcode/";
			if (!is_dir($path)) {
				mkdir($path, 511, true);
			}
			$filename = "qrcode_" . $uid . ".jpg";
			try {
				$res = $wxapi->getUnlimited($access_token, $uid, $path, $filename);
				if ($res) {
					$da["qrcode"] = $path . $filename;
					pdo_update($this->t_user, $da, ["id" => $uid]);
				}
			} catch (Exception $e) {
				return $this->result(1, "生成二维码错误了", $e);
			}
		} else {
			if ($uinfo["status"] != 1) {
				return $this->result(1, "您已被禁用,请联系管理员处理~", $uinfo);
			}
			$data["last_login_time"] = time();
			pdo_update($this->t_user, $data, ["weid" => $_W["uniacid"], "id" => $uinfo["id"]]);
			$uid = $uinfo["id"];
			if (!empty($uinfo["phone"])) {
				$info_status = 1;
			}
		}
		return $this->result(0, "登录成功", ["uid" => $uid, "info_status" => $info_status]);
	}
	public function dopageMember()
	{
		global $_W;
		$time_num = unserialize(TIME_NUM);
		$info = pdo_get($this->t_member, ["weid" => $_W["uniacid"]]);
		$info["info"] = unserialize($info["info"]);
		foreach ($info["info"] as $k => $v) {
			$info["info"][$k]["cut"] = intval($v["old_price"]) - intval($v["price"]);
			$info["info"][$k]["price"] = sprintf("%1\$.2f", $v["price"]);
		}
		$info["scale"] = rtrim(rtrim($info["scale"] * 10, "0"), ".");
		return $this->result(0, "会员价格信息11", ["time_num" => $time_num, "info" => $info]);
	}
	public function dopageRelieve()
	{
		global $_W;
		global $_GPC;
		$uid = intval($_GPC["uid"]);
		if (empty($uid)) {
			return $this->result(1, "传递的参数不存在或失效", "1001");
		}
		$mobile = $_GPC["phone"];
		$smsCode = $_GPC["code"];
		if (!$mobile || !$smsCode) {
			return $this->result(1, "手机号或验证码为空", ["msg" => "手机号或验证码为空"]);
		}
		if (empty($mobile) || !preg_match("/^1[356789]\\d{9}\$/", $mobile)) {
			return $this->result(1, "手机号有误");
		}
		$checkCode = pdo_fetch("select * from " . tablename("goouc_fullexam_phonecode") . " where weid = :weid AND phone = :phone order by id desc", [":weid" => $_W["uniacid"], ":phone" => $mobile]);
		if ($checkCode["createtime"] + 300 < time()) {
			return $this->result(1, "验证码已过期", ["msg" => "验证码已过期"]);
		}
		if ($checkCode["code"] != $smsCode) {
			return $this->result(1, "验证码错误", ["msg" => "验证码错误"]);
		}
		$data = ["openid" => "", "nickname" => "", "headimg" => "", "nativeplace" => ""];
		$relieve = pdo_update($this->t_user, $data, ["weid" => $_W["uniacid"], "id" => $uid]);
		if ($relieve) {
			return $this->result(0, "解绑成功", "1011");
		} else {
			return $this->result(1, "解绑失败", "1012");
		}
	}
	public function dopageSetuserinfo()
	{
		global $_W;
		global $_GPC;
		$op = $_GPC["op"];
		$params[":weid"] = $_W["uniacid"];
		if ($op == "getinfo") {
			$protocol = !empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] !== "off" || $_SERVER["SERVER_PORT"] == 443 ? "https://" : "http://";
			$domainName = $_SERVER["HTTP_HOST"];
			$http = $protocol . $domainName;
			$uid = intval($_GPC["uid"]);
			if (empty($uid)) {
				return $this->result(1, "用户ID不存在");
			}
			$info = pdo_get($this->t_user, ["weid" => $_W["uniacid"], "istatus" => 1, "id" => $uid], ["id", "nickname", "headimg", "name", "phone", "grade", "ismember", "member_endtime", "nativeplace", "integral", "student_id", "id_card", "school", "level", "openid"]);
			if ($info["ismember"] == 1 && $info["member_endtime"] < time()) {
				$data["ismember"] = 2;
				pdo_update($this->t_user, $data, ["weid" => $_W["uniacid"], "id" => $info["id"]]);
			}
			$info["member_endtime"] = date("Y-m-s", $info["member_endtime"]);
			$info_status = pdo_get("goouc_fullexam_setting", ["weid" => $_W["uniacid"]], ["info_status", "IOS", "customer_service"]);
			$is_ok = 1;
			if ($info_status["info_status"] == 1) {
				if (empty($info["phone"])) {
					$is_ok = 2;
				}
				if (empty($info["name"])) {
					$is_ok = 2;
				}
			}
			$info["IOS"] = $info_status["IOS"];
			$info["customer_service"] = $_W["attachurl"] . $info_status["customer_service"];
			$info["is_open"] = pdo_fetchcolumn("SELECT status FROM " . tablename("goouc_fullexam_user_member") . " WHERE weid=:weid AND istatus=:istatus ", [":weid" => $_W["uniacid"], ":istatus" => 1]);
			$info["is_ok"] = $is_ok;
			$info["stu_have"] = 2;
			$info["student_id"] = 0;
			$info["xuesheng_id"] = 0;
			if (!empty($info["phone"]) && !empty($info["name"])) {
				$stu_info = pdo_fetch("SELECT xuesheng_id,name,phone,student_name,sex FROM " . tablename("goouc_fullexam_xuesheng") . " WHERE weid=:weid AND `name`=:name AND phone=:phone ", [":weid" => $_W["uniacid"], ":name" => $info["name"], ":phone" => $info["phone"]]);
				if (!empty($stu_info)) {
					$info["student_id"] = $stu_info["student_name"];
					$info["xuesheng_id"] = $stu_info["xuesheng_id"];
					$info["stu_have"] = 1;
				}
			}
			if (empty($info["openid"])) {
				$info["is_bind"] = 0;
			} else {
				$info["is_bind"] = 1;
			}
			return $this->result(0, "用户详细信息", ["info" => $info, "http" => $http]);
		} elseif ($op == "checkStudent") {
			$phone = $_GPC["phone"];
			$name = $_GPC["name"];
			if (empty($phone) || empty($name)) {
				return $this->result(1, "传递的参数不存在", ["phone" => $phone, "name" => $name]);
			}
			$info = pdo_fetch("SELECT xuesheng_id,name,phone,student_name,sex FROM " . tablename("goouc_fullexam_xuesheng") . " WHERE weid=:weid AND `name`=:name AND phone=:phone ", [":weid" => $_W["uniacid"], ":name" => $name, ":phone" => $phone]);
			if (!empty($info)) {
				return $this->result(0, "获取学生信息", ["list" => $info]);
			} else {
				return $this->result(1, "学生信息不存在", "1001");
			}
		} elseif ($op == "getcode") {
			$phone = $_GPC["phone"];
			if (empty($phone) || !preg_match("/^1[356789]\\d{9}\$/", $phone)) {
				return $this->result(1, "手机号有误");
			}
			$config = pdo_get($this->t_setting, ["weid" => $_W["uniacid"]]);
			cache_write('config', $config);
			$obj = new send();
			$code = random(4, true);
			$res = $obj->sendcode($phone, $code, $config);
			$res = json_decode(json_encode($res), true);
			if ($res["Code"] == "OK") {
				$data["phone"] = $phone;
				$data["code"] = $code;
				$data["createtime"] = time();
				$data["weid"] = $_W["uniacid"];
				$result = pdo_insert($this->t_phonecode, $data);
				return $this->result(0, "发送成功", 1);
			} else {
				return $this->result(1, "发送失败错误信息", $res["Message"]);
			}
		} elseif ($op == "checkcode") {
			$uid = intval($_GPC["uid"]);
			$inputCode = trim($_GPC["code"]);
			$phone = $_GPC["phone"];
			if (empty($inputCode) || empty($phone)) {
				return $this->result(1, "传递的参数不存在");
			}
			$info = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_phonecode") . " WHERE weid=:weid AND phone=:phone ORDER BY createtime DESC ", [":weid" => $_W["uniacid"], ":phone" => $phone]);
			if ($info["createtime"] + 300 > time()) {
				if ($info["code"] == $inputCode) {
					$data["phone"] = $phone;
					$is_phone = pdo_get("goouc_fullexam_user", ["weid" => $_W["uniacid"], "phone" => $phone], ["id"]);
					if (!empty($is_phone)) {
						return $this->result(1, "该手机号已绑定其他账号！");
					}
					$res = pdo_update($this->t_user, $data, ["id" => $uid]);
					if ($res) {
						pdo_update("goouc_fullexam_xuesheng", $data, ["weid" => $_W["uniacid"], "name" => $has["name"], "phone" => $has["phone"]]);
					}
					return $this->result(0, "绑定成功");
				} else {
					return $this->result(1, "验证码错误");
				}
			} else {
				return $this->result(1, "验证码过期");
			}
		} else {
			$uid = intval($_GPC["uid"]);
			if (empty($uid)) {
				return $this->result(1, "传递的参数不存在");
			}
			$has = pdo_get($this->t_user, ["weid" => $_W["uniacid"], "istatus" => 1, "id" => $uid], ["id", "name", "phone"]);
			if (empty($has)) {
				return $this->result(1, "非法用户ID");
			}
			$data = [];
			$data["name"] = trim($_GPC["name"]);
			$res = pdo_update($this->t_user, $data, ["id" => $uid]);
			if ($res) {
				pdo_update("goouc_fullexam_xuesheng", $data, ["weid" => $_W["uniacid"], "name" => $has["name"], "phone" => $has["phone"]]);
				return $this->result(0, "信息保存成功", 1);
			} else {
				return $this->result(1, "信息保存失败", 0);
			}
		}
	}
	public function dopageIndex()
	{
		global $_W;
		global $_GPC;
		$uid = intval($_GPC["uid"]);
		$banner_height = pdo_getcolumn("goouc_fullexam_setting", ["weid" => $_W["uniacid"]], "banner_height");
		$params[":weid"] = $_W["uniacid"];
		$banner = pdo_fetchall("select `id`,`title`,`image`,`type`,`link` from " . tablename($this->t_banner) . " where " . $this->contion . " AND status = 1 order by createtime DESC limit 0,3", $params);
		if (!empty($banner)) {
			foreach ($banner as &$row) {
				$row["image"] = $_W["attachurl"] . $row["image"];
			}
			unset($row);
		}
		$set = pdo_fetch("SELECT `is_display`,`display_num` FROM " . tablename("goouc_fullexam_setting") . " WHERE weid=:weid ", [":weid" => $_W["uniacid"]]);
		$new_notice = "";
		if ($set["is_display"] == 1) {
			$display_num = !empty($set["display_num"]) ? intval($set["display_num"]) : 5;
			$new_notice = pdo_fetchall("select id,title from " . tablename($this->t_notice) . " where " . $this->contion . " and type = 1 and status = 1 order by id DESC LIMIT " . $display_num, $params);
		}
		$share_title = pdo_fetchcolumn("SELECT share_title FROM " . tablename("goouc_fullexam_setting") . " WHERE weid=:weid ", [":weid" => $_W["uniacid"]]);
		$icons = pdo_fetchall("SELECT * FROM " . tablename("goouc_fullexam_index_btn") . " WHERE weid=:weid ORDER BY sort asc", [":weid" => $_W["uniacid"]]);
		if (!empty($icons)) {
			foreach ($icons as &$row) {
				if (!empty($row["icon"])) {
					$row["icon"] = $_W["attachurl"] . $row["icon"];
				}
				$lib = pdo_get("goouc_fullexam_test_type", ["id" => $row["library_id"]], ["gpid", "pid", "price"]);
				$t_lib = pdo_get("goouc_fullexam_test_type", ["id" => $lib["pid"]], ["gpid", "pid", "price"]);
				$row["gpid"] = $lib["gpid"];
				$row["is_can"] = 0;
				$is_member = pdo_getcolumn($this->t_user, ["weid" => $_W["uniacid"], "id" => $uid], "ismember");
				if ($t_lib["price"] > 0) {
					$kid = pdo_getcolumn("goouc_fullexam_user_pool", ["weid" => $_W["uniacid"], "uid" => $uid, "poolid" => $lib["pid"], "istatus" => 1], "id");
					if (!empty($kid)) {
						$row["is_can"] = 1;
					}
				} else {
					$row["is_can"] = 1;
				}
				$z_vip = pdo_get("goouc_fullexam_user_member", ["weid" => $_W["uniacid"]]);
				$row["vip_price"] = $t_lib["price"] * $z_vip["scale"];
				$row["vip_price"] = floor($row["vip_price"] * 100) / 100;
				if ($row["vip_price"] > 0) {
					$kid = pdo_getcolumn("goouc_fullexam_user_pool", ["weid" => $_W["uniacid"], "uid" => $uid, "poolid" => $lib["pid"], "istatus" => 1], "id");
					if (!empty($kid)) {
						$row["is_can"] = 1;
					}
				} else {
					$row["is_can"] = 1;
				}
				if ($is_member == 1) {
					if ($row["vip_price"] <= 0) {
						$row["is_can"] = 1;
					}
				}
				$now_time = date("Y-m-d H:i:s");
				$cdkeys = pdo_getall("goouc_fullexam_cdkeys", ["weid" => $_W["uniacid"], "kpool_id" => $row["pid"], "type" => 2], ["code_id"]);
				$cdkeys = array_column($cdkeys, "code_id");
				$cdkeys = implode(",", $cdkeys);
				if (!empty($cdkeys)) {
					$active = pdo_fetch(" SELECT * FROM " . tablename("goouc_fullexam_cdkey") . " WHERE weid =:weid AND uid=:uid AND status =2 AND display=1 AND kpool > :kpool AND cid in (" . $cdkeys . ")", [":weid" => $_W["uniacid"], "uid" => $uid, ":kpool" => $now_time]);
					if ($active) {
						$row["is_can"] = 1;
					}
				}
			}
			unset($row);
		}
		$countdown = pdo_fetch("SELECT `countdown`,`countdowntime`,`time_display` FROM " . tablename("goouc_fullexam_setting") . " WHERE weid=:weid ", [":weid" => $_W["uniacid"]]);
		if (!empty($countdown) && !empty($countdown["countdowntime"])) {
			$countdown["countdowntime"] = strtotime($countdown["countdowntime"]);
		}
		$count_day = 0;
		$count_day_rank = 0;
		if (!empty($uid)) {
			$count_day = pdo_getcolumn("goouc_fullexam_user", ["weid" => $_W["uniacid"], "id" => $uid], "count_day");
			$count_day_rank = pdo_getcolumn("goouc_fullexam_user", ["weid" => $_W["uniacid"], "count_day >=" => $count_day], "count(id)");
		}
		$rate = 0;
		$rate_rank = 0;
		if (!empty($uid)) {
			$all = pdo_getcolumn("goouc_fullexam_exercise", ["weid" => $_W["uniacid"], "uid" => $uid, "istatus" => 1], "COUNT(id)");
			$right = pdo_getcolumn("goouc_fullexam_exercise", ["weid" => $_W["uniacid"], "uid" => $uid, "istatus" => 1, "isright" => 1], "COUNT(id)");
			if (!empty($all)) {
				$rate = min(100, intval($right / $all * 100));
			}
			$rate_rank = pdo_fetch("SELECT count(b.num) as allnum FROM (SELECT count(a.id) as num FROM " . tablename("goouc_fullexam_exercise") . " as a where a.istatus=1 AND a.isright=1 group by a.uid ) as b WHERE b.num > :num ", [":num" => intval($right)]);
			$rate_rank = 1 + intval($rate_rank["allnum"]);
		}
		$data = ["banner" => $banner, "banner_height" => $banner_height, "notice" => $new_notice, "share_title" => $share_title, "icons" => $icons, "countdown" => $countdown, "count_day" => ["count_day" => intval($count_day), "count_day_rank" => $count_day_rank], "rate" => ["rate" => $rate, "rate_rank" => $rate_rank]];
		return $this->result(0, "首页数据", $data);
	}
	public function dopageTotalqNum()
	{
		global $_W;
		global $_GPC;
		$weid = $_W["uniacid"];
		$uid = intval($_GPC["uid"]);
		if (!empty($uid)) {
			$user_info = pdo_fetch("SELECT id,name,phone,integral,status FROM " . tablename("goouc_fullexam_user") . " WHERE weid=:weid AND id=:uid ", [":weid" => $_W["uniacid"], ":uid" => $uid]);
			if (empty($user_info)) {
				return $this->result(1, "用户不存在", "1002");
			}
			if ($user_info["status"] != 1) {
				return $this->result(1, "用户被禁用", "1003");
			}
			$last_id = pdo_fetchcolumn("SELECT question_id FROM " . tablename("goouc_fullexam_user_spequence") . " WHERE weid=:weid AND user_id=:uid", [":weid" => $_W["uniacid"], ":uid" => $uid]);
			$last_id = intval($last_id);
			$is_student = pdo_getcolumn("goouc_fullexam_xuesheng", ["weid" => $_W["uniacid"], "name" => $user_info["name"], "phone" => $user_info["phone"]], "xuesheng_id");
			$freepool = [];
			if (!empty($is_student)) {
				$fpool = pdo_fetchall("SELECT id FROM " . tablename("goouc_fullexam_test_type") . " WHERE weid = :weid AND istatus = 1 AND status = 1 AND price <= 0 AND pid != 0 AND gpid = 0 ", [":weid" => $_W["uniacid"]]);
				if (!empty($fpool)) {
					foreach ($fpool as $key => $val) {
						$list = pdo_fetchall("SELECT id FROM " . tablename("goouc_fullexam_test_type") . " WHERE weid=:weid AND pid=:pid AND istatus = 1 AND status = 1 AND gpid != 0 ", [":weid" => $_W["uniacid"], ":pid" => $val["id"]]);
						if (!empty($list)) {
							foreach ($list as $k => $v) {
								$freepool[] = $v["id"];
							}
						}
					}
				}
			} else {
				$fpool = pdo_fetchall("SELECT id FROM " . tablename("goouc_fullexam_test_type") . " WHERE weid = :weid AND istatus = 1 AND status = 1 AND price <= 0 AND is_student != 1 AND pid != 0 AND gpid = 0 ", [":weid" => $_W["uniacid"]]);
				if (!empty($fpool)) {
					foreach ($fpool as $key => $val) {
						$list = pdo_fetchall("SELECT id FROM " . tablename("goouc_fullexam_test_type") . " WHERE weid=:weid AND pid=:pid AND istatus = 1 AND status = 1 AND gpid != 0 ", [":weid" => $_W["uniacid"], ":pid" => $val["id"]]);
						if (!empty($list)) {
							foreach ($list as $k => $v) {
								$freepool[] = $v["id"];
							}
						}
					}
				}
			}
			$pool = [];
			if (!empty($freepool)) {
				foreach ($freepool as $key => $val) {
					$pool[] = $val;
				}
			}
			$userpool = [];
			$upool = pdo_fetchall("SELECT up.id,up.poolid FROM " . tablename("goouc_fullexam_user_pool") . " as up LEFT JOIN " . tablename("goouc_fullexam_test_type") . " AS tt ON up.poolid=tt.id WHERE up.weid=:weid AND up.uid=:uid AND tt.istatus = 1 AND tt.status = 1 ", [":weid" => $_W["uniacid"], ":uid" => $uid]);
			if (!empty($upool)) {
				foreach ($upool as $key => $val) {
					$list = pdo_fetchall("SELECT id FROM " . tablename("goouc_fullexam_test_type") . " WHERE weid=:weid AND pid=:pid AND istatus = 1 AND status = 1 AND gpid != 0 ", [":weid" => $_W["uniacid"], ":pid" => $val["poolid"]]);
					if (!empty($list)) {
						foreach ($list as $k => $v) {
							$userpool[] = $v["id"];
						}
					}
				}
			}
			if (!empty($userpool)) {
				foreach ($userpool as $key => $val) {
					$pool[] = $val;
				}
			}
			$pool = array_unique($pool);
			$poolstr = "";
			$total = 0;
			if (!empty($pool)) {
				$poolstr = implode(",", $pool);
				$total = pdo_fetchcolumn("SELECT COUNT(id) FROM " . tablename("goouc_fullexam_test") . " WHERE weid=:weid AND istatus=1 AND `type`!=0 AND display=1 AND type<9 AND libraryid IN (" . $poolstr . ") ORDER BY id ASC ", [":weid" => $_W["uniacid"]]);
			}
			if ($total < $last_id) {
				$last_id = $total;
			} else {
				if ($last_id == $total - 1) {
					$last_id = 0;
				}
			}
			if ($total > 0) {
				return $this->result(0, "总题数,进度ID", ["total" => intval($total), "last_id" => intval($last_id)]);
			} else {
				return $this->result(1, "暂无试题", ["total" => 0, "last_id" => 0, "is_can" => 0]);
			}
		} else {
			return $this->result(1, "请先登录", ["total" => 0, "last_id" => 0, "is_can" => 2]);
		}
	}
	public function dopageReadnotice()
	{
		global $_W;
		global $_GPC;
		$uid = intval($_GPC["uid"]);
		$nid = intval($_GPC["nid"]);
		$params[":weid"] = $_W["uniacid"];
		$contion = " and id = :id ";
		$params[":id"] = $nid;
		$info = pdo_get($this->t_notice, ["id" => $nid, "weid" => $_W["uniacid"], "istatus" => 1], ["id", "title", "content", "createtime", "readnum", "image", "video_audio_id"]);
		$info["title"] = htmlspecialchars_decode($info["title"]);
		if (empty($info)) {
			return $this->result(0, "未找到请求的相关信息", "1002");
		}
		if (!empty($info["image"])) {
			$info["image"] = $_W["attachurl"] . $info["image"];
		}
		if (empty($info["video_audio_id"])) {
			$info["have_video"] = 2;
		} else {
			$info["have_video"] = 1;
			$config = pdo_fetch("SELECT `AccessKeyId`,`AccessKeySecret`,`RegionId` FROM " . tablename("goouc_fullexam_setting") . " WHERE weid=:weid ", [":weid" => $_W["uniacid"]]);
			$aliyunVod = new AliyunUploadVod($config["RegionId"], $config["AccessKeyId"], $config["AccessKeySecret"]);
			$video = $aliyunVod->getPlayInfo($info["video_audio_id"]);
			$info["video"]["url"] = $video->PlayInfoList->PlayInfo[1]->PlayURL;
			$info["video"]["time"] = $video->PlayInfoList->PlayInfo[1]->Duration;
			$info["video"]["img"] = $video->VideoBase->CoverURL;
			$info["video"]["title"] = $video->VideoBase->Title;
		}
		pdo_query('update ' . tablename($this->t_notice) . " set readnum = readnum + 1 where " . $this->contion . $contion, $params);
		$has = pdo_get($this->t_user_read, ["weid" => $_W["uniacid"], "uid" => $uid, "noticeid" => $nid, "istatus" => 1], ["id"]);
		if ($has) {
			$data["createtime"] = time();
			pdo_update($this->t_user_read, $data, ["id" => $has["id"], "weid" => $_W["uniacid"]]);
		} else {
			$data["weid"] = $_W["uniacid"];
			$data["uid"] = $uid;
			$data["noticeid"] = $nid;
			$dara["createtime"] = time();
			pdo_insert($this->t_user_read, $data);
		}
		$info["createtime"] = date("Y-m-d", $info["createtime"]);
		return $this->result(0, "文章/公告详情信息", ["info" => $info]);
	}
	public function dopageAtype()
	{
		global $_W;
		global $_GPC;
		$list = pdo_fetchall("SELECT id,`name` FROM " . tablename("goouc_fullexam_category") . " WHERE weid=:weid AND status=1 AND istatus=1 AND pid=0 ORDER BY `order` DESC ", [":weid" => $_W["uniacid"]]);
		if (!empty($list)) {
			foreach ($list as $k => $v) {
				$list[$k]["son"] = pdo_fetchall("SELECT id,`name` FROM " . tablename("goouc_fullexam_category") . " WHERE weid=:weid AND status=1 AND istatus=1 AND pid=:pid ORDER BY `order` DESC ", [":weid" => $_W["uniacid"], ":pid" => $v["id"]]);
			}
			return $this->result(0, "一级二级分类", ["list" => $list]);
		} else {
			return $this->result(1, "暂无分类", $list);
		}
	}
	public function dopageArticle()
	{
		global $_W;
		global $_GPC;
		$params[":weid"] = $_W["uniacid"];
		$contion = " and type = :type";
		$params[":type"] = 3;
		$pindex = max(1, $_GPC["page"]);
		$psize = 5;
		if (!empty($_GPC["pcate"])) {
			$contion .= " AND pcate=:pcate ";
			$params[":pcate"] = intval($_GPC["pcate"]);
		}
		if (!empty($_GPC["ccate"])) {
			$contion .= " AND ccate=:ccate ";
			$params[":ccate"] = intval($_GPC["ccate"]);
		}
		$list = pdo_fetchall("select `id`,`title`,`content`,`image`,`createtime`,`video_audio_id`,`readnum` from " . tablename($this->t_notice) . " where " . $this->contion . $contion . " order by createtime DESC limit " . ($pindex - 1) * $psize . "," . $psize, $params);
		if (!empty($list)) {
			foreach ($list as &$val) {
				if (!empty($val["image"])) {
					$val["image"] = $_W["attachurl"] . $val["image"];
				}
				$val["title"] = htmlspecialchars_decode($val["title"]);
				if (empty($val["video_audio_id"])) {
					$val["have_video"] = 2;
				} else {
					$val["have_video"] = 2;
				}
			}
			$total = pdo_fetchcolumn("select COUNT(*) from " . tablename($this->t_notice) . " where " . $this->contion . $contion, $params);
			return $this->result(0, "文章列表", ["list" => $list, "total" => intval($total), "psize" => $psize]);
		} else {
			$total = 0;
			return $this->result(0, "文章列表暂无数据", ["list" => $list, "total" => $total]);
		}
	}
	public function dopageReadvideo()
	{
		global $_W;
		global $_GPC;
		$uid = intval($_GPC["uid"]);
		$id = intval($_GPC["id"]);
		$weid = $_W["uniacid"];
		if (empty($uid) || empty($id)) {
			return $this->result(1, "传递的参数不存在或失效");
		}
		$params[":weid"] = $_W["uniacid"];
		$contion = " and id = :id ";
		$params[":id"] = $id;
		pdo_query('update ' . tablename($this->t_notice) . " set readnum = readnum + 1 where " . $this->contion . $contion, $params);
		$has = pdo_get($this->t_user_read, ["weid" => $weid, "uid" => $uid, "noticeid" => $id, "istatus" => 1], ["id"]);
		if ($has) {
			$data["createtime"] = time();
			pdo_update($this->t_user_read, $data, ["id" => $has["id"], "weid" => $weid]);
		} else {
			$data["weid"] = $weid;
			$data["uid"] = $uid;
			$data["noticeid"] = $id;
			$dara["createtime"] = time();
			pdo_insert($this->t_user_read, $data);
		}
		$info = pdo_fetch("SELECT `id`,`readnum` FROM " . tablename("goouc_fullexam_notice") . " WHERE weid=:weid AND id=:id ", [":weid" => $weid, ":id" => $id]);
		return $this->result(0, "操作成功,返回文章阅读量", $info);
	}
	public function dopageMedal()
	{
		global $_W;
		global $_GPC;
		$uid = $_GPC["uid"];
		if (empty($uid)) {
			return $this->result(1, "传递的uid不存在或失效", "1001");
		}
		$user_info = pdo_fetch("SELECT `integral`,`status` FROM " . tablename("goouc_fullexam_user") . " WHERE weid=:weid AND id=:uid ", [":weid" => $_W["uniacid"], ":uid" => $uid]);
		if (empty($user_info)) {
			return $this->result(1, "用户不存在", "1002");
		}
		if ($user_info["status"] != 1) {
			return $this->result(1, "用户被禁用", "1003");
		}
		$quanzhen_have = pdo_fetchall("SELECT * FROM " . tablename("goouc_fullexam_user_doexam") . " WHERE weid=:weid AND uid=:uid ", [":weid" => $_W["uniacid"], ":uid" => $uid]);
		$other_have = pdo_fetchall("SELECT * FROM " . tablename("goouc_fullexam_user_doother_exam") . " WHERE weid=:weid AND uid=:uid ", [":weid" => $_W["uniacid"], ":uid" => $uid]);
		$resuser = [1 => ["medal" => 1, "have" => 2], 2 => ["medal" => 2, "have" => 2], 3 => ["medal" => 3, "have" => 2], 4 => ["medal" => 4, "have" => 2], 5 => ["medal" => 5, "have" => 2], 6 => ["medal" => 6, "have" => 2]];
		$full_mark = 0;
		if (!empty($quanzhen_have)) {
			foreach ($quanzhen_have as $key => $val) {
				$paper_info = pdo_fetch("SELECT id,total_franction FROM " . tablename("goouc_fullexam_paper") . " WHERE weid=:weid AND istatus=1 AND id=:paperid ", [":weid" => $_W["uniacid"], ":paperid" => $val["examid"]]);
				if ($val["franction"] == $paper_info["total_franction"]) {
					$full_mark += 1;
				}
				if ($val["franction"] >= $paper_info["total_franction"] * 0.6) {
					$resuser[1] = ["medal" => 1, "have" => 1];
				}
			}
		}
		if (!empty($other_have)) {
			$setting = pdo_fetch("SELECT franction,paper_time FROM " . tablename("goouc_fullexam_setting") . " WHERE weid=:weid ", [":weid" => $_W["uniacid"]]);
			$setting["franction"] = unserialize($setting["franction"]);
			$data = [];
			$total_score = 0;
			$total_qnum = 0;
			foreach ($setting["franction"] as $key => $val) {
				$data["type_num_" . $key] = $val["num_" . $key];
				$data["type_score_" . $key] = $val["num_" . $key] * $val["franction_" . $key];
				$total_score += $data["type_score_" . $key];
				$total_qnum += $data["type_num_" . $key];
			}
			foreach ($other_have as $kk => $vv) {
				if ($vv["franction"] == $total_score) {
					$full_mark += 1;
				}
				if ($vv["franction"] >= $total_score * 0.6) {
					$resuser[1] = ["medal" => 1, "have" => 1];
				}
			}
		}
		if ($full_mark >= 3 && $full_mark < 10) {
			$resuser[2] = ["medal" => 2, "have" => 1];
			$resuser[3] = ["medal" => 3, "have" => 1];
		} elseif ($full_mark >= 10 && $full_mark < 30) {
			$resuser[2] = ["medal" => 2, "have" => 1];
			$resuser[3] = ["medal" => 3, "have" => 1];
			$resuser[5] = ["medal" => 5, "have" => 1];
		} elseif ($full_mark >= 30) {
			$resuser[2] = ["medal" => 2, "have" => 1];
			$resuser[3] = ["medal" => 3, "have" => 1];
			$resuser[5] = ["medal" => 5, "have" => 1];
			$resuser[6] = ["medal" => 6, "have" => 1];
		} elseif ($full_mark >= 1 && $full_mark < 3) {
			$resuser[2] = ["medal" => 2, "have" => 1];
		}
		$do_total = pdo_fetchcolumn("SELECT count(*) FROM " . tablename("goouc_fullexam_exercise") . " WHERE weid=:weid AND uid=:uid ", [":weid" => $_W["uniacid"], ":uid" => $uid]);
		$test_total = pdo_fetchcolumn("SELECT count(*) FROM " . tablename("goouc_fullexam_test") . " WHERE weid=:weid AND istatus=1 AND `type`!=0 ", [":weid" => $_W["uniacid"]]);
		if ($do_total == $test_total) {
			$resuser[4] = ["medal" => 4, "have" => 1];
		}
		return $this->result(0, "我的勋章", $resuser);
	}
	public function dopageGiftList()
	{
		global $_W;
		global $_GPC;
		$weid = $_W["uniacid"];
		$uid = intval($_GPC["uid"]);
		if (empty($uid)) {
			return $this->result(1, "传递的参数不存在或失效");
		}
		$userCoins = pdo_fetch("SELECT `integral`,`status` FROM " . tablename("goouc_fullexam_user") . " WHERE weid=:weid AND id=:uid ", [":weid" => $weid, ":uid" => $uid]);
		$wechat_number = pdo_fetchcolumn("SELECT `wechat_number` FROM " . tablename("goouc_fullexam_setting") . " WHERE weid=:weid ", [":weid" => $weid]);
		$data = $this->get_gift_list();
		if (!empty($data)) {
			return $this->result(0, "礼品列表,用户积分,商家微信", ["list" => $data, "userCoins" => $userCoins["integral"], "wechat_number" => $wechat_number]);
		}
		return $this->result(1, "暂无礼品", ["userCoins" => $userCoins["integral"], "wechat_number" => $wechat_number]);
	}
	public function get_gift_list()
	{
		global $_GPC;
		global $_W;
		$weid = $_W["uniacid"];
		$list = pdo_fetchall("select * from " . tablename("goouc_fullexam_gift") . " where weid=:weid ", [":weid" => $weid]);
		foreach ($list as $k => $v) {
			$list[$k]["image"] = $_W["attachurl"] . $v["image"];
		}
		return $list;
	}
	public function dopageExchangeGift()
	{
		global $_W;
		global $_GPC;
		$uid = intval($_GPC["uid"]);
		$gid = intval($_GPC["gid"]);
		$consignee_name = trim($_GPC["consignee_name"]);
		$consignee_phone = trim($_GPC["consignee_phone"]);
		$consignee_address = trim($_GPC["consignee_address"]);
		if (empty($gid) || empty($uid) || empty($consignee_name) || empty($consignee_phone) || empty($consignee_address)) {
			return $this->result(1, "传递的参数不存在或失效");
		}
		$user_info = pdo_fetch("SELECT `integral`,`status` FROM " . tablename("goouc_fullexam_user") . " WHERE weid=:weid AND id=:uid ", [":weid" => $_W["uniacid"], ":uid" => $uid]);
		if ($user_info["status"] != 1) {
			return $this->result(1, "用户被禁用", $user_info["status"]);
		}
		$usercoins = $user_info["integral"];
		$giftcoins = pdo_fetchcolumn("SELECT `coins` FROM " . tablename("goouc_fullexam_gift") . " WHERE weid=:weid AND id=:gid ", [":weid" => $_W["uniacid"], ":gid" => $gid]);
		if (intval($usercoins) >= intval($giftcoins)) {
			pdo_update("goouc_fullexam_user", ["integral -=" => $giftcoins], ["id" => $uid, "weid" => $_W["uniacid"]]);
			pdo_insert('goouc_fullexam_user_gift', ['uid' => $uid, "giftid" => $gid, "weid" => $_W["uniacid"], "createtime" => time(), "consignee_name" => $consignee_name, "consignee_phone" => $consignee_phone, "consignee_address" => $consignee_address]);
			return $this->result(0, "兑换成功,联系卖家发货", "OK");
		} else {
			return $this->result(1, "积分不足,兑换失败", "NO");
		}
	}
	public function dopageExchangeGiftList()
	{
		global $_W;
		global $_GPC;
		$uid = intval($_GPC["uid"]);
		if (empty($uid)) {
			return $this->result(1, "传递的参数不存在或失效");
		}
		$list = pdo_fetchall("SELECT `giftid`,`createtime`,`status` FROM " . tablename("goouc_fullexam_user_gift") . " WHERE weid=:weid AND uid=:uid ", [":weid" => $_W["uniacid"], ":uid" => $uid]);
		if (!empty($list)) {
			foreach ($list as $key => $val) {
				$gift = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_gift") . " WHERE weid=:weid AND id=:gid", [":weid" => $_W["uniacid"], ":gid" => $val["giftid"]]);
				$gift["createtime"] = $val["createtime"];
				$gift["image"] = $_W["attachurl"] . $gift["image"];
				$gift["status"] = $list[$key]["status"];
				$data[] = $gift;
			}
			return $this->result(0, "兑换记录", $data);
		}
		return $this->result(1, "暂无兑换记录");
	}
	public function dopagePreExamInfo()
	{
		global $_W;
		global $_GPC;
		$uid = intval($_GPC["uid"]);
		if (empty($uid)) {
			return $this->result(1, "传递的参数不存在或失效", "1001");
		}
		$user_info = pdo_fetch("SELECT `integral`,`status` FROM " . tablename("goouc_fullexam_user") . " WHERE weid=:weid AND id=:uid ", [":weid" => $_W["uniacid"], ":uid" => $uid]);
		if (empty($user_info)) {
			return $this->result(1, "用户不存在", "1002");
		}
		if ($user_info["status"] != 1) {
			return $this->result(1, "用户被禁用", "1003");
		}
		$quanzhen_highest = pdo_fetchcolumn("SELECT franction FROM " . tablename("goouc_fullexam_user_doexam") . " WHERE weid=:weid AND uid=:uid ORDER BY franction DESC LIMIT 1 ", [":weid" => $_W["uniacid"], ":uid" => $uid]);
		$other_highest = pdo_fetchcolumn("SELECT franction FROM " . tablename("goouc_fullexam_user_doother_exam") . " WHERE weid=:weid AND uid=:uid ORDER BY franction DESC LIMIT 1 ", [":weid" => $_W["uniacid"], ":uid" => $uid]);
		if (empty($highest)) {
			$highest = 0;
		}
		if (empty($other_highest)) {
			$highest = 0;
		}
		if ($other_highest < $quanzhen_highest) {
			$highest = $quanzhen_highest;
		} else {
			$highest = $other_highest;
		}
		$setting = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_setting") . " WHERE weid=:weid ", [":weid" => $_W["uniacid"]]);
		$franction = unserialize($setting["franction"]);
		$paper_time = $setting["paper_time"];
		$data = [];
		$total_score = 0;
		$total_qnum = 0;
		if (!empty($franction)) {
			foreach ($franction as $key => $val) {
				$data["type_num_" . $key] = $val["num_" . $key];
				$data["type_score_" . $key] = intval($val["num_" . $key]) * intval($val["franction_" . $key]);
				$total_score += $data["type_score_" . $key];
				$total_qnum += intval($data["type_num_" . $key]);
			}
			$pass_score = round($total_score * 0.6, 1);
			return $this->result(0, "总分,时长,及格,历史最高", ["total_score" => $total_score, "paper_time" => $paper_time, "pass_score" => $pass_score, "highest" => $highest]);
		} else {
			return $this->result(1, "暂未设置考试信息", "1004");
		}
	}
	public function dopageGetExamList()
	{
		global $_W;
		global $_GPC;
		$uid = $_GPC["uid"];
		$pindex = max(1, $_GPC["page"]);
		$psize = 10;
		$list = pdo_fetchall("SELECT id,title,total_franction,createtime,price,is_repeat FROM " . tablename("goouc_fullexam_paper") . " WHERE weid=:weid AND istatus=:istatus AND status=:status ORDER BY displayorder DESC LIMIT " . ($pindex - 1) * $psize . "," . $psize, [":weid" => $_W["uniacid"], ":istatus" => 1, ":status" => 1]);
		$total = pdo_fetchall("SELECT id,title,total_franction,createtime,price,is_repeat FROM " . tablename("goouc_fullexam_paper") . " WHERE weid=:weid AND istatus=:istatus AND status=:status ORDER BY displayorder DESC ", [":weid" => $_W["uniacid"], ":istatus" => 1, ":status" => 1]);
		$total = count($total);
		if (!empty($list)) {
			foreach ($list as $k => $v) {
				$list[$k]["name"] = $v["title"];
				$list[$k]["qnum"] = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename("goouc_fullexam_paper_test") . " WHERE weid=:weid AND istatus=:istatus AND paperid=:paperid ", [":weid" => $_W["uniacid"], ":istatus" => 1, ":paperid" => $v["id"]]);
				$list[$k]["createtime"] = date("Y-m-d", $list[$k]["createtime"]);
				$list[$k]["is_can"] = 0;
				if ($list[$k]["price"] > 0) {
					$kid = pdo_getcolumn("goouc_fullexam_user_pool", ["weid" => $_W["uniacid"], "uid" => $uid, "paperid" => $v["id"], "istatus" => 1], "id");
					if (!empty($kid)) {
						$list[$k]["is_can"] = 1;
					}
				} else {
					$list[$k]["is_can"] = 1;
				}
				$is_member = pdo_getcolumn($this->t_user, ["weid" => $_W["uniacid"], "id" => $uid], "ismember");
				$z_vip = pdo_get("goouc_fullexam_user_member", ["weid" => $_W["uniacid"]]);
				$list[$k]["vip_price"] = $v["price"] * $z_vip["scale"];
				$list[$k]["vip_price"] = floor($list[$k]["vip_price"] * 100) / 100;
				$list[$k]["simple"] = 2;
				if ($is_member == 1) {
					if ($list[$k]["vip_price"] <= 0) {
						$list[$k]["is_can"] = 1;
					}
				}
				$now_time = date("Y-m-d H:i:s");
				$cdkeys = pdo_getall("goouc_fullexam_cdkeys", ["weid" => $_W["uniacid"], "kpool_id" => $v["id"], "type" => 1], ["code_id"]);
				$cdkeys = array_column($cdkeys, "code_id");
				$cdkeys = implode(",", $cdkeys);
				if (!empty($cdkeys)) {
					$active = pdo_fetch(" SELECT * FROM " . tablename("goouc_fullexam_cdkey") . " WHERE weid =:weid AND uid=:uid AND status =2 AND display=1 AND kpool > :kpool AND cid in (" . $cdkeys . ")", [":weid" => $_W["uniacid"], "uid" => $uid, ":kpool" => $now_time]);
					if ($active) {
						$list[$k]["is_can"] = 1;
					}
				}
				$paper_test = pdo_getall($this->t_paper_test, ["paperid" => $v["id"]], ["testid"]);
				foreach ($paper_test as $key => $value) {
					$res = pdo_get($this->t_test, ["weid" => $_W["uniacid"], "type" => 8, "id" => $value["testid"]], ["id"]);
					if ($res) {
						$list[$k]["simple"] = 1;
						$list[$k]["is_repeat"] = 2;
						break;
					}
				}
				$do_number = pdo_fetchcolumn(" SELECT COUNT(*) FROM " . tablename($this->t_user_doexam) . " WHERE weid = :weid AND uid = :uid AND examid= :examid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":examid" => $v["id"]]);
				$list[$k]["do_number"] = $do_number;
			}
			$have = 1;
			return $this->result(0, "全真卷列表", ["list" => $list, "have" => $have, "total" => $total, "psize" => $psize]);
		} else {
			$have = 2;
			return $this->result(0, "暂无全真试卷", ["list" => $list, "have" => $have]);
		}
	}
	public function dopageExamInfo()
	{
		global $_W;
		global $_GPC;
		$uid = $_GPC["uid"];
		$paper_id = $_GPC["paper_id"];
		$paper_info = pdo_get("goouc_fullexam_paper", ["weid" => $_W["uniacid"], "id" => $paper_id], ["title", "times", "total_franction", "times", "is_repeat"]);
		$paper_info["pass_franction"] = ceil($paper_info["total_franction"] * 0.6);
		$do_number = pdo_fetchcolumn(" SELECT COUNT(*) FROM " . tablename($this->t_user_doexam) . " WHERE weid = :weid AND uid = :uid AND examid= :examid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":examid" => $paper_id]);
		$paper_info["do_number"] = $do_number;
		return $this->result(0, "考试信息", ["list" => $paper_info]);
	}
	public function dopageMockexam()
	{
		global $_W;
		global $_GPC;
		$uid = intval($_GPC["uid"]);
		$exam_type = intval($_GPC["exam_type"]);
		if (empty($uid)) {
			return $this->result(1, "传递的参数不存在或失效", "1001");
		}
		if (empty($exam_type)) {
			return $this->result(1, "传递的参数不存在或失效", "1002");
		}
		$user_info = pdo_fetch("SELECT `integral`,`status` FROM " . tablename("goouc_fullexam_user") . " WHERE weid=:weid AND id=:uid ", [":weid" => $_W["uniacid"], ":uid" => $uid]);
		if (empty($user_info)) {
			return $this->result(1, "用户不存在", "1003");
		}
		if ($user_info["status"] != 1) {
			return $this->result(1, "用户被禁用", "1004");
		}
		$is_student = pdo_getcolumn("goouc_fullexam_xuesheng", ["weid" => $_W["uniacid"], "name" => $user_info["name"], "phone" => $user_info["phone"]], "xuesheng_id");
		$freepool = [];
		if (!empty($is_student)) {
			$fpool = pdo_fetchall("SELECT id FROM " . tablename("goouc_fullexam_test_type") . " WHERE weid = :weid AND istatus = 1 AND status = 1 AND price <= 0 AND pid != 0 AND gpid = 0 ", [":weid" => $_W["uniacid"]]);
			if (!empty($fpool)) {
				foreach ($fpool as $key => $val) {
					$list = pdo_fetchall("SELECT id FROM " . tablename("goouc_fullexam_test_type") . " WHERE weid=:weid AND pid=:pid AND istatus = 1 AND status = 1 AND gpid != 0 ", [":weid" => $_W["uniacid"], ":pid" => $val["id"]]);
					if (!empty($list)) {
						foreach ($list as $k => $v) {
							$freepool[] = $v["id"];
						}
					}
				}
			}
		} else {
			$fpool = pdo_fetchall("SELECT id FROM " . tablename("goouc_fullexam_test_type") . " WHERE weid = :weid AND istatus = 1 AND status = 1 AND price <= 0 AND is_student != 1 AND pid != 0 AND gpid = 0 ", [":weid" => $_W["uniacid"]]);
			if (!empty($fpool)) {
				foreach ($fpool as $key => $val) {
					$list = pdo_fetchall("SELECT id FROM " . tablename("goouc_fullexam_test_type") . " WHERE weid=:weid AND pid=:pid AND istatus = 1 AND status = 1 AND gpid != 0 ", [":weid" => $_W["uniacid"], ":pid" => $val["id"]]);
					if (!empty($list)) {
						foreach ($list as $k => $v) {
							$freepool[] = $v["id"];
						}
					}
				}
			}
		}
		$pool = [];
		if (!empty($freepool)) {
			foreach ($freepool as $key => $val) {
				$pool[] = $val;
			}
		}
		$userpool = [];
		$upool = pdo_fetchall("SELECT up.id,up.poolid FROM " . tablename("goouc_fullexam_user_pool") . " as up LEFT JOIN " . tablename("goouc_fullexam_test_type") . " AS tt ON up.poolid=tt.id WHERE up.weid=:weid AND up.uid=:uid AND tt.istatus = 1 AND tt.status = 1 ", [":weid" => $_W["uniacid"], ":uid" => $uid]);
		if (!empty($upool)) {
			foreach ($upool as $key => $val) {
				$list = pdo_fetchall("SELECT id FROM " . tablename("goouc_fullexam_test_type") . " WHERE weid=:weid AND pid=:pid AND istatus = 1 AND status = 1 AND gpid != 0 ", [":weid" => $_W["uniacid"], ":pid" => $val["poolid"]]);
				if (!empty($list)) {
					foreach ($list as $k => $v) {
						$userpool[] = $v["id"];
					}
				}
			}
		}
		if (!empty($userpool)) {
			foreach ($userpool as $key => $val) {
				$pool[] = $val;
			}
		}
		$now_time = date("Y-m-d H:i:s");
		$cdkeys = pdo_fetchall(" SELECT * FROM " . tablename("goouc_fullexam_cdkey") . " WHERE weid =:weid AND uid=:uid AND status =2 AND display=1 AND kpool > :kpool ", [":weid" => $_W["uniacid"], "uid" => $uid, ":kpool" => $now_time]);
		$active_pool = [];
		foreach ($cdkeys as $index => $cdkey) {
			$pools = pdo_getall("goouc_fullexam_cdkeys", ["weid" => $_W["uniacid"], "code_id" => $cdkey["cid"], "type" => 2], "kpool_id");
			$active_pool = array_merge($active_pool, $pools);
		}
		$t_pools = [];
		foreach ($active_pool as $i => $a_pool) {
			$t_pool = pdo_getall("goouc_fullexam_test_type", ["pid" => $a_pool["kpool_id"], "status" => 1, "istatus" => 1], "id");
			$t_pools = array_merge($t_pools, $t_pool);
		}
		$active_pools = array_column($t_pools, "id");
		$pool = array_merge($pool, $active_pools);
		$pool = array_unique($pool);
		$poolstr = "";
		if (!empty($pool)) {
			$poolstr = implode(",", $pool);
		}
		$setting = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_setting") . " WHERE weid=:weid ", [":weid" => $_W["uniacid"]]);
		$franction = unserialize($setting["franction"]);
		$paper_time = $setting["paper_time"];
		$data = [];
		$total_score = 0;
		$total_qnum = 0;
		if (!empty($franction)) {
			foreach ($franction as $key => $val) {
				$data["type_num_" . $key] = $val["num_" . $key];
				$data["type_score_" . $key] = intval($val["num_" . $key]) * intval($val["franction_" . $key]);
				$total_score += $data["type_score_" . $key];
				$total_qnum += intval($data["type_num_" . $key]);
			}
		} else {
			return $this->result(1, "暂未设置考试信息", "1005");
		}
		$questionlist = [];
		if ($exam_type == 1) {
			$paperid = intval($_GPC["paperid"]);
			if (empty($paperid)) {
				return $this->result(1, "传递的参数不存在", "1006");
			}
			$paper = pdo_fetch("SELECT id,title,total_franction FROM " . tablename("goouc_fullexam_paper") . " WHERE weid=:weid AND status=1 AND istatus=1 AND id=:paperid ", [":weid" => $_W["uniacid"], ":paperid" => $paperid]);
			$questionlist = pdo_fetchall("SELECT q.id as id,q.type,q.question,q.qimage,q.qvideo,q.qaudio,q.a_type,q.option,q.rightkey,q.analysis,q.aimage,q.analysis_audio FROM " . tablename("goouc_fullexam_paper_test") . " AS pt JOIN " . tablename("goouc_fullexam_test") . " AS q ON pt.testid=q.id WHERE pt.paperid=:paperid AND q.istatus=1 ", [":paperid" => $paper["id"]]);
			if (!empty($questionlist)) {
				$questionlist = $this->Makeformat($questionlist);
				return $this->result(0, "全真模拟试卷试题", ["paperid" => $paper["id"], "list" => $questionlist, "total_score" => $total_score, "paper_time" => $paper_time, "total_qnum" => $total_qnum]);
			} else {
				$list = [];
				$have = 2;
				return $this->result(0, "获取全真试卷失败", ["list" => $list, "have" => $have]);
			}
		} elseif ($exam_type == 2) {
			$testid_arr = pdo_fetchall("SELECT testid FROM " . tablename("goouc_fullexam_user_exam_answer") . " WHERE weid=:weid AND uid=:uid ORDER BY testid ASC ", [":weid" => $_W["uniacid"], ":uid" => 1]);
			$newid_arr = [];
			foreach ($testid_arr as $key => $val) {
				foreach ($val as $k => $v) {
					$newid_arr[] = $v;
				}
			}
			$testid_str = implode("','", $newid_arr);
			if (!empty($testid_str)) {
				$i = 0;
				$where = "";
				foreach ($data as $k => $v) {
					$i++;
					if ($i <= 5) {
						if ($i == 5) {
							$where .= " AND son_status = 1 ";
						} else {
							$where .= " ";
						}
						$questionlist[] = pdo_fetchall("SELECT id,`type`,question,qimage,qvideo,qaudio,a_type,`option`,rightkey,analysis,aimage,analysis_audio FROM " . tablename("goouc_fullexam_test") . " WHERE weid=:weid AND libraryid IN (" . $poolstr . ") AND istatus=1 AND type < 8 AND `type`=:type " . $where . " AND display=:display ORDER BY rand() LIMIT " . $data["type_num_" . $i], [":weid" => $_W["uniacid"], ":type" => $i, ":display" => 1]);
					}
				}
				$new_question = [];
				if (!empty($questionlist)) {
					foreach ($questionlist as $key => $val) {
						foreach ($val as $k => $v) {
							$new_question[] = $v;
						}
					}
					$list = $this->Makeformat($new_question);
					$now_total = count($list);
					if ($now_total != $total_qnum) {
						$list = [];
						$have = 2;
						return $this->result(0, "获取优先未做试卷试题失败1", ["list" => $list, "have" => $have]);
					} else {
						return $this->result(0, "优先未做试卷试题", ["list" => $list, "total_score" => $total_score, "paper_time" => $paper_time, "total_qnum" => $total_qnum, "ceshi" => 1]);
					}
				} else {
					$list = [];
					$total = 0;
					$have = 2;
					return $this->result(0, "获取优先未做试卷试题失败2", ["list" => $list, "total_qnum" => $total, "have" => $have]);
				}
			} else {
				$i = 0;
				foreach ($data as $k => $v) {
					$i++;
					if ($i <= 7) {
						$where = " AND type=" . $i . "";
						$questionlist[] = pdo_fetchall("SELECT id,`type`,question,qimage,qvideo,qaudio,a_type,`option`,rightkey,analysis,aimage,analysis_audio FROM " . tablename("goouc_fullexam_test") . " WHERE weid=:weid AND type < 8 AND libraryid IN (" . $poolstr . ") AND istatus=1 " . $where . " AND display=:display ORDER BY rand() LIMIT " . $data["type_num_" . $i], [":weid" => $_W["uniacid"], ":display" => 1]);
					}
				}
				$new_question = [];
				if (!empty($questionlist)) {
					foreach ($questionlist as $key => $val) {
						foreach ($val as $k => $v) {
							$new_question[] = $v;
						}
					}
					$list = $this->Makeformat($new_question);
					$now_total = count($list);
					if ($now_total != $total_qnum) {
						$list = [];
						$have = 2;
						return $this->result(0, "获取优先未做试卷试题失败3", ["list" => $list, "have" => $have]);
					} else {
						return $this->result(0, "优先未做试卷试题", ["list" => $list, "total_score" => $total_score, "paper_time" => $paper_time, "total_qnum" => $total_qnum, "ceshi" => 2]);
					}
				} else {
					$list = [];
					$total = 0;
					$have = 2;
					return $this->result(0, "获取优先未做试卷试题失败4", ["list" => $list, "total_qnum" => $total, "have" => $have]);
				}
			}
		} elseif ($exam_type == 3) {
			$i = 0;
			foreach ($data as $k => $v) {
				$i++;
				if ($i <= 7) {
					$questionlist[] = pdo_fetchall("SELECT `id`,`type`,`question`,`qimage`,`qvideo`,`qaudio`,`a_type`,`option`,`rightkey`,`analysis`,`aimage`,`analysis_audio`  FROM " . tablename("goouc_fullexam_test") . " WHERE weid=:weid AND type < 8 AND  libraryid IN (" . $poolstr . ") AND istatus=1 " . $where . " AND `type`=:type AND display=:display ORDER BY rand() LIMIT " . $data["type_num_" . $i], [":weid" => $_W["uniacid"], ":type" => $i, ":display" => 1]);
				}
			}
			$new_question = [];
			if (!empty($questionlist)) {
				foreach ($questionlist as $key => $val) {
					foreach ($val as $k => $v) {
						$new_question[] = $v;
					}
				}
				$list = $this->Makeformat($new_question);
				$now_total = count($list);
				if ($now_total != $total_qnum) {
					$list = [];
					$have = 2;
					return $this->result(0, "获取智能考试试卷试题失败1", ["list" => $list, "have" => $have]);
				} else {
					return $this->result(0, "智能考试试卷试题", ["list" => $list, "total_score" => $total_score, "paper_time" => $paper_time, "total_qnum" => $total_qnum]);
				}
			} else {
				$list = [];
				$total = 0;
				$have = 2;
				return $this->result(0, "获取智能考试试卷试题失败2", ["list" => $list, "total_qnum" => $total, "have" => $have]);
			}
		}
	}
	public function dopageSequence()
	{
		global $_W;
		global $_GPC;
		$uid = intval($_GPC["uid"]);
		$op = $_GPC["op"];
		if (empty($uid)) {
			return $this->result(1, "传递的参数不存在或失效", "1001");
		}
		$user_info = pdo_fetch("SELECT id,name,phone,integral,status FROM " . tablename("goouc_fullexam_user") . " WHERE weid=:weid AND id=:uid ", [":weid" => $_W["uniacid"], ":uid" => $uid]);
		if (empty($user_info)) {
			return $this->result(1, "用户不存在", "1002");
		}
		if ($user_info["status"] != 1) {
			return $this->result(1, "用户被禁用", "1003");
		}
		$is_student = pdo_getcolumn("goouc_fullexam_xuesheng", ["weid" => $_W["uniacid"], "name" => $user_info["name"], "phone" => $user_info["phone"]], "xuesheng_id");
		$freepool = [];
		$lib_id = $_GPC["lib_id"];
		if ($op == "sequence") {
			$last_id = pdo_fetchcolumn("SELECT question_id FROM " . tablename("goouc_fullexam_user_spequence") . " WHERE weid=:weid AND user_id=:uid", [":weid" => $_W["uniacid"], ":uid" => $uid]);
			$questionlist = pdo_fetchall("SELECT `id`,`type`,`question`,`qimage`,`qvideo`,`qaudio`,`a_type`,`option`,`rightkey`,`analysis`,`aimage`,`analysis_audio` FROM " . tablename("goouc_fullexam_test") . " WHERE weid=:weid AND istatus=1 AND `type`!=0 AND display=1 AND type < 9 AND libraryid =:libraryid ORDER BY id ASC ", [":weid" => $_W["uniacid"], ":libraryid" => $lib_id]);
			$total_qnum = count($questionlist);
			$last_id = intval($last_id);
			if ($total_qnum <= $last_id) {
				$last_id = $total_qnum - 1;
			} else {
				if ($last_id == $total_qnum - 1) {
					$last_id = 0;
				}
			}
			if (!empty($questionlist)) {
				foreach ($questionlist as $key => $val) {
					$iscollect = pdo_getcolumn("goouc_fullexam_user_collection_praction", ["weid" => $_W["uniacid"], "uid" => $uid, "testid" => $val["id"], "test_type" => $val["type"]], "id");
					if ($iscollect) {
						$questionlist[$key]["wrong_have"] = 1;
					} else {
						$questionlist[$key]["wrong_have"] = 2;
					}
				}
				$list = $this->Makeformat($questionlist);
				return $this->result(0, "顺序练习试题,总题数,上次练习试题ID", ["list" => $list, "total_qnum" => $total_qnum, "last_id" => $last_id]);
			} else {
				return $this->result(0, "暂无顺序练习试题数据", ["list" => [], "total_qnum" => 0, "have" => 2]);
			}
		} elseif ($op == "randoms") {
			$questionlist = pdo_fetchall("SELECT `id`,`type`,`question`,`qimage`,`qaudio`,`a_type`,`option`,`rightkey`,`analysis`,`aimage`,`createtime`,`analysis_audio` FROM " . tablename("goouc_fullexam_test") . " WHERE weid=:weid AND istatus=1 AND `type`!=0 AND display=1 AND type < 9 AND libraryid =:libraryid ORDER BY rand() ", [":weid" => $_W["uniacid"], ":libraryid" => $lib_id]);
			$total_qnum = count($questionlist);
			if (!empty($questionlist)) {
				foreach ($questionlist as $key => $val) {
					$iscollect = pdo_getcolumn("goouc_fullexam_user_collection_praction", ["weid" => $_W["uniacid"], "uid" => $uid, "testid" => $val["id"], "test_type" => $val["type"]], "id");
					if ($iscollect) {
						$questionlist[$key]["wrong_have"] = 1;
					} else {
						$questionlist[$key]["wrong_have"] = 2;
					}
				}
				$list = $this->Makeformat($questionlist);
				return $this->result(0, "随机练习试题,总题数", ["list" => $list, "total_qnum" => $total_qnum]);
			} else {
				$list = [];
				$total = 0;
				$have = 2;
				return $this->result(0, "暂无随机练习试题数据", ["list" => $list, "total_qnum" => $total, "have" => $have]);
			}
		} elseif ($op == "getallspecial") {
			$pay_open = pdo_getcolumn("goouc_fullexam_setting", ["weid" => $_W["uniacid"]], "pay_open");
			$freepoolnum = pdo_getcolumn("goouc_fullexam_setting", ["weid" => $_W["uniacid"]], "freepoolnum");
			if (!empty($is_student)) {
				$list = pdo_fetchall("SELECT `id`,`name` FROM " . tablename("goouc_fullexam_test_type") . " WHERE weid=:weid AND istatus=1  AND pid = 0 AND status = 1 ORDER BY id ASC ", [":weid" => $_W["uniacid"]]);
			} else {
				$list = pdo_fetchall("SELECT `id`,`name` FROM " . tablename("goouc_fullexam_test_type") . " WHERE weid=:weid AND istatus=1 AND is_student = 2 AND pid = 0 AND status = 1 ORDER BY id ASC ", [":weid" => $_W["uniacid"]]);
			}
			if (!empty($list)) {
				foreach ($list as &$val) {
					$son = pdo_fetchall("SELECT `id`,`name`,price FROM " . tablename("goouc_fullexam_test_type") . " WHERE weid=:weid AND istatus=1 AND pid=:pid AND status = 1 ORDER BY id ASC ", [":weid" => $_W["uniacid"], ":pid" => $val["id"]]);
					if (!empty($son)) {
						foreach ($son as &$v) {
							$vson = pdo_fetchall("SELECT `id`,`name` FROM " . tablename("goouc_fullexam_test_type") . " WHERE weid=:weid AND istatus=1 AND pid=:pid AND status = 1 ORDER BY id ASC ", [":weid" => $_W["uniacid"], ":pid" => $v["id"]]);
							$v["is_can"] = 0;
							$is_member = pdo_getcolumn($this->t_user, ["weid" => $_W["uniacid"], "id" => $uid], "ismember");
							if ($v["price"] > 0) {
								$kid = pdo_getcolumn("goouc_fullexam_user_pool", ["weid" => $_W["uniacid"], "uid" => $uid, "poolid" => $v["id"], "istatus" => 1], "id");
								if (!empty($kid)) {
									$v["is_can"] = 1;
								}
							} else {
								$v["is_can"] = 1;
							}
							$z_vip = pdo_get("goouc_fullexam_user_member", ["weid" => $_W["uniacid"]]);
							$v["vip_price"] = $v["price"] * $z_vip["scale"];
							$v["vip_price"] = floor($v["vip_price"] * 100) / 100;
							if ($v["price"] > 0) {
								$kid = pdo_getcolumn("goouc_fullexam_user_pool", ["weid" => $_W["uniacid"], "uid" => $uid, "poolid" => $v["id"], "istatus" => 1], "id");
								if (!empty($kid)) {
									$v["is_can"] = 1;
								}
							} else {
								$v["is_can"] = 1;
							}
							if ($is_member == 1) {
								if ($v["vip_price"] <= 0) {
									$v["is_can"] = 1;
								}
							}
							$now_time = date("Y-m-d H:i:s");
							$cdkeys = pdo_getall("goouc_fullexam_cdkeys", ["weid" => $_W["uniacid"], "kpool_id" => $v["id"], "type" => 2], ["code_id"]);
							$cdkeys = array_column($cdkeys, "code_id");
							$cdkeys = implode(",", $cdkeys);
							if (!empty($cdkeys)) {
								$active = pdo_fetch(" SELECT * FROM " . tablename("goouc_fullexam_cdkey") . " WHERE weid =:weid AND uid=:uid AND status =2 AND display=1 AND kpool > :kpool AND cid in (" . $cdkeys . ")", [":weid" => $_W["uniacid"], "uid" => $uid, ":kpool" => $now_time]);
								if ($active) {
									$v["is_can"] = 1;
								}
							}
							if (!empty($vson)) {
								foreach ($vson as $k => $a) {
									$is_can = 0;
									if ($v["is_can"] == 1) {
										$is_can = 1;
									} else {
										if ($k < 1) {
											$is_can = 1;
										}
									}
									$vson[$k]["is_can"] = $is_can;
								}
								$v["son"] = $vson;
							}
						}
						unset($v);
						$val["son"] = $son;
					}
				}
				unset($val);
			}
			return $this->result(0, "获取专项", ["list" => $list, "pay_open" => $pay_open, "freenum" => $freepoolnum]);
		} elseif ($op == "special") {
			$special_id = intval($_GPC["typeId"]);
			$pid = pdo_getcolumn("goouc_fullexam_test_type", ["weid" => $_W["uniacid"], "id" => $special_id, "istatus" => 1, "status" => 1], "pid");
			$pool = pdo_fetchall("SELECT id,name,price FROM " . tablename("goouc_fullexam_test_type") . " WHERE weid=:weid AND istatus = 1 AND status = 1 AND id=:id ", [":weid" => $_W["uniacid"], ":id" => $pid]);
			$is_can = 0;
			if ($pool["price"] <= 0) {
				$is_can = 1;
			} else {
				$kid = pdo_getcolumn("goouc_fullexam_user_pool", ["weid" => $_W["uniacid"], "uid" => $uid, "poolid" => $pool["id"], "istatus" => 1], "id");
				if (!empty($kid)) {
					$is_can = 1;
				}
			}
			if ($is_can == 1) {
				$questionlist = pdo_fetchall("SELECT `id`,`type`,`question`,`qimage`,`qaudio`,`a_type`,`option`,`rightkey`,`analysis`,`aimage`,`analysis_audio` FROM " . tablename("goouc_fullexam_test") . " WHERE weid=:weid AND istatus=1 AND `type`!=0  AND type < 9 AND display=1 AND libraryid=:libraryid ORDER BY id ASC ", [":weid" => $_W["uniacid"], ":libraryid" => $special_id]);
				$total_qnum = count($questionlist);
			} else {
				$freepoolnum = pdo_getcolumn("goouc_fullexam_setting", ["weid" => $_W["uniacid"]], "freepoolnum");
				$questionlist = pdo_fetchall("SELECT `id`,`type`,`question`,`qimage`,`qaudio`,`a_type`,`option`,`rightkey`,`analysis`,`aimage`,`analysis_audio` FROM " . tablename("goouc_fullexam_test") . " WHERE weid=:weid AND istatus=1 AND `type`!=0  AND type < 9 AND display=1 AND libraryid=:libraryid ORDER BY id ASC LIMIT " . intval($freepoolnum), [":weid" => $_W["uniacid"], ":libraryid" => $special_id]);
				$total_qnum = count($questionlist);
			}
			$last_id = pdo_fetchcolumn("SELECT last_id FROM " . tablename("goouc_fullexam_user_special") . " WHERE weid=:weid AND uid=:uid AND special_id=:special_id AND istatus=1 ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":special_id" => $special_id]);
			$last_id = intval($last_id);
			if ($total_qnum <= $last_id) {
				$last_id = $total_qnum - 1;
			} else {
				if ($last_id == $total_qnum - 1) {
					$last_id = 0;
				}
			}
			if (!empty($questionlist)) {
				foreach ($questionlist as $key => $val) {
					$iscollect = pdo_getcolumn("goouc_fullexam_user_collection_praction", ["weid" => $_W["uniacid"], "uid" => $uid, "testid" => $val["id"], "test_type" => $val["type"]], "id");
					if ($iscollect) {
						$questionlist[$key]["wrong_have"] = 1;
					} else {
						$questionlist[$key]["wrong_have"] = 2;
					}
				}
				$list = $this->Makeformat($questionlist);
				return $this->result(0, "知识点专项练习试题,总题数,进度下标", ["list" => $list, "total_qnum" => $total_qnum, "last_id" => $last_id]);
			} else {
				return $this->result(0, "暂无该知识点试题数据", ["list" => [], "total_qnum" => 0, "have" => 2]);
			}
		} elseif ($op == "getalltypes") {
			$type_list = [1 => "单选题", 2 => "多选题", 3 => "判断题", 4 => "填空题", 5 => "语音题", 6 => "完形填空", 7 => "阅读理解", 8 => "简答题"];
			$typelist = [];
			foreach ($type_list as $key => $val) {
				if ($key == 5) {
					$q_have = pdo_fetchcolumn("select count(id) from " . tablename("goouc_fullexam_test") . " WHERE weid=:weid AND `type`=:type AND istatus=1 AND son_status=1 AND display=1 AND libraryid = :libraryid ", [":weid" => $_W["uniacid"], ":type" => $key, ":libraryid" => $lib_id]);
					if ($q_have == 0) {
						continue;
					}
				} else {
					$q_have = pdo_fetchcolumn("select count(id) from " . tablename("goouc_fullexam_test") . " WHERE weid=:weid AND `type`=:type AND istatus=1 AND display=1 AND libraryid = :libraryid ", [":weid" => $_W["uniacid"], ":type" => $key, ":libraryid" => $lib_id]);
					if ($q_have == 0) {
						continue;
					}
				}
				$typelist[] = ["id" => $key, "name" => $val];
			}
			$type_list_t = pdo_fetchall(" SELECT * FROM " . tablename("goouc_fullexam_son_simple") . " WHERE weid = :weid ORDER BY id", [":weid" => $_W["uniacid"]]);
			if (!empty($typelist)) {
				$son = 2;
				if (!empty($type_list_t)) {
					$son = 1;
				}
				return $this->result(0, "获取题型", ["type_list" => $typelist, "son" => $son]);
			} else {
				return $this->result(0, "暂无题型", ["type_list" => [], "have" => 2]);
			}
		} elseif ($op == "getallsimple") {
			$psize = 20;
			$pindex = max(1, $_GPC["page"]);
			$type_list_t = pdo_fetchall(" SELECT * FROM " . tablename("goouc_fullexam_son_simple") . " WHERE weid = :weid ORDER BY id DESC LIMIT " . ($pindex - 1) * $psize . "," . $psize, [":weid" => $_W["uniacid"]]);
			$total = pdo_fetchall(" SELECT * FROM " . tablename("goouc_fullexam_son_simple") . " WHERE weid = :weid ORDER BY id DESC ", [":weid" => $_W["uniacid"]]);
			$total = count($total) + 1;
			$type_list = [["id" => "0", "son_title" => "简答题"]];
			if (!empty($type_list_t)) {
				foreach ($type_list as $key => $value) {
					array_unshift($type_list_t, $value);
				}
				foreach ($type_list_t as $k => $v) {
					$type_list_t[$k]["son_title"] = $v["son_title"];
				}
			}
			if (!empty($type_list_t)) {
				return $this->result(0, "获取题型", ["type_list" => $type_list_t, "total" => $total, "psize" => $psize]);
			} else {
				return $this->result(0, "暂无题型", ["type_list" => []]);
			}
		} elseif ($op == "qtype") {
			$qtype = intval($_GPC["typeId"]);
			$uid = intval($_GPC["uid"]);
			if (empty($qtype) || empty($uid)) {
				return $this->result(1, "传递的参数不存在或失效", "1009");
			}
			$last_id = pdo_fetchcolumn("SELECT last_id FROM " . tablename("goouc_fullexam_user_qtype") . " WHERE weid=:weid AND uid=:uid AND type_id=:type_id AND istatus=1 ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":type_id" => $qtype]);
			$questionlist = pdo_fetchall("SELECT `id`,`type`,`title`,`question`,`qimage`,`qaudio`,`a_type`,`option`,`rightkey`,`analysis`,`aimage`,`createtime`,`analysis_audio` FROM " . tablename("goouc_fullexam_test") . " WHERE `weid`=:weid AND `istatus`=1  AND `type`=:qtype AND display=1 AND libraryid = :libraryid ORDER BY id ASC ", [":weid" => $_W["uniacid"], ":qtype" => $qtype, ":libraryid" => $lib_id]);
			$total_qnum = count($questionlist);
			$last_id = intval($last_id);
			if ($total_qnum <= $last_id) {
				$last_id = $total_qnum - 1;
			} else {
				if ($last_id == $total_qnum - 1) {
					$last_id = 0;
				}
			}
			if (!empty($questionlist)) {
				foreach ($questionlist as $key => $val) {
					$iscollect = pdo_getcolumn("goouc_fullexam_user_collection_praction", ["weid" => $_W["uniacid"], "uid" => $uid, "testid" => $val["id"], "test_type" => $val["type"]], "id");
					if ($iscollect) {
						$questionlist[$key]["wrong_have"] = 1;
					} else {
						$questionlist[$key]["wrong_have"] = 2;
					}
				}
				$list = $this->Makeformat($questionlist);
				return $this->result(0, "题型练习试题,总题数", ["list" => $list, "total_qnum" => $total_qnum, "last_id" => $last_id]);
			} else {
				return $this->result(0, "暂无该题型试题数据", ["list" => [], "total_qnum" => 0, "have" => 2]);
			}
		} elseif ($op == "simple_type") {
			$qtype = intval($_GPC["typeId"]);
			$son_type = $_GPC["son_type"];
			$uid = intval($_GPC["uid"]);
			if (empty($qtype) || empty($uid)) {
				return $this->result(1, "传递的参数不存在或失效", "1009");
			}
			$last_id = pdo_fetchcolumn("SELECT last_id FROM " . tablename("goouc_fullexam_user_qtype") . " WHERE weid=:weid AND uid=:uid AND type_id=:type_id AND istatus=1 ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":type_id" => $qtype]);
			$questionlist = pdo_fetchall("SELECT `id`,`type`,`title`,`question`,`qimage`,`qaudio`,`a_type`,`option`,`rightkey`,`analysis`,`aimage`,`createtime`,`analysis_audio` FROM " . tablename("goouc_fullexam_test") . " WHERE `weid`=:weid AND `istatus`=1 AND son_simple = :son_simple AND `type`=:qtype AND display=1 AND libraryid = :libraryid  ORDER BY id ASC ", [":weid" => $_W["uniacid"], ":qtype" => $qtype, ":son_simple" => $son_type, ":libraryid" => $lib_id]);
			$total_qnum = count($questionlist);
			$last_id = intval($last_id);
			if ($total_qnum <= $last_id) {
				$last_id = $total_qnum - 1;
			} else {
				if ($last_id == $total_qnum - 1) {
					$last_id = 0;
				}
			}
			if (!empty($questionlist)) {
				foreach ($questionlist as $key => $val) {
					$iscollect = pdo_getcolumn("goouc_fullexam_user_collection_praction", ["weid" => $_W["uniacid"], "uid" => $uid, "testid" => $val["id"], "test_type" => $val["type"]], "id");
					if ($iscollect) {
						$questionlist[$key]["wrong_have"] = 1;
					} else {
						$questionlist[$key]["wrong_have"] = 2;
					}
				}
				$list = $this->Makeformat($questionlist);
				return $this->result(0, "题型练习试题,总题数", ["list" => $list, "total_qnum" => $total_qnum, "last_id" => $last_id]);
			} else {
				return $this->result(0, "暂无该题型试题数据", ["list" => [], "total_qnum" => 0, "have" => 2]);
			}
		} elseif ($op == "notdone") {
			$testid_arr = pdo_fetchall("SELECT testid FROM " . tablename("goouc_fullexam_exercise") . " WHERE weid=:weid AND uid=:uid ORDER BY testid ASC ", [":weid" => $_W["uniacid"], ":uid" => $uid]);
			$newid_arr = [];
			if (!empty($testid_arr)) {
				foreach ($testid_arr as $key => $val) {
					$newid_arr[] = $val["testid"];
				}
			}
			$testid_str = implode("','", $newid_arr);
			if (!empty($testid_str)) {
				$where = "";
				$where .= " AND id NOT IN ('" . $testid_str . "') ";
				$questionlist = pdo_fetchall("SELECT id,`type`,question,qimage,qaudio,a_type,`option`,rightkey,analysis,aimage,analysis_audio FROM " . tablename("goouc_fullexam_test") . " WHERE weid=:weid AND istatus=1 AND `type`!=0 AND type < 8 " . $where . " AND display=1 AND libraryid = :libraryid ORDER BY id ASC ", [":weid" => $_W["uniacid"], ":libraryid" => $lib_id]);
				if (!empty($questionlist)) {
					foreach ($questionlist as $key => $val) {
						if ($val["type"] == 5) {
							$sonlist = pdo_fetchall("SELECT * FROM " . tablename("goouc_fullexam_test") . " WHERE weid=:weid AND pid=:pid ORDER BY id ASC ", [":weid" => $_W["uniacid"], ":pid" => $val["id"]]);
							foreach ($sonlist as $k => $v) {
								$have_do = pdo_fetch("SELECT id,testid,test_type FROM " . tablename("goouc_fullexam_exercise") . " WHERE weid=:weid AND uid=:uid AND testid=:testid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":testid" => $v["id"]]);
								if ($have_do) {
									unset($questionlist[$key]);
									break;
								}
							}
						}
					}
					if (!empty($questionlist)) {
						foreach ($questionlist as $key => $val) {
							$iscollect = pdo_getcolumn("goouc_fullexam_user_collection_praction", ["weid" => $_W["uniacid"], "uid" => $uid, "testid" => $val["id"], "test_type" => $val["type"]], "id");
							if ($iscollect) {
								$questionlist[$key]["wrong_have"] = 1;
							} else {
								$questionlist[$key]["wrong_have"] = 2;
							}
						}
						$list = $this->Makeformat($questionlist);
						$have = 1;
					} else {
						$list = [];
						$have = 2;
					}
					$total_qnum = count($list);
					return $this->result(0, "未做练习试题,总题数", ["list" => $list, "total_qnum" => $total_qnum, "have" => $have]);
				} else {
					return $this->result(0, "暂无未做练习试题", ["list" => [], "total_qnum" => 0, "have" => 2]);
				}
			} else {
				$where = "";
				$questionlist = pdo_fetchall("SELECT id,`type`,question,qimage,qaudio,a_type,`option`,rightkey,analysis,aimage,analysis_audio FROM " . tablename("goouc_fullexam_test") . " WHERE weid=:weid AND istatus=1 AND `type`!=0 AND type < 8 AND display=1 AND libraryid = :libraryid ORDER BY id ASC ", [":weid" => $_W["uniacid"], ":libraryid" => $lib_id]);
				if (!empty($questionlist)) {
					foreach ($questionlist as $key => $val) {
						$iscollect = pdo_getcolumn("goouc_fullexam_user_collection_praction", ["weid" => $_W["uniacid"], "uid" => $uid, "testid" => $val["id"], "test_type" => $val["type"]], "id");
						if ($iscollect) {
							$questionlist[$key]["wrong_have"] = 1;
						} else {
							$questionlist[$key]["wrong_have"] = 2;
						}
					}
					$list = $this->Makeformat($questionlist);
					$have = 1;
					$total_qnum = count($list);
					return $this->result(0, "未做练习试题,总题数", ["list" => $list, "total_qnum" => $total_qnum, "have" => $have]);
				} else {
					$have = 2;
					$list = [];
					$total_qnum = 0;
					return $this->result(0, "暂无未做练习试题", ["list" => [], "total_qnum" => 0, "have" => 2]);
				}
			}
		} elseif ($op == "todayerr_question") {
			$start = strtotime(date("Y-m-d"));
			$id_list = pdo_fetchall("SELECT testid,test_type FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND istatus=1 AND createtime > :sttime ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":sttime" => $start]);
			$err_id_list = pdo_fetchall("SELECT testid,test_type FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND istatus=1 ORDER BY createtime ASC ", [":weid" => $_W["uniacid"], ":uid" => $uid]);
			if (empty($id_list)) {
				return $this->result(1, "今日暂无错题", "1004");
			} else {
				$err_list = [];
				$errid_list = [];
				foreach ($err_id_list as $k => $v) {
					if ($v["test_type"] > 4) {
						$pid = pdo_getcolumn("goouc_fullexam_test", ["weid" => $_W["uniacid"], "id" => $v["testid"], "istatus" => 1], "pid");
						if (!in_array($pid, $errid_list)) {
							$errid_list[] = $pid;
							$err_list[] = pdo_fetch("SELECT `id`,`type`,`question`,`qimage`,`qaudio`,`a_type`,`option`,`rightkey`,`analysis`,`aimage`,`createtime`,`qvideo`,`analysis_audio` FROM " . tablename("goouc_fullexam_test") . " WHERE weid=:weid AND istatus=1 AND id=:id ", [":weid" => $_W["uniacid"], ":id" => $pid]);
						}
					} else {
						$err_list[] = pdo_fetch("SELECT `id`,`type`,`question`,`qimage`,`qaudio`,`a_type`,`option`,`rightkey`,`analysis`,`aimage`,`createtime`,`qvideo`,`analysis_audio` FROM " . tablename("goouc_fullexam_test") . " WHERE weid=:weid  AND istatus=1 AND id=:testid  ORDER BY id ASC ", [":weid" => $_W["uniacid"], ":testid" => $v["testid"]]);
					}
				}
				foreach ($err_list as $key => $val) {
					$iscollect = pdo_getcolumn("goouc_fullexam_user_collection_praction", ["weid" => $_W["uniacid"], "uid" => $uid, "testid" => $val["id"], "test_type" => $val["type"]], "id");
					if ($iscollect) {
						$err_list[$key]["wrong_have"] = 1;
					} else {
						$err_list[$key]["wrong_have"] = 2;
					}
				}
				$list = $this->Makeformat($err_list);
				$total = count($list);
				return $this->result(0, "今日错题", ["list" => $list, "total" => $total]);
			}
		} elseif ($op == "allerr_question") {
			$err_id_list = pdo_fetchall("SELECT testid,test_type FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND istatus=1 ORDER BY createtime ASC ", [":weid" => $_W["uniacid"], ":uid" => $uid]);
			if (empty($err_id_list)) {
				return $this->result(1, "暂无错题", "1004");
			} else {
				$err_list = [];
				$errid_list = [];
				foreach ($err_id_list as $k => $v) {
					if ($v["test_type"] > 4) {
						$pid = pdo_getcolumn("goouc_fullexam_test", ["weid" => $_W["uniacid"], "id" => $v["testid"], "istatus" => 1], "pid");
						if (!in_array($pid, $errid_list)) {
							$errid_list[] = $pid;
							$err_list[] = pdo_fetch("SELECT `id`,`type`,`question`,`qimage`,`qaudio`,`a_type`,`option`,`rightkey`,`analysis`,`aimage`,`createtime`,`qvideo`,`analysis_audio` FROM " . tablename("goouc_fullexam_test") . " WHERE weid=:weid AND istatus=1 AND id=:id ", [":weid" => $_W["uniacid"], ":id" => $pid]);
						}
					} else {
						$err_list[] = pdo_fetch("SELECT `id`,`type`,`question`,`qimage`,`qaudio`,`a_type`,`option`,`rightkey`,`analysis`,`aimage`,`createtime`,`qvideo`,`analysis_audio` FROM " . tablename("goouc_fullexam_test") . " WHERE weid=:weid  AND istatus=1 AND id=:testid  ORDER BY id ASC ", [":weid" => $_W["uniacid"], ":testid" => $v["testid"]]);
					}
				}
				foreach ($err_list as $key => $val) {
					$iscollect = pdo_getcolumn("goouc_fullexam_user_collection_praction", ["weid" => $_W["uniacid"], "uid" => $uid, "testid" => $val["id"], "test_type" => $val["type"]], "id");
					if ($iscollect) {
						$err_list[$key]["wrong_have"] = 1;
					} else {
						$err_list[$key]["wrong_have"] = 2;
					}
				}
				$list = $this->Makeformat($err_list);
				return $this->result(0, "全部错题", ["list" => $list]);
			}
		} elseif ($op == "geterr_bytype") {
			$typeId = intval($_GPC["typeId"]);
			$id_arr = pdo_fetchall("SELECT testid,test_type FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND istatus=1 AND test_type=:test_type ORDER BY id ASC ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":test_type" => $typeId]);
			if (empty($id_arr)) {
				return $this->result(0, "暂无该题型错题", "1005");
			} else {
				$err_list = [];
				$errid_list = [];
				foreach ($id_arr as $k => $v) {
					if ($v["test_type"] > 4) {
						$pid = pdo_getcolumn("goouc_fullexam_test", ["weid" => $_W["uniacid"], "id" => $v["testid"], "istatus" => 1], "pid");
						if (!in_array($pid, $errid_list)) {
							$errid_list[] = $pid;
							$err_list[] = pdo_fetch("SELECT `id`,`type`,`question`,`qimage`,`qaudio`,`a_type`,`option`,`rightkey`,`analysis`,`aimage`,`createtime`,`qvideo`,`analysis_audio` FROM " . tablename("goouc_fullexam_test") . " WHERE weid=:weid AND istatus=1 AND id=:id ", [":weid" => $_W["uniacid"], ":id" => $pid]);
						}
					} else {
						$err_list[] = pdo_fetch("SELECT `id`,`type`,`question`,`qimage`,`qaudio`,`a_type`,`option`,`rightkey`,`analysis`,`aimage`,`createtime`,`qvideo`,`analysis_audio` FROM " . tablename("goouc_fullexam_test") . " WHERE weid=:weid  AND istatus=1 AND id=:testid  ORDER BY id ASC ", [":weid" => $_W["uniacid"], ":testid" => $v["testid"]]);
					}
				}
				foreach ($err_list as $key => $val) {
					$iscollect = pdo_getcolumn("goouc_fullexam_user_collection_praction", ["weid" => $_W["uniacid"], "uid" => $uid, "testid" => $val["id"], "test_type" => $val["type"]], "id");
					if ($iscollect) {
						$err_list[$key]["wrong_have"] = 1;
					} else {
						$err_list[$key]["wrong_have"] = 2;
					}
				}
				$list = $this->Makeformat($err_list);
				$total = count($list);
				return $this->result(0, "该题型错题列表,总数", ["list" => $list, "total" => $total]);
			}
		} elseif ($op == "seeErr") {
			$paperid = intval($_GPC["paperid"]);
			$uid = intval($_GPC["uid"]);
			if (empty($paperid) || empty($uid)) {
				return $this->result(1, "传递的参数不存在", "1001");
			}
			$recordid = pdo_fetchcolumn("SELECT recordid FROM " . tablename("goouc_fullexam_user_doexam") . " WHERE weid=:weid AND uid=:uid AND examid=:examid ORDER BY recordid DESC LIMIT 1 ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":examid" => $paperid]);
			$list = pdo_fetchall("SELECT uid,examid,testid,test_type FROM " . tablename("goouc_fullexam_user_exam_answer") . " WHERE weid=:weid AND uid=:uid AND examid=:examid AND recordid=:recordid AND test_type != 0 AND isright=:isright ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":examid" => $paperid, ":recordid" => $recordid, ":isright" => 0]);
			$err_list = [];
			$errid_list = [];
			$err_id_list = $list;
			foreach ($err_id_list as $k => $v) {
				if ($v["test_type"] > 4 && $v["test_type"] < 8) {
					$pid = pdo_getcolumn("goouc_fullexam_test", ["weid" => $_W["uniacid"], "id" => $v["testid"], "istatus" => 1], "pid");
					if (!in_array($pid, $errid_list)) {
						$errid_list[] = $pid;
						$err_list[] = pdo_fetch("SELECT `id`,`type`,`question`,`qimage`,`qaudio`,`a_type`,`option`,`rightkey`,`analysis`,`aimage`,`createtime`,`qvideo`,`analysis_audio` FROM " . tablename("goouc_fullexam_test") . " WHERE weid=:weid AND istatus=1 AND id=:id ", [":weid" => $_W["uniacid"], ":id" => $pid]);
					}
				} else {
					$err_list[] = pdo_fetch("SELECT `id`,`type`,`question`,`qimage`,`qaudio`,`a_type`,`option`,`rightkey`,`analysis`,`aimage`,`createtime`,`qvideo`,`analysis_audio` FROM " . tablename("goouc_fullexam_test") . " WHERE weid=:weid  AND istatus=1 AND id=:testid  ORDER BY id ASC ", [":weid" => $_W["uniacid"], ":testid" => $v["testid"]]);
				}
			}
			foreach ($err_list as $key => $val) {
				$iscollect = pdo_getcolumn("goouc_fullexam_user_collection_praction", ["weid" => $_W["uniacid"], "uid" => $uid, "testid" => $val["id"], "test_type" => $val["type"]], "id");
				if ($iscollect) {
					$err_list[$key]["wrong_have"] = 1;
				} else {
					$err_list[$key]["wrong_have"] = 2;
				}
			}
			$list = $this->Makeformat($err_list, $uid, $paperid);
			$total = count($list);
			return $this->result(0, "本次考试错题列表,总数", ["list" => $list, "total" => $total]);
		} elseif ($op == "collection_question") {
			$id_list = pdo_fetchall("SELECT testid,test_type FROM " . tablename("goouc_fullexam_user_collection_praction") . " WHERE weid=:weid AND uid=:uid AND istatus=1 ORDER BY id ASC ", [":weid" => $_W["uniacid"], ":uid" => $uid]);
			if (!empty($id_list)) {
				$questionlist = [];
				foreach ($id_list as $key => $val) {
					$questionlist[] = pdo_fetch("SELECT `id`,`type`,`question`,`qimage`,`qaudio`,`a_type`,`option`,`rightkey`,`analysis`,`aimage`,`createtime`,`qvideo`,`analysis_audio` FROM " . tablename("goouc_fullexam_test") . " WHERE weid=:weid  AND istatus=1 AND id=:testid  ORDER BY id ASC ", [":weid" => $_W["uniacid"], ":testid" => $val["testid"]]);
				}
				if (!empty($questionlist)) {
					foreach ($questionlist as $key => $val) {
						$iscollect = pdo_getcolumn("goouc_fullexam_user_collection_praction", ["weid" => $_W["uniacid"], "uid" => $uid, "testid" => $val["id"], "test_type" => $val["type"]], "id");
						if ($iscollect) {
							$questionlist[$key]["wrong_have"] = 1;
						} else {
							$questionlist[$key]["wrong_have"] = 2;
						}
					}
				}
				$list = $this->Makeformat($questionlist);
				return $this->result(0, "全部收藏", ["list" => $list]);
			} else {
				return $this->result(1, "暂无收藏", "1004");
			}
		}
	}
	public function dopageMockexam_submit()
	{
		global $_W;
		global $_GPC;
		$uid = intval($_GPC["uid"]);
		$exam_type = intval($_GPC["exam_type"]);
		$answerdata = $_GPC["answerdata"];
		$answerdata = json_decode(htmlspecialchars_decode($answerdata), true);
		$usetime = $_GPC["usetime"];
		if (empty($uid)) {
			return $this->result(1, "传递的参数不存在或失效", "1001");
		}
		if (empty($exam_type)) {
			return $this->result(1, "传递的参数不存在或失效", "1002");
		}
		$user_info = pdo_fetch("SELECT `status`,`integral` FROM " . tablename("goouc_fullexam_user") . " WHERE weid=:weid AND id=:uid ", [":weid" => $_W["uniacid"], ":uid" => $uid]);
		if (empty($user_info)) {
			return $this->result(1, "用户不存在", "1003");
		}
		if ($user_info["status"] != 1) {
			return $this->result(1, "用户被禁用", "1004");
		}
		if ($exam_type == 1) {
			$paperid = intval($_GPC["paperid"]);
			$resuser["is_simple"] = 2;
			$questions = pdo_getall($this->t_paper_test, ["paperid" => $paperid], ["testid"]);
			foreach ($questions as $kk => $vv) {
				$type = pdo_getcolumn($this->t_test, ["id" => $vv["testid"], "weid" => $_W["uniacid"]], "type");
				if ($type == 8) {
					$resuser["is_simple"] = 1;
					break;
				}
			}
			if (empty($paperid)) {
				return $this->result(1, "传递的参数不存在或失效", "1005");
			}
			$paper_info = pdo_fetch("SELECT id,title,franction,total_franction,dnum FROM " . tablename("goouc_fullexam_paper") . " WHERE weid=:weid AND id=:paperid LIMIT 1 ", [":weid" => $_W["uniacid"], ":paperid" => $paperid]);
			if (empty($paper_info)) {
				return $this->result(1, "试卷信息错误,请联系管理员处理", "1006");
			}
			$this->updatePaperUserNum($paperid);
			$records = pdo_fetchcolumn("SELECT count(*) FROM " . tablename("goouc_fullexam_user_doexam") . " WHERE weid=:weid AND uid=:uid AND examid=:examid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":examid" => $paperid]);
			if (empty($records)) {
				$insert = [];
				$insert["uid"] = $uid;
				$insert["weid"] = $_W["uniacid"];
				$insert["examid"] = $paperid;
				$insert["recordid"] = 1;
				$insert["franction"] = 0;
				$insert["usetime"] = $usetime;
				$insert["createtime"] = time();
				pdo_insert('goouc_fullexam_user_doexam', $insert);
				$rid = pdo_insertid();
				$recordid = 1;
			} else {
				$insert = [];
				$insert["uid"] = $uid;
				$insert["weid"] = $_W["uniacid"];
				$insert["examid"] = $paperid;
				$insert["recordid"] = $records + 1;
				$insert["franction"] = 0;
				$insert["usetime"] = $usetime;
				$insert["createtime"] = time();
				pdo_insert('goouc_fullexam_user_doexam', $insert);
				$rid = pdo_insertid();
				$recordid = $records + 1;
			}
			foreach ($answerdata as $k => $v) {
				$type = $v["type"];
				$answer = $v["answer"];
				$tid = $v["tid"];
				if ($type == 2) {
					sort($answer);
					$answer = implode(",", $answer);
				}
				if ($type == 4) {
					if (strpos($answer, ",") !== false) {
						$str = $answer;
						$answer = str_replace(",", "", $str);
					} else {
						$answer = $answer;
					}
				}
				if ($type > 4 && $type < 8) {
					foreach ($answer as $kk => $vv) {
						$tid = $vv["tid"];
						$answer = $vv["answer"];
						$now_question_info = $this->get_one_question($tid);
						if (empty($answer) && $answer != 0) {
							$isright = 0;
						} else {
							if ($now_question_info["rightkey"] == $answer) {
								$isright = 1;
							} else {
								$isright = 0;
							}
						}
						$array = [];
						$array["isright"] = $isright;
						$array["weid"] = $_W["uniacid"];
						$array["examid"] = $paperid;
						$array["uid"] = $uid;
						$array["testid"] = $tid;
						$array["test_type"] = $type;
						$array["uanswer"] = $answer;
						$array["createtime"] = time();
						$array["recordid"] = $recordid;
						$array["type"] = $exam_type;
						pdo_insert('goouc_fullexam_user_exam_answer', $array);
						if ($isright) {
							$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
							if ($wrong_have) {
								pdo_delete("goouc_fullexam_user_wrong_praction", ["id" => $wrong_have["id"]]);
							}
							$this->updateQuestionMemberNum($tid, 3);
						} else {
							$wrong_arr = [];
							$wrong_arr["weid"] = $_W["uniacid"];
							$wrong_arr["uid"] = $uid;
							$wrong_arr["testid"] = $tid;
							$wrong_arr["test_type"] = $type;
							$wrong_arr["uanswer"] = $answer;
							$wrong_arr["createtime"] = time();
							$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:testid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":testid" => $tid]);
							if ($wrong_have) {
								pdo_update("goouc_fullexam_user_wrong_praction", $wrong_arr, ["id" => $wrong_have["id"]]);
							} else {
								pdo_insert('goouc_fullexam_user_wrong_praction', $wrong_arr);
							}
							$this->updateQuestionMemberNum($tid, 1);
						}
					}
				} else {
					$now_question_info = $this->get_one_question($tid);
					if (empty($answer) && $answer != 0) {
						$isright = 0;
					} else {
						if ($now_question_info["rightkey"] == $answer) {
							$isright = 1;
						} else {
							$isright = 0;
						}
					}
					$array = [];
					$array["isright"] = $isright;
					$array["weid"] = $_W["uniacid"];
					$array["examid"] = $paperid;
					$array["uid"] = $uid;
					$array["testid"] = $tid;
					$array["test_type"] = $type;
					$array["uanswer"] = $answer;
					$array["createtime"] = time();
					$array["recordid"] = $recordid;
					$array["type"] = $exam_type;
					pdo_insert('goouc_fullexam_user_exam_answer', $array);
					if ($isright) {
						$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
						if ($wrong_have) {
							pdo_delete("goouc_fullexam_user_wrong_praction", ["id" => $wrong_have["id"]]);
						}
						$this->updateQuestionMemberNum($tid, 3);
					} else {
						$wrong_arr = [];
						$wrong_arr["weid"] = $_W["uniacid"];
						$wrong_arr["uid"] = $uid;
						$wrong_arr["testid"] = $tid;
						$wrong_arr["test_type"] = $type;
						$wrong_arr["uanswer"] = $answer;
						$wrong_arr["createtime"] = time();
						$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:testid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":testid" => $tid]);
						if ($wrong_have) {
							pdo_update("goouc_fullexam_user_wrong_praction", $wrong_arr, ["id" => $wrong_have["id"]]);
						} else {
							pdo_insert('goouc_fullexam_user_wrong_praction', $wrong_arr);
						}
						$this->updateQuestionMemberNum($tid, 1);
					}
				}
			}
			$now_question = $this->get_record_question($paper_info, $recordid, $uid);
			$data = [];
			$data["franction"] = $now_question["user_score"];
			$userscore = $data["franction"];
			$resuser["score"] = $now_question["user_score"];
			pdo_update('goouc_fullexam_user_doexam', $data, ["uid" => $uid, "examid" => $paperid, "recordid" => $recordid]);
			$addcoinsql = "SELECT COUNT(*) FROM " . tablename("goouc_fullexam_user_exam_answer") . " WHERE weid=:weid AND uid=:uid AND examid=:examid AND recordid=:recordid AND isright=1 AND `type`=:exam_type ";
			$coinnumsql = "SELECT reward_integral FROM " . tablename("goouc_fullexam_setting") . " WHERE weid=:weid ";
			$coinnum = pdo_fetchcolumn($coinnumsql, [":weid" => $_W["uniacid"]]);
			$addcoin = pdo_fetchcolumn($addcoinsql, [":weid" => $_W["uniacid"], ":uid" => $uid, "examid" => $paperid, "recordid" => $recordid, "exam_type" => $exam_type]) * $coinnum;
			$setting = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_setting") . " WHERE weid=:weid ", [":weid" => $_W["uniacid"]]);
			if ($recordid == 1) {
				pdo_update("goouc_fullexam_user", ["integral +=" => $addcoin], ["id" => $uid]);
			}
			if ($userscore < $setting["pass"]) {
				$resuser["comment"] = "加油";
			} elseif ($setting["pass"] <= $userscore && $userscore < $setting["good"]) {
				$resuser["comment"] = "合格";
			} elseif ($setting["good"] <= $userscore && $userscore < $setting["excellent"]) {
				$resuser["comment"] = "良好";
			} elseif ($setting["excellent"] <= $userscore) {
				$resuser["comment"] = "优异";
			}
			$resuser["time"] = $usetime;
			$setting = pdo_fetch("SELECT franction,paper_time FROM " . tablename("goouc_fullexam_setting") . " WHERE weid=:weid ", [":weid" => $_W["uniacid"]]);
			$setting["franction"] = unserialize($setting["franction"]);
			$data = [];
			$setting_qnum = 0;
			$setting_score = 0;
			foreach ($setting["franction"] as $k => $v) {
				$data["type_num_" . $k] = $v["num_" . $k];
				$data["type_score_" . $k] = $v["num_" . $k] * $v["franction_" . $k];
				$setting_qnum += $data["type_num_" . $k];
				$setting_score += $data["type_score_" . $k];
			}
			$have = pdo_fetchall("SELECT * FROM " . tablename("goouc_fullexam_user_doexam") . " WHERE weid=:weid AND uid=:uid ", [":weid" => $_W["uniacid"], ":uid" => $uid]);
			$other_have = pdo_fetchall("SELECT * FROM " . tablename("goouc_fullexam_user_doother_exam") . " WHERE weid=:weid AND uid=:uid ", [":weid" => $_W["uniacid"], ":uid" => $uid]);
			if ($have || $other_have) {
				$full_mark = 0;
				$have_pass = 0;
				if (!empty($have)) {
					foreach ($have as $key => $val) {
						if ($val["franction"] == $paper_info["total_franction"]) {
							$full_mark += 1;
						}
						if ($val["franction"] < $setting["pass"]) {
							if ($setting["pass"] <= $userscore && $userscore != $paper_info["total_franction"]) {
								$have_pass += 1;
							}
						} else {
							$have_pass += 1;
						}
					}
				}
				if (!empty($other_have)) {
					foreach ($other_have as $kk => $vv) {
						if ($vv["franction"] == $setting_score) {
							$full_mark += 1;
						}
						if ($vv["franction"] < $setting["pass"]) {
							if ($setting["pass"] <= $userscore && $userscore != $paper_info["total_franction"]) {
								$have_pass += 1;
							}
						} else {
							$have_pass += 1;
						}
					}
				}
				if ($have_pass == 1) {
					$resuser["medal"] = "1";
				}
				if ($full_mark == 1 && $userscore == $paper_info["total_franction"]) {
					$resuser["medal"] = "2";
				} elseif ($full_mark == 3 && $userscore == $paper_info["total_franction"]) {
					$resuser["medal"] = "3";
				} elseif ($full_mark == 10 && $userscore == $paper_info["total_franction"]) {
					$resuser["medal"] = "5";
				} elseif ($full_mark == 30 && $userscore == $paper_info["total_franction"]) {
					$resuser["medal"] = "6";
				}
			} else {
				if ($setting["pass"] <= $userscore && $userscore != $paper_info["total_franction"]) {
					$resuser["medal"] = "1";
				}
				if ($userscore == $paper_info["total_franction"]) {
					$resuser["medal"] = "2";
				}
			}
			$right_num = pdo_fetchcolumn("SELECT count(*) FROM " . tablename("goouc_fullexam_user_exam_answer") . " WHERE weid=:weid AND uid=:uid AND examid=:examid AND recordid=:recordid AND `type`=1 AND isright=1 ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":examid" => $paperid, ":recordid" => $recordid]);
			$total_num = pdo_fetchall("SELECT pt.id,pt.test_type,pt.testid FROM " . tablename("goouc_fullexam_paper_test") . " pt JOIN " . tablename("goouc_fullexam_paper") . " p ON pt.paperid=p.id WHERE pt.weid=:weid AND pt.paperid=:paperid AND pt.istatus=1 ", [":weid" => $_W["uniacid"], ":paperid" => $paperid]);
			$b = 0;
			$a = 0;
			foreach ($total_num as $m => $n) {
				if ($n["test_type"] > 4) {
					$b++;
					$a += pdo_fetchcolumn("SELECT count(*) FROM " . tablename("goouc_fullexam_test") . " WHERE weid=:weid AND istatus=1 AND pid = :pid ", [":pid" => $n["testid"], ":weid" => $_W["uniacid"]]);
				}
			}
			$total_num = count($total_num) - $b + $a;
			if ($total_num != 0) {
				$right_lv = round($right_num / $total_num, 2) * 100;
			}
			if ($right_lv != 0) {
				$resuser["right_lv"] = $right_lv . "%";
			} else {
				$resuser["right_lv"] = 0;
			}
			$all = pdo_fetchall("SELECT uid,franction FROM " . tablename("goouc_fullexam_user_doexam") . " WHERE weid=:weid AND examid=:examid AND istatus=1 GROUP BY uid ORDER BY franction DESC ", [":weid" => $_W["uniacid"], ":examid" => $paperid]);
			if (!empty($all)) {
				for ($i = 0; $i < count($all); $i++) {
					for ($j = $i + 1; $j < count($all); $j++) {
						if ($all[$i] < $all[$j]) {
							$tmp = $all[$i];
							$all[$i] = $all[$j];
							$all[$j] = $tmp;
						}
					}
				}
				foreach ($all as $key => $val) {
					if ($uid == $val["uid"]) {
						$resuser["ranking"] = $key + 1;
					}
				}
			} else {
				$resuser["ranking"] = "暂无排名数据";
			}
			return $this->result(0, "全真模拟提交成功,成绩,时间,结果评测,正确率,排名,勋章(或有或无)", ["resuser" => $resuser, "rid" => $rid]);
		} elseif ($exam_type == 2) {
			$records = pdo_fetchcolumn("SELECT count(*) FROM " . tablename("goouc_fullexam_user_doother_exam") . " WHERE weid=:weid AND uid=:uid AND `type`=:type ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":type" => $exam_type]);
			if (empty($records)) {
				$insert = [];
				$insert["uid"] = $uid;
				$insert["weid"] = $_W["uniacid"];
				$insert["recordid"] = 1;
				$insert["franction"] = 0;
				$insert["usetime"] = $usetime;
				$insert["createtime"] = time();
				$insert["type"] = $exam_type;
				pdo_insert('goouc_fullexam_user_doother_exam', $insert);
				$recordid = 1;
			} else {
				$insert = [];
				$insert["uid"] = $uid;
				$insert["weid"] = $_W["uniacid"];
				$insert["recordid"] = $records + 1;
				$insert["franction"] = 0;
				$insert["usetime"] = $usetime;
				$insert["createtime"] = time();
				$insert["type"] = $exam_type;
				pdo_insert('goouc_fullexam_user_doother_exam', $insert);
				$recordid = $records + 1;
			}
			foreach ($answerdata as $k => $v) {
				$type = $v["type"];
				$answer = $v["answer"];
				$tid = $v["tid"];
				if ($type > 4) {
					foreach ($answer as $kk => $vv) {
						$tid = $vv["tid"];
						$answer = $vv["answer"];
						$now_question_info = $this->get_one_question($tid);
						if (empty($answer) && $answer != 0) {
							$isright = 0;
						} else {
							if ($now_question_info["rightkey"] == $answer) {
								$isright = 1;
							} else {
								$isright = 0;
							}
						}
						$array = [];
						$array["isright"] = $isright;
						$array["weid"] = $_W["uniacid"];
						$array["uid"] = $uid;
						$array["recordid"] = $recordid;
						$array["testid"] = $tid;
						$array["test_type"] = $type;
						$array["uanswer"] = $answer;
						$array["createtime"] = time();
						$array["type"] = $exam_type;
						pdo_insert('goouc_fullexam_user_doother_exam_answer', $array);
						if ($isright) {
							$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
							if ($wrong_have) {
								pdo_delete("goouc_fullexam_user_wrong_praction", ["id" => $wrong_have["id"]]);
							}
							$this->updateQuestionMemberNum($tid, 3);
						} else {
							$wrong_arr = [];
							$wrong_arr["weid"] = $_W["uniacid"];
							$wrong_arr["uid"] = $uid;
							$wrong_arr["testid"] = $tid;
							$wrong_arr["test_type"] = $type;
							$wrong_arr["uanswer"] = $answer;
							$wrong_arr["createtime"] = time();
							$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:testid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":testid" => $tid]);
							if ($wrong_have) {
								pdo_update("goouc_fullexam_user_wrong_praction", $wrong_arr, ["id" => $wrong_have["id"]]);
							} else {
								pdo_insert('goouc_fullexam_user_wrong_praction', $wrong_arr);
							}
							$this->updateQuestionMemberNum($tid, 1);
						}
					}
				} else {
					if ($type == 2) {
						sort($answer);
						$answer = implode(",", $answer);
					}
					if ($type == 4) {
						if (strpos($answer, ",") !== false) {
							$str = $answer;
							$answer = str_replace(",", "", $str);
						} else {
							$answer = $answer;
						}
					}
					$now_question_info = $this->get_one_question($tid);
					if (empty($answer) && $answer != 0) {
						$isright = 0;
					} else {
						if ($now_question_info["rightkey"] == $answer) {
							$isright = 1;
						} else {
							$isright = 0;
						}
					}
					$array = [];
					$array["isright"] = $isright;
					$array["weid"] = $_W["uniacid"];
					$array["uid"] = $uid;
					$array["testid"] = $tid;
					$array["test_type"] = $type;
					$array["uanswer"] = $answer;
					$array["createtime"] = time();
					$array["recordid"] = $recordid;
					$array["type"] = $exam_type;
					pdo_insert('goouc_fullexam_user_doother_exam_answer', $array);
					if ($isright) {
						$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
						if ($wrong_have) {
							pdo_delete("goouc_fullexam_user_wrong_praction", ["id" => $wrong_have["id"]]);
						}
						$this->updateQuestionMemberNum($tid, 3);
					} else {
						$wrong_arr = [];
						$wrong_arr["weid"] = $_W["uniacid"];
						$wrong_arr["uid"] = $uid;
						$wrong_arr["testid"] = $tid;
						$wrong_arr["test_type"] = $type;
						$wrong_arr["uanswer"] = $answer;
						$wrong_arr["createtime"] = time();
						$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:testid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":testid" => $tid]);
						if ($wrong_have) {
							pdo_update("goouc_fullexam_user_wrong_praction", $wrong_arr, ["id" => $wrong_have["id"]]);
						} else {
							pdo_insert('goouc_fullexam_user_wrong_praction', $wrong_arr);
						}
						$this->updateQuestionMemberNum($tid, 1);
					}
				}
			}
			$setting = pdo_fetch("SELECT franction,paper_time,pass,good,excellent FROM " . tablename("goouc_fullexam_setting") . " WHERE weid=:weid ", [":weid" => $_W["uniacid"]]);
			$setting["franction"] = unserialize($setting["franction"]);
			$data = [];
			$total_score = 0;
			$total_qnum = 0;
			foreach ($setting["franction"] as $key => $val) {
				$data["type_num_" . $key] = $val["num_" . $key];
				$data["type_score_" . $key] = $val["num_" . $key] * $val["franction_" . $key];
				$total_score += $data["type_score_" . $key];
				$total_qnum += $data["type_num_" . $key];
				$params = [];
				$params[":weid"] = $_W["uniacid"];
				$params[":uid"] = $uid;
				$params[":type"] = $exam_type;
				$params[":recordid"] = $recordid;
				$count_sql = " SELECT count(*) FROM " . tablename("goouc_fullexam_user_doother_exam_answer");
				$count_sql .= " WHERE recordid = :recordid ";
				$count_sql .= " AND weid = :weid ";
				$count_sql .= " AND uid = :uid ";
				$count_sql .= " AND type = :type ";
				$count_sql .= " AND isright = 1 ";
				if ($val["num_" . $key] > 0) {
					if ($key > 4) {
						$type5_score = 0;
						$count = " SELECT count(id) FROM " . tablename("goouc_fullexam_user_doother_exam_answer");
						$count .= " WHERE recordid = :recordid ";
						$count .= " AND weid = :weid ";
						$count .= " AND uid = :uid ";
						$count .= " AND type = :type ";
						$count .= " AND test_type = 5 ";
						$total_type5 = pdo_fetchcolumn($count, $params);
						$count .= " AND isright = 1 ";
						$right_type5 = pdo_fetchcolumn($count, $params);
						if ($val["num_" . $key] > 0) {
							$type5_totalfranction = $val["num_" . $key] * $val["franction_" . $key];
							if ($total_type5 != 0) {
								$every_score = round($type5_totalfranction / $total_type5);
							} else {
								$type5_score = 0;
							}
							$type5_score += $right_type5 * $every_score;
						}
					} elseif ($key == 1) {
						$count_sql .= " AND test_type = :test_type ";
						$params[":test_type"] = $key;
						$total = pdo_fetchcolumn($count_sql, $params);
						$type1 = $total * $val["franction_" . $key];
					} elseif ($key == 2) {
						$count_sql .= " AND test_type = :test_type ";
						$params[":test_type"] = $key;
						$total = pdo_fetchcolumn($count_sql, $params);
						$type2 = $total * $val["franction_" . $key];
					} elseif ($key == 3) {
						$count_sql .= " AND test_type = :test_type ";
						$params[":test_type"] = $key;
						$total = pdo_fetchcolumn($count_sql, $params);
						$type3 = $total * $val["franction_" . $key];
					} elseif ($key == 4) {
						$count_sql .= " AND test_type = :test_type ";
						$params[":test_type"] = $key;
						$total = pdo_fetchcolumn($count_sql, $params);
						$type4 = $total * $val["franction_" . $key];
					}
				}
			}
			$data = [];
			$data["franction"] = $type5_score + $type1 + $type2 + $type3 + $type4;
			$userscore = $data["franction"];
			pdo_update('goouc_fullexam_user_doother_exam', $data, ["uid" => $uid, "recordid" => $recordid, "weid" => $_W["uniacid"], "type" => $exam_type]);
			$addcoinsql = "SELECT COUNT(*) FROM " . tablename("goouc_fullexam_user_doother_exam_answer") . " WHERE weid=:weid AND uid=:uid AND recordid=:recordid AND isright=1 AND `type`=:exam_type ";
			$coinnumsql = "SELECT reward_integral FROM " . tablename("goouc_fullexam_setting") . " WHERE weid=:weid ";
			$coinnum = pdo_fetchcolumn($coinnumsql, [":weid" => $_W["uniacid"]]);
			$addcoin = pdo_fetchcolumn($addcoinsql, [":weid" => $_W["uniacid"], ":uid" => $uid, "recordid" => $recordid, ":exam_type" => $exam_type]) * $coinnum;
			if ($recordid == 1) {
				pdo_update("goouc_fullexam_user", ["integral +=" => $addcoin], ["id" => $uid]);
			}
			$resuser = [];
			if ($userscore < $setting["pass"]) {
				$resuser["comment"] = "加油";
			} elseif ($setting["pass"] <= $userscore && $userscore < $setting["good"]) {
				$resuser["comment"] = "合格";
			} elseif ($setting["good"] <= $userscore && $userscore < $setting["excellent"]) {
				$resuser["comment"] = "良好";
			} elseif ($setting["excellent"] <= $userscore) {
				$resuser["comment"] = "优异";
			}
			$resuser["score"] = $userscore;
			$resuser["time"] = $usetime;
			$have = pdo_fetchall("SELECT * FROM " . tablename("goouc_fullexam_user_doexam") . " WHERE weid=:weid AND uid=:uid ", [":weid" => $_W["uniacid"], ":uid" => $uid]);
			$other_have = pdo_fetchall("SELECT * FROM " . tablename("goouc_fullexam_user_doother_exam") . " WHERE weid=:weid AND uid=:uid ", [":weid" => $_W["uniacid"], ":uid" => $uid]);
			if ($have || $other_have) {
				$full_mark = 0;
				$have_pass = 0;
				if (!empty($have)) {
					foreach ($have as $key => $val) {
						$have[$key]["paper_score"] = pdo_fetchcolumn("SELECT total_franction FROM " . tablename("goouc_fullexam_paper") . " WHERE weid=:weid AND id=:id ", [":weid" => $_W["uniacid"], ":id" => $val["examid"]]);
						if ($val["franction"] == $have[$key]["paper_score"]) {
							$full_mark += 1;
						}
						if ($val["franction"] < $setting["pass"]) {
							if ($setting["pass"] <= $userscore && $userscore != $have[$key]["paper_score"]) {
								$have_pass += 1;
							}
						} else {
							$have_pass += 1;
						}
					}
				}
				if (!empty($other_have)) {
					foreach ($other_have as $kk => $vv) {
						if ($vv["franction"] == $total_score) {
							$full_mark += 1;
						}
						if ($vv["franction"] < $setting["pass"]) {
							if ($vv["franction"] >= $setting["pass"] && $vv["franction"] != $total_score) {
								$have_pass += 1;
							}
						} else {
							$have_pass += 1;
						}
					}
				}
				if ($have_pass == 1) {
					$resuser["medal"] = "1";
				}
				if ($full_mark == 1 && $userscore == $total_score) {
					$resuser["medal"] = "2";
				} elseif ($full_mark == 3 && $userscore == $total_score) {
					$resuser["medal"] = "3";
				} elseif ($full_mark == 10 && $userscore == $total_score) {
					$resuser["medal"] = "5";
				} elseif ($full_mark == 30 && $userscore == $total_score) {
					$resuser["medal"] = "6";
				}
			} else {
				if ($setting["pass"] <= $userscore && $userscore != $total_score) {
					$resuser["medal"] = "1";
				}
				if ($userscore == $total_score) {
					$resuser["medal"] = "2";
				}
			}
			$rightall = pdo_fetchall("SELECT id,testid,test_type FROM " . tablename("goouc_fullexam_user_doother_exam_answer") . " WHERE weid=:weid AND uid=:uid AND recordid=:recordid AND `type`=:type AND isright=1 ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":recordid" => $recordid, ":type" => $exam_type]);
			$right_num = pdo_fetchcolumn("SELECT count(*) FROM " . tablename("goouc_fullexam_user_doother_exam_answer") . " WHERE weid=:weid AND uid=:uid AND recordid=:recordid AND `type`=:type AND isright=1 ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":recordid" => $recordid, ":type" => $exam_type]);
			$par = 0;
			$son = 0;
			$parent_arr = [];
			if (!empty($rightall)) {
				foreach ($rightall as $kkk => $vvv) {
					if ($vvv["test_type"] > 4) {
						$son++;
						$small_info = pdo_fetch("SELECT id,pid FROM " . tablename("goouc_fullexam_test") . " WHERE weid=:weid AND istatus=1 AND id=:id ", [":weid" => $_W["uniacid"], ":id" => $vvv["testid"]]);
						$parent = pdo_fetch("SELECT id,`type` FROM " . tablename("goouc_fullexam_test") . " WHERE weid=:weid AND istatus=1 AND id=:pid ", [":weid" => $_W["uniacid"], ":pid" => $small_info["pid"]]);
						if (!in_array($parent, $parent_arr)) {
							$parent_arr[] = $parent;
							$par++;
						}
					}
				}
				$total_num = $total_qnum - $par + $son;
				if (!empty($total_num)) {
					$right_lv = round($right_num / $total_num, 2) * 100;
				}
			} else {
				$right_lv = 0;
			}
			if ($right_lv != 0) {
				$resuser["right_lv"] = $right_lv . "%";
			} else {
				$resuser["right_lv"] = 0;
			}
			$all = pdo_fetchall("SELECT uid,franction FROM " . tablename("goouc_fullexam_user_doother_exam") . " WHERE weid=:weid AND istatus=1 AND `type`=:type GROUP BY uid ORDER BY franction DESC ", [":weid" => $_W["uniacid"], ":type" => $exam_type]);
			if (!empty($all)) {
				for ($i = 0; $i < count($all); $i++) {
					for ($j = $i + 1; $j < count($all); $j++) {
						if ($all[$i] < $all[$j]) {
							$tmp = $all[$i];
							$all[$i] = $all[$j];
							$all[$j] = $tmp;
						}
					}
				}
				foreach ($all as $key => $val) {
					if ($uid == $val["uid"]) {
						$resuser["ranking"] = $key + 1;
					}
				}
			} else {
				$resuser["ranking"] = "暂无排名";
			}
			return $this->result(0, "优先未做提交成功,成绩,时间,结果评测,正确率,排名,勋章(或有或无)", ["resuser" => $resuser]);
		} elseif ($exam_type == 3) {
			$records = pdo_fetchcolumn("SELECT count(*) FROM " . tablename("goouc_fullexam_user_doother_exam") . " WHERE weid=:weid AND uid=:uid AND `type`=:type ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":type" => $exam_type]);
			if (empty($records)) {
				$insert = [];
				$insert["uid"] = $uid;
				$insert["weid"] = $_W["uniacid"];
				$insert["recordid"] = 1;
				$insert["franction"] = 0;
				$insert["usetime"] = $usetime;
				$insert["createtime"] = time();
				$insert["type"] = $exam_type;
				pdo_insert('goouc_fullexam_user_doother_exam', $insert);
				$recordid = 1;
			} else {
				$insert = [];
				$insert["uid"] = $uid;
				$insert["weid"] = $_W["uniacid"];
				$insert["recordid"] = $records + 1;
				$insert["franction"] = 0;
				$insert["usetime"] = $usetime;
				$insert["createtime"] = time();
				$insert["type"] = $exam_type;
				pdo_insert('goouc_fullexam_user_doother_exam', $insert);
				$recordid = $records + 1;
			}
			foreach ($answerdata as $k => $v) {
				$type = $v["type"];
				$answer = $v["answer"];
				$tid = $v["tid"];
				if ($type > 4) {
					foreach ($answer as $kk => $vv) {
						$tid = $vv["tid"];
						$answer = $vv["answer"];
						$now_question_info = $this->get_one_question($tid);
						if (empty($answer) && $answer != 0) {
							$isright = 0;
						} else {
							if ($now_question_info["rightkey"] == $answer) {
								$isright = 1;
							} else {
								$isright = 0;
							}
						}
						$array = [];
						$array["isright"] = $isright;
						$array["weid"] = $_W["uniacid"];
						$array["uid"] = $uid;
						$array["recordid"] = $recordid;
						$array["testid"] = $tid;
						$array["test_type"] = $type;
						$array["uanswer"] = $answer;
						$array["createtime"] = time();
						$array["type"] = $exam_type;
						pdo_insert('goouc_fullexam_user_doother_exam_answer', $array);
						if ($isright) {
							$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
							if ($wrong_have) {
								pdo_delete("goouc_fullexam_user_wrong_praction", ["id" => $wrong_have["id"]]);
							}
							$this->updateQuestionMemberNum($tid, 3);
						} else {
							$wrong_arr = [];
							$wrong_arr["weid"] = $_W["uniacid"];
							$wrong_arr["uid"] = $uid;
							$wrong_arr["testid"] = $tid;
							$wrong_arr["test_type"] = $type;
							$wrong_arr["uanswer"] = $answer;
							$wrong_arr["createtime"] = time();
							$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:testid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":testid" => $tid]);
							if ($wrong_have) {
								pdo_update("goouc_fullexam_user_wrong_praction", $wrong_arr, ["id" => $wrong_have["id"]]);
							} else {
								pdo_insert('goouc_fullexam_user_wrong_praction', $wrong_arr);
							}
							$this->updateQuestionMemberNum($tid, 1);
						}
					}
				} else {
					if ($type == 2) {
						sort($answer);
						$answer = implode(",", $answer);
					}
					if ($type == 4) {
						if (strpos($answer, ",") !== false) {
							$str = $answer;
							$answer = str_replace(",", "", $str);
						} else {
							$answer = $answer;
						}
					}
					$now_question_info = $this->get_one_question($tid);
					if (empty($answer) && $answer != 0) {
						$isright = 0;
					} else {
						if ($now_question_info["rightkey"] == $answer) {
							$isright = 1;
						} else {
							$isright = 0;
						}
					}
					$array = [];
					$array["isright"] = $isright;
					$array["weid"] = $_W["uniacid"];
					$array["uid"] = $uid;
					$array["testid"] = $tid;
					$array["test_type"] = $type;
					$array["uanswer"] = $answer;
					$array["createtime"] = time();
					$array["recordid"] = $recordid;
					$array["type"] = $exam_type;
					pdo_insert('goouc_fullexam_user_doother_exam_answer', $array);
					if ($isright) {
						$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
						if ($wrong_have) {
							pdo_delete("goouc_fullexam_user_wrong_praction", ["id" => $wrong_have["id"]]);
						}
						$this->updateQuestionMemberNum($tid, 3);
					} else {
						$wrong_arr = [];
						$wrong_arr["weid"] = $_W["uniacid"];
						$wrong_arr["uid"] = $uid;
						$wrong_arr["testid"] = $tid;
						$wrong_arr["test_type"] = $type;
						$wrong_arr["uanswer"] = $answer;
						$wrong_arr["createtime"] = time();
						$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:testid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":testid" => $tid]);
						if ($wrong_have) {
							pdo_update("goouc_fullexam_user_wrong_praction", $wrong_arr, ["id" => $wrong_have["id"]]);
						} else {
							pdo_insert('goouc_fullexam_user_wrong_praction', $wrong_arr);
						}
						$this->updateQuestionMemberNum($tid, 1);
					}
				}
			}
			$setting = pdo_fetch("SELECT franction,paper_time,pass,good,excellent FROM " . tablename("goouc_fullexam_setting") . " WHERE weid=:weid ", [":weid" => $_W["uniacid"]]);
			$setting["franction"] = unserialize($setting["franction"]);
			$data = [];
			$total_score = 0;
			$total_qnum = 0;
			foreach ($setting["franction"] as $key => $val) {
				$data["type_num_" . $key] = $val["num_" . $key];
				$data["type_score_" . $key] = $val["num_" . $key] * $val["franction_" . $key];
				$total_score += $data["type_score_" . $key];
				$total_qnum += $data["type_num_" . $key];
				$params = [];
				$params[":weid"] = $_W["uniacid"];
				$params[":uid"] = $uid;
				$params[":type"] = $exam_type;
				$params[":recordid"] = $recordid;
				$count_sql = " SELECT count(*) FROM " . tablename("goouc_fullexam_user_doother_exam_answer");
				$count_sql .= " WHERE recordid = :recordid ";
				$count_sql .= " AND weid = :weid ";
				$count_sql .= " AND uid = :uid ";
				$count_sql .= " AND type = :type ";
				$count_sql .= " AND isright = 1 ";
				if ($val["num_" . $key] > 0) {
					if ($key > 4) {
						$type5_score = 0;
						$count = " SELECT count(id) FROM " . tablename("goouc_fullexam_user_doother_exam_answer");
						$count .= " WHERE recordid = :recordid ";
						$count .= " AND weid = :weid ";
						$count .= " AND uid = :uid ";
						$count .= " AND type = :type ";
						$count .= " AND test_type = 5 ";
						$total_type5 = pdo_fetchcolumn($count, $params);
						$count .= " AND isright = 1 ";
						$right_type5 = pdo_fetchcolumn($count, $params);
						if ($val["num_" . $key] > 0) {
							$type5_totalfranction = $val["num_" . $key] * $val["franction_" . $key];
							if ($total_type5 != 0) {
								$every_score = round($type5_totalfranction / $total_type5);
							} else {
								$type5_score = 0;
							}
							$type5_score += $right_type5 * $every_score;
						}
					} elseif ($key == 1) {
						$params[":test_type"] = $key;
						$count_sql .= " AND test_type = :test_type ";
						$total = pdo_fetchcolumn($count_sql, $params);
						$type1 = $total * $val["franction_" . $key];
					} elseif ($key == 2) {
						$params[":test_type"] = $key;
						$count_sql .= " AND test_type = :test_type ";
						$total = pdo_fetchcolumn($count_sql, $params);
						$type2 = $total * $val["franction_" . $key];
					} elseif ($key == 3) {
						$params[":test_type"] = $key;
						$count_sql .= " AND test_type = :test_type ";
						$total = pdo_fetchcolumn($count_sql, $params);
						$type3 = $total * $val["franction_" . $key];
					} elseif ($key == 4) {
						$params[":test_type"] = $key;
						$count_sql .= " AND test_type = :test_type ";
						$total = pdo_fetchcolumn($count_sql, $params);
						$type4 = $total * $val["franction_" . $key];
					}
				}
			}
			$data = [];
			$data["franction"] = $type5_score + $type1 + $type2 + $type3 + $type4;
			$userscore = $data["franction"];
			pdo_update('goouc_fullexam_user_doother_exam', $data, ["uid" => $uid, "recordid" => $recordid, "weid" => $_W["uniacid"], "type" => $exam_type]);
			$addcoinsql = "SELECT COUNT(*) FROM " . tablename("goouc_fullexam_user_doother_exam_answer") . " WHERE weid=:weid AND uid=:uid AND recordid=:recordid AND isright=1 AND `type`=:exam_type ";
			$coinnumsql = "SELECT reward_integral FROM " . tablename("goouc_fullexam_setting") . " WHERE weid=:weid ";
			$coinnum = pdo_fetchcolumn($coinnumsql, [":weid" => $_W["uniacid"]]);
			$addcoin = pdo_fetchcolumn($addcoinsql, [":weid" => $_W["uniacid"], ":uid" => $uid, "recordid" => $recordid, ":exam_type" => $exam_type]) * $coinnum;
			if ($recordid == 1) {
				pdo_update("goouc_fullexam_user", ["integral +=" => $addcoin], ["id" => $uid]);
			}
			$resuser = [];
			if ($userscore < $setting["pass"]) {
				$resuser["comment"] = "加油";
			} elseif ($setting["pass"] <= $userscore && $userscore < $setting["good"]) {
				$resuser["comment"] = "合格";
			} elseif ($setting["good"] <= $userscore && $userscore < $setting["excellent"]) {
				$resuser["comment"] = "良好";
			} elseif ($setting["excellent"] <= $userscore) {
				$resuser["comment"] = "优异";
			}
			$resuser["score"] = $userscore;
			$resuser["time"] = $usetime;
			$have = pdo_fetchall("SELECT * FROM " . tablename("goouc_fullexam_user_doexam") . " WHERE weid=:weid AND uid=:uid ", [":weid" => $_W["uniacid"], ":uid" => $uid]);
			$other_have = pdo_fetchall("SELECT * FROM " . tablename("goouc_fullexam_user_doother_exam") . " WHERE weid=:weid AND uid=:uid ", [":weid" => $_W["uniacid"], ":uid" => $uid]);
			if ($have || $other_have) {
				$full_mark = 0;
				$have_pass = 0;
				if (!empty($have)) {
					foreach ($have as $key => $val) {
						$have[$key]["paper_score"] = pdo_fetchcolumn("SELECT total_franction FROM " . tablename("goouc_fullexam_paper") . " WHERE weid=:weid AND id=:id ", [":weid" => $_W["uniacid"], ":id" => $val["examid"]]);
						if ($val["franction"] == $have[$key]["paper_score"]) {
							$full_mark += 1;
						}
						if ($val["franction"] < $setting["pass"]) {
							if ($setting["pass"] <= $userscore && $userscore != $have[$key]["paper_score"]) {
								$have_pass += 1;
							}
						} else {
							$have_pass += 1;
						}
					}
				}
				if (!empty($other_have)) {
					foreach ($other_have as $kk => $vv) {
						if ($vv["franction"] == $total_score) {
							$full_mark += 1;
						}
						if ($vv["franction"] < $setting["pass"]) {
							if ($setting["pass"] <= $userscore && $userscore != $total_score) {
								$have_pass += 1;
							}
						} else {
							$have_pass += 1;
						}
					}
				}
				if ($have_pass == 1) {
					$resuser["medal"] = "1";
				}
				if ($full_mark == 1 && $userscore == $total_score) {
					$resuser["medal"] = "2";
				} elseif ($full_mark == 3 && $userscore == $total_score) {
					$resuser["medal"] = "3";
				} elseif ($full_mark == 10 && $userscore == $total_score) {
					$resuser["medal"] = "5";
				} elseif ($full_mark == 30 && $userscore == $total_score) {
					$resuser["medal"] = "6";
				}
			} else {
				if ($setting["pass"] <= $userscore && $userscore != $total_score) {
					$resuser["medal"] = "1";
				}
				if ($userscore == $total_score) {
					$resuser["medal"] = "2";
				}
			}
			$rightall = pdo_fetchall("SELECT id,testid,test_type FROM " . tablename("goouc_fullexam_user_doother_exam_answer") . " WHERE weid=:weid AND uid=:uid AND recordid=:recordid AND `type`=:type AND isright=1 ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":recordid" => $recordid, ":type" => $exam_type]);
			$right_num = pdo_fetchcolumn("SELECT count(*) FROM " . tablename("goouc_fullexam_user_doother_exam_answer") . " WHERE weid=:weid AND uid=:uid AND recordid=:recordid AND `type`=:type AND isright=1 ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":recordid" => $recordid, ":type" => $exam_type]);
			$par = 0;
			$son = 0;
			$parent_arr = [];
			if (!empty($rightall)) {
				foreach ($rightall as $kkk => $vvv) {
					if ($vvv["test_type"] > 4) {
						$son++;
						$small_info = pdo_fetch("SELECT id,pid FROM " . tablename("goouc_fullexam_test") . " WHERE weid=:weid AND istatus=1 AND id=:id ", [":weid" => $_W["uniacid"], ":id" => $vvv["testid"]]);
						$parent = pdo_fetch("SELECT id,`type` FROM " . tablename("goouc_fullexam_test") . " WHERE weid=:weid AND istatus=1 AND id=:pid ", [":weid" => $_W["uniacid"], ":pid" => $small_info["pid"]]);
						if (!in_array($parent, $parent_arr)) {
							$parent_arr[] = $parent;
							$par++;
						}
					}
				}
				$total_num = $total_qnum - $par + $son;
				if (!empty($total_num)) {
					$right_lv = round($right_num / $total_num, 2) * 100;
				}
			} else {
				$right_lv = 0;
			}
			if ($right_lv != 0) {
				$resuser["right_lv"] = $right_lv . "%";
			} else {
				$resuser["right_lv"] = 0;
			}
			$all = pdo_fetchall("SELECT uid,franction FROM " . tablename("goouc_fullexam_user_doother_exam") . " WHERE weid=:weid AND istatus=1 AND `type`=:type GROUP BY uid ORDER BY franction DESC ", [":weid" => $_W["uniacid"], ":type" => $exam_type]);
			if (!empty($all)) {
				for ($i = 0; $i < count($all); $i++) {
					for ($j = $i + 1; $j < count($all); $j++) {
						if ($all[$i] < $all[$j]) {
							$tmp = $all[$i];
							$all[$i] = $all[$j];
							$all[$j] = $tmp;
						}
					}
				}
				foreach ($all as $key => $val) {
					if ($uid == $val["uid"]) {
						$resuser["ranking"] = $key + 1;
					}
				}
			} else {
				$resuser["ranking"] = "暂无排名";
			}
			return $this->result(0, "智能考试提交成功,成绩,时间,结果评测,正确率,排名,勋章(或许有或许无)", ["resuser" => $resuser]);
		}
	}
	public function get_one_question($questionid)
	{
		global $_W;
		$sql = "SELECT * FROM " . tablename("goouc_fullexam_test");
		$sql .= " WHERE id = :id AND istatus=1 AND weid = :weid LIMIT 1";
		$question_item = pdo_fetch($sql, [":id" => $questionid, ":weid" => $_W["uniacid"]]);
		return $question_item;
	}
	public function get_one_user_question($array, $exam_type)
	{
		global $_GPC;
		global $_W;
		$sql = "SELECT * FROM " . tablename("goouc_fullexam_user_exam_answer");
		if ($exam_type == 1) {
			$sql .= " WHERE recordid = :recordid ";
		} else {
			$sql .= " WHERE recordid is null ";
		}
		$sql .= " AND examid = :examid ";
		$sql .= " AND testid = :testid ";
		$sql .= " AND uid = :uid ";
		$sql .= " AND type = :exam_type ";
		$sql .= " AND weid = :weid LIMIT 1";
		$question_item = pdo_fetch($sql, $array);
		return $question_item;
	}
	public function updatePaperUserNum($paperid)
	{
		global $_W;
		$set = " dnum = dnum + 1 ";
		pdo_query('update ' . tablename('goouc_fullexam_paper') . ' set ' . $set . " where id=:id and weid=:weid ", [":id" => $paperid, ":weid" => $_W["uniacid"]]);
	}
	public function updateQuestionMemberNum($questionid, $type)
	{
		switch ($type) {
			case 1:
				$set = " anum = anum + 1";
				break;
			case 2:
				$set = " rnum = rnum + 1";
				break;
			case 3:
				$set = " rnum = rnum + 1, anum = anum + 1";
				break;
		}
		pdo_query('update ' . tablename('goouc_fullexam_test') . ' set ' . $set . " where id=:id", [":id" => $questionid]);
	}
	public function get_record_question($array, $recordid, $uid)
	{
		global $_W;
		$params = [];
		$params[":paperid"] = $array["id"];
		$params[":recordid"] = $recordid;
		$params[":weid"] = $_W["uniacid"];
		$params[":uid"] = $uid;
		$num5 = pdo_fetchcolumn("SELECT count(*) FROM " . tablename("goouc_fullexam_paper_test") . " WHERE weid=:weid AND paperid=:paperid AND istatus=1 AND test_type=5 ", [":weid" => $_W["uniacid"], ":paperid" => $array["id"]]);
		$num6 = pdo_fetchcolumn("SELECT count(*) FROM " . tablename("goouc_fullexam_paper_test") . " WHERE weid=:weid AND paperid=:paperid AND istatus=1 AND test_type=6 ", [":weid" => $_W["uniacid"], ":paperid" => $array["id"]]);
		$num7 = pdo_fetchcolumn("SELECT count(*) FROM " . tablename("goouc_fullexam_paper_test") . " WHERE weid=:weid AND paperid=:paperid AND istatus=1 AND test_type=7 ", [":weid" => $_W["uniacid"], ":paperid" => $array["id"]]);
		$array["franction"] = unserialize($array["franction"]);
		foreach ($array["franction"] as $key => $val) {
			if ($val["num_" . $key] >= 0) {
				$params[":type"] = 1;
				$count_sql = "SELECT COUNT(id) FROM " . tablename("goouc_fullexam_user_exam_answer");
				$count_sql .= " WHERE recordid = :recordid ";
				$count_sql .= " AND examid = :paperid ";
				$count_sql .= " AND weid = :weid ";
				$count_sql .= " AND isright = 1 ";
				$count_sql .= " AND type = :type ";
				$count_sql .= " AND uid = :uid ";
				if ($key == 5) {
					$type5_score = 0;
					$count = " SELECT count(id) FROM " . tablename("goouc_fullexam_user_exam_answer");
					$count .= " WHERE recordid = :recordid ";
					$count .= " AND examid = :paperid ";
					$count .= " AND weid = :weid ";
					$count .= " AND type = :type ";
					$count .= " AND test_type = 5 ";
					$count .= " AND uid = :uid ";
					$total_type5 = pdo_fetchcolumn($count, $params);
					$count .= " AND isright = 1 ";
					$right_type5 = pdo_fetchcolumn($count, $params);
					$type5_franction = $val["franction_" . $key];
					if ($num5 > 0) {
						$total5_franction = $num5 * $type5_franction;
						if ($total_type5 != 0) {
							$one_score = round($total5_franction / $total_type5);
						}
						$type5_score += $one_score * $right_type5;
					}
				} elseif ($key == 6) {
					$type6_score = 0;
					$count = " SELECT count(id) FROM " . tablename("goouc_fullexam_user_exam_answer");
					$count .= " WHERE recordid = :recordid ";
					$count .= " AND examid = :paperid ";
					$count .= " AND weid = :weid ";
					$count .= " AND type = :type ";
					$count .= " AND test_type = 6 ";
					$count .= " AND uid = :uid ";
					$total_type6 = pdo_fetchcolumn($count, $params);
					$count .= " AND isright = 1 ";
					$right_type6 = pdo_fetchcolumn($count, $params);
					$type6_franction = $val["franction_" . $key];
					if ($num6 > 0) {
						$total6_franction = $num6 * $type6_franction;
						if ($total_type6 != 0) {
							$one_score = round($total6_franction / $total_type6);
						}
						$type6_score += $one_score * $right_type6;
					}
				} elseif ($key == 7) {
					$type7_score = 0;
					$count = " SELECT count(id) FROM " . tablename("goouc_fullexam_user_exam_answer");
					$count .= " WHERE recordid = :recordid ";
					$count .= " AND examid = :paperid ";
					$count .= " AND weid = :weid ";
					$count .= " AND type = :type ";
					$count .= " AND test_type = 7 ";
					$count .= " AND uid = :uid ";
					$total_type7 = pdo_fetchcolumn($count, $params);
					$count .= " AND isright = 1 ";
					$right_type7 = pdo_fetchcolumn($count, $params);
					$type7_franction = $val["franction_" . $key];
					if ($num7 > 0) {
						$total7_franction = $num7 * $type7_franction;
						if ($total_type7 != 0) {
							$one_score = round($total7_franction / $total_type7);
						}
						$type7_score += $one_score * $right_type7;
					}
				} elseif ($key == 1) {
					$count_sql .= " AND test_type = 1 ";
					$total = pdo_fetchcolumn($count_sql, $params);
					$type1_score = intval($total) * intval($val["franction_" . $key]);
				} elseif ($key == 2) {
					$count_sql .= " AND test_type = 2 ";
					$total = pdo_fetchcolumn($count_sql, $params);
					$type2_score = intval($total) * intval($val["franction_" . $key]);
				} elseif ($key == 3) {
					$count_sql .= " AND test_type = 3 ";
					$total = pdo_fetchcolumn($count_sql, $params);
					$type3_score = intval($total) * intval($val["franction_" . $key]);
				} elseif ($key == 4) {
					$count_sql .= " AND test_type = 4 ";
					$total = pdo_fetchcolumn($count_sql, $params);
					$type4_score = intval($total) * intval($val["franction_" . $key]);
				}
			}
		}
		$data = [];
		$data["user_score"] = $type5_score + $type1_score + $type2_score + $type3_score + $type4_score + $type6_score + $type7_score;
		return $data;
	}
	public function dopageAddWrong()
	{
		global $_W;
		global $_GPC;
		$uid = $_GPC["uid"];
		$tid = $_GPC["tid"];
		$test_type = $_GPC["test_type"];
		$iscollect = $_GPC["wrong_have"];
		if (empty($uid) || empty($tid) || empty($test_type) || empty($iscollect)) {
			return $this->result(1, "传递的参数不存在或失效", "1001");
		}
		$user_info = pdo_fetch("SELECT `status` FROM " . tablename("goouc_fullexam_user") . " WHERE weid=:weid AND id=:uid ", [":weid" => $_W["uniacid"], ":uid" => $uid]);
		if (empty($user_info)) {
			return $this->result(1, "用户不存在", "1002");
		}
		if ($user_info["status"] != 1) {
			return $this->result(1, "用户被禁用", "1003");
		}
		$have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_collection_praction") . " WHERE weid=:weid AND istatus=1 AND uid=:uid AND testid=:testid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":testid" => $tid]);
		$mess = 0;
		if (empty($have)) {
			$insert = [];
			$insert["weid"] = $_W["uniacid"];
			$insert["uid"] = $uid;
			$insert["testid"] = $tid;
			$insert["test_type"] = $test_type;
			$insert["istatus"] = 1;
			$insert["createtime"] = TIMESTAMP;
			$res = pdo_insert("goouc_fullexam_user_collection_praction", $insert);
			$mess = 1;
		} else {
			$res = pdo_delete("goouc_fullexam_user_collection_praction", ["weid" => $_W["uniacid"], "uid" => $uid, "testid" => $tid]);
		}
		if ($res) {
			return $this->result(0, "操作成功", $mess);
		} else {
			return $this->result(1, "操作失败", "1005");
		}
	}
	public function dopageSequence_submit()
	{
		global $_W;
		global $_GPC;
		$uid = intval($_GPC["uid"]);
		$answerdata = $_GPC["answerdata"];
		$answerdata = json_decode(htmlspecialchars_decode($answerdata), true);
		$op = $_GPC["op"];
		if (empty($uid)) {
			return $this->result(1, "传递的参数不存在或失效", "1001");
		}
		if (empty($answerdata)) {
			return $this->result(1, "传递的参数不存在或失效", "1003");
		}
		$user_info = pdo_fetch("SELECT `status`,integral FROM " . tablename("goouc_fullexam_user") . " WHERE weid=:weid AND id=:uid ", [":weid" => $_W["uniacid"], ":uid" => $uid]);
		if (empty($user_info)) {
			return $this->result(1, "用户不存在", "1002");
		}
		if ($user_info["status"] != 1) {
			return $this->result(1, "用户被禁用", "1003");
		}
		$todaytime = strtotime(date("Y-m-d"));
		$is_add = pdo_getcolumn("goouc_fullexam_exercise", ["weid" => $_W["uniacid"], "uid" => $uid, "createtime >" => $todaytime], "id");
		if (empty($is_add)) {
			pdo_update("goouc_fullexam_user", ["count_day +=" => 1], ["id" => $uid]);
		}
		if ($op == "shunxu") {
			$last_index = intval($_GPC["index"]);
			$type = $answerdata["type"];
			$tid = $answerdata["tid"];
			$answer = $answerdata["answer"];
			if ($type == 2) {
				sort($answer);
				$answer = implode(",", $answer);
			}
			if ($type == 4) {
				if (strpos($answer, ",") !== false) {
					$str = $answer;
					$answer = str_replace(",", "", $str);
				} else {
					$answer = $answer;
				}
			}
			if ($type > 4) {
				foreach ($answer as $kk => $vv) {
					$tid = $vv["tid"];
					$answer = $vv["answer"];
					$now_question_info = $this->get_one_question($tid);
					if (empty($answer) && $answer != 0) {
						$isright = 0;
					} else {
						if ($now_question_info["rightkey"] == $answer) {
							$isright = 1;
						} else {
							$isright = 0;
						}
					}
					$item = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_exercise") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
					$array = [];
					$array["isright"] = $isright;
					$array["uanswer"] = $answer;
					$array["test_type"] = $type;
					$array["createtime"] = time();
					if ($item) {
						pdo_update("goouc_fullexam_exercise", $array, ["id" => $item["id"]]);
						if ($isright == 1) {
							$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
							if ($wrong_have) {
								pdo_delete("goouc_fullexam_user_wrong_praction", ["id" => $wrong_have["id"]]);
							}
							$this->updateQuestionMemberNum($tid, 3);
						}
						if (!$isright) {
							$wrong_arr = [];
							$wrong_arr["weid"] = $_W["uniacid"];
							$wrong_arr["uid"] = $uid;
							$wrong_arr["testid"] = $tid;
							$wrong_arr["test_type"] = $type;
							$wrong_arr["uanswer"] = $answer;
							$wrong_arr["createtime"] = time();
							$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
							if ($wrong_have) {
								pdo_update("goouc_fullexam_user_wrong_praction", $wrong_arr, ["id" => $wrong_have["id"]]);
							} else {
								pdo_insert('goouc_fullexam_user_wrong_praction', $wrong_arr);
								$this->updateQuestionMemberNum($tid, 1);
							}
						}
					} else {
						$array["weid"] = $_W["uniacid"];
						$array["uid"] = $uid;
						$array["testid"] = $tid;
						$array["test_type"] = $type;
						$array["uanswer"] = $answer;
						$array["createtime"] = time();
						$array["istatus"] = 1;
						pdo_insert('goouc_fullexam_exercise', $array);
						if ($isright) {
							$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
							if ($wrong_have) {
								pdo_delete("goouc_fullexam_user_wrong_praction", ["id" => $wrong_have["id"]]);
							}
							$this->updateQuestionMemberNum($tid, 3);
						} else {
							$wrong_arr = [];
							$wrong_arr["weid"] = $_W["uniacid"];
							$wrong_arr["uid"] = $uid;
							$wrong_arr["testid"] = $tid;
							$wrong_arr["test_type"] = $type;
							$wrong_arr["uanswer"] = $answer;
							$wrong_arr["createtime"] = time();
							$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:testid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":testid" => $tid]);
							if ($wrong_have) {
								pdo_update("goouc_fullexam_user_wrong_praction", $wrong_arr, ["id" => $wrong_have["id"]]);
							} else {
								pdo_insert('goouc_fullexam_user_wrong_praction', $wrong_arr);
							}
							$this->updateQuestionMemberNum($tid, 1);
						}
					}
				}
			}
			$now_question_info = $this->get_one_question($tid);
			if (empty($answer) && $answer != 0) {
				$isright = 0;
			} else {
				if ($now_question_info["rightkey"] == $answer) {
					$isright = 1;
				} else {
					$isright = 0;
				}
			}
			$item = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_exercise") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
			$array = [];
			$array["isright"] = $isright;
			$array["uanswer"] = $answer;
			$array["test_type"] = $type;
			$array["createtime"] = time();
			if ($item) {
				pdo_update("goouc_fullexam_exercise", $array, ["id" => $item["id"]]);
				if ($isright == 1) {
					$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
					if ($wrong_have) {
						pdo_delete("goouc_fullexam_user_wrong_praction", ["id" => $wrong_have["id"]]);
					}
					$this->updateQuestionMemberNum($tid, 3);
					$coinnum = pdo_fetchcolumn("SELECT reward_integral FROM " . tablename("goouc_fullexam_setting") . " WHERE weid=:weid ", [":weid" => $_W["uniacid"]]);
				}
				if (!$isright) {
					$wrong_arr = [];
					$wrong_arr["weid"] = $_W["uniacid"];
					$wrong_arr["uid"] = $uid;
					$wrong_arr["testid"] = $tid;
					$wrong_arr["test_type"] = $type;
					$wrong_arr["uanswer"] = $answer;
					$wrong_arr["createtime"] = time();
					$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
					if ($wrong_have) {
						pdo_update("goouc_fullexam_user_wrong_praction", $wrong_arr, ["id" => $wrong_have["id"]]);
					} else {
						pdo_insert('goouc_fullexam_user_wrong_praction', $wrong_arr);
						$this->updateQuestionMemberNum($tid, 1);
					}
				}
			} else {
				$array["weid"] = $_W["uniacid"];
				$array["uid"] = $uid;
				$array["testid"] = $tid;
				$array["test_type"] = $type;
				$array["uanswer"] = $answer;
				$array["createtime"] = time();
				$array["istatus"] = 1;
				pdo_insert('goouc_fullexam_exercise', $array);
				if ($isright) {
					$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
					if ($wrong_have) {
						pdo_delete("goouc_fullexam_user_wrong_praction", ["id" => $wrong_have["id"]]);
					}
					$this->updateQuestionMemberNum($tid, 3);
					$coinnum = pdo_fetchcolumn("SELECT reward_integral FROM " . tablename("goouc_fullexam_setting") . " WHERE weid=:weid ", [":weid" => $_W["uniacid"]]);
					pdo_update('goouc_fullexam_user', ['integral +=' => $coinnum], ["id" => $uid]);
				} else {
					$wrong_arr = [];
					$wrong_arr["weid"] = $_W["uniacid"];
					$wrong_arr["uid"] = $uid;
					$wrong_arr["testid"] = $tid;
					$wrong_arr["test_type"] = $type;
					$wrong_arr["uanswer"] = $answer;
					$wrong_arr["createtime"] = time();
					$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:testid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":testid" => $tid]);
					if ($wrong_have) {
						pdo_update("goouc_fullexam_user_wrong_praction", $wrong_arr, ["id" => $wrong_have["id"]]);
					} else {
						pdo_insert('goouc_fullexam_user_wrong_praction', $wrong_arr);
					}
					$this->updateQuestionMemberNum($tid, 1);
				}
			}
			$insert = [];
			$insert["user_id"] = $uid;
			$insert["weid"] = $_W["uniacid"];
			$insert["question_id"] = $last_index;
			$insert["istatus"] = 1;
			$insert["create_time"] = time();
			$is_have = pdo_fetch("select * from " . tablename("goouc_fullexam_user_spequence") . " WHERE weid=:weid AND user_id=:uid ", [":weid" => $_W["uniacid"], ":uid" => $uid]);
			if ($is_have) {
				$res = pdo_update("goouc_fullexam_user_spequence", ["question_id" => $last_index, "create_time" => time()], ["id" => $is_have["id"]]);
			} else {
				$res = pdo_insert("goouc_fullexam_user_spequence", $insert);
			}
			$do_total = pdo_fetchcolumn("SELECT count(*) FROM " . tablename("goouc_fullexam_exercise") . " WHERE weid=:weid AND uid=:uid ", [":weid" => $_W["uniacid"], ":uid" => $uid]);
			$test_total = pdo_fetchcolumn("SELECT count(*) FROM " . tablename("goouc_fullexam_test") . " WHERE weid=:weid AND istatus=1 AND `type`!=0 ", [":weid" => $_W["uniacid"]]);
			if ($do_total == $test_total) {
				$medal4_have = 1;
			} else {
				$medal4_have = 2;
			}
			if ($res) {
				return $this->result(0, "顺序练习提交成功", ["medal4_have" => $medal4_have]);
			} else {
				return $this->result(1, "顺序提交失败", "1005");
			}
		} elseif ($op == "other") {
			$type = $answerdata["type"];
			$tid = $answerdata["tid"];
			$answer = $answerdata["answer"];
			if ($type == 2) {
				sort($answer);
				$answer = implode(",", $answer);
			}
			if ($type == 4) {
				if (strpos($answer, ",") !== false) {
					$str = $answer;
					$answer = str_replace(",", "", $str);
				} else {
					$answer = $answer;
				}
			}
			if ($type == 5) {
				foreach ($answer as $kk => $vv) {
					$tid = $vv["tid"];
					$answer = $vv["answer"];
					$now_question_info = $this->get_one_question($tid);
					if (empty($answer) && $answer != 0) {
						$isright = 0;
					} else {
						if ($now_question_info["rightkey"] == $answer) {
							$isright = 1;
						} else {
							$isright = 0;
						}
					}
					$item = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_exercise") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
					$array = [];
					$array["isright"] = $isright;
					$array["uanswer"] = $answer;
					$array["test_type"] = $type;
					$array["createtime"] = time();
					if ($item) {
						pdo_update("goouc_fullexam_exercise", $array, ["id" => $item["id"]]);
						if ($isright == 1) {
							$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
							if ($wrong_have) {
								pdo_delete("goouc_fullexam_user_wrong_praction", ["id" => $wrong_have["id"]]);
							}
							$this->updateQuestionMemberNum($tid, 3);
						}
						if (!$isright) {
							$wrong_arr = [];
							$wrong_arr["weid"] = $_W["uniacid"];
							$wrong_arr["uid"] = $uid;
							$wrong_arr["testid"] = $tid;
							$wrong_arr["test_type"] = $type;
							$wrong_arr["uanswer"] = $answer;
							$wrong_arr["createtime"] = time();
							$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
							if ($wrong_have) {
								pdo_update("goouc_fullexam_user_wrong_praction", $wrong_arr, ["id" => $wrong_have["id"]]);
							} else {
								pdo_insert('goouc_fullexam_user_wrong_praction', $wrong_arr);
								$this->updateQuestionMemberNum($tid, 1);
							}
						}
					} else {
						$array["weid"] = $_W["uniacid"];
						$array["uid"] = $uid;
						$array["testid"] = $tid;
						$array["test_type"] = $type;
						$array["uanswer"] = $answer;
						$array["createtime"] = time();
						$array["istatus"] = 1;
						pdo_insert('goouc_fullexam_exercise', $array);
						if ($isright) {
							$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
							if ($wrong_have) {
								pdo_delete("goouc_fullexam_user_wrong_praction", ["id" => $wrong_have["id"]]);
							}
							$this->updateQuestionMemberNum($tid, 3);
						} else {
							$wrong_arr = [];
							$wrong_arr["weid"] = $_W["uniacid"];
							$wrong_arr["uid"] = $uid;
							$wrong_arr["testid"] = $tid;
							$wrong_arr["test_type"] = $type;
							$wrong_arr["uanswer"] = $answer;
							$wrong_arr["createtime"] = time();
							$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:testid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":testid" => $tid]);
							if ($wrong_have) {
								pdo_update("goouc_fullexam_user_wrong_praction", $wrong_arr, ["id" => $wrong_have["id"]]);
							} else {
								pdo_insert('goouc_fullexam_user_wrong_praction', $wrong_arr);
							}
							$this->updateQuestionMemberNum($tid, 1);
						}
					}
				}
			}
			$now_question_info = $this->get_one_question($tid);
			if (empty($answer) && $answer != 0) {
				$isright = 0;
			} else {
				if ($now_question_info["rightkey"] == $answer) {
					$isright = 1;
				} else {
					$isright = 0;
				}
			}
			$item = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_exercise") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
			$array = [];
			$array["isright"] = $isright;
			$array["uanswer"] = $answer;
			$array["test_type"] = $type;
			$array["createtime"] = time();
			if ($item) {
				pdo_update("goouc_fullexam_exercise", $array, ["id" => $item["id"]]);
				if ($isright == 1) {
					$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
					if ($wrong_have) {
						pdo_delete("goouc_fullexam_user_wrong_praction", ["id" => $wrong_have["id"]]);
					}
					$this->updateQuestionMemberNum($tid, 3);
				}
				if (!$isright) {
					$wrong_arr = [];
					$wrong_arr["weid"] = $_W["uniacid"];
					$wrong_arr["uid"] = $uid;
					$wrong_arr["testid"] = $tid;
					$wrong_arr["test_type"] = $type;
					$wrong_arr["uanswer"] = $answer;
					$wrong_arr["createtime"] = time();
					$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
					if ($wrong_have) {
						pdo_update("goouc_fullexam_user_wrong_praction", $wrong_arr, ["id" => $wrong_have["id"]]);
					} else {
						pdo_insert('goouc_fullexam_user_wrong_praction', $wrong_arr);
						$this->updateQuestionMemberNum($tid, 1);
					}
				}
			} else {
				$array["weid"] = $_W["uniacid"];
				$array["uid"] = $uid;
				$array["testid"] = $tid;
				$array["test_type"] = $type;
				$array["uanswer"] = $answer;
				$array["createtime"] = time();
				$array["istatus"] = 1;
				pdo_insert('goouc_fullexam_exercise', $array);
				if ($isright) {
					$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
					if ($wrong_have) {
						pdo_delete("goouc_fullexam_user_wrong_praction", ["id" => $wrong_have["id"]]);
					}
					$this->updateQuestionMemberNum($tid, 3);
					$coinnum = pdo_fetchcolumn("SELECT reward_integral FROM " . tablename("goouc_fullexam_setting") . " WHERE weid=:weid ", [":weid" => $_W["uniacid"]]);
					pdo_update('goouc_fullexam_user', ['integral +=' => $coinnum], ["id" => $uid]);
				} else {
					$wrong_arr = [];
					$wrong_arr["weid"] = $_W["uniacid"];
					$wrong_arr["uid"] = $uid;
					$wrong_arr["testid"] = $tid;
					$wrong_arr["test_type"] = $type;
					$wrong_arr["uanswer"] = $answer;
					$wrong_arr["createtime"] = time();
					$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:testid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":testid" => $tid]);
					if ($wrong_have) {
						pdo_update("goouc_fullexam_user_wrong_praction", $wrong_arr, ["id" => $wrong_have["id"]]);
					} else {
						pdo_insert('goouc_fullexam_user_wrong_praction', $wrong_arr);
					}
					$this->updateQuestionMemberNum($tid, 1);
				}
			}
			return $this->result(0, "其他练习提交", "OK");
		} elseif ($op == "qhigh") {
			$last_index = intval($_GPC["index"]);
			$use_integral_num = pdo_fetchcolumn("SELECT `use_integral_num` FROM " . tablename("goouc_fullexam_setting") . " WHERE weid=:weid", [":weid" => $_W["uniacid"]]);
			if (!empty($use_integral_num)) {
				$update = [];
				$update["integral"] = $user_info["integral"] - $use_integral_num;
				pdo_update('goouc_fullexam_user', $update, ["weid" => $_W["uniacid"], "id" => $uid]);
			}
			$type = $answerdata["type"];
			$tid = $answerdata["tid"];
			$answer = $answerdata["answer"];
			if ($type == 2) {
				sort($answer);
				$answer = implode(",", $answer);
			}
			if ($type == 4) {
				if (strpos($answer, ",") !== false) {
					$str = $answer;
					$answer = str_replace(",", "", $str);
				} else {
					$answer = $answer;
				}
			}
			if ($type == 5) {
				foreach ($answer as $kk => $vv) {
					$tid = $vv["tid"];
					$answer = $vv["answer"];
					$now_question_info = $this->get_one_question($tid);
					if (empty($answer) && $answer != 0) {
						$isright = 0;
					} else {
						if ($now_question_info["rightkey"] == $answer) {
							$isright = 1;
						} else {
							$isright = 0;
						}
					}
					$item = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_exercise") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
					$array = [];
					$array["isright"] = $isright;
					$array["uanswer"] = $answer;
					$array["test_type"] = $type;
					$array["createtime"] = time();
					if ($item) {
						pdo_update("goouc_fullexam_exercise", $array, ["id" => $item["id"]]);
						if ($isright == 1) {
							$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
							if ($wrong_have) {
								pdo_delete("goouc_fullexam_user_wrong_praction", ["id" => $wrong_have["id"]]);
							}
							$this->updateQuestionMemberNum($tid, 3);
						}
						if (!$isright) {
							$wrong_arr = [];
							$wrong_arr["weid"] = $_W["uniacid"];
							$wrong_arr["uid"] = $uid;
							$wrong_arr["testid"] = $tid;
							$wrong_arr["test_type"] = $type;
							$wrong_arr["uanswer"] = $answer;
							$wrong_arr["createtime"] = time();
							$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
							if ($wrong_have) {
								pdo_update("goouc_fullexam_user_wrong_praction", $wrong_arr, ["id" => $wrong_have["id"]]);
							} else {
								pdo_insert('goouc_fullexam_user_wrong_praction', $wrong_arr);
								$this->updateQuestionMemberNum($tid, 1);
							}
						}
					} else {
						$array["weid"] = $_W["uniacid"];
						$array["uid"] = $uid;
						$array["testid"] = $tid;
						$array["test_type"] = $type;
						$array["uanswer"] = $answer;
						$array["createtime"] = time();
						$array["istatus"] = 1;
						pdo_insert('goouc_fullexam_exercise', $array);
						if ($isright) {
							$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
							if ($wrong_have) {
								pdo_delete("goouc_fullexam_user_wrong_praction", ["id" => $wrong_have["id"]]);
							}
							$this->updateQuestionMemberNum($tid, 3);
						} else {
							$wrong_arr = [];
							$wrong_arr["weid"] = $_W["uniacid"];
							$wrong_arr["uid"] = $uid;
							$wrong_arr["testid"] = $tid;
							$wrong_arr["test_type"] = $type;
							$wrong_arr["uanswer"] = $answer;
							$wrong_arr["createtime"] = time();
							$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:testid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":testid" => $tid]);
							if ($wrong_have) {
								pdo_update("goouc_fullexam_user_wrong_praction", $wrong_arr, ["id" => $wrong_have["id"]]);
							} else {
								pdo_insert('goouc_fullexam_user_wrong_praction', $wrong_arr);
							}
							$this->updateQuestionMemberNum($tid, 1);
						}
					}
				}
			}
			$now_question_info = $this->get_one_question($tid);
			if (empty($answer) && $answer != 0) {
				$isright = 0;
			} else {
				if ($now_question_info["rightkey"] == $answer) {
					$isright = 1;
				} else {
					$isright = 0;
				}
			}
			$item = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_exercise") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
			$array = [];
			$array["isright"] = $isright;
			$array["uanswer"] = $answer;
			$array["test_type"] = $type;
			$array["createtime"] = time();
			if ($item) {
				pdo_update("goouc_fullexam_exercise", $array, ["id" => $item["id"]]);
				if ($isright == 1) {
					$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
					if ($wrong_have) {
						pdo_delete("goouc_fullexam_user_wrong_praction", ["id" => $wrong_have["id"]]);
					}
					$this->updateQuestionMemberNum($tid, 3);
				}
				if (!$isright) {
					$wrong_arr = [];
					$wrong_arr["weid"] = $_W["uniacid"];
					$wrong_arr["uid"] = $uid;
					$wrong_arr["testid"] = $tid;
					$wrong_arr["test_type"] = $type;
					$wrong_arr["uanswer"] = $answer;
					$wrong_arr["createtime"] = time();
					$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
					if ($wrong_have) {
						pdo_update("goouc_fullexam_user_wrong_praction", $wrong_arr, ["id" => $wrong_have["id"]]);
					} else {
						pdo_insert('goouc_fullexam_user_wrong_praction', $wrong_arr);
						$this->updateQuestionMemberNum($tid, 1);
					}
				}
			} else {
				$array["weid"] = $_W["uniacid"];
				$array["uid"] = $uid;
				$array["testid"] = $tid;
				$array["test_type"] = $type;
				$array["uanswer"] = $answer;
				$array["createtime"] = time();
				$array["istatus"] = 1;
				pdo_insert('goouc_fullexam_exercise', $array);
				if ($isright) {
					$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
					if ($wrong_have) {
						pdo_delete("goouc_fullexam_user_wrong_praction", ["id" => $wrong_have["id"]]);
					}
					$this->updateQuestionMemberNum($tid, 3);
					$coinnum = pdo_fetchcolumn("SELECT reward_integral FROM " . tablename("goouc_fullexam_setting") . " WHERE weid=:weid ", [":weid" => $_W["uniacid"]]);
					pdo_update('goouc_fullexam_user', ['integral +=' => $coinnum], ["id" => $uid]);
				} else {
					$wrong_arr = [];
					$wrong_arr["weid"] = $_W["uniacid"];
					$wrong_arr["uid"] = $uid;
					$wrong_arr["testid"] = $tid;
					$wrong_arr["test_type"] = $type;
					$wrong_arr["uanswer"] = $answer;
					$wrong_arr["createtime"] = time();
					$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:testid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":testid" => $tid]);
					if ($wrong_have) {
						pdo_update("goouc_fullexam_user_wrong_praction", $wrong_arr, ["id" => $wrong_have["id"]]);
					} else {
						pdo_insert('goouc_fullexam_user_wrong_praction', $wrong_arr);
					}
					$this->updateQuestionMemberNum($tid, 1);
				}
			}
			$insert = [];
			$insert["user_id"] = $uid;
			$insert["weid"] = $_W["uniacid"];
			$insert["question_id"] = $last_index;
			$insert["istatus"] = 1;
			$insert["create_time"] = time();
			$is_have = pdo_fetch("select * from " . tablename("goouc_fullexam_user_qhigh") . " WHERE weid=:weid AND user_id=:uid ", [":weid" => $_W["uniacid"], ":uid" => $uid]);
			if ($is_have) {
				$res = pdo_update("goouc_fullexam_user_qhigh", ["question_id" => $last_index, "create_time" => time()], ["id" => $is_have["id"]]);
			} else {
				$res = pdo_insert("goouc_fullexam_user_qhigh", $insert);
			}
			if ($res) {
				return $this->result(0, "高频练习提交成功");
			} else {
				return $this->result(1, "高频练习提交失败", "1005");
			}
		} elseif ($op == "intensive") {
			$last_index = intval($_GPC["index"]);
			$type = $answerdata["type"];
			$tid = $answerdata["tid"];
			$answer = $answerdata["answer"];
			if ($type == 2) {
				sort($answer);
				$answer = implode(",", $answer);
			}
			if ($type == 4) {
				if (strpos($answer, ",") !== false) {
					$str = $answer;
					$answer = str_replace(",", "", $str);
				} else {
					$answer = $answer;
				}
			}
			if ($type == 5) {
				foreach ($answer as $kk => $vv) {
					$tid = $vv["tid"];
					$answer = $vv["answer"];
					$now_question_info = $this->get_one_question($tid);
					if (empty($answer) && $answer != 0) {
						$isright = 0;
					} else {
						if ($now_question_info["rightkey"] == $answer) {
							$isright = 1;
						} else {
							$isright = 0;
						}
					}
					$item = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_exercise") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
					$array = [];
					$array["isright"] = $isright;
					$array["uanswer"] = $answer;
					$array["test_type"] = $type;
					$array["createtime"] = time();
					if ($item) {
						pdo_update("goouc_fullexam_exercise", $array, ["id" => $item["id"]]);
						if ($isright == 1) {
							$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
							if ($wrong_have) {
								pdo_delete("goouc_fullexam_user_wrong_praction", ["id" => $wrong_have["id"]]);
							}
							$this->updateQuestionMemberNum($tid, 3);
						}
						if (!$isright) {
							$wrong_arr = [];
							$wrong_arr["weid"] = $_W["uniacid"];
							$wrong_arr["uid"] = $uid;
							$wrong_arr["testid"] = $tid;
							$wrong_arr["test_type"] = $type;
							$wrong_arr["uanswer"] = $answer;
							$wrong_arr["createtime"] = time();
							$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
							if ($wrong_have) {
								pdo_update("goouc_fullexam_user_wrong_praction", $wrong_arr, ["id" => $wrong_have["id"]]);
							} else {
								pdo_insert('goouc_fullexam_user_wrong_praction', $wrong_arr);
								$this->updateQuestionMemberNum($tid, 1);
							}
						}
					} else {
						$array["weid"] = $_W["uniacid"];
						$array["uid"] = $uid;
						$array["testid"] = $tid;
						$array["test_type"] = $type;
						$array["uanswer"] = $answer;
						$array["createtime"] = time();
						$array["istatus"] = 1;
						pdo_insert('goouc_fullexam_exercise', $array);
						if ($isright) {
							$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
							if ($wrong_have) {
								pdo_delete("goouc_fullexam_user_wrong_praction", ["id" => $wrong_have["id"]]);
							}
							$this->updateQuestionMemberNum($tid, 3);
						} else {
							$wrong_arr = [];
							$wrong_arr["weid"] = $_W["uniacid"];
							$wrong_arr["uid"] = $uid;
							$wrong_arr["testid"] = $tid;
							$wrong_arr["test_type"] = $type;
							$wrong_arr["uanswer"] = $answer;
							$wrong_arr["createtime"] = time();
							$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:testid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":testid" => $tid]);
							if ($wrong_have) {
								pdo_update("goouc_fullexam_user_wrong_praction", $wrong_arr, ["id" => $wrong_have["id"]]);
							} else {
								pdo_insert('goouc_fullexam_user_wrong_praction', $wrong_arr);
							}
							$this->updateQuestionMemberNum($tid, 1);
						}
					}
				}
			}
			$now_question_info = $this->get_one_question($tid);
			if (empty($answer) && $answer != 0) {
				$isright = 0;
			} else {
				if ($now_question_info["rightkey"] == $answer) {
					$isright = 1;
				} else {
					$isright = 0;
				}
			}
			$item = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_exercise") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
			$array = [];
			$array["isright"] = $isright;
			$array["uanswer"] = $answer;
			$array["test_type"] = $type;
			$array["createtime"] = time();
			if ($item) {
				pdo_update("goouc_fullexam_exercise", $array, ["id" => $item["id"]]);
				if ($isright == 1) {
					$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
					if ($wrong_have) {
						pdo_delete("goouc_fullexam_user_wrong_praction", ["id" => $wrong_have["id"]]);
					}
					$this->updateQuestionMemberNum($tid, 3);
				}
				if (!$isright) {
					$wrong_arr = [];
					$wrong_arr["weid"] = $_W["uniacid"];
					$wrong_arr["uid"] = $uid;
					$wrong_arr["testid"] = $tid;
					$wrong_arr["test_type"] = $type;
					$wrong_arr["uanswer"] = $answer;
					$wrong_arr["createtime"] = time();
					$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
					if ($wrong_have) {
						pdo_update("goouc_fullexam_user_wrong_praction", $wrong_arr, ["id" => $wrong_have["id"]]);
					} else {
						pdo_insert('goouc_fullexam_user_wrong_praction', $wrong_arr);
						$this->updateQuestionMemberNum($tid, 1);
					}
				}
			} else {
				$array["weid"] = $_W["uniacid"];
				$array["uid"] = $uid;
				$array["testid"] = $tid;
				$array["test_type"] = $type;
				$array["uanswer"] = $answer;
				$array["createtime"] = time();
				$array["istatus"] = 1;
				pdo_insert('goouc_fullexam_exercise', $array);
				if ($isright) {
					$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
					if ($wrong_have) {
						pdo_delete("goouc_fullexam_user_wrong_praction", ["id" => $wrong_have["id"]]);
					}
					$this->updateQuestionMemberNum($tid, 3);
					$coinnum = pdo_fetchcolumn("SELECT reward_integral FROM " . tablename("goouc_fullexam_setting") . " WHERE weid=:weid ", [":weid" => $_W["uniacid"]]);
					pdo_update('goouc_fullexam_user', ['integral +=' => $coinnum], ["id" => $uid]);
				} else {
					$wrong_arr = [];
					$wrong_arr["weid"] = $_W["uniacid"];
					$wrong_arr["uid"] = $uid;
					$wrong_arr["testid"] = $tid;
					$wrong_arr["test_type"] = $type;
					$wrong_arr["uanswer"] = $answer;
					$wrong_arr["createtime"] = time();
					$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:testid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":testid" => $tid]);
					if ($wrong_have) {
						pdo_update("goouc_fullexam_user_wrong_praction", $wrong_arr, ["id" => $wrong_have["id"]]);
					} else {
						pdo_insert('goouc_fullexam_user_wrong_praction', $wrong_arr);
					}
					$this->updateQuestionMemberNum($tid, 1);
				}
			}
			$insert = [];
			$insert["user_id"] = $uid;
			$insert["weid"] = $_W["uniacid"];
			$insert["question_id"] = $last_index;
			$insert["istatus"] = 1;
			$insert["create_time"] = time();
			$is_have = pdo_fetch("select * from " . tablename("goouc_fullexam_user_qintensive") . " WHERE weid=:weid AND user_id=:uid ", [":weid" => $_W["uniacid"], ":uid" => $uid]);
			if ($is_have) {
				$res = pdo_update("goouc_fullexam_user_qintensive", ["question_id" => $last_index, "create_time" => time()], ["id" => $is_have["id"]]);
			} else {
				$res = pdo_insert("goouc_fullexam_user_qintensive", $insert);
			}
			if ($res) {
				return $this->result(0, "精编练习提交成功");
			} else {
				return $this->result(1, "精编练习提交失败", "1005");
			}
		} elseif ($op == "qspecial") {
			$last_index = intval($_GPC["index"]);
			$special_id = intval($_GPC["special_id"]);
			$type = $answerdata["type"];
			$tid = $answerdata["tid"];
			$answer = $answerdata["answer"];
			if ($type == 2) {
				sort($answer);
				$answer = implode(",", $answer);
			}
			if ($type == 4) {
				if (strpos($answer, ",") !== false) {
					$str = $answer;
					$answer = str_replace(",", "", $str);
				} else {
					$answer = $answer;
				}
			}
			if ($type == 5) {
				foreach ($answer as $kk => $vv) {
					$tid = $vv["tid"];
					$answer = $vv["answer"];
					$now_question_info = $this->get_one_question($tid);
					if (empty($answer) && $answer != 0) {
						$isright = 0;
					} else {
						if ($now_question_info["rightkey"] == $answer) {
							$isright = 1;
						} else {
							$isright = 0;
						}
					}
					$item = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_exercise") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
					$array = [];
					$array["isright"] = $isright;
					$array["uanswer"] = $answer;
					$array["test_type"] = $type;
					$array["createtime"] = time();
					if ($item) {
						pdo_update("goouc_fullexam_exercise", $array, ["id" => $item["id"]]);
						if ($isright == 1) {
							$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
							if ($wrong_have) {
								pdo_delete("goouc_fullexam_user_wrong_praction", ["id" => $wrong_have["id"]]);
							}
							$this->updateQuestionMemberNum($tid, 3);
						}
						if (!$isright) {
							$wrong_arr = [];
							$wrong_arr["weid"] = $_W["uniacid"];
							$wrong_arr["uid"] = $uid;
							$wrong_arr["testid"] = $tid;
							$wrong_arr["test_type"] = $type;
							$wrong_arr["uanswer"] = $answer;
							$wrong_arr["createtime"] = time();
							$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
							if ($wrong_have) {
								pdo_update("goouc_fullexam_user_wrong_praction", $wrong_arr, ["id" => $wrong_have["id"]]);
							} else {
								pdo_insert('goouc_fullexam_user_wrong_praction', $wrong_arr);
								$this->updateQuestionMemberNum($tid, 1);
							}
						}
					} else {
						$array["weid"] = $_W["uniacid"];
						$array["uid"] = $uid;
						$array["testid"] = $tid;
						$array["test_type"] = $type;
						$array["uanswer"] = $answer;
						$array["createtime"] = time();
						$array["istatus"] = 1;
						pdo_insert('goouc_fullexam_exercise', $array);
						if ($isright) {
							$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
							if ($wrong_have) {
								pdo_delete("goouc_fullexam_user_wrong_praction", ["id" => $wrong_have["id"]]);
							}
							$this->updateQuestionMemberNum($tid, 3);
						} else {
							$wrong_arr = [];
							$wrong_arr["weid"] = $_W["uniacid"];
							$wrong_arr["uid"] = $uid;
							$wrong_arr["testid"] = $tid;
							$wrong_arr["test_type"] = $type;
							$wrong_arr["uanswer"] = $answer;
							$wrong_arr["createtime"] = time();
							$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:testid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":testid" => $tid]);
							if ($wrong_have) {
								pdo_update("goouc_fullexam_user_wrong_praction", $wrong_arr, ["id" => $wrong_have["id"]]);
							} else {
								pdo_insert('goouc_fullexam_user_wrong_praction', $wrong_arr);
							}
							$this->updateQuestionMemberNum($tid, 1);
						}
					}
				}
			}
			$now_question_info = $this->get_one_question($tid);
			if (empty($answer) && $answer != 0) {
				$isright = 0;
			} else {
				if ($now_question_info["rightkey"] == $answer) {
					$isright = 1;
				} else {
					$isright = 0;
				}
			}
			$item = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_exercise") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
			$array = [];
			$array["isright"] = $isright;
			$array["uanswer"] = $answer;
			$array["test_type"] = $type;
			$array["createtime"] = time();
			if ($item) {
				pdo_update("goouc_fullexam_exercise", $array, ["id" => $item["id"]]);
				if ($isright == 1) {
					$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
					if ($wrong_have) {
						pdo_delete("goouc_fullexam_user_wrong_praction", ["id" => $wrong_have["id"]]);
					}
					$this->updateQuestionMemberNum($tid, 3);
				}
				if (!$isright) {
					$wrong_arr = [];
					$wrong_arr["weid"] = $_W["uniacid"];
					$wrong_arr["uid"] = $uid;
					$wrong_arr["testid"] = $tid;
					$wrong_arr["test_type"] = $type;
					$wrong_arr["uanswer"] = $answer;
					$wrong_arr["createtime"] = time();
					$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
					if ($wrong_have) {
						pdo_update("goouc_fullexam_user_wrong_praction", $wrong_arr, ["id" => $wrong_have["id"]]);
					} else {
						pdo_insert('goouc_fullexam_user_wrong_praction', $wrong_arr);
						$this->updateQuestionMemberNum($tid, 1);
					}
				}
			} else {
				$array["weid"] = $_W["uniacid"];
				$array["uid"] = $uid;
				$array["testid"] = $tid;
				$array["test_type"] = $type;
				$array["uanswer"] = $answer;
				$array["createtime"] = time();
				$array["istatus"] = 1;
				pdo_insert('goouc_fullexam_exercise', $array);
				if ($isright) {
					$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
					if ($wrong_have) {
						pdo_delete("goouc_fullexam_user_wrong_praction", ["id" => $wrong_have["id"]]);
					}
					$this->updateQuestionMemberNum($tid, 3);
					$coinnum = pdo_fetchcolumn("SELECT reward_integral FROM " . tablename("goouc_fullexam_setting") . " WHERE weid=:weid ", [":weid" => $_W["uniacid"]]);
					pdo_update('goouc_fullexam_user', ['integral +=' => $coinnum], ["id" => $uid]);
				} else {
					$wrong_arr = [];
					$wrong_arr["weid"] = $_W["uniacid"];
					$wrong_arr["uid"] = $uid;
					$wrong_arr["testid"] = $tid;
					$wrong_arr["test_type"] = $type;
					$wrong_arr["uanswer"] = $answer;
					$wrong_arr["createtime"] = time();
					$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:testid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":testid" => $tid]);
					if ($wrong_have) {
						pdo_update("goouc_fullexam_user_wrong_praction", $wrong_arr, ["id" => $wrong_have["id"]]);
					} else {
						pdo_insert('goouc_fullexam_user_wrong_praction', $wrong_arr);
					}
					$this->updateQuestionMemberNum($tid, 1);
				}
			}
			$insert = [];
			$insert["uid"] = $uid;
			$insert["weid"] = $_W["uniacid"];
			$insert["special_id"] = $special_id;
			$insert["last_id"] = $last_index;
			$insert["istatus"] = 1;
			$insert["createtime"] = time();
			$is_have = pdo_fetch("select * from " . tablename("goouc_fullexam_user_special") . " WHERE weid=:weid AND uid=:uid AND special_id=:special_id ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":special_id" => $special_id]);
			if ($is_have) {
				$res = pdo_update("goouc_fullexam_user_special", ["last_id" => $last_index, "createtime" => time()], ["id" => $is_have["id"]]);
			} else {
				$res = pdo_insert("goouc_fullexam_user_special", $insert);
			}
			if ($res) {
				return $this->result(0, "知识点练习提交成功");
			} else {
				return $this->result(1, "知识点练习提交失败", "1005");
			}
		} elseif ($op == "qtype_submit") {
			$last_index = intval($_GPC["index"]);
			$type_id = intval($_GPC["type_id"]);
			$type = $answerdata["type"];
			$tid = $answerdata["tid"];
			$answer = $answerdata["answer"];
			if ($type == 2) {
				sort($answer);
				$answer = implode(",", $answer);
			}
			if ($type == 4) {
				if (strpos($answer, ",") !== false) {
					$str = $answer;
					$answer = str_replace(",", "", $str);
				} else {
					$answer = $answer;
				}
			}
			if ($type == 5) {
				foreach ($answer as $kk => $vv) {
					$tid = $vv["tid"];
					$answer = $vv["answer"];
					$now_question_info = $this->get_one_question($tid);
					if (empty($answer) && $answer != 0) {
						$isright = 0;
					} else {
						if ($now_question_info["rightkey"] == $answer) {
							$isright = 1;
						} else {
							$isright = 0;
						}
					}
					$item = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_exercise") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
					$array = [];
					$array["isright"] = $isright;
					$array["uanswer"] = $answer;
					$array["test_type"] = $type;
					$array["createtime"] = time();
					if ($item) {
						pdo_update("goouc_fullexam_exercise", $array, ["id" => $item["id"]]);
						if ($isright == 1) {
							$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
							if ($wrong_have) {
								pdo_delete("goouc_fullexam_user_wrong_praction", ["id" => $wrong_have["id"]]);
							}
							$this->updateQuestionMemberNum($tid, 3);
						}
						if (!$isright) {
							$wrong_arr = [];
							$wrong_arr["weid"] = $_W["uniacid"];
							$wrong_arr["uid"] = $uid;
							$wrong_arr["testid"] = $tid;
							$wrong_arr["test_type"] = $type;
							$wrong_arr["uanswer"] = $answer;
							$wrong_arr["createtime"] = time();
							$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
							if ($wrong_have) {
								pdo_update("goouc_fullexam_user_wrong_praction", $wrong_arr, ["id" => $wrong_have["id"]]);
							} else {
								pdo_insert('goouc_fullexam_user_wrong_praction', $wrong_arr);
								$this->updateQuestionMemberNum($tid, 1);
							}
						}
					} else {
						$array["weid"] = $_W["uniacid"];
						$array["uid"] = $uid;
						$array["testid"] = $tid;
						$array["test_type"] = $type;
						$array["uanswer"] = $answer;
						$array["createtime"] = time();
						$array["istatus"] = 1;
						pdo_insert('goouc_fullexam_exercise', $array);
						if ($isright) {
							$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
							if ($wrong_have) {
								pdo_delete("goouc_fullexam_user_wrong_praction", ["id" => $wrong_have["id"]]);
							}
							$this->updateQuestionMemberNum($tid, 3);
						} else {
							$wrong_arr = [];
							$wrong_arr["weid"] = $_W["uniacid"];
							$wrong_arr["uid"] = $uid;
							$wrong_arr["testid"] = $tid;
							$wrong_arr["test_type"] = $type;
							$wrong_arr["uanswer"] = $answer;
							$wrong_arr["createtime"] = time();
							$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:testid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":testid" => $tid]);
							if ($wrong_have) {
								pdo_update("goouc_fullexam_user_wrong_praction", $wrong_arr, ["id" => $wrong_have["id"]]);
							} else {
								pdo_insert('goouc_fullexam_user_wrong_praction', $wrong_arr);
							}
							$this->updateQuestionMemberNum($tid, 1);
						}
					}
				}
			}
			$now_question_info = $this->get_one_question($tid);
			if (empty($answer) && $answer != 0) {
				$isright = 0;
			} else {
				if ($now_question_info["rightkey"] == $answer) {
					$isright = 1;
				} else {
					$isright = 0;
				}
			}
			$item = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_exercise") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
			$array = [];
			$array["isright"] = $isright;
			$array["uanswer"] = $answer;
			$array["test_type"] = $type;
			$array["createtime"] = time();
			if ($item) {
				pdo_update("goouc_fullexam_exercise", $array, ["id" => $item["id"]]);
				if ($isright == 1) {
					$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
					if ($wrong_have) {
						pdo_delete("goouc_fullexam_user_wrong_praction", ["id" => $wrong_have["id"]]);
					}
					$this->updateQuestionMemberNum($tid, 3);
				}
				if (!$isright) {
					$wrong_arr = [];
					$wrong_arr["weid"] = $_W["uniacid"];
					$wrong_arr["uid"] = $uid;
					$wrong_arr["testid"] = $tid;
					$wrong_arr["test_type"] = $type;
					$wrong_arr["uanswer"] = $answer;
					$wrong_arr["createtime"] = time();
					$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
					if ($wrong_have) {
						pdo_update("goouc_fullexam_user_wrong_praction", $wrong_arr, ["id" => $wrong_have["id"]]);
					} else {
						pdo_insert('goouc_fullexam_user_wrong_praction', $wrong_arr);
						$this->updateQuestionMemberNum($tid, 1);
					}
				}
			} else {
				$array["weid"] = $_W["uniacid"];
				$array["uid"] = $uid;
				$array["testid"] = $tid;
				$array["test_type"] = $type;
				$array["uanswer"] = $answer;
				$array["createtime"] = time();
				$array["istatus"] = 1;
				pdo_insert('goouc_fullexam_exercise', $array);
				if ($isright) {
					$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:tid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":tid" => $tid]);
					if ($wrong_have) {
						pdo_delete("goouc_fullexam_user_wrong_praction", ["id" => $wrong_have["id"]]);
					}
					$this->updateQuestionMemberNum($tid, 3);
					$coinnum = pdo_fetchcolumn("SELECT reward_integral FROM " . tablename("goouc_fullexam_setting") . " WHERE weid=:weid ", [":weid" => $_W["uniacid"]]);
					pdo_update('goouc_fullexam_user', ['integral +=' => $coinnum], ["id" => $uid]);
				} else {
					$wrong_arr = [];
					$wrong_arr["weid"] = $_W["uniacid"];
					$wrong_arr["uid"] = $uid;
					$wrong_arr["testid"] = $tid;
					$wrong_arr["test_type"] = $type;
					$wrong_arr["uanswer"] = $answer;
					$wrong_arr["createtime"] = time();
					$wrong_have = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND testid=:testid ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":testid" => $tid]);
					if ($wrong_have) {
						pdo_update("goouc_fullexam_user_wrong_praction", $wrong_arr, ["id" => $wrong_have["id"]]);
					} else {
						pdo_insert('goouc_fullexam_user_wrong_praction', $wrong_arr);
					}
					$this->updateQuestionMemberNum($tid, 1);
				}
			}
			$insert = [];
			$insert["uid"] = $uid;
			$insert["weid"] = $_W["uniacid"];
			$insert["type_id"] = $type_id;
			$insert["last_id"] = $last_index;
			$insert["istatus"] = 1;
			$insert["createtime"] = time();
			$is_have = pdo_fetch("select * from " . tablename("goouc_fullexam_user_qtype") . " WHERE weid=:weid AND uid=:uid AND type_id=:type_id ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":type_id" => $type_id]);
			if ($is_have) {
				$res = pdo_update("goouc_fullexam_user_qtype", ["last_id" => $last_index, "createtime" => time()], ["id" => $is_have["id"]]);
			} else {
				$res = pdo_insert("goouc_fullexam_user_qtype", $insert);
			}
			if ($res) {
				return $this->result(0, "题型练习提交成功");
			} else {
				return $this->result(1, "题型练习提交失败", "1005");
			}
		}
	}
	public function dopageGetsetting()
	{
		global $_W;
		$info = pdo_fetch("SELECT `wechat_number`,`share_title` FROM " . tablename("goouc_fullexam_setting") . " WHERE weid=:weid ", [":weid" => $_W["uniacid"]]);
		return $this->result(0, "基本设置信息", $info);
	}
	public function dopageAboutus()
	{
		global $_W;
		$info = pdo_fetch("SELECT `id`, `about` FROM " . tablename("goouc_fullexam_setting") . " WHERE weid=:weid ", [":weid" => $_W["uniacid"]]);
		return $this->result(0, "获取关于我们", $info);
	}
	public function dopageAdvert()
	{
		global $_W;
		global $_GPC;
		$op = $_GPC["op"];
		if (empty($op)) {
			return $this->result(1, "参数错误", "1001");
		}
		if ($op == "home") {
			$info = pdo_fetch("SELECT id,homeId FROM " . tablename("goouc_fullexam_advert") . " WHERE weid=:weid ", [":weid" => $_W["uniacid"]]);
			if (empty($info)) {
				$ad_have = 2;
				return $this->result(0, "暂无广告", ["info" => $info, "ad_have" => $ad_have]);
			} else {
				$ad_have = 1;
				return $this->result(0, "首页广告", ["info" => $info, "ad_have" => $ad_have]);
			}
		} elseif ($op == "second") {
			$info = pdo_fetch("SELECT id,secondId FROM " . tablename("goouc_fullexam_advert") . " WHERE weid=:weid ", [":weid" => $_W["uniacid"]]);
			if (empty($info)) {
				$ad_have = 2;
				return $this->result(0, "暂无广告", ["info" => $info, "ad_have" => $ad_have]);
			} else {
				$ad_have = 1;
				return $this->result(0, "解析页广告", ["info" => $info, "ad_have" => $ad_have]);
			}
		}
	}
	public function dopageShare()
	{
		global $_W;
		global $_GPC;
		$uid = $_GPC["uid"];
		if (empty($uid)) {
			return $this->result(1, "传递的参数不存在", "1001");
		}
		$user_info = pdo_fetch("SELECT `id`,`integral`,`status` FROM " . tablename("goouc_fullexam_user") . " WHERE weid=:weid AND id=:uid ", [":weid" => $_W["uniacid"], ":uid" => $uid]);
		if (empty($user_info)) {
			return $this->result(1, "用户不存在", "1001");
		}
		if ($user_info["status"] != 1) {
			return $this->result(1, "用户被禁用", "1002");
		}
		$setting = pdo_fetch("SELECT `share_integral`,`share_title`,`shareupper` FROM " . tablename("goouc_fullexam_setting") . " WHERE weid=:weid ", [":weid" => $_W["uniacid"]]);
		$day_num = pdo_fetch("SELECT id,uid,num FROM " . tablename("goouc_fullexam_share_record") . " WHERE weid=:weid AND uid=:uid AND `day`=:day ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":day" => date("Y-m-d")]);
		if ($setting["shareupper"] == 0) {
			$data = [];
			if ($setting["share_integral"] != 0) {
				if ($day_num) {
					$update = [];
					$update["num"] = $day_num["num"] + $setting["share_integral"];
					$update["day"] = date("Y-m-d");
					$update["createtime"] = time();
					$result = pdo_update("goouc_fullexam_share_record", $update, ["id" => $day_num["id"], "uid" => $day_num["uid"]]);
					if ($result) {
						$data["integral"] = $user_info["integral"] + $setting["share_integral"];
						$res = pdo_update("goouc_fullexam_user", $data, ["id" => $user_info["id"]]);
					}
				} else {
					$insert = [];
					$insert["uid"] = $uid;
					$insert["weid"] = $_W["uniacid"];
					$insert["num"] = $setting["share_integral"];
					$insert["istatus"] = 1;
					$insert["day"] = date("Y-m-d");
					$insert["createtime"] = time();
					$result = pdo_insert("goouc_fullexam_share_record", $insert);
				}
				if ($result) {
					$data["integral"] = $user_info["integral"] + $setting["share_integral"];
					$res = pdo_update("goouc_fullexam_user", $data, ["id" => $user_info["id"]]);
				}
			}
		} else {
			if ($setting["share_integral"] != 0) {
				$data = [];
				if ($day_num) {
					if ($day_num["num"] < $setting["shareupper"]) {
						$can_num = $setting["shareupper"] - $day_num["num"];
						if ($setting["share_integral"] <= $can_num) {
							$update = [];
							$update["num"] = $day_num["num"] + $setting["share_integral"];
							$update["day"] = date("Y-m-d");
							$update["createtime"] = time();
							$result = pdo_update("goouc_fullexam_share_record", $update, ["id" => $day_num["id"], "uid" => $day_num["uid"]]);
							if ($result) {
								$data["integral"] = $user_info["integral"] + $setting["share_integral"];
								$res = pdo_update("goouc_fullexam_user", $data, ["id" => $user_info["id"]]);
							}
						}
					}
				} else {
					$insert = [];
					$insert["uid"] = $uid;
					$insert["weid"] = $_W["uniacid"];
					$insert["num"] = $setting["share_integral"];
					$insert["istatus"] = 1;
					$insert["day"] = date("Y-m-d");
					$insert["createtime"] = time();
					$result = pdo_insert("goouc_fullexam_share_record", $insert);
					if ($result) {
						$data["integral"] = $user_info["integral"] + $setting["share_integral"];
						$res = pdo_update("goouc_fullexam_user", $data, ["id" => $user_info["id"]]);
					}
				}
			}
		}
		if ($res) {
			return $this->result(0, "分享成功", ["code" => 1, "num" => $setting["share_integral"]]);
		} else {
			return $this->result(1, "分享失败", ["code" => 2]);
		}
	}
	public function dopageFeedback()
	{
		global $_W;
		global $_GPC;
		$uid = $_GPC["uid"];
		$testid = $_GPC["tid"];
		$relation = $_GPC["relation"];
		$content = trim($_GPC["content"]);
		if (empty($uid) || empty($relation)) {
			return $this->result(1, "传递的参数不存在或失效", "1001");
		}
		$user_info = pdo_fetch("SELECT `status` FROM " . tablename("goouc_fullexam_user") . " WHERE weid=:weid AND id=:uid ", [":weid" => $_W["uniacid"], ":uid" => $uid]);
		if (empty($user_info)) {
			return $this->result(1, "用户不存在", "1002");
		}
		if ($user_info["status"] != 1) {
			return $this->result(1, "用户被禁用", "1003");
		}
		if (empty($content)) {
			return $this->result(1, "传递的参数不存在或失效", "1004");
		}
		$insert = [];
		$insert["uid"] = $uid;
		$insert["weid"] = $_W["uniacid"];
		$insert["content"] = $content;
		$insert["relation"] = $relation;
		$insert["testid"] = $testid;
		$insert["istatus"] = 1;
		$insert["createtime"] = time();
		$res = pdo_insert("goouc_fullexam_feedback", $insert);
		if ($res) {
			return $this->result(0, "反馈成功");
		} else {
			return $this->result(0, "反馈失败", "1005");
		}
	}
	public function dopageMyerrList()
	{
		global $_W;
		global $_GPC;
		$uid = $_GPC["uid"];
		if (empty($uid)) {
			return $this->result(1, "传递的参数不存在或失效", "1001");
		}
		$user_info = pdo_fetch("SELECT `status` FROM " . tablename("goouc_fullexam_user") . " WHERE weid=:weid AND id=:uid ", [":weid" => $_W["uniacid"], ":uid" => $uid]);
		if (empty($user_info)) {
			return $this->result(1, "用户不存在", "1002");
		}
		if ($user_info["status"] != 1) {
			return $this->result(1, "用户被禁用", "1003");
		}
		$all = pdo_fetchall("SELECT * from " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND istatus=1 ORDER BY createtime ASC ", [":weid" => $_W["uniacid"], ":uid" => $uid]);
		$e_list = [];
		foreach ($all as $k => $v) {
			if ($v["test_type"] > 4) {
				$info = pdo_fetch("SELECT id,pid from " . tablename("goouc_fullexam_test") . " where weid=:weid AND id=:id and istatus=1 ", [":weid" => $_W["uniacid"], ":id" => $v["testid"]]);
				$parent = pdo_fetch("select * from " . tablename("goouc_fullexam_test") . " where weid=:weid AND id=:id and istatus=1 ", [":weid" => $_W["uniacid"], ":id" => $info["pid"]]);
				if (!in_array($parent, $e_list)) {
					$e_list[] = $parent;
				}
			} else {
				$info = pdo_fetch("SELECT id,pid from " . tablename("goouc_fullexam_test") . " where weid=:weid AND id=:id and istatus=1 ", [":weid" => $_W["uniacid"], ":id" => $v["testid"]]);
				$e_list[] = $info;
			}
		}
		$total = count($e_list);
		$start = strtotime(date("Y-m-d"));
		$end = time();
		$day_id_list = pdo_fetchall("SELECT testid,test_type FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND istatus=1 AND (createtime between :sttime and :endtime) ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":sttime" => $start, ":endtime" => $end]);
		if (empty($day_id_list)) {
			$day_have_err = 2;
		} else {
			$day_have_err = 1;
		}
		$all_err_id = pdo_fetchall("SELECT testid,test_type FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND istatus=1 ORDER BY createtime ASC ", [":weid" => $_W["uniacid"], ":uid" => $uid]);
		if (empty($all_err_id)) {
			$all_have_err = 2;
		} else {
			$all_have_err = 1;
		}
		$start_day = strtotime("-1 week");
		$endtime = time();
		$err_id_list = pdo_fetchall("SELECT testid,test_type FROM " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND istatus=1 AND (createtime between :sttime and :endtime) ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":sttime" => $start_day, ":endtime" => $endtime]);
		if (empty($err_id_list)) {
			return $this->result(0, "近七日暂无错题,错题总数", ["total" => $total, "day_have_err" => $day_have_err, "all_have_err" => $all_have_err]);
		} else {
			$typelist = [];
			$test_type = unserialize(TEST_TYPE);
			foreach ($test_type as $key => $val) {
				if ($key > 4) {
					$q_have = pdo_fetchcolumn("select count(*) from " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND `test_type`=:type AND istatus=1  ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":type" => $key]);
					if ($q_have == 0) {
						continue;
					}
				} else {
					$q_have = pdo_fetchcolumn("select count(*) from " . tablename("goouc_fullexam_user_wrong_praction") . " WHERE weid=:weid AND uid=:uid AND `test_type`=:type AND istatus=1 ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":type" => $key]);
					if ($q_have == 0) {
						continue;
					}
				}
				$typelist[] = ["id" => $key, "name" => $val];
			}
			return $this->result(0, "错题界面,总数,题型列表", ["total" => $total, "typelist" => $typelist, "day_have_err" => $day_have_err, "all_have_err" => $all_have_err]);
		}
	}
	public function dopageGetAchievement()
	{
		global $_W;
		global $_GPC;
		$op = empty($_GPC["op"]) ? "myexam_info" : $_GPC["op"];
		if ($op == "myexam_info") {
			$uid = $_GPC["uid"];
			if (empty($uid)) {
				return $this->result(1, "传递的参数不存在或失效", "1001");
			}
			$user_info = pdo_fetch("SELECT `status` FROM " . tablename("goouc_fullexam_user") . " WHERE weid=:weid AND id=:uid ", [":weid" => $_W["uniacid"], ":uid" => $uid]);
			if (empty($user_info)) {
				return $this->result(1, "用户不存在", "1002");
			}
			if ($user_info["status"] != 1) {
				return $this->result(1, "用户被禁用", "1003");
			}
			$doexam_list = pdo_fetchall("SELECT examid,franction FROM " . tablename("goouc_fullexam_user_doexam") . " WHERE weid=:weid AND uid=:uid ", [":weid" => $_W["uniacid"], ":uid" => $uid]);
			$other_list = pdo_fetchall("SELECT recordid,franction FROM " . tablename("goouc_fullexam_user_doother_exam") . " WHERE weid=:weid AND uid=:uid ", [":weid" => $_W["uniacid"], ":uid" => $uid]);
			$pass_num = 0;
			$doexam_num = 0;
			$calculate = 0;
			$id_arr = pdo_fetchall("SELECT testid,test_type FROM " . tablename("goouc_fullexam_exercise") . " WHERE weid=:weid AND uid=:uid AND istatus=1 ", [":weid" => $_W["uniacid"], ":uid" => $uid]);
			$parent_arr = [];
			$num = 0;
			foreach ($id_arr as $kk => $vv) {
				if ($vv["test_type"] == 5) {
					$info = pdo_fetch("SELECT id,pid FROM " . tablename("goouc_fullexam_test") . " WHERE weid=:weid AND istatus=1 AND id=:id ", [":weid" => $_W["uniacid"], ":id" => $vv["testid"]]);
					$parent = pdo_fetchcolumn("SELECT id FROM " . tablename("goouc_fullexam_test") . " WHERE weid=:weid AND istatus=1 AND id=:pid ", [":weid" => $_W["uniacid"], ":pid" => $info["pid"]]);
					if (!in_array($parent, $parent_arr)) {
						$parent_arr[] = $parent;
					}
				} else {
					$num += 1;
				}
			}
			$pnum = count($parent_arr);
			$dotest_total_num = $pnum + $num;
			$dotest_right_num = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename("goouc_fullexam_exercise") . " WHERE weid=:weid AND uid=:uid AND isright=1 ", [":weid" => $_W["uniacid"], ":uid" => $uid]);
			if ($dotest_total_num != 0) {
				$right_lv = round($dotest_right_num / $dotest_total_num, 2) * 100;
				if ($right_lv != 0) {
					$right_lv = $right_lv;
				} else {
					$right_lv = 0;
				}
			} else {
				$right_lv = 0;
				$dotest_total_num = 0;
			}
			$test_total = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename("goouc_fullexam_test") . " WHERE weid=:weid AND istatus=1 and `type`!=0 ", [":weid" => $_W["uniacid"]]);
			$not_donum = $test_total - $dotest_total_num;
			if (!empty($other_list)) {
				$setting = pdo_fetch("SELECT franction,paper_time FROM " . tablename("goouc_fullexam_setting") . " WHERE weid=:weid ", [":weid" => $_W["uniacid"]]);
				$setting["franction"] = unserialize($setting["franction"]);
				$data = [];
				$total_score = 0;
				$total_qnum = 0;
				foreach ($setting["franction"] as $key => $val) {
					$data["type_num_" . $key] = $val["num_" . $key];
					$data["type_score_" . $key] = $val["num_" . $key] * $val["franction_" . $key];
					$total_score += $data["type_score_" . $key];
					$total_qnum += $data["type_num_" . $key];
				}
				foreach ($other_list as $kk => $vv) {
					if ($vv["franction"] >= $total_score * 0.6) {
						$pass_num += 1;
					}
				}
				$doexam_num += count($other_list);
				$my_other_score = pdo_fetchcolumn("SELECT franction FROM " . tablename("goouc_fullexam_user_doother_exam") . " WHERE weid=:weid AND uid=:uid ORDER BY franction DESC LIMIT 1", [":weid" => $_W["uniacid"], ":uid" => $uid]);
				$other_sum_score = pdo_fetchcolumn("select sum(franction) from " . tablename("goouc_fullexam_user_doother_exam") . " WHERE weid=:weid AND uid=:uid ", [":weid" => $_W["uniacid"], ":uid" => $uid]);
				$other_exam_num = pdo_fetchcolumn("SELECT count(*) FROM " . tablename("goouc_fullexam_user_doother_exam") . " WHERE weid=:weid AND uid=:uid ", [":weid" => $_W["uniacid"], ":uid" => $uid]);
			}
			if (!empty($doexam_list)) {
				foreach ($doexam_list as $key => $val) {
					$paper_score = pdo_fetchcolumn("SELECT total_franction FROM " . tablename("goouc_fullexam_paper") . " WHERE weid=:weid AND id=:paperid AND istatus=1 ", [":weid" => $_W["uniacid"], ":paperid" => $val["examid"]]);
					if ($val["franction"] >= $paper_score * 0.6) {
						$pass_num += 1;
					}
				}
				$doexam_num += count($doexam_list);
				$my_exam_score = pdo_fetchcolumn("SELECT franction FROM " . tablename("goouc_fullexam_user_doexam") . " WHERE weid=:weid AND uid=:uid ORDER BY franction DESC LIMIT 1", [":weid" => $_W["uniacid"], ":uid" => $uid]);
				$sum_score = pdo_fetchcolumn("select sum(franction) from " . tablename("goouc_fullexam_user_doexam") . " WHERE weid=:weid AND uid=:uid AND istatus=1 ", [":weid" => $_W["uniacid"], ":uid" => $uid]);
				$do_exam_num = pdo_fetchcolumn("SELECT count(*) FROM " . tablename("goouc_fullexam_user_doexam") . " WHERE weid=:weid AND uid=:uid AND istatus=1 ", [":weid" => $_W["uniacid"], ":uid" => $uid]);
			}
			if (!!($other_exam_num + $doexam_num)) {
				$calculate = round(($other_sum_score + $sum_score) / ($other_exam_num + $do_exam_num), 2);
			}
			if ($my_exam_score != 0 || $my_other_score != 0) {
				if ($my_exam_score <= $my_other_score) {
					$my_score = $my_other_score;
				} else {
					$my_score = $my_exam_score;
				}
			} else {
				$my_score = 0;
			}
			$setting = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_setting") . " WHERE weid=:weid ", [":weid" => $_W["uniacid"]]);
			$standard_num = $setting["standard"];
			$leiji = 0;
			$all_record = pdo_fetchall("SELECT count(*) as day_total FROM " . tablename("goouc_fullexam_exercise") . " WHERE weid=:weid AND uid=:uid group by FROM_UNIXTIME(createtime,'%Y-%m-%d') ORDER BY createtime ASC ", [":weid" => $_W["uniacid"], ":uid" => $uid]);
			foreach ($all_record as $k => $v) {
				if ($standard_num <= $v["day_total"]) {
					$leiji += 1;
				}
			}
			$everyday = [];
			$continuity = 0;
			$oneday = 86400;
			$monday = strtotime("this week Monday", time());
			$day = $monday + $oneday;
			for ($i = 0; $i <= 6; $i++) {
				$everyday[$i]["donum"] = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename("goouc_fullexam_exercise") . " WHERE weid=:weid AND uid=:uid AND istatus=1 AND (createtime between :begintime and :endtime) ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":begintime" => $monday, ":endtime" => $day]);
				$monday += $oneday;
				$day += $oneday;
				if (!empty($everyday[$i]["donum"])) {
					if ($standard_num <= $everyday[$i]["donum"]) {
						$everyday[$i]["standard"] = 1;
						$continuity += 1;
					} else {
						$everyday[$i]["standard"] = 2;
					}
				} else {
					$everyday[$i]["standard"] = 3;
				}
			}
			$info = [];
			$info["continuity"] = $continuity;
			$info["leiji"] = $leiji;
			$info["dabiao_num"] = $standard_num;
			$right_lv = round($right_lv);
			return $this->result(0, "成绩,及格次数,考试次数,分数预测,正确率,做题量,未做数量,统计图,(连续达标天数,累计达标天数,每天几道题达标)", ["myscore" => $my_score, "pass_num" => $pass_num, "doexam_num" => $doexam_num, "calculate" => $calculate, "right_lv" => $right_lv, "dotest_num" => $dotest_total_num, "not_donum" => $not_donum, "tongji_chart" => $everyday, "info" => $info]);
		} elseif ($op == "ranking") {
			$rankType = intval($_GPC["rankType"]);
			if (empty($rankType)) {
				return $this->result(1, "传递的参数不存在", "1004");
			}
			if ($rankType == 1) {
				$whole_list = pdo_fetchall("SELECT uid,franction FROM " . tablename("goouc_fullexam_user_doexam") . " WHERE weid=:weid AND istatus=1 ORDER BY franction DESC LIMIT 20 ", [":weid" => $_W["uniacid"]]);
				$other_list = pdo_fetchall("SELECT uid,franction FROM " . tablename("goouc_fullexam_user_doother_exam") . " WHERE weid=:weid AND istatus=1 ORDER BY franction DESC LIMIT 20 ", [":weid" => $_W["uniacid"]]);
				foreach ($whole_list as $k => $v) {
					$whole_list[$k] = pdo_fetch("SELECT ud.franction,u.nickname,u.headimg,u.id FROM " . tablename("goouc_fullexam_user_doexam") . " ud LEFT JOIN " . tablename("goouc_fullexam_user") . " u ON ud.uid = u.id WHERE ud.weid=:weid AND ud.istatus=1 AND u.status=1 AND ud.uid=:uid ORDER BY ud.franction DESC LIMIT 1 ", [":weid" => $_W["uniacid"], ":uid" => $v["uid"]]);
				}
				foreach ($other_list as $k => $v) {
					$other_list[$k] = pdo_fetch("SELECT ude.franction,u.nickname,u.headimg,u.id FROM " . tablename("goouc_fullexam_user_doother_exam") . " ude LEFT JOIN " . tablename("goouc_fullexam_user") . " u ON ude.uid=u.id WHERE ude.weid=:weid AND ude.istatus=1 AND u.status=1 AND ude.uid=:uid ORDER BY ude.franction DESC LIMIT 1 ", [":weid" => $_W["uniacid"], ":uid" => $v["uid"]]);
				}
				if (empty($whole_list) && empty($other_list)) {
					return $this->result(1, "暂无全部排行数据", "1005");
				} else {
					$list = [];
					foreach ($whole_list as $k => $v) {
						if (!in_array($v, $list)) {
							$list[] = $v;
						}
					}
					foreach ($other_list as $k => $v) {
						if (!in_array($v, $list)) {
							$list[] = $v;
						}
					}
					for ($i = 0; $i < count($list); $i++) {
						for ($j = $i + 1; $j < count($list); $j++) {
							if ($list[$i]["franction"] < $list[$j]["franction"]) {
								$tmp = $list[$i];
								$list[$i] = $list[$j];
								$list[$j] = $tmp;
							}
						}
					}
					$newList = [];
					foreach ($list as $key => $val) {
						$has = "";
						foreach ($newList as $v) {
							if ($v["id"] == $val["id"]) {
								$has = 1;
								break;
							}
						}
						if (!$has) {
							$newList[] = $val;
						}
					}
					return $this->result(0, "全部排行", ["list" => $newList]);
				}
			} elseif ($rankType == 2) {
				$school = intval($_GPC["school_id"]);
				if (empty($school)) {
					return $this->result(1, "传递的参数不存在", "1006");
				}
				$whole_list = pdo_fetchall("SELECT uid,franction FROM " . tablename("goouc_fullexam_user_doexam") . " WHERE weid=:weid AND istatus=1 ORDER BY franction DESC LIMIT 20 ", [":weid" => $_W["uniacid"]]);
				$other_list = pdo_fetchall("SELECT uid,franction FROM " . tablename("goouc_fullexam_user_doother_exam") . " WHERE weid=:weid AND istatus=1 ORDER BY franction DESC LIMIT 20 ", [":weid" => $_W["uniacid"]]);
				if (!empty($whole_list)) {
					foreach ($whole_list as $k => $v) {
						$whole_list[$k] = pdo_fetch("SELECT ud.franction,u.nickname,u.headimg,u.id FROM " . tablename("goouc_fullexam_user_doexam") . " ud LEFT JOIN " . tablename("goouc_fullexam_user") . " u ON ud.uid = u.id WHERE ud.weid=:weid AND ud.istatus=1 AND u.status=1 AND ud.uid=:uid AND school=:school ORDER BY ud.franction DESC LIMIT 1 ", [":weid" => $_W["uniacid"], ":uid" => $v["uid"], ":school" => $school]);
					}
					foreach ($whole_list as $k => $v) {
						if (!$v) {
							unset($whole_list[$k]);
						}
					}
				}
				if (!empty($other_list)) {
					foreach ($other_list as $k => $v) {
						$other_list[$k] = pdo_fetch("SELECT ude.franction,u.nickname,u.headimg,u.id FROM " . tablename("goouc_fullexam_user_doother_exam") . " ude LEFT JOIN " . tablename("goouc_fullexam_user") . " u ON ude.uid=u.id WHERE ude.weid=:weid AND ude.istatus=1 AND u.status=1 AND ude.uid=:uid AND u.school=:school ORDER BY ude.franction DESC LIMIT 1 ", [":weid" => $_W["uniacid"], ":uid" => $v["uid"], ":school" => $school]);
					}
					foreach ($other_list as $k => $v) {
						if (!$v) {
							unset($other_list[$k]);
						}
					}
				}
				if (empty($whole_list) && empty($other_list)) {
					return $this->result(1, "暂无校内排行数据", "1007");
				} else {
					$list = [];
					foreach ($whole_list as $k => $v) {
						if (!in_array($v, $list)) {
							$list[] = $v;
						}
					}
					foreach ($other_list as $k => $v) {
						if (!in_array($v, $list)) {
							$list[] = $v;
						}
					}
					for ($i = 0; $i < count($list); $i++) {
						for ($j = $i + 1; $j < count($list); $j++) {
							if ($list[$i]["franction"] < $list[$j]["franction"]) {
								$tmp = $list[$i];
								$list[$i] = $list[$j];
								$list[$j] = $tmp;
							}
						}
					}
					$newList = [];
					foreach ($list as $key => $val) {
						$has = "";
						foreach ($newList as $v) {
							if ($v["id"] == $val["id"]) {
								$has = 1;
								break;
							}
						}
						if (!$has) {
							$newList[] = $val;
						}
					}
					return $this->result(0, "校内排行", ["list" => $newList]);
				}
			} elseif ($rankType == 3) {
				$grade = intval($_GPC["banji_id"]);
				if (empty($grade)) {
					return $this->result(1, "传递的参数不存在", "1008");
				}
				$whole_list = pdo_fetchall("SELECT uid,franction FROM " . tablename("goouc_fullexam_user_doexam") . " WHERE weid=:weid AND istatus=1 ORDER BY franction DESC LIMIT 20 ", [":weid" => $_W["uniacid"]]);
				$other_list = pdo_fetchall("SELECT uid,franction FROM " . tablename("goouc_fullexam_user_doother_exam") . " WHERE weid=:weid AND istatus=1 ORDER BY franction DESC LIMIT 20 ", [":weid" => $_W["uniacid"]]);
				if (!empty($whole_list)) {
					foreach ($whole_list as $k => $v) {
						$whole_list[$k] = pdo_fetch("SELECT ud.franction,u.nickname,u.headimg,u.id FROM " . tablename("goouc_fullexam_user_doexam") . " ud LEFT JOIN " . tablename("goouc_fullexam_user") . " u ON ud.uid = u.id WHERE ud.weid=:weid AND ud.istatus=1 AND u.status=1 AND ud.uid=:uid AND u.grade=:grade ORDER BY ud.franction DESC LIMIT 1 ", [":weid" => $_W["uniacid"], ":uid" => $v["uid"], ":grade" => $grade]);
					}
					foreach ($whole_list as $k => $v) {
						if (!$v) {
							unset($whole_list[$k]);
						}
					}
				}
				if (!empty($other_list)) {
					foreach ($other_list as $k => $v) {
						$other_list[$k] = pdo_fetch("SELECT ude.franction,u.nickname,u.headimg,u.id FROM " . tablename("goouc_fullexam_user_doother_exam") . " ude LEFT JOIN " . tablename("goouc_fullexam_user") . " u ON ude.uid=u.id WHERE ude.weid=:weid AND ude.istatus=1 AND u.status=1 AND ude.uid=:uid AND u.grade=:grade ORDER BY ude.franction DESC LIMIT 1 ", [":weid" => $_W["uniacid"], ":uid" => $v["uid"], ":grade" => $grade]);
					}
					foreach ($other_list as $k => $v) {
						if (!$v) {
							unset($other_list[$k]);
						}
					}
				}
				if (empty($whole_list) && empty($other_list)) {
					return $this->result(1, "暂无班内排行数据", "1009");
				} else {
					$list = [];
					foreach ($whole_list as $k => $v) {
						if (!in_array($v, $list)) {
							$list[] = $v;
						}
					}
					foreach ($other_list as $k => $v) {
						if (!in_array($v, $list)) {
							$list[] = $v;
						}
					}
					for ($i = 0; $i < count($list); $i++) {
						for ($j = $i + 1; $j < count($list); $j++) {
							if ($list[$i]["franction"] < $list[$j]["franction"]) {
								$tmp = $list[$i];
								$list[$i] = $list[$j];
								$list[$j] = $tmp;
							}
						}
					}
					$newList = [];
					foreach ($list as $key => $val) {
						$has = "";
						foreach ($newList as $v) {
							if ($v["id"] == $val["id"]) {
								$has = 1;
								break;
							}
						}
						if (!$has) {
							$newList[] = $val;
						}
					}
					return $this->result(0, "班内排行", ["list" => $newList]);
				}
			}
		}
	}
	public function dopageUploadImage()
	{
		global $_GPC;
		global $_W;
		$uptypes = ["image/jpg", "image/jpeg", "image/png", "image/pjpeg", "image/gif", "image/bmp", "image/x-png"];
		$max_file_size = 2000000;
		$destination_folder = $_GPC["m"] . "/";
		if (!is_uploaded_file($_FILES["upfile"]["tmp_name"])) {
			echo "图片不存在!";
			exit;
		}
		$file = $_FILES["upfile"];
		if ($max_file_size < $file["size"]) {
			echo "文件太大!";
			exit;
		}
		if (!in_array($file["type"], $uptypes)) {
			echo "文件类型不符!" . $file["type"];
			exit;
		}
		if (!file_exists('../attachment/' . $destination_folder)) {
			mkdir("../attachment/" . $destination_folder);
		}
		$filename = $file["tmp_name"];
		$pinfo = pathinfo($file["name"]);
		$ftype = $pinfo["extension"];
		$destination = "../attachment/" . $destination_folder . str_shuffle(time() . rand(111111, 999999)) . "." . $ftype;
		if (!move_uploaded_file($filename, $destination)) {
			echo "移动文件出错";
			exit;
		}
		$pinfo = pathinfo($destination);
		$fname = $pinfo["basename"];
		echo $_W["attachurl"] . $destination_folder . $fname;
	}
	public function dopageUpdateHeadimg()
	{
		global $_W;
		global $_GPC;
		$uid = intval($_GPC["uid"]);
		$headimg = $_GPC["headimg"];
		if (empty($uid) || empty($headimg)) {
			return $this->result(1, "传递的参数不存在", "1001");
		}
		$res = pdo_update("goouc_fullexam_user", ["headimg" => $headimg], ["weid" => $_W["uniacid"], "id" => $uid]);
		if ($res) {
			return $this->result(0, "ok", "ok");
		} else {
			return $this->result(1, "error", "error");
		}
	}
	public function mb_rtrim($string, $trim_chars = "\\s")
	{
		return preg_replace("/^[" . $trim_chars . "]*(?U)(.*)[" . $trim_chars . "]*\$/u", "\\1", $string);
	}
	public function Makeformat($itembank, $uid = "", $paperid = "")
	{
		global $_W;
		foreach ($itembank as $k => $v) {
			if (!empty($v["qaudio"])) {
				$itembank[$k]["qaudio"] = $_W["attachurl"] . $v["qaudio"];
			}
			if (!empty($v["qimage"])) {
				$itembank[$k]["qimage"] = unserialize($v["qimage"]);
				foreach ($itembank[$k]["qimage"] as $kk => $vv) {
					if (!preg_match("/(http:\\/\\/)|(https:\\/\\/)/i", $vv)) {
						$itembank[$k]["qimage"][$kk] = $_W["attachurl"] . $vv;
					}
				}
			}
			if (!empty($v["question"])) {
				$itembank[$k]["question"] = htmlspecialchars_decode($v["question"], ENT_QUOTES);
			}
			if (!empty($v["aimage"])) {
				$itembank[$k]["aimage"] = unserialize($v["aimage"]);
				foreach ($itembank[$k]["aimage"] as $kk => $vv) {
					if (!preg_match("/(http:\\/\\/)|(https:\\/\\/)/i", $vv)) {
						$itembank[$k]["aimage"][$kk] = $_W["attachurl"] . $vv;
					}
				}
			}
			if (!empty($v["analysis_audio"])) {
				$itembank[$k]["analysis_audio"] = $_W["attachurl"] . $v["analysis_audio"];
			}
			if (!empty($v["analysis"])) {
				$itembank[$k]["analysis"] = htmlspecialchars_decode($v["analysis"]);
			}
			$itembank[$k]["option"] = unserialize($v["option"]);
			if (!empty($itembank[$k]["option"])) {
				foreach ($itembank[$k]["option"] as $kk => $vv) {
					$vv = htmlspecialchars_decode($vv, ENT_QUOTES);
					if ($v["a_type"] != 0) {
						if (!empty($vv)) {
							if (!preg_match("/(http:\\/\\/)|(https:\\/\\/)/i", $vv)) {
								$vv = $_W["attachurl"] . $vv;
							}
						}
					}
					$itembank[$k]["option"][] = ["o" => $kk, "p" => $vv];
					unset($itembank[$k]["option"][$kk]);
				}
			}
			if ($v["type"] == 4) {
				$v["rightkey"] = explode("|", $v["rightkey"]);
				foreach ($v["rightkey"] as $kk => $value) {
					mb_internal_encoding("UTF-8");
					$encoding = mb_internal_encoding();
					$value = $this->mb_rtrim($value, "【");
					$value = $this->mb_rtrim($value, "】");
					$itembank[$k]["rightarray"] = explode("】【", $value);
				}
			}
			if ($v["type"] > 4 && $v["type"] < 8) {
				$sonlist = pdo_fetchall("SELECT * FROM " . tablename("goouc_fullexam_test") . " WHERE weid=:weid AND pid=:pid ORDER BY id ASC ", [":weid" => $_W["uniacid"], ":pid" => $v["id"]]);
				if (!empty($sonlist)) {
					$itembank[$k]["list"] = $this->Makeformat($sonlist);
				}
			}
			if ($v["type"] == 8) {
				$do_answer = pdo_fetch(" SELECT * FROM " . tablename($this->t_user_exam_answer) . " WHERE weid = :weid AND uid = :uid AND testid = :testid AND examid = :examid order by createtime DESC ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":examid" => $paperid, "testid" => $v["id"]]);
				if ($do_answer == "") {
					$itembank[$k]["comments"] = "未填写评语";
				} else {
					$itembank[$k]["comments"] = $do_answer["comments"];
				}
				$itembank[$k]["uanswer"] = $do_answer["uanswer"];
				$itembank[$k]["get_simple_scores"] = $do_answer["simple_score"];
				$simple_questions = pdo_getcolumn($this->t_paper, ["weid" => $_W["uniacid"], "id" => $paperid], "franction");
				$simples = unserialize($simple_questions);
				$itembank[$k]["simple_scores"] = $simples[8]["franction_8"];
			}
		}
		return $itembank;
	}
	public function dopageKnowledge()
	{
		global $_W;
		global $_GPC;
		$uid = $_GPC["uid"];
		$op = $_GPC["op"];
		$freeknowledgenum = pdo_getcolumn("goouc_fullexam_setting", ["weid" => $_W["uniacid"]], "freeknowledgenum");
		$pay_open = pdo_getcolumn("goouc_fullexam_setting", ["weid" => $_W["uniacid"]], "pay_open");
		if ($op == "cate") {
			$type = intval($_GPC["type"]);
			$list = pdo_fetchall("SELECT `id`,`name` FROM " . tablename("goouc_fullexam_knowledge_cate") . " WHERE weid=:weid AND istatus=1 AND pid = 0 AND status = 1 AND type = :type ORDER BY id ASC ", [":weid" => $_W["uniacid"], ":type" => $type]);
			if (!empty($list)) {
				foreach ($list as &$val) {
					$son = pdo_fetchall("SELECT `id`,`name`,price FROM " . tablename("goouc_fullexam_knowledge_cate") . " WHERE weid=:weid AND istatus=1 AND pid=:pid AND status = 1 ORDER BY id ASC ", [":weid" => $_W["uniacid"], ":pid" => $val["id"]]);
					if (!empty($son)) {
						foreach ($son as &$v) {
							$vson = pdo_fetchall("SELECT `id`,`name` FROM " . tablename("goouc_fullexam_knowledge_cate") . " WHERE weid=:weid AND istatus=1 AND pid=:pid AND status = 1 ORDER BY id ASC ", [":weid" => $_W["uniacid"], ":pid" => $v["id"]]);
							$v["is_can"] = 0;
							if ($v["price"] > 0) {
								$kid = pdo_getcolumn("goouc_fullexam_user_knowledge_cate", ["weid" => $_W["uniacid"], "uid" => $uid, "cate" => $v["id"], "istatus" => 1], "id");
								if (!empty($kid)) {
									$v["is_can"] = 1;
								}
							} else {
								$v["is_can"] = 1;
							}
							$is_member = pdo_getcolumn($this->t_user, ["weid" => $_W["uniacid"], "id" => $uid], "ismember");
							$z_vip = pdo_get("goouc_fullexam_user_member", ["weid" => $_W["uniacid"]]);
							$v["vip_price"] = $v["price"] * $z_vip["scale"];
							$v["vip_price"] = floor($v["vip_price"] * 100) / 100;
							if ($is_member == 1) {
								if ($v["vip_price"] <= 0) {
									$v["is_can"] = 1;
								}
							}
							$now_time = date("Y-m-d H:i:s");
							$cdkeys = pdo_getall("goouc_fullexam_cdkeys", ["weid" => $_W["uniacid"], "kpool_id" => $v["id"], "type" => 3], ["code_id"]);
							$cdkeys = array_column($cdkeys, "code_id");
							$cdkeys = implode(",", $cdkeys);
							if (!empty($cdkeys)) {
								$active = pdo_fetch(" SELECT * FROM " . tablename("goouc_fullexam_cdkey") . " WHERE weid =:weid AND uid=:uid AND status =2 AND display=1 AND kpool > :kpool AND cid in (" . $cdkeys . ")", [":weid" => $_W["uniacid"], "uid" => $uid, ":kpool" => $now_time]);
								if ($active) {
									$v["is_can"] = 1;
								}
							}
							if (!empty($vson)) {
								foreach ($vson as $k => $a) {
									$is_can = 0;
									if ($v["is_can"] == 1) {
										$is_can = 1;
									} else {
										if ($k < intval($freeknowledgenum)) {
											$is_can = 1;
										}
									}
									$vson[$k]["is_can"] = $is_can;
								}
								$v["son"] = $vson;
							}
						}
						unset($v);
						$val["son"] = $son;
					}
				}
				unset($val);
			}
			return $this->result(0, "获取知识点列表", ["list" => $list, "pay_open" => intval($pay_open)]);
		} elseif ($op == "knowledgelist") {
			$cate = intval($_GPC["cate"]);
			$fcate = pdo_getcolumn("goouc_fullexam_knowledge_cate", ["weid" => $_W["uniacid"], "id" => $cate], "pid");
			$price = pdo_getcolumn("goouc_fullexam_knowledge_cate", ["weid" => $_W["uniacid"], "id" => $fcate], "price");
			$is_member = pdo_getcolumn($this->t_user, ["weid" => $_W["uniacid"], "id" => $uid], "ismember");
			$z_vip = pdo_get("goouc_fullexam_user_member", ["weid" => $_W["uniacid"]]);
			$vip_price = $price * $z_vip["scale"];
			$vip_price = floor($vip_price * 100) / 100;
			$is_can = 0;
			if ($price <= 0) {
				$is_can = 1;
			} else {
				$kid = pdo_getcolumn("goouc_fullexam_user_knowledge_cate", ["weid" => $_W["uniacid"], "uid" => $uid, "cate" => $fcate, "istatus" => 1], "id");
				if (!empty($kid)) {
					$is_can = 1;
				}
			}
			if ($is_member == 1) {
				if ($vip_price <= 0) {
					$is_can = 1;
				}
			}
			$now_time = date("Y-m-d H:i:s");
			$cdkeys = pdo_getall("goouc_fullexam_cdkeys", ["weid" => $_W["uniacid"], "kpool_id" => $fcate, "type" => 3], ["code_id"]);
			$cdkeys = array_column($cdkeys, "code_id");
			$cdkeys = implode(",", $cdkeys);
			if (!empty($cdkeys)) {
				$active = pdo_fetch(" SELECT * FROM " . tablename("goouc_fullexam_cdkey") . " WHERE weid =:weid AND uid=:uid AND status =2 AND display=1 AND kpool > :kpool AND cid in (" . $cdkeys . ")", [":weid" => $_W["uniacid"], "uid" => $uid, ":kpool" => $now_time]);
				if ($active) {
					$is_can = 1;
				}
			}
			$list = pdo_fetchall("SELECT `id`,title,content FROM " . tablename("goouc_fullexam_knowledge") . " WHERE weid=:weid AND istatus=1 AND three = :three AND status = 1 ORDER BY id ASC ", [":weid" => $_W["uniacid"], ":three" => $cate]);
			if (!empty($list)) {
				foreach ($list as $key => $val) {
					$list[$key]["is_can"] = $is_can;
					if ($key < intval($freeknowledgenum)) {
						$list[$key]["is_can"] = 1;
					}
				}
			}
			return $this->result(0, "获取知识点", ["list" => $list, "pay_open" => intval($pay_open), "price" => $price, "vip_price" => $vip_price]);
		}
	}
	public function dopageSetCDKey()
	{
		global $_W;
		global $_GPC;
		$uid = intval($_GPC["uid"]);
		$code = trim($_GPC["code"]);
		$sql = "SELECT k.id,k.cid,k.kpool as kpools,c.msg,c.papers FROM " . tablename("goouc_fullexam_cdkey") . " as k LEFT JOIN " . tablename("goouc_fullexam_cdkey_cate") . " AS c ON k.cid=c.id WHERE k.`weid`=:weid AND k.code = :code AND k.status = 1  AND c.is_delete = 1 AND k.uid = 0 ";
		$params = [];
		$params[":weid"] = $_W["uniacid"];
		$params[":code"] = $code;
		$item = pdo_fetch($sql, $params);
		if (empty($item)) {
			return $this->result(1, "该激活码不可用", "");
		}
		$time = date("Y/m/d H:i:s");
		if (strtotime($time) >= strtotime($item["kpools"])) {
			return $this->result(1, "该激活码已过期", "");
		}
		$qpool = [];
		$kpool = [];
		pdo_update('goouc_fullexam_cdkey', ['status' => 2, 'usetime' => TIMESTAMP, 'uid' => $uid], ["id" => $item["id"]]);
		$msg = "激活成功";
		if (!empty($item["msg"])) {
			$msg = $item["msg"];
		}
		return $this->result(0, $msg, "");
	}
	public function dopageWxPay()
	{
		global $_W;
		global $_GPC;
		$uid = intval($_GPC["uid"]);
		$type = intval($_GPC["type"]);
		$id = intval($_GPC["id"]);
		$pay_open = pdo_getcolumn("goouc_fullexam_setting", ["weid" => $_W["uniacid"]], "pay_open");
		$openid = pdo_getcolumn("goouc_fullexam_user", ["weid" => $_W["uniacid"], "id" => $uid], "openid");
		if ($pay_open != 1) {
			return $this->result(1, "未开启支付", []);
		}
		$price = 0;
		$is_member = pdo_getcolumn("goouc_fullexam_user", ["weid" => $_W["uniacid"], "id" => $uid], "ismember");
		if ($type == 1) {
			$price = pdo_getcolumn("goouc_fullexam_test_type", ["weid" => $_W["uniacid"], "status" => 1, "istatus" => 1, "id" => $id], "price");
			if ($is_member == 1) {
				$z_vip = pdo_get("goouc_fullexam_user_member", ["weid" => $_W["uniacid"]]);
				$price = $price * $z_vip["scale"];
				$price = floor($price * 100) / 100;
			}
			if ($price > 0) {
				$has = pdo_getcolumn("goouc_fullexam_user_pool", ["weid" => $_W["uniacid"], "uid" => $uid, "poolid" => $id, "istatus" => 1], "id");
				if (!empty($has)) {
					return $this->result(1, "您已经购买过该题库了", []);
				}
			} else {
				return $this->result(1, "该题库不需要购买", []);
			}
		} elseif ($type == 2) {
			$price = pdo_getcolumn("goouc_fullexam_knowledge_cate", ["weid" => $_W["uniacid"], "status" => 1, "istatus" => 1, "id" => $id], "price");
			if ($is_member == 1) {
				$z_vip = pdo_get("goouc_fullexam_user_member", ["weid" => $_W["uniacid"]]);
				$price = $price * $z_vip["scale"];
				$price = floor($price * 100) / 100;
			}
			if ($price > 0) {
				$has = pdo_getcolumn("goouc_fullexam_user_knowledge_cate", ["weid" => $_W["uniacid"], "uid" => $uid, "cate" => $id, "istatus" => 1], "id");
				if (!empty($has)) {
					return $this->result(1, "您已经购买过该知识点了", []);
				}
			} else {
				return $this->result(1, "该知识点不需要购买", []);
			}
		} elseif ($type == 3) {
			$vipinfo = pdo_get("goouc_fullexam_user_member", ["weid" => $_W["uniacid"]]);
			$vipinfo["info"] = unserialize($vipinfo["info"]);
			$id = intval($_GPC["memberid"]);
			$uid = intval($_GPC["uid"]);
			if (empty($uid) || empty($id)) {
				return $this->result(1, "传递参数不存在", "1001");
			}
			$uinfo = pdo_get("goouc_fullexam_user", ["weid" => $_W["uniacid"], "id" => $uid, "istatus" => 1]);
			foreach ($vipinfo["info"] as $k => $v) {
				if ($v["id"] == $id) {
					$minfo = $v;
				}
			}
			if (empty($minfo)) {
				return $this->result(1, "VIP信息错误", "1002");
			}
			$price = $minfo["price"];
			if ($price <= 0) {
				return $this->result(1, "支付金额错误", "1003");
			}
		} elseif ($type == 4) {
			$price = pdo_getcolumn("goouc_fullexam_paper", ["weid" => $_W["uniacid"], "status" => 1, "istatus" => 1, "id" => $id], "price");
			if ($is_member == 1) {
				$z_vip = pdo_get("goouc_fullexam_user_member", ["weid" => $_W["uniacid"]]);
				$price = $price * $z_vip["scale"];
				$price = floor($price * 100) / 100;
			}
			if ($price > 0) {
				$has = pdo_getcolumn("goouc_fullexam_user_pool", ["weid" => $_W["uniacid"], "uid" => $uid, "poolid" => $id, "istatus" => 1], "id");
				if (!empty($has)) {
					return $this->result(1, "您已经购买过该题库了", []);
				}
			} else {
				return $this->result(1, "该题库不需要购买", []);
			}
		}
		if ($price > 0) {
			$order_sn = getNonceStr(8) . date("his") . getNonceStr(8);
			$insert = [];
			$insert["weid"] = $_W["uniacid"];
			$insert["type"] = $type;
			$insert["out_trade_no"] = $order_sn;
			$insert["userid"] = $uid;
			$insert["openid"] = $openid;
			$insert["order_status"] = 0;
			$insert["all_money"] = $price;
			$insert["true_money"] = $price;
			$insert["createtime"] = TIMESTAMP;
			$insert["msg"] = "微信支付";
			$insert["dataid"] = $id;
			pdo_insert('goouc_fullexam_order', $insert);
			$orderid = pdo_insertid();
			$sys = pdo_fetch("SELECT mchid,pay_secret FROM " . tablename("goouc_fullexam_setting") . " WHERE weid = :weid ", [":weid" => $_W["uniacid"]]);
			$nonce_str = getNonceStr(32);
			$fee = $price * 100;
			$spbill_create_ip = $_SERVER["REMOTE_ADDR"];
			$notify = $_W["siteroot"] . "addons/goouc_fullexam/wxresult.php";
			$orderinfo = ["appid" => $_W["account"]["key"], "mch_id" => $sys["mchid"], "nonce_str" => $nonce_str, "body" => "资料购买", "out_trade_no" => $order_sn, "total_fee" => $fee, "spbill_create_ip" => $spbill_create_ip, "notify_url" => $notify, "trade_type" => "JSAPI", "openid" => $openid];
			$sign = getSign($orderinfo, $sys["pay_secret"]);
			$orderinfo["sign"] = $sign;
			$xml = arrayToXml($orderinfo);
			$url = "https://api.mch.weixin.qq.com/pay/unifiedorder";
			$res = api_notice_increment($url, $xml);
			libxml_disable_entity_loader(true);
			$xmlstring = simplexml_load_string($res, "SimpleXMLElement", LIBXML_NOCDATA);
			$returnarr = json_decode(json_encode($xmlstring), true);
			$data = [];
			if ($returnarr["return_code"] == "SUCCESS" && $returnarr["result_code"] == "SUCCESS") {
				$prepay_id = $returnarr["prepay_id"];
				$update = [];
				$update["transaction_sn"] = $prepay_id;
				pdo_update('goouc_fullexam_order', $update, ["id" => $orderid, "weid" => $_W["uniacid"]]);
				$data = ["appId" => $_W["account"]["key"], "timeStamp" => TIMESTAMP, "nonceStr" => $nonce_str, "package" => "prepay_id=" . $prepay_id, "signType" => "MD5"];
				$paySign = getSign($data, $sys["pay_secret"]);
				$data["paySign"] = $paySign;
				return $this->result(0, "获取支付参数", $data);
			} else {
				$data["msg"] = $returnarr["return_msg"];
				return $this->result(1, "支付失败，请重试", $data);
			}
		}
	}
	public function dopageGetFormid()
	{
		global $_W;
		global $_GPC;
		$uid = intval($_GPC["uid"]);
		$formid = trim($_GPC["formid"]);
		if ($formid == "the formId is a mock one") {
			return $this->result(1, $formid, "");
		}
		$insert = ["weid" => $_W["uniacid"], "uid" => $uid, "formid" => $formid, "createtime" => TIMESTAMP];
		pdo_insert('goouc_fullexam_user_formid', $insert);
		return $this->result(0, "保存成功", "");
	}
	public function dopageWatermark()
	{
		global $_W;
		$item = pdo_get("goouc_fullexam_watermark", ["weid" => $_W["uniacid"]]);
		$item["content"] = unserialize($item["content"]);
		return $this->result(0, "获取水印信息成功", $item);
	}
	public function dopageMyTest()
	{
		global $_W;
		global $_GPC;
		$uid = $_GPC["uid"];
		$pindex = max(1, $_GPC["page"]);
		$psize = 10;
		$list = pdo_fetchall(" SELECT a.id as rid,a.uid,a.examid,a.recordid,c.id,c.title,c.createtime FROM " . tablename($this->t_user_doexam) . " a inner join (select uid ,examid ,max(recordid) recordids from " . tablename($this->t_user_doexam) . " where weid = " . $_W["uniacid"] . " group by examid,uid) b on a.recordid = b.recordids and a.uid = b.uid and a.examid = b.examid inner join " . tablename($this->t_paper) . " c on a.examid= c.id and a.weid =c.weid where a.weid = :weid and c.istatus = :istatus and a.uid = :uid order by a.createtime desc limit " . ($pindex - 1) * $psize . "," . $psize, [":weid" => $_W["uniacid"], ":uid" => $uid, ":istatus" => 1]);
		$total = pdo_fetchall(" SELECT a.id as rid,a.uid,a.examid,a.recordid,c.id,c.title,c.createtime FROM " . tablename($this->t_user_doexam) . " a inner join (select uid ,examid ,max(recordid) recordids from " . tablename($this->t_user_doexam) . " where weid = " . $_W["uniacid"] . " group by examid,uid) b on a.recordid = b.recordids and a.uid = b.uid and a.examid = b.examid inner join " . tablename($this->t_paper) . " c on a.examid= c.id and a.weid =c.weid where a.weid = :weid and c.istatus = :istatus and a.uid = :uid order by a.createtime desc ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":istatus" => 1]);
		$total = count($total);
		foreach ($list as $k => $v) {
			$list[$k]["is_simple"] = 2;
			$questions = pdo_getall($this->t_paper_test, ["paperid" => $v["examid"]], ["testid"]);
			foreach ($questions as $kk => $vv) {
				$type = pdo_getcolumn($this->t_test, ["id" => $vv["testid"], "weid" => $_W["uniacid"]], "type");
				if ($type == 8) {
					$list[$k]["is_simple"] = 1;
					break;
				}
			}
			$complete = pdo_get($this->t_user_doexam, ["weid" => $_W["uniacid"], "examid" => $v["examid"], "evaluation" => 2], "id");
			if ($complete) {
				$list[$k]["complete"] = 2;
			} else {
				$list[$k]["complete"] = 1;
			}
			$list[$k]["name"] = $v["title"];
			$list[$k]["qnum"] = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename("goouc_fullexam_paper_test") . " WHERE weid=:weid AND istatus=:istatus AND paperid=:paperid ", [":weid" => $_W["uniacid"], ":istatus" => 1, ":paperid" => $v["id"]]);
			$list[$k]["createtime"] = date("Y-m-d", $list[$k]["createtime"]);
		}
		return $this->result(0, "我做过试卷列表", ["list" => $list, "total" => $total, "psize" => $psize]);
	}
	public function dopageMyTestExplain()
	{
		global $_W;
		global $_GPC;
		$uid = $_GPC["uid"];
		$paperid = intval($_GPC["paperid"]);
		if (!($paperid || $uid)) {
			return $this->result(1, "传递的参数不存在", "1006");
		}
		$id = $_GPC["id"];
		$paper_info = pdo_fetch("SELECT id,title,franction,total_franction,dnum FROM " . tablename($this->t_paper) . " WHERE weid = :weid AND id =:id ", [":weid" => $_W["uniacid"], ":id" => $paperid]);
		if (empty($paper_info)) {
			return $this->result(1, "试卷信息错误,请联系管理员处理", "1006");
		}
		$records = pdo_fetch(" SELECT * FROM " . tablename("goouc_fullexam_user_doexam") . " WHERE weid=:weid AND uid=:uid  AND id =:id ", [":weid" => $_W["uniacid"], ":uid" => $uid, "id" => $id]);
		$setting = pdo_fetch("SELECT * FROM " . tablename("goouc_fullexam_setting") . " WHERE weid=:weid ", [":weid" => $_W["uniacid"]]);
		$simple_score = pdo_fetch(" SELECT id,SUM(simple_score) scores FROM " . tablename($this->t_user_exam_answer) . " WHERE weid = :weid AND uid = :uid AND examid = :examid AND test_type = 8", [":weid" => $_W["uniacid"], ":uid" => $uid, ":examid" => $paperid]);
		if (empty($simple_score["scores"])) {
			$simple_score["scores"] = 0;
		}
		$resuser["simple_score"] = $simple_score["scores"];
		$resuser["scores"] = intval($records["franction"]) + intval($resuser["simple_score"]);
		$userscore = $records["fraction"];
		if ($userscore < $setting["pass"]) {
			$resuser["comment"] = "加油";
		} elseif ($setting["pass"] <= $userscore && $userscore < $setting["good"]) {
			$resuser["comment"] = "合格";
		} elseif ($setting["good"] <= $userscore && $userscore < $setting["excellent"]) {
			$resuser["comment"] = "良好";
		} elseif ($setting["excellent"] <= $userscore) {
			$resuser["comment"] = "优异";
		}
		$resuser["time"] = $records["usetime"];
		$all = pdo_fetchall("SELECT uid,franction FROM " . tablename("goouc_fullexam_user_doexam") . " WHERE weid=:weid AND id=:id AND istatus=1 GROUP BY uid ORDER BY franction DESC ", [":weid" => $_W["uniacid"], ":id" => $id]);
		if (!empty($all)) {
			for ($i = 0; $i < count($all); $i++) {
				for ($j = $i + 1; $j < count($all); $j++) {
					if ($all[$i] < $all[$j]) {
						$tmp = $all[$i];
						$all[$i] = $all[$j];
						$all[$j] = $tmp;
					}
				}
			}
			foreach ($all as $key => $val) {
				if ($uid == $val["uid"]) {
					$resuser["ranking"] = $key + 1;
				}
			}
		} else {
			$resuser["ranking"] = "暂无排名数据";
		}
		$right_num = pdo_fetchcolumn("SELECT count(*) FROM " . tablename("goouc_fullexam_user_exam_answer") . " WHERE weid=:weid AND uid=:uid AND examid=:examid  AND `type`=1 AND isright=1 ", [":weid" => $_W["uniacid"], ":uid" => $uid, ":examid" => $paperid]);
		$total_num = pdo_fetchall("SELECT pt.id,pt.test_type,pt.testid FROM " . tablename("goouc_fullexam_paper_test") . " pt JOIN " . tablename("goouc_fullexam_paper") . " p ON pt.paperid=p.id WHERE pt.weid=:weid AND pt.paperid=:paperid AND pt.istatus=1 ", [":weid" => $_W["uniacid"], ":paperid" => $paperid]);
		$b = 0;
		$a = 0;
		foreach ($total_num as $m => $n) {
			if ($n["test_type"] > 4) {
				$b++;
				$a += pdo_fetchcolumn("SELECT count(*) FROM " . tablename("goouc_fullexam_test") . " WHERE weid=:weid AND istatus=1 AND pid = :pid ", [":pid" => $n["testid"], ":weid" => $_W["uniacid"]]);
			}
		}
		$total_num = count($total_num) - $b + $a;
		if ($total_num != 0) {
			$right_lv = round($right_num / $total_num, 2) * 100;
		}
		if ($right_lv != 0) {
			$resuser["right_lv"] = $right_lv . "%";
		} else {
			$resuser["right_lv"] = 0;
		}
		$resuser["is_simple"] = 2;
		$questions = pdo_getall($this->t_paper_test, ["paperid" => $paperid], ["testid"]);
		foreach ($questions as $kk => $vv) {
			$type = pdo_getcolumn($this->t_test, ["id" => $vv["testid"], "weid" => $_W["uniacid"]], "type");
			if ($type == 8) {
				$resuser["is_simple"] = 1;
				break;
			}
		}
		$complete = pdo_get($this->t_user_doexam, ["weid" => $_W["uniacid"], "examid" => $paperid, "evaluation" => 2], "id");
		if ($complete) {
			$resuser["complete"] = 2;
		} else {
			$resuser["complete"] = 1;
		}
		return $this->result(0, "全真模拟提交成功,成绩,时间,结果评测,正确率,排名,勋章(或有或无)", ["resuser" => $resuser]);
	}
}