def respond_allocation(self, code=None): if code is not None: allocation = find_element_by_id(self.suggested_allocations, code) else: allocation = self.allocation allocation_dict = {} allocation_dict["algorithm"] = allocation.internal_algorithm allocation_dict["indices"] = { "strong_strong_indicator": allocation.strong_strong_indicator } allocation_dict["large_warings"] = allocation.large_warnings allocation_conv = [] for lattice in allocation: allocation_conv.append({ "teams": tools.get_ids(lattice.grid.teams), "warnings": [ w.status for w in lattice.warnings ], ############################################################# "chairs": [lattice.chair.code], ##############fix in next version "venue": lattice.venue.code if lattice.venue is not None else None, "panels": tools.get_ids(lattice.panels) }) allocation_dict["allocation"] = allocation_conv allocation_dict["code"] = allocation.code return allocation_dict
def fetch_adjudicator(self, code): data = {} adjudicator = tools.find_element_by_id(self.adjudicator_list, code) data['code'] = adjudicator.code data['name'] = adjudicator.name data['reputation'] = adjudicator.reputation data['judge_test'] = adjudicator.judge_test data['institutions'] = tools.get_ids(adjudicator.institutions) data['conflicts'] = tools.get_ids(adjudicator.conflict_teams) data['url'] = adjudicator.url data['available'] = not adjudicator.absent return data
def respond_matchup(self, code=None): if code is not None: matchup = find_element_by_id(self.suggested_matchups, code) else: matchup = self.matchup matchup_dict = {} matchup_dict["algorithm"] = matchup.internal_algorithm matchup_dict["indices"] = { "power_pairing_indicator": matchup.power_pairing_indicator, "adopt_indicator": matchup.adopt_indicator, "adopt_indicator2": matchup.adopt_indicator2, "adopt_indicator_sd": matchup.adopt_indicator_sd, "gini_index": matchup.gini_index, "scatter_indicator": matchup.scatter_indicator } matchup_dict["large_warings"] = matchup.large_warnings matchup_conv = [] for grid in matchup: matchup_conv.append({ "teams": tools.get_ids(grid.teams), "warnings": [w.status for w in grid.warnings] }) matchup_dict["allocation"] = matchup_conv matchup_dict["code"] = matchup.code return matchup_dict
def total_team_results(self): result_dicts = [] if self.style["team_num"] == 2: win_text = "wins" else: win_text = "win-points" for team in self.team_list: result_dict = OrderedDict() result_dict["name"] = team.name result_dict["code"] = team.code result_dict[win_text] = team.sum_wins() result_dict["sum"] = round(team.sum_scores(), 2) result_dict["margin"] = round(team.margin, 2) result_dict["average"] = round(team.average(), 2) result_dict["sd"] = round(team.sd(), 2) for i, score in enumerate( [round_str2float(score, 2) for score in team.scores_sub]): result_dict["round" + str(i + 1)] = score result_dicts.append(result_dict) team_codes = tools.get_ids(self.team_list) result_dicts.sort(key=lambda d: (d[win_text], d["sum"], d["margin"]), reverse=True) f = lambda d1, d2: d1[win_text] != d2[win_text] or d1["sum"] != d2[ "sum"] or d1["margin"] != d2["margin"] results_dict = insert_ranking(result_dicts, f) return results_dict
def fetch_team(self, code): data = {} team = tools.find_element_by_id(self.team_list, code) data['code'] = team.code data['name'] = team.name data['speakers'] = tools.get_ids(team.debaters) data['available'] = team.available data['url'] = team.url return data
def list_teams(self): data = [] for code in tools.get_ids(self.team_list): data.append(self.fetch_team(code)) return data
def list_institutions(self): data = [] for code in tools.get_ids(self.institution_list): data.append(self.fetch_institution(code)) return data
def list_debaters(self): data = [] for code in tools.get_ids(self.debater_list): data.append(self.fetch_debater(code)) return data
def list_venues(self): data = [] for code in tools.get_ids(self.venue_list): data.append(self.fetch_venue(code)) return data
def list_adjudicators(self): data = [] for code in tools.get_ids(self.adjudicator_list): data.append(self.fetch_adjudicator(code)) return data