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