Пример #1
0
 function deleteCriteria(Request $request, Criteria $criteria)
 {
     // Double check to make sure the current user is authorized to do this...
     $this->authorize('delete-criteria');
     $criteria->delete();
     $request->session()->flash('success', 'The criteria has been deleted.');
     return redirect('/criteria');
 }
Пример #2
0
 public function viewScore(Application $application)
 {
     $criteria = Criteria::get();
     $judges = User::where(['role' => 'judge'])->get();
     $judgeScores = [];
     // Select all scores made by each judge
     foreach ($judges as $judge) {
         $scores = $application->scores()->where('user_id', $judge->id)->get();
         foreach ($scores as $score) {
             $judgeScores[$judge->id][$score->criteria_id] = $score->score;
         }
     }
     return view('pages/scores/view', compact('application', 'criteria', 'judges', 'judgeScores'));
 }
 public function reviewApplication(Application $application, Request $request)
 {
     // Did the current user create this application?
     if ($application->user->id != Auth::user()->id) {
         // If not, are they authorized to view applications?
         if (!(Auth::user()->can('view-application') || Auth::user()->can('view-submitted-application') && $application->status != 'new')) {
             $request->session()->flash('error', 'You are not authorized to view this application.');
             return redirect('/login');
         }
     }
     $questions = Question::get();
     $criteria = ['objective' => Criteria::where('type', 'objective')->get(), 'subjective' => Criteria::where('type', 'subjective')->get()];
     // Generate an array of answers based on their associated question ID
     $answers = [];
     foreach ($application->answers as $answer) {
         $answers[$answer->question_id] = $answer;
     }
     $scores = [];
     // Select all scores made by the current user
     foreach ($application->scores()->where('user_id', Auth::user()->id)->get() as $score) {
         $scores[$score->criteria_id] = $score;
     }
     $judged = Judged::where(['application_id' => $application->id, 'user_id' => Auth::user()->id])->get()->first();
     return view('pages/applications/review', compact('application', 'questions', 'answers', 'criteria', 'scores', 'judged'));
 }