Пример #1
0
 /**
  * Match all newcomer without a team to a team
  *
  * Current algorithme put user of a branch inside one of the team
  * with the same branch (because we want to have PMOM with PMOM),
  * or if there is no team with the same branch, we put them in team
  * with null as a branch.
  */
 public static function matchTeams()
 {
     $newcomers = Newcomer::whereNull('team_id')->get();
     // Create an array to branch_id with number of newcomers in the team
     $countPerTeam = [];
     $teams = Team::all();
     foreach ($teams as $team) {
         if (!isset($countPerTeam[$team->branch])) {
             $countPerTeam[$team->branch] = [];
         }
         $countPerTeam[$team->branch][$team->id] = $team->newcomers->count();
     }
     foreach ($newcomers as $newcomer) {
         // Select teams associated with newcomer's branch if exist
         $branch = null;
         if (isset($countPerTeam[$newcomer->branch])) {
             $branch = $newcomer->branch;
         }
         // find teams with less newcomers and take it randomly
         $min = min($countPerTeam[$branch]);
         $keys = array_keys($countPerTeam[$branch], $min);
         $key = array_rand($keys);
         // set the new team and tell there is another number
         $newcomer->team_id = $keys[$key];
         $countPerTeam[$branch][$keys[$key]]++;
     }
     // Save it to DB
     foreach ($newcomers as $newcomer) {
         $newcomer->save();
     }
 }
Пример #2
0
 /**
  * List all the teams and show a creation form.
  *
  * @return Response
  */
 public function list()
 {
     if (!EtuUTT::student()->isAdmin()) {
         return $this->error('Vous n\'avez pas le droit d\'accéder à cette page.');
     }
     return View::make('dashboard.teams.list', ['teams' => Team::all()]);
 }
Пример #3
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param int $id
  *
  * @return mixed
  */
 public function edit($id)
 {
     $fixture = Fixture::findOrFail($id);
     $divisions = Division::all();
     $teams = Team::all();
     $venues = Venue::all();
     return view('admin.data-management.fixtures.edit', compact('fixture', 'divisions', 'teams', 'venues'));
 }
 public function getReset()
 {
     $teams = Team::all();
     foreach ($teams as $team) {
         $team->games = 0;
         $team->wins = 0;
         $team->save();
     }
     return "Ok";
 }
Пример #5
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $newcomers = Newcomer::where('team_id', null)->orderByRaw(' RAND()')->get();
     if ($newcomers->count() == 0) {
         die($this->info('All the newcomers have a team.'));
     }
     $teams = Team::all();
     $count = floor($newcomers->count() / $teams->count());
     foreach ($teams as $team) {
         for ($i = 0; $i < $count; $i++) {
             $newcomer = $newcomers->pop();
             $newcomer->team_id = $team->id;
             if (!$newcomer->save()) {
                 die($this->error('Unable to add #' . $newcomer->id . ' to a team.'));
             }
         }
     }
     $this->info('Newcomers were added to their respective teams!');
 }
Пример #6
0
 public function index()
 {
     $branchs = Branch::all(['id', 'name']);
     $branchselectlist = array();
     array_push($branchselectlist, ':เลือกสาขา');
     foreach ($branchs as $item) {
         array_push($branchselectlist, $item->id . ':' . $item->name);
     }
     $departments = Department::all(['id', 'name']);
     $departmentselectlist = array();
     array_push($departmentselectlist, ':เลือกแผนก');
     foreach ($departments as $item) {
         array_push($departmentselectlist, $item->id . ':' . $item->name);
     }
     $teams = Team::all(['id', 'name']);
     $teamselectlist = array();
     array_push($teamselectlist, ':เลือกทีม');
     foreach ($teams as $item) {
         array_push($teamselectlist, $item->id . ':' . $item->name);
     }
     return view('employee', ['branchselectlist' => implode(";", $branchselectlist), 'departmentselectlist' => implode(";", $departmentselectlist), 'teamselectlist' => implode(";", $teamselectlist)]);
 }
 public function getEditTeam(LoggedInRequest $request, $id = 0)
 {
     if ($id == 0) {
         $teams = Team::all();
         return view('pages.teams', compact('teams'));
     }
     $team = Team::find($id);
     return view('pages.team-detail', compact('team'));
 }
Пример #8
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $teams = Team::all();
     return view('team.index', compact('teams'));
 }
Пример #9
0
 /**
  * List all the teams and show a creation form.
  *
  * @return Response
  */
 public function teamList()
 {
     return View::make('dashboard.ce.teamlist', ['teams' => Team::all(), 'teamLeft' => Config::get('services.ce.maxteam') - Team::count()]);
 }
Пример #10
0
 public function getTeams()
 {
     if (!Auth::user()->hasRole('exec')) {
         //TODO middleware perhaps?
         return;
     }
     $teams = Team::all();
     foreach ($teams as $team) {
         $team['hackers_detail'] = $team->getHackersWithRating();
         $hackerRatings = [];
         $ratingSum = 0;
         $ratingCount = 0;
         foreach ($team['hackers_detail'] as $eachHackerDetail) {
             $eachHackerRating = $eachHackerDetail['application']['ratinginfo']['average'];
             $hackerRatings[] = $eachHackerRating;
             $ratingCount += $eachHackerDetail['application']['ratinginfo']['count'];
             $ratingSum += $eachHackerRating;
         }
         $min = 0;
         $max = 0;
         $avg = 0;
         if ($ratingCount != 0) {
             $avg = $ratingSum / $ratingCount;
             $min = min($hackerRatings);
             $max = max($hackerRatings);
         }
         $team['overall_ratings'] = ["count" => $ratingCount, "min" => $min, "max" => $max, "average" => $avg];
     }
     return $teams;
 }
Пример #11
0
 public function index()
 {
     $team = Team::all()->first();
     return view('backend.teams.view')->with('team', $team);
 }
Пример #12
-1
 public function index()
 {
     if (!$this->hasPermission($this->menuPermissionName)) {
         return view($this->viewPermissiondeniedName);
     }
     $branchs = Branch::all(['id', 'name']);
     $branchselectlist = array();
     array_push($branchselectlist, ':เลือกสาขา');
     foreach ($branchs as $item) {
         array_push($branchselectlist, $item->id . ':' . $item->name);
     }
     $departments = Department::all(['id', 'nameth', 'nameen']);
     $departmentselectlist = array();
     array_push($departmentselectlist, ':เลือกแผนก');
     foreach ($departments as $item) {
         array_push($departmentselectlist, $item->id . ':' . str_replace('&', '\\u0026', $item->nameth) . ' - ' . str_replace('&', '\\u0026', $item->nameen));
     }
     $teams = Team::all(['id', 'name']);
     $teamselectlist = array();
     array_push($teamselectlist, ':เลือกทีม');
     foreach ($teams as $item) {
         array_push($teamselectlist, $item->id . ':' . $item->name);
     }
     return view('employee', ['branchselectlist' => implode(";", $branchselectlist), 'departmentselectlist' => implode(";", $departmentselectlist), 'teamselectlist' => implode(";", $teamselectlist)]);
 }