<?php
namespace app\components;

use Yii;
use app\models\Questi_type;
use app\models\Resour_course;
use app\models\User;

class QuestionHelper{

	//显示题目类型
	public static function ShowStemtypeName($typeid){
		$msg = "";
		if(empty($typeid) || !is_numeric($typeid)){
			return $msg;
		}
		$questitype = Questi_type::find()->where("id=". $typeid)->one();
		if(!empty($questitype)){
			$msg = $questitype->name;
		}
		return $msg;
	}

	//显示课程名称
	public static function ShowCourseName($courseid){
		$msg = "";
		if(empty($courseid) || !is_numeric($courseid)){
			return $msg;
		}
		$cate = Resour_course::find()->where("id=". $courseid)->one();
		if(!empty($cate)){
			$msg = $cate->name;
		}
		return $msg;
	}

	//显示难度系数
	public static function ShowLevelsName($levelid){
		$msg = "简单";
		if($levelid==1){
			$msg = "简单";
		}elseif($levelid==2){
			$msg = "一般";
		}elseif($levelid==3){
			$msg = "困难";
		}
		return $msg;
	}

	//显示上传人名称
	public static function ShowAuthorName($userid){
		$msg = "";
		if(empty($userid) || !is_numeric($userid)){
			return $msg;
		}
		$author = User::find()->where("id=". $userid)->one();
		if(!empty($author)){
			$msg = $author->realname;
		}
		return $msg;
	}
	
}
?>