初始化项目:添加后端代码、ThinkPHP框架、前端资源

This commit is contained in:
amb
2026-09-03 12:42:39 +08:00
commit 482bece22e
3726 changed files with 416708 additions and 0 deletions
@@ -0,0 +1,66 @@
<?php
namespace app\admin\model\app\testpaper;
use think\Model;
class Group extends Model
{
// 表名
protected $name = 'app_testpaper_group';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'integer';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = false;
protected $deleteTime = false;
// 追加属性
protected $append = [
'status_text',
'testpaper_count'
];
public $defaultGroudId = 990000;
public function getStatusList()
{
return ['11' => __('Status 11')];
}
public function getStatusTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
$list = $this->getStatusList();
return isset($list[$value]) ? $list[$value] : '';
}
/**
* 获取分组绑定的题目数量
* @param $value
* @param $data
* @return mixed
*/
public function getTestpaperCountAttr($value, $data)
{
if(!$data['id']){
$ids = self::field('id')->column('id');
$count = \app\admin\model\app\testpaper\Testpaper::where(['group_id'=>['NOT IN',$ids]])->count();
return $count;
}
$count = \app\admin\model\app\testpaper\Testpaper::where([
'group_id'=>$data['id']
])->count();
return $count;
}
}
@@ -0,0 +1,91 @@
<?php
namespace app\admin\model\app\testpaper;
use think\Model;
class Question extends Model
{
// 表名
protected $name = 'app_testpaper_question';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'integer';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = false;
protected $deleteTime = false;
// 追加属性
protected $append = [
];
/**
* 设置试卷绑定的题目
* @return void
*/
public function setPaperQuestion($paperId,$questionList){
self::where(['testpaper_id'=>$paperId])->delete();
$data = [];
foreach ($questionList as $value) {
$data[] = [
'uniacid'=>UNIACID,
'testpaper_id'=>$paperId,
'question_id'=>$value['question_id'],
'miss_score_type'=>$value['miss_score_type'],
'score'=>$value['score'],
'score_miss'=>$value['score_miss'],
'score_miss_single'=>$value['score_miss_single'],
'createtime'=>time()
];
}
self::insertAll($data);
return true;
}
/**
* 获取试卷绑定的题目
* @param $paperId
* @return void
*/
public function getPaperQuestion($paperId){
$data = self::with('questionbank')
->where('testpaper_id',$paperId)
->order('id','asc')->select();
if(!empty($data)){
$data = collection($data)->toArray();
foreach ($data as $key => $item){
$data[$key] = array_merge($item,$item['questionbank']);
unset($data[$key]['questionbank']);
}
}
return $data;
}
public function questionbank()
{
return $this->belongsTo('app\admin\model\app\exam\WarehouseQuestion', 'question_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
public function testpaper()
{
return $this->belongsTo('app\admin\model\app\Testpaper', 'testpaper_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
}
@@ -0,0 +1,103 @@
<?php
namespace app\admin\model\app\testpaper;
use think\Model;
class Testpaper extends Model
{
// 表名
protected $name = 'app_testpaper';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'integer';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $deleteTime = false;
// 追加属性
protected $append = [
'random_type_text',
'status_text',
'random_type_val',
'score_amount',
'question_amount'
];
public function getRandomTypeValAttr($value, $data)
{
if(!$data['random_type_val']){
return [];
}
return json_decode($data['random_type_val'],true);
}
public function getRandomTypeList()
{
return ['random' => __('Random_type random'), 'type' => __('Random_type type')];
}
public function getStatusList()
{
return ['1' => __('Status 1'), '0' => __('Status 0')];
}
public function getRandomTypeTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['random_type']) ? $data['random_type'] : '');
$list = $this->getRandomTypeList();
return isset($list[$value]) ? $list[$value] : '';
}
public function getStatusTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
$list = $this->getStatusList();
return isset($list[$value]) ? $list[$value] : '';
}
public function group()
{
return $this->belongsTo('Group', 'group_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
/**
* 获取试卷总分
* @param $value
* @param $data
* @return mixed
*/
public function getScoreAmountAttr($value, $data)
{
$count = Question::where([
'testpaper_id'=>$data['id']
])->sum('score');
return $count;
}
/**
* 获取题目数量
* @param $value
* @param $data
* @return mixed
*/
public function getQuestionAmountAttr($value, $data)
{
$count = Question::where([
'testpaper_id'=>$data['id']
])->count();
return $count;
}
}