コード例 #1
0
 /**
  * @param CreateExerciseRequest $request
  * @param Lesson $lesson
  * @return JsonResponse
  */
 public function createExercise(CreateExerciseRequest $request, Lesson $lesson)
 {
     $exercise = new Exercise($request->all());
     $exercise->lesson_id = $lesson->id;
     $exercise->save();
     return $this->response($exercise);
 }
コード例 #2
0
 /**
  * @param Lesson $lesson
  * @param CreateExerciseRequest $request
  * @return RedirectResponse
  */
 public function store(Lesson $lesson, CreateExerciseRequest $request) : RedirectResponse
 {
     $exercise = new Exercise($request->all());
     $exercise->lesson_id = $lesson->id;
     $exercise->save();
     return redirect('/lessons/' . $lesson->id);
 }
コード例 #3
0
 public function storeCopy($id, CreateExerciseRequest $request)
 {
     $input = $request->all();
     $exercise = new Exercise();
     $exercise->question = $input['question'];
     $exercise->tips = $input['tips'];
     $exercise->start_code = $input['start_code'];
     $exercise->expected_result = $input['expected_result'];
     $exercise->seriesId = $input['series_selection'];
     $exercise->makerId = Auth::id();
     $exercise->language = $input['language'];
     storeExercise($exercise);
     $userIds = loadUsersBeganSeries($input['series_selection']);
     foreach ($userIds as $userId) {
         if ($userId->uId != loadSerieWithIdOrTitle($id)[0]->makerId) {
             storeNotification($userId->uId, 'series updated', -1, $input['series_selection']);
         }
     }
     storeNotification($input['makerId'], "exercise copied", -1, $input['series_selection']);
     return redirect('series/' . $input['series_selection']);
 }
コード例 #4
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id, CreateExerciseRequest $request)
 {
     if (!isMakerOfExercise($id, Auth::id())) {
         flash()->error("You must be logged in as the maker of this exercise.");
         return redirect('exercises/' . $id);
     }
     $input = $request->all();
     $exercise = new Exercise();
     $exercise->question = $input['question'];
     $exercise->tips = $input['tips'];
     $exercise->start_code = $input['start_code'];
     $exercise->expected_result = $input['expected_result'];
     $exercise->language = $input['language'];
     $exercise->id = $id;
     updateExercise($exercise);
     flash()->success('Your exercise has been successfully updated.');
     return redirect('exercises/' . $id);
 }