学生课程作业
This commit is contained in:
parent
5914ac9cc6
commit
c6ad05e4ff
@ -37,7 +37,7 @@ class StudentHomeworkController extends BaseController
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @desc 获取学生所有的家庭作业
|
* @desc 获取学生所有的家庭作业的课程
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return \support\Response
|
* @return \support\Response
|
||||||
*/
|
*/
|
||||||
@ -48,6 +48,18 @@ class StudentHomeworkController extends BaseController
|
|||||||
return $this->json($result);
|
return $this->json($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @desc 获取学生所有的家庭作业
|
||||||
|
* @param Request $request
|
||||||
|
* @return \support\Response
|
||||||
|
*/
|
||||||
|
public function getStudentSubjectHomeworkDetail(Request $request)
|
||||||
|
{
|
||||||
|
$service = new StudentHomeworkService();
|
||||||
|
$result = $service->getStudentSubjectHomeworkDetail($request);
|
||||||
|
return $this->json($result);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @desc 学生查看作业
|
* @desc 学生查看作业
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
|
@ -4,6 +4,7 @@ namespace app\common\model;
|
|||||||
|
|
||||||
use app\BaseModel;
|
use app\BaseModel;
|
||||||
use support\Model;
|
use support\Model;
|
||||||
|
|
||||||
//
|
//
|
||||||
///**
|
///**
|
||||||
// * wa_student_schedule 课表
|
// * wa_student_schedule 课表
|
||||||
@ -25,7 +26,7 @@ class StudentSchedule extends BaseModel
|
|||||||
|
|
||||||
public function teacher()
|
public function teacher()
|
||||||
{
|
{
|
||||||
return $this->hasOne(Teacher::class, 'id', 'teacher_id')->bind(['teacher_account'=>'account', 'teacher_name']);
|
return $this->hasOne(Teacher::class, 'id', 'teacher_id')->bind(['teacher_account' => 'account', 'teacher_name']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function subject()
|
public function subject()
|
||||||
@ -35,7 +36,7 @@ class StudentSchedule extends BaseModel
|
|||||||
|
|
||||||
public function student()
|
public function student()
|
||||||
{
|
{
|
||||||
return $this->hasOne(Student::class, 'id', 'student_id')->bind(['student_name', 'student_account'=>'account']);
|
return $this->hasOne(Student::class, 'id', 'student_id')->bind(['student_student_name' => 'student_name', 'student_account' => 'account']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function subjectHomeworkArr()
|
public function subjectHomeworkArr()
|
||||||
|
@ -4,6 +4,7 @@ namespace app\common\service;
|
|||||||
|
|
||||||
use app\common\model\Student;
|
use app\common\model\Student;
|
||||||
use app\common\model\StudentHomework;
|
use app\common\model\StudentHomework;
|
||||||
|
use app\common\model\StudentSchedule;
|
||||||
use app\common\model\SubjectHomework;
|
use app\common\model\SubjectHomework;
|
||||||
use app\common\model\TeacherScheduleTime;
|
use app\common\model\TeacherScheduleTime;
|
||||||
use app\constant\ResponseCode;
|
use app\constant\ResponseCode;
|
||||||
@ -149,20 +150,30 @@ class StudentHomeworkService
|
|||||||
$page = isset($data['page']) ? $data['page'] : 1;
|
$page = isset($data['page']) ? $data['page'] : 1;
|
||||||
$limit = isset($data['limit']) ? $data['limit'] : 10;
|
$limit = isset($data['limit']) ? $data['limit'] : 10;
|
||||||
|
|
||||||
$student_homework = StudentHomework::where(['student_id' => $student->id])->order('start_time desc');
|
if ($data['status'] == 0) {
|
||||||
if ($data['status']) {
|
//未提交作业的课程
|
||||||
|
$model = StudentSchedule::order('id desc')->where('id', 'not in', function ($query) use ($student) {
|
||||||
|
$query->table('wa_student_homework')->where('student_id', $student->id)->field('teacher_schedule_time_id');
|
||||||
|
});
|
||||||
|
$total = $model->count();
|
||||||
|
$list = $model->with(['student', 'subject', 'teacher'])->page($page, $limit)
|
||||||
|
->select();
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$total = $student_homework->count();
|
$model = StudentSchedule::order('id desc')->alias('ss')
|
||||||
$list = $student_homework->with(['student', 'subject', 'teacher'])
|
->leftJoin('student_homework sh', 'ss.subject_homework_id = su.id')
|
||||||
|
->where(['ss.student_id' => $student->id]);
|
||||||
|
$total = $model->count();
|
||||||
|
$list = $model->with(['student', 'subject', 'teacher'])
|
||||||
->page($page, $limit)
|
->page($page, $limit)
|
||||||
->select()->toArray();
|
->select()->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($list as &$item){
|
foreach ($list as &$item) {
|
||||||
if($item['feedback_file_url']){
|
if ($item['feedback_file_url']) {
|
||||||
$item['feedback_file_url'] = json_decode($item['feedback_file_url'],true);
|
$item['feedback_file_url'] = json_decode($item['feedback_file_url'], true);
|
||||||
}else{
|
} else {
|
||||||
$item['feedback_file_url'] = [];
|
$item['feedback_file_url'] = [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -184,6 +195,47 @@ class StudentHomeworkService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getStudentSubjectHomeworkDetail($request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
|
||||||
|
if (empty((array)$request->student) && empty((array)$request->parent)) {
|
||||||
|
throw new Exception('请登陆后再查看');
|
||||||
|
}
|
||||||
|
if (!empty((array)$request->student)) {
|
||||||
|
$student = Student::where(['id' => $request->student->id])->findOrEmpty();
|
||||||
|
if ($student->isEmpty()) {
|
||||||
|
throw new Exception('未找到用户信息');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!empty((array)$request->parent)) {
|
||||||
|
$student = Student::where(['parent_id' => $request->parent->id])->findOrEmpty();
|
||||||
|
if ($student->isEmpty()) {
|
||||||
|
throw new Exception('未找到用户信息');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$homework = StudentHomework::where(['student_id' => $student->id, 'teacher_schedule_time_id' => $request->get('teacher_schedule_time_id')])
|
||||||
|
->with(['student', 'teacher', 'subject'])
|
||||||
|
->findOrEmpty();
|
||||||
|
|
||||||
|
if($homework->feedback_file_url){
|
||||||
|
$homework->feedback_file_url = json_decode($homework->feedback_file_url, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'code' => ResponseCode::SUCCESS,
|
||||||
|
'data' => $homework,
|
||||||
|
'msg' => 'success',
|
||||||
|
];
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return [
|
||||||
|
'code' => ResponseCode::FAIL,
|
||||||
|
'msg' => $e->getMessage()
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @desc 获取课程的家庭作业
|
* @desc 获取课程的家庭作业
|
||||||
|
Loading…
x
Reference in New Issue
Block a user