add displaying of test results
This commit is contained in:
parent
2ad0115405
commit
699754236b
@ -7,6 +7,7 @@ use App\Models\MultipleChoiceAnswers;
|
|||||||
use App\Models\SingleChoiceAnswer;
|
use App\Models\SingleChoiceAnswer;
|
||||||
use App\Models\SingleQuestionAnswers;
|
use App\Models\SingleQuestionAnswers;
|
||||||
use App\Models\Test;
|
use App\Models\Test;
|
||||||
|
use App\Models\TestResult;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
@ -101,11 +102,19 @@ class TestController extends Controller
|
|||||||
array_push($assigned_students, $assigned_student);
|
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", [
|
return view("tests.edit", [
|
||||||
"test" => $test,
|
"test" => $test,
|
||||||
"questions" => $questions,
|
"questions" => $questions,
|
||||||
"students" => $students,
|
"students" => $students,
|
||||||
"assigned_students" => $assigned_students,
|
"assigned_students" => $assigned_students,
|
||||||
|
"test_results" => $test_results
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,6 +142,22 @@
|
|||||||
<hr class="mt-6 mb-6">
|
<hr class="mt-6 mb-6">
|
||||||
<div>
|
<div>
|
||||||
<h2 class="text-center text-lg font-medium">{{ __("Test results") }}</h2>
|
<h2 class="text-center text-lg font-medium">{{ __("Test results") }}</h2>
|
||||||
|
|
||||||
|
<table class="mt-6 border border-gray-300 w-full text-left">
|
||||||
|
<tr>
|
||||||
|
<th class="border border-gray-300 p-1">{{ __("Student") }}</th>
|
||||||
|
<th class="border border-gray-300 p-1">{{ __("Points") }}</th>
|
||||||
|
<th class="border border-gray-300 p-1">{{ __("Grade") }}</th>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
@foreach ($test_results as $test_result)
|
||||||
|
<tr>
|
||||||
|
<td class="border border-gray-300 p-1">{{ $test_result->student_name }}</td>
|
||||||
|
<td class="border border-gray-300 p-1">{{ $test_result->points }}</td>
|
||||||
|
<td class="border border-gray-300 p-1">{{ round($test_result->points / $test_result->max_points * 10, 2) }}</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</x-app-layout>
|
</x-app-layout>
|
||||||
|
Loading…
Reference in New Issue
Block a user