/**
  * Filter and Sort users.
  *
  * @param Request $request
  * @param Submission $submission
  * @return mixed
  */
 public function search(Request $request, Submission $submission)
 {
     $query = User::where('admin', 0);
     $filter = $request->get('filter');
     $sort = $request->get('sort');
     $order = $request->get('order');
     if ($filter && $filter != 'none') {
         if (strpos($filter, 'L0') !== false) {
             $query = $query->where('lab', $filter);
         } elseif ($filter == "file_submitted") {
             $query = $submission->users();
         }
         //            elseif ($filter == "not_marked")
         //            {
         //                $id = $submission->id;
         //                $graded = $query->whereHas('grades', function ($q) use ($id){
         //                    $q->where('submission_id', $id);
         //                });
         //                $query = $query->whereNotIn('id',$graded->list('id'));
         //            }
     }
     if ($sort && $sort != 'none') {
         if ($sort == 'last_name') {
             if ($order && $order == 'desc') {
                 $query = $query->orderBy('last_name', 'desc');
             } else {
                 $query = $query->orderBy('last_name');
             }
         } elseif ($sort == 'first_name') {
             if ($order && $order == 'desc') {
                 $query = $query->orderBy('first_name', 'desc');
             } else {
                 $query = $query->orderBy('first_name');
             }
         } elseif ($sort == 'student_number') {
             if ($order && $order == 'desc') {
                 $query = $query->orderBy('student_number', 'desc');
             } else {
                 $query = $query->orderBy('student_number');
             }
         } elseif ($sort == 'submission_date') {
             if ($order && $order == 'desc') {
                 $query = $submission->users()->orderBy('pivot_created_at', 'desc');
             } else {
                 $query = $submission->users()->orderBy('pivot_created_at');
             }
         }
     }
     // Flash old input to repopulate on search
     $request->flash();
     return $query->get();
 }
 public function destroy($form_slug, $submission_id, Request $request)
 {
     $submission = Submission::findOrFail($submission_id);
     $form = $submission->form;
     $submission->delete();
     return redirect()->route('admin.forms.submissions.index', $form->slug)->with('message', trans('submission.message.delete_success'));
 }
 /**
  * Update the specified resource in storage.
  *
  * @param SubmissionRequest $request
  * @param Submission $submission
  * @return \Illuminate\Http\RedirectResponse
  */
 public function update(SubmissionRequest $request, Submission $submission)
 {
     $submission->update($request->all());
     if ($request->get('active')) {
         $submission->active = true;
     } else {
         $submission->active = false;
     }
     if ($request->get('bonus')) {
         $submission->bonus = true;
     } else {
         $submission->bonus = false;
     }
     $submission->save();
     return redirect()->action('SubmissionsController@index');
 }
 public function adminStats()
 {
     $submissions = Submission::all();
     $labs = Submission::where('name', 'like', 'Lab%')->get();
     $assignments = Submission::where('name', 'like', 'Assignment%')->get();
     $inClasses = Submission::where('name', 'like', 'in-class%')->get();
     $midterms = Submission::where('name', 'like', 'Midterm%')->get();
     $surveys = Submission::where('name', 'like', 'Survey%')->get();
     return view('stats.admin', ['submissions' => $submissions, 'labs' => $labs, 'assignments' => $assignments, 'inClasses' => $inClasses, 'midterms' => $midterms, 'surveys' => $surveys]);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $users = User::where('admin', false)->get();
     $submissions = Submission::all();
     foreach ($users as $user) {
         foreach ($submissions as $submission) {
             $user->grades()->create(['user_id' => $user->id, 'submission_id' => $submission->id, 'mark' => rand(0, $submission->total)]);
         }
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $data = $request->all();
     if (!empty($data) && isset($data['id'])) {
         $videoId = $data['id'];
         $song = new Song();
         $row = $song->where('video_id', $videoId)->first();
         if (is_null($row)) {
             $submission = new Submission();
             $user = \Auth::user();
             $latestSong = new Song();
             $latestSong = $latestSong->orderby('updated_at', 'desc')->first();
             // Add song
             $song->video_id = $videoId;
             $song->video_name = $data['name'];
             $song->video_duration = $data['duration'];
             $song->created_at = Carbon::now()->addHours(2);
             if (is_null($latestSong)) {
                 $song->updated_at = $song->created_at;
             } else {
                 // We want to set the updated_at coorsponding to latest added
                 // song duration, for a consistent playlist.
                 $latestSongUpdateDate = Carbon::parse($latestSong->updated_at)->timestamp;
                 $latestSongDuration = $latestSong->video_duration;
                 $nextUpdateAtStop = $latestSongUpdateDate + $latestSongDuration;
                 $song->updated_at = Carbon::createFromTimestamp($nextUpdateAtStop)->toDateTimeString();
             }
             $song->save();
             $submission->facebook_id = $user->facebook_id;
             $submission->playlist_id = $song->video_id;
             $submission->save();
             // Publish song added
             $this->pusher->trigger('playlist-channel', 'song-added', []);
             return new Response(json_encode($song), Response::HTTP_CREATED);
         } else {
             // Song record already exists
             return new Response('Conflict', Response::HTTP_CONFLICT);
         }
     }
     // Request data not supported
     return new Response('Unprocessable Entity', Response::HTTP_UNPROCESSABLE_ENTITY);
 }
Beispiel #7
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $circles = Circle::all();
     foreach ($circles as $circle) {
         $pupils = $circle->pupils()->get();
         $batches = $circle->batches()->get();
         foreach ($pupils as $pupil) {
             foreach ($batches as $batch) {
                 Submission::create(['batch_id' => $batch->id, 'pupil_id' => $pupil->id, 'score' => rand(0, $batch->maxscore)]);
             }
         }
     }
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $gallery = Gallery::findOrFail($id);
     $submissions = Submission::gallerySubmissions($id);
     $subCount = $gallery->reblogs;
     if ($subCount) {
         $grids = $this->dispatchFrom('App\\Jobs\\CreateSubmissionsGrid', new Request(), ['submissions' => $submissions, 'page' => 'gallery']);
     } else {
         $noRecordsFound = 'No submissions for this gallery.';
         $grids['narrowGrid'] = $noRecordsFound;
         $grids['grid'] = $noRecordsFound;
     }
     return view('galleries.show')->with(['narrowGrid' => $grids['narrowGrid'], 'grid' => $grids['grid'], 'gallery' => $gallery, 'submissions' => $submissions]);
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $photo = Photo::findOrFail($id);
     $submissions = Submission::photoSubmissions($id);
     $subCount = $submissions->count();
     if ($subCount) {
         $grids = $this->dispatchFrom('App\\Jobs\\CreateSubmissionsGrid', new Request(), ['submissions' => $submissions, 'page' => 'photo']);
     } else {
         $noRecordsFound = 'No submissions for this photo.';
         $grids['narrowGrid'] = $noRecordsFound;
         $grids['grid'] = $noRecordsFound;
     }
     return view('photos.show')->with(['narrowGrid' => $grids['narrowGrid'], 'grid' => $grids['grid'], 'photo' => $photo, 'submissions' => $submissions, 'subCount' => $subCount]);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Eloquent::unguard();
     // Delete all records
     Submission::whereNotNull('id')->delete();
     Form::whereNotNull('id')->delete();
     $form1 = Form::create(['slug' => 'the-test', 'title' => 'Nice test Form']);
     $form1->fields()->save(new Field(['slug' => 'name', 'title' => 'Name', 'rules' => 'required|string']));
     $form1->fields()->save(new Field(['slug' => 'rating', 'title' => 'Rating', 'rules' => 'required|integer|min:1|max:5']));
     $form2 = Form::create(['slug' => 'test-with-email-confirmation', 'title' => 'Test that sends email confirmation', 'confirmation_message' => 'Thanks for the message !', 'confirmation_email_field' => 'email', 'owner_email' => '*****@*****.**', 'owner_name' => 'That Company']);
     $form2->fields()->save(new Field(['slug' => 'email', 'title' => 'Email', 'rules' => 'required|email']));
     Form::create(['slug' => 'test-with-email-notification', 'title' => 'Test with email notification', 'send_email_to' => 'john@example.com,max@example.com', 'owner_email' => '*****@*****.**', 'owner_name' => 'That Company']);
     Form::create(['slug' => 'test-with-redirect', 'title' => 'Test with a redirect', 'redirect_to_url' => 'https://example.com/']);
     Form::create(['slug' => 'test-closed', 'title' => 'Closed form test', 'accept_submissions' => false]);
     Eloquent::reguard();
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $submission = Submission::findOrFail($id);
     $data = $submission->getSubmissionData();
     return view('submissions.show', ['response' => $data]);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $submission = Submission::findOrFail($id);
     $id = $submission->submission_id;
     $submission->delete();
     flashMessage("Submission with ID {$id} has been deleted.", "alert-success");
     return redirect('submissions');
 }
Beispiel #13
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $this->validate($request, ['maxscore' => 'required|numeric|min:1|max:40']);
     $batch = Batch::findOrFail($id);
     $batch->maxscore = $request->maxscore;
     $batch->save();
     foreach ($request->scores as $pupil_id => $score) {
         if ($score != "") {
             $submission = Submission::firstOrCreate(['pupil_id' => $pupil_id, 'batch_id' => $batch->id]);
             if ($submission->score != $score) {
                 $submission->score = $score;
                 $submission->save();
             }
         } else {
             Submission::where('pupil_id', $pupil_id)->where('batch_id', $batch->id)->delete();
         }
     }
     return redirect('circle/' . $batch->circle_id . '/analyze');
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $submission = Submission::findOrFail($id);
     return view('submissions.show', compact('submission'));
 }