def build_solve_prob_div(self, database, userId, contest, body): title = HtmlElement('h2').addAttr(Attr('class', 'center-align')).addNode('Problemas resolvidos pelo usuário') body.addNode(title) allProblems = parseSignedlist(database.get_problems_of_user_from_db(userId)['data']) problems = sumarise_problems_by_column(allProblems, 'PROBLEM') body.addNode(self.build_probs_table(problems, contest))
def get_solved_problems_by_user(self, user): subs = self.get_database().get_problems_of_user_from_db(user) probs = parseSignedlist(subs['data']) if probs is not None: p = sumarise_problems_by_column(probs, LABEL_COLUMN_ACCEPTED) if ACCEPTED in p: return [prob[LABEL_PROBLEM_COLUMN] for prob in p[ACCEPTED]] return []
def process_submission(self, submission, acRate): subDict = parseSignedlist(submission['data']) probs = sumarise_problems_by_column(subDict, 'RESULT') cnt = 0 for prob in probs[ACCEPTED]: acRate[prob['PROBLEM']] += 1 cnt += 1 self.totalAcc += cnt
def process_submission(self, submission, acRate): subDict = parseSignedlist(submission['data']) probs = sumarise_problems_by_column(subDict, 'RESULT') cnt = 0 for prob in probs[ACCEPTED]: acRate[prob['PROBLEM']] += 1 cnt += 1 self.totalAcc += cnt
def process_submission(self, submission, dacus): subDict = parseSignedlist(submission['data']) probs = sumarise_problems_by_column(subDict, LABEL_COLUMN_ACCEPTED) try: distinctProbs = set([x[LABEL_PROBLEM_COLUMN] for x in probs[ACCEPTED]]) except: print submission['_id'], probs for prob in distinctProbs: dacus[prob] += 1
def process_submission(self, submission, dacus): subDict = parseSignedlist(submission['data']) probs = sumarise_problems_by_column(subDict, LABEL_COLUMN_ACCEPTED) try: distinctProbs = set( [x[LABEL_PROBLEM_COLUMN] for x in probs[ACCEPTED]]) except: print submission['_id'], probs for prob in distinctProbs: dacus[prob] += 1
def process_submission(self, submission): user = submission['_id'] subDict = parseSignedlist(submission['data']) probs = sumarise_problems_by_column(subDict, 'RESULT') distinctProbs = set([x['PROBLEM'] for x in probs[ACCEPTED]]) self.dacu[user] = self.dacuRec.compute_user_dacu(distinctProbs, self.topk) for problem in distinctProbs: if problem not in self.usersByProblems: self.usersByProblems[problem] = [] self.usersByProblems[problem].append(user)
def process_submission(self, submission): user = submission['_id'] subDict = parseSignedlist(submission['data']) probs = sumarise_problems_by_column(subDict, 'RESULT') distinctProbs = set([x['PROBLEM'] for x in probs[ACCEPTED]]) self.dacu[user] = self.dacuRec.compute_user_dacu( distinctProbs, self.topk) for problem in distinctProbs: if problem not in self.usersByProblems: self.usersByProblems[problem] = [] self.usersByProblems[problem].append(user)
def build_stats_div(self, database, userId, head, body): allProblems = parseSignedlist(database.get_problems_of_user_from_db(userId)['data']) problems = sumarise_problems_by_column(allProblems, 'RESULT') subTable = self.build_submission_stats_table(problems) probTable = self.build_problems_stats_table(allProblems) table = HtmlElement('table') table.addAttr(Attr('class', 'allStats')) body.addNode(table) tr = HtmlElement('tr') table.addNode(tr) tr.addNode(HtmlElement('td').addNode(probTable)) tr.addNode(HtmlElement('td').addNode(subTable)) self.build_submitions_chart(allProblems, head, body)
def process_submission(self, submission): user = submission['_id'] subDict = parseSignedlist(submission['data']) probs = sumarise_problems_by_column(subDict, 'RESULT') distinctProbs = set([x['PROBLEM'] for x in probs[ACCEPTED]]) self.solvedProblemsByUser[user] = distinctProbs self.hubs[user] = 1.0 self.auth[user] = 1.0 for problem in distinctProbs: if problem not in self.usersByProblems: self.usersByProblems[problem] = [] self.hubs[problem] = 1.0 self.auth[problem] = 1.0 self.usersByProblems[problem].append(user)
def process_submission(self, submission): user = submission['_id'] subDict = parseSignedlist(submission['data']) probs = sumarise_problems_by_column(subDict, 'RESULT') distinctProbs = set([x['PROBLEM'] for x in probs[ACCEPTED]]) self.solvedProblemsByUser[user] = distinctProbs self.hubs[user] = 1.0 self.auth[user] = 1.0 for problem in distinctProbs: if problem not in self.usersByProblems: self.usersByProblems[problem] = [] self.hubs[problem] = 1.0 self.auth[problem] = 1.0 self.usersByProblems[problem].append(user)
def build_problems_stats_table(self, problems): problems = sumarise_problems_by_column(problems, 'PROBLEM') stats = sumarize_stats_of_user(problems) probTable = HtmlElement('table') probTable.addAttr(Attr('class', 'statTable')) th = HtmlElement('tr').addNode(HtmlElement('th').addAttr(Attr('colspan', '2')).addNode('Problemas')) probTable.addNode(th) labels = ['Problemas tentados', 'Resolvidos', 'Não resolvidos', 'Resolvidos na 1ª tentativa', 'Mais tentados', 'Média de tentativas'] values = [stats['attempted'], stats['solved'], stats['failures'], stats['accepted_1'], stats['most_failures'], '%.2f' % stats['avg_attempted_per_problem']] cnt = 0 for label in labels: tr = HtmlElement('tr') tr.addNode(HtmlElement('td').addNode(label)) tr.addNode(HtmlElement('td').addNode(values[cnt])) cnt += 1 probTable.addNode(tr) return probTable