You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
zhishifufei_php/application/merchant/model/questions/TestPaperScoreGrade.php

68 lines
2.2 KiB

10 months ago
<?php
// +----------------------------------------------------------------------
// | 天诚科技 [ 刘海东 17600099397赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2020 https://www.tczxkj.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 该系统并不是自由软件,未经许可不能去掉相关版权
// +----------------------------------------------------------------------
// | Author:甘肃天诚志信电子商务有限公司 刘海东 联系电话维系17600099397
// +----------------------------------------------------------------------
namespace app\merchant\model\questions;
use traits\ModelTrait;
use basic\ModelBasic;
use service\UtilService as Util;
use app\merchant\model\questions\TestPaper as TestPaperModel;
/**
* 试卷分数等级划分 Model
* Class TestPaperScoreGrade
* @package app\merchant\model\questions
*/
class TestPaperScoreGrade extends ModelBasic
{
use ModelTrait;
/**添加/修改试卷分数等级
* @param array $data
*/
public static function testPaperScoreGradeAdd($id = 0, $data = [])
{
if (!$id || count($data) <= 0) return false;
self::where('test_id', $id)->delete();
foreach ($data as $k => $time) {
$time['test_id'] = $id;
self::set($time);
}
return true;
}
/**
* 试卷分数等级列表
*/
public static function testPaperScoreGradeList($id = 0)
{
return self::where(['test_id' => $id])->order('id asc')->select();
}
/**获得分数对应的等级
* @param $score
*/
public static function getTestPaperScoreGrade($test_id, $score)
{
$grade = self::where(['test_id' => $test_id])->order('id asc')->select();
$grade = count($grade) > 0 ? $grade->toArray() : [];
if (!count($grade)) return '无';
foreach ($grade as $key => $value) {
$arr = explode('~', $value['grade_standard']);
if ($score >= $arr[0] && $score <= $arr[1]) {
return $value['grade_name'];
}
}
return '无';
}
}