コード例 #1
0
 /**
  * Update the specified assignment with request info.
  *
  * @param  Request  $request
  * @return Response
  */
 public function update_assignment(Request $request, $assignment_id)
 {
     if (!Auth::user()->hasRole('admin')) {
         return view('access_denied');
     }
     $assignment = Assignment::find($request->assignment_id);
     //check whether professor matches the course
     $correctProfessorCheck = DB::select('select * from current_professors where user_id = ? and course_id = ?', [$request->professor, $request->course]);
     if ($correctProfessorCheck == null) {
         $errors['badProf'] = 'This professor is not currently teaching this course!';
         session()->put('error', $errors['badProf']);
     }
     //check whether tutor matches the course
     $correctTutorCheck = DB::select('select * from available_tutors where user_id = ? and course_id = ?', [$request->tutor, $request->course]);
     if ($correctTutorCheck == null) {
         $errors['badTutor'] = 'This tutor is not currently tutoring this course!';
         session()->put('error', $errors['badTutor']);
     }
     //handles errors by setting $errors array and displaying the value in blade
     if (!empty($errors)) {
         $data = array('errors' => $errors, 'old' => $request, 'assignment' => $assignment, 'courses' => Course::all(), 'tutors' => UserController::getTutors(), 'students' => UserController::getStudents(), 'professors' => UserController::getProfessors());
         return view('assignment_edit', $data);
     }
     $assignment->tutor_id = $request->tutor;
     $assignment->student_id = $request->student;
     $assignment->course_id = $request->course;
     $assignment->professor_id = $request->professor;
     $assignment->save();
     session()->put('success', 'Tutor assignment successfully updated!');
     return redirect('/assignment/' . $assignment->id);
 }
コード例 #2
0
ファイル: EvalController.php プロジェクト: Calvin-TMO/TMO
 /**
  * Display a list of all evals.
  *
  * @return Response
  */
 public function all_evals()
 {
     $data = array('evals' => UserController::getTutors());
     return view('evals', $data);
 }