1
0
mirror of https://github.com/robonen/education-project.git synced 2026-03-20 02:44:31 +00:00

Модуль Задания(fix some bugs)

This commit is contained in:
ashen-1-dev
2020-12-11 01:47:33 +07:00
parent 854ffc83c8
commit 9c3874a2a0
4 changed files with 15 additions and 22 deletions

View File

@@ -49,7 +49,7 @@ class TaskFileController extends Controller
'extension' => $ext,
'task_id' => $taskId,
'url' => $path,
'user_id' => '2',
'user_id' => 2,
'review' => $review,
$file,
$request->name . $ext

View File

@@ -59,21 +59,14 @@ class TeacherController extends Controller
return response()->json(collect($classes)->unique(), 200);
}
// public function getUncheckedTask(Teacher $teacher, SchoolClass $class) {
// $studentsId = Student::where('class_id', '=', $class->id)->get(['id']);
// $tasksId = Task::where('teacher_id', '=', $teacher->id)->get(['id']);
// $answers = [];
// $test = new Task();
// foreach ($studentsId as $studentId) {
// foreach ($tasksId as $taskId) {
//
// AnswerToTask::where([
// ['task_id', '=', $taskId->id],
// ['student_id', '=', $studentId->id],
// ['checked', '=', 0]
// ])->get();
// }
// }
// return $answers;
// }
public function getUncheckedTask(Teacher $teacher, SchoolClass $class) {
$temp = [];
$tasks = $teacher->tasks->where('class_id', '=', $class->id);
foreach ($tasks as $task) {
$answers = Task::find($task->id)->answers->where('checked', '=', false);
array_push($temp, $answers);
}
return response()->json($temp, 200);
}
}

View File

@@ -19,15 +19,15 @@ class Task extends Model
}
public function class() {
$this->belongsTo(SchoolClass::class);
return $this->belongsTo(SchoolClass::class);
}
public function tasks() {
$this->hasMany(Task::class);
return $this->hasMany(Task::class);
}
public function answers() {
$this->hasMany(AnswerToTask::class);
return $this->hasMany(AnswerToTask::class);
}
}