diff --git a/app/Http/Controllers/TestController.php b/app/Http/Controllers/TestController.php index 2a3a380..07a3207 100644 --- a/app/Http/Controllers/TestController.php +++ b/app/Http/Controllers/TestController.php @@ -7,6 +7,7 @@ use App\Models\MultipleChoiceAnswers; use App\Models\SingleChoiceAnswer; use App\Models\SingleQuestionAnswers; use App\Models\Test; +use App\Models\TestResult; use App\Models\User; use Illuminate\Http\Request; @@ -101,11 +102,19 @@ class TestController extends Controller array_push($assigned_students, $assigned_student); } + $test_results = []; + foreach (TestResult::where("test_id", $test->id)->get() as $test_result) { + $student = User::where("id", $test_result->student_id)->first(); + $test_result->student_name = $student->name; + array_push($test_results, $test_result); + } + return view("tests.edit", [ "test" => $test, "questions" => $questions, "students" => $students, "assigned_students" => $assigned_students, + "test_results" => $test_results ]); } diff --git a/resources/views/tests/edit.blade.php b/resources/views/tests/edit.blade.php index 8f802d4..39abc6e 100644 --- a/resources/views/tests/edit.blade.php +++ b/resources/views/tests/edit.blade.php @@ -142,6 +142,22 @@
{{ __("Student") }} | +{{ __("Points") }} | +{{ __("Grade") }} | +
---|---|---|
{{ $test_result->student_name }} | +{{ $test_result->points }} | +{{ round($test_result->points / $test_result->max_points * 10, 2) }} | +