<?php
namespace app\api\controller;
use app\common\controller\Authentication;
use app\common\model\QuestionModel;
use \think\Db;

class Question extends Authentication{
    
    private static $M_question;
    public function __construct(){
        parent::__construct();
        $this->init();
    }

    private function init(){
        self::$M_question = new QuestionModel();
    }

    public function index(){
        echo 'index';
        die;
    }
    // 检测用户是否是首次登陆并存储用户
    public function get_rand(){
        $where['grade'] = input('grade');
        $where['lv'] = 'LV' . input('lv');
        $query = "(SELECT * FROM jr_question WHERE  grade = ".$where['grade']."  AND lv = '".$where["lv"]."' and level = 0 ORDER BY rand() LIMIT 4) union all (SELECT * FROM jr_question WHERE  grade = ".$where['grade']."  AND lv = '".$where['lv']."' and level = 10 ORDER BY rand() LIMIT 1)";
        $result = Db::query($query);
        return json($result);
    }
}
