学生课程作业
This commit is contained in:
parent
5914ac9cc6
commit
c6ad05e4ff
@ -37,7 +37,7 @@ class StudentHomeworkController extends BaseController
|
||||
|
||||
|
||||
/**
|
||||
* @desc 获取学生所有的家庭作业
|
||||
* @desc 获取学生所有的家庭作业的课程
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
@ -48,6 +48,18 @@ class StudentHomeworkController extends BaseController
|
||||
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 学生查看作业
|
||||
* @param Request $request
|
||||
|
@ -4,6 +4,7 @@ namespace app\common\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use support\Model;
|
||||
|
||||
//
|
||||
///**
|
||||
// * wa_student_schedule 课表
|
||||
@ -35,7 +36,7 @@ class StudentSchedule extends BaseModel
|
||||
|
||||
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()
|
||||
|
@ -4,6 +4,7 @@ namespace app\common\service;
|
||||
|
||||
use app\common\model\Student;
|
||||
use app\common\model\StudentHomework;
|
||||
use app\common\model\StudentSchedule;
|
||||
use app\common\model\SubjectHomework;
|
||||
use app\common\model\TeacherScheduleTime;
|
||||
use app\constant\ResponseCode;
|
||||
@ -149,12 +150,22 @@ class StudentHomeworkService
|
||||
$page = isset($data['page']) ? $data['page'] : 1;
|
||||
$limit = isset($data['limit']) ? $data['limit'] : 10;
|
||||
|
||||
$student_homework = StudentHomework::where(['student_id' => $student->id])->order('start_time desc');
|
||||
if ($data['status']) {
|
||||
if ($data['status'] == 0) {
|
||||
//未提交作业的课程
|
||||
$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 {
|
||||
$total = $student_homework->count();
|
||||
$list = $student_homework->with(['student', 'subject', 'teacher'])
|
||||
$model = StudentSchedule::order('id desc')->alias('ss')
|
||||
->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)
|
||||
->select()->toArray();
|
||||
}
|
||||
@ -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 获取课程的家庭作业
|
||||
|
Loading…
x
Reference in New Issue
Block a user