Ejemplo n.º 1
0
 public function score(Request $request)
 {
     $json = $request->get('data');
     /** @var StudyExam $exam */
     $exam = json_decode($json);
     /** @var Exam $actualExam */
     $actualExam = Exam::findOrFail($exam->id);
     $ret = $this->_score($exam, $actualExam);
     return response()->json($ret);
 }
Ejemplo n.º 2
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request -- Not applicable anymore
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(ExamRequest $request, $id)
 {
     $exam = Exam::findOrFail($id);
     $exam->update($request->all());
     foreach ($request->all()['categories-select'] as $key => $value) {
         $category = Category::findOrFail($value);
         $found = false;
         foreach ($exam->categories as $exam_category) {
             if ($exam_category->id == $category->id) {
                 $found = true;
                 break;
             }
         }
         if (!$found) {
             $exam->categories()->attach($category);
         }
     }
     return redirect('admin/exams');
 }