|
|
|
@ -10,6 +10,7 @@ use App\Services\QuestionService; |
|
|
|
|
use App\Services\SkillService; |
|
|
|
|
use Illuminate\Http\Request; |
|
|
|
|
use Illuminate\Support\Facades\DB; |
|
|
|
|
use Symfony\Component\HttpFoundation\Response; |
|
|
|
|
|
|
|
|
|
class ExerciseController extends Controller |
|
|
|
|
{ |
|
|
|
@ -35,14 +36,14 @@ class ExerciseController extends Controller |
|
|
|
|
'status' => true, |
|
|
|
|
'data' => $exercises, |
|
|
|
|
'message' => 'Không có dữ liệu.', |
|
|
|
|
]); |
|
|
|
|
], Response::HTTP_NOT_FOUND); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return response()->json([ |
|
|
|
|
'status' => true, |
|
|
|
|
'data' => $exercises, |
|
|
|
|
'message' => 'Lấy danh sách đề thi thành công.', |
|
|
|
|
]); |
|
|
|
|
], Response::HTTP_OK); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function create(CreateExerciseRequest $request) |
|
|
|
@ -65,14 +66,14 @@ class ExerciseController extends Controller |
|
|
|
|
'success' => true, |
|
|
|
|
'message' => 'Tạo đề thi thành công.', |
|
|
|
|
'exercise_id' => $exerciseId |
|
|
|
|
], 201); |
|
|
|
|
], Response::HTTP_OK); |
|
|
|
|
} catch (\Exception $e) { |
|
|
|
|
DB::rollBack(); |
|
|
|
|
return response()->json([ |
|
|
|
|
'success' => false, |
|
|
|
|
'message' => 'Tạo đề thi thất bại.', |
|
|
|
|
'error' => $e->getMessage() |
|
|
|
|
], 500); |
|
|
|
|
], Response::HTTP_INTERNAL_SERVER_ERROR); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -85,13 +86,30 @@ class ExerciseController extends Controller |
|
|
|
|
'status' => true, |
|
|
|
|
'data' => $exercise, |
|
|
|
|
'message' => 'Không có dữ liệu.', |
|
|
|
|
]); |
|
|
|
|
], Response::HTTP_NOT_FOUND); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return response()->json([ |
|
|
|
|
'status' => true, |
|
|
|
|
'data' => $exercise, |
|
|
|
|
'message' => 'Lấy danh sách đề thi thành công.', |
|
|
|
|
]); |
|
|
|
|
], Response::HTTP_OK); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function destroy($id) |
|
|
|
|
{ |
|
|
|
|
$result = $this->exerciseService->destroy($id); |
|
|
|
|
|
|
|
|
|
if (!$result['status']) { |
|
|
|
|
return response()->json([ |
|
|
|
|
'status' => false, |
|
|
|
|
'message' => $result['message'], |
|
|
|
|
], Response::HTTP_INTERNAL_SERVER_ERROR); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return response()->json([ |
|
|
|
|
'status' => true, |
|
|
|
|
'message' => $result['message'], |
|
|
|
|
], Response::HTTP_OK); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|