public function challenges() { $startd = DB::table('Games')->select('start')->first(); $endd = DB::table('Games')->select('stop')->first(); if ($startd->start > Carbon::now()) { return view("pages.countdown"); } elseif ($endd->stop < Carbon::now()) { return view('pages.closed'); } $num_users = User::count(); $completed = Submitted_flag::count(); $num_challenges = Challenge::count(); $average_c = $completed / $num_users / $num_challenges * 100; $stats = array('num_users' => $num_users, 'completed' => $completed, 'average' => $average_c); $mycompleted = Submitted_flag::where('user_id', Auth::user()->id)->get()->toArray(); $game = Game::first(); $categories = Category::get(); $categories = $categories->toArray(); foreach ($categories as $category) { $challenges = Challenge::where('category_id', $category['id'])->orderby('point_value', 'ASC')->get()->toArray(); $categories[(int) $category['id'] - 1]['challenges'] = $challenges; } $directory = base_path() . '/public/Challenges_Repo/'; $files = scandir($directory); $startd = DB::table('Games')->select('start')->first(); if ($startd->start > Carbon::now()) { $start = true; } else { $start = false; } $data = array('user' => Auth::user(), 'game' => $game, 'categories' => $categories, 'stats' => $stats, 'files' => $files, 'completed' => $mycompleted, 'start' => $start); return view("pages.challenges")->with('data', $data); }
public function challenges() { /*$game = Game::first(); $categories = Category::get(); $categories = $categories->toArray(); foreach($categories as $category) { $challenges = Challenge::where('category_id', $category['id'])->get()->toArray(); $categories[(int)$category['id'] - 1]['challenges'] = $challenges; } $data = array('game' => $game, 'categories' => $categories);*/ $num_users = User::count(); $completed = Submitted_flag::count(); $num_challenges = Challenge::count(); $average_c = $completed / $num_users / $num_challenges * 100; $stats = array('num_users' => $num_users, 'completed' => $completed, 'average' => $average_c); $game = Game::first(); $categories = Category::get(); $categories = $categories->toArray(); foreach ($categories as $category) { $challenges = Challenge::where('category_id', $category['id'])->get()->toArray(); $categories[(int) $category['id'] - 1]['challenges'] = $challenges; } $directory = base_path() . '/public/Challenges_Repo/'; $files = scandir($directory); $data = array('user' => Auth::user(), 'game' => $game, 'categories' => $categories, 'stats' => $stats, 'files' => $files); return view("pages.challenges")->with('data', $data); }
public static function listGroup() { $data = []; $data += ['' => '-- Selecciona Reto --']; $datas = Challenge::where('active', 1)->lists('name', 'id'); $data += $datas->toArray(); return $data; }
public function quest(Request $request) { if ($request->user()->role->name !== 'Technologist') { return redirect('dashboard'); } $this->data['players'] = User::with(['points', 'team'])->get(); $this->data['user'] = $request->user(); $this->data['challenges'] = \App\Challenge::where('active_time', '<', date('Y-m-d H:i:s'))->get(); return View::make('team.quest', $this->data); }
/** * returns challenges. with some additional information, that have already started, ordered desc by start date. * * @param $challengeType * @return string */ public function getSpecific($challengeType) { $type = $challengeType; if ($type == "monthly") { $challenges = Challenge::where('isWeekly', '=', 0)->started()->orderBy('start', 'DESC')->get(); } else { if ($type == 'weekly') { $challenges = Challenge::where('isWeekly', '=', 1)->started()->orderBy('start', 'DESC')->get(); } else { return 'wrong challenge type'; } } foreach ($challenges as $challenge) { $challenge->img = $challenge->featuredImg(); $challenge->howManyUploads = $challenge->entryCount(); $challenge->end = $challenge->getEndDate(); unset($challenge->isWeekly); unset($challenge->created_at); unset($challenge->updated_at); } return $challenges; }
public function getReferee() { $role = [' ' => 'Seleciona el rol']; $role += Role::lists('name', 'id')->toArray(); $challenge = [' ' => '-- Seleccionar Reto --']; $challenge += Challenge::where('active', '=', '1')->lists('name', 'id')->toArray(); $url_actual = "http://" . $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]; $url_actual = explode('?', $url_actual); $user = User::where('rb_users.role_id', '=', 9)->join('rb_role', 'rb_role.id', '=', 'rb_users.role_id')->select('rb_users.*', 'rb_role.name as nombre_rol')->orderBy('id', 'DESC')->paginate(env('PAG')); $user->setPath($url_actual[0]); return view('users.referee', compact('user', 'role', 'challenge')); }