def groupTagCompare(request, groupid): #groupid可以是整数,也可以是学号列表 if len(groupid) > 6: stuNOList = groupid.split(",") else: group = studentgroup.objects.get(id=groupid) pattern = re.compile(r'\d+') s = pattern.findall(str(group.groupstuID)) stuNOList = [] for sid in s: stuNOList.append(int(sid)) cons = Contest.objects.filter(ctype="cf") endtime = {} for con in cons: endtime[con.cid] = con.endtimestamp cfContest = CFContest.objects.all() stuList = Student.objects.all() datalist = {} names = [] colors = datautils.ncolors(len(stuNOList)) tags = [ 'brute force', 'greedy', 'math', 'sortings', 'implementation', 'binary search', 'ternary search', 'number theory', 'dp', 'strings', 'data structures', 'two pointers', 'constructive algorithms', 'combinatorics', 'flows', 'bitmasks', 'dfs and similar', 'expression parsing', 'shortest paths', 'geometry', 'meet-in-the-middle', 'divide and conquer', 'trees', 'graphs', 'games', 'dsu', 'interactive', 'hashing', 'matrices', 'string suffix structures', 'chinese remainder theorem', 'probabilities', '2-sat', 'graph matchings', 'fft' ] allcount = [0] * len(tags) for stuNO in stuNOList: names.append(stuList.get(stuNO=stuNO).realName) slist = [] clist = [] for ids, tag in enumerate(tags): clist = [] solve = 0 contests = cfContest.filter(stuNO=stuNO, realName=names[-1], statu="OK", tag__contains=tag) for con in contests: if str(con.cid) + con.index not in clist: if endtime[con.cid] > con.ctime: clist.append(str(con.cid) + con.index) solve = solve + 1 slist.append(solve) allcount[ids] += solve datalist[names[-1]] = slist content = { 'tags': json.dumps(tags), 'datalist': json.dumps(datalist), 'namesforit': names, 'names': json.dumps(names), 'colors': json.dumps(colors), 'allcount': json.dumps(allcount), } return render(request, "VisualData/TagCompare.html", content)
def groupRatingLine(request, groupid): group = studentgroup.objects.get(id=groupid) pattern = re.compile(r'\d+') s = pattern.findall(str(group.groupstuID)) stuNOList = [] for sid in s: stuNOList.append(int(sid)) # stuNOList = [ 2016014323] logger = logging.getLogger('log') stuList = Student.objects.filter(stuNO__in=stuNOList) color = datautils.ncolors(len(stuList)) stuNOList = [] lineX = [] names = [] dic_stuNO_rating = {} dic_stuNO_year = {} for stu in stuList: stuNOList.append(stu.stuNO) names.append(stu.realName) dic_stuNO_rating[stu.stuNO] = [] dic_stuNO_year[stu.stuNO] = stu.year yearlist = ['Freshman', 'Sophomore', 'Junior'] monthlist = [ '09', '10', '11', '12', '01', '02', '03', '04', '05', '06', '07', '08' ] dic_year_gap = {'Freshman': 0, 'Sophomore': 1, 'Junior': 2} dic_month_gap = { '09': 0, '10': 0, '11': 0, '12': 0, '01': 1, '02': 1, '03': 1, '04': 1, '05': 1, '06': 1, '07': 1, '08': 1 } for year in yearlist: for month in monthlist: if month == '09': lineX.append(year + month) else: lineX.append(month) for stuNO in stuNOList: date = str(dic_stuNO_year[stuNO] + dic_year_gap[year] + dic_month_gap[month]) + "-" + month value = datautils.getLatestCFRating(stuNO, date) if value == 0 and len(dic_stuNO_rating[stuNO]) > 0: value = dic_stuNO_rating[stuNO][-1] logger.info(date + ":" + str(value)) dic_stuNO_rating[stuNO].append(value) # logger.info(lineX) # logger.info(names) # logger.info(dic_stuNO_rating) context = { "lineX": json.dumps(lineX), "names": json.dumps(names), "stuNOList": json.dumps(stuNOList), "dic_stuNO_rating": json.dumps(dic_stuNO_rating), "color": json.dumps(color) } return render(request, 'groupRatingLine.html', context)
def groupdata(request, groupid): #队数据 group = studentgroup.objects.get(id=groupid) StuContestList = StudentContest.objects.all().filter( ctype='cf').order_by('cdate') pattern = re.compile(r'\d+') s = pattern.findall(str(group.groupstuID)) stuNOList = [] for sid in s: stuNOList.append(int(sid)) logger = logging.getLogger('log') stuList = Student.objects.filter(stuNO__in=stuNOList) color = datautils.ncolors(len(stuList)) stuNOList = [] lineX = [] names = [] dic_stuNO_rating = {} dic_stuNO_year = {} for stu in stuList: stuNOList.append(stu.stuNO) names.append(stu.realName) dic_stuNO_rating[stu.stuNO] = [] dic_stuNO_year[stu.stuNO] = stu.year yearlist = ['Freshman', 'Sophomore', 'Junior'] monthlist = [ '09', '10', '11', '12', '01', '02', '03', '04', '05', '06', '07', '08' ] dic_year_gap = {'Freshman': 0, 'Sophomore': 1, 'Junior': 2} dic_month_gap = { '09': 0, '10': 0, '11': 0, '12': 0, '01': 1, '02': 1, '03': 1, '04': 1, '05': 1, '06': 1, '07': 1, '08': 1 } for year in yearlist: for month in monthlist: if month == '09': lineX.append(year + month) else: lineX.append(month) for stuNO in stuNOList: date = str(dic_stuNO_year[stuNO] + dic_year_gap[year] + dic_month_gap[month]) + "-" + month value = datautils.getLatestCFRating_fasterVersion( StuContestList, stuNO, date, ) if value == 0 and len(dic_stuNO_rating[stuNO]) > 0: value = dic_stuNO_rating[stuNO][-1] logger.info(date + ":" + str(value)) dic_stuNO_rating[stuNO].append(value) grouplist = studentgroup.objects.filter(enable=True) cons = Contest.objects.filter(ctype="cf") endtime = {} for con in cons: endtime[con.cid] = con.endtimestamp cfContest = CFContest.objects.all() datalist = {} names = [] tags = [ 'brute force', 'greedy', 'math', 'sortings', 'implementation', 'binary search', 'ternary search', 'number theory', 'dp', 'strings', 'data structures', 'two pointers', 'constructive algorithms', 'combinatorics', 'flows', 'bitmasks', 'dfs and similar', 'expression parsing', 'shortest paths', 'geometry', 'meet-in-the-middle', 'divide and conquer', 'trees', 'graphs', 'games', 'dsu', 'interactive', 'hashing', 'matrices', 'string suffix structures', 'chinese remainder theorem', 'probabilities', '2-sat', 'graph matchings', 'fft' ] allcount = [0] * len(tags) for stuNO in stuNOList: names.append(stuList.get(stuNO=stuNO).realName) slist = [] clist = [] for ids, tag in enumerate(tags): clist = [] solve = 0 contests = cfContest.filter(stuNO=stuNO, realName=names[-1], statu="OK", tag__contains=tag) for con in contests: if str(con.cid) + con.index not in clist: if endtime[con.cid] > con.ctime: clist.append(str(con.cid) + con.index) solve = solve + 1 slist.append(solve) allcount[ids] += solve datalist[names[-1]] = slist # logger.info(lineX) # logger.info(names) # logger.info(dic_stuNO_rating) context = { "lineX": json.dumps(lineX), "names": json.dumps(names), "stuNOList": json.dumps(stuNOList), "dic_stuNO_rating": json.dumps(dic_stuNO_rating), "grouplist": grouplist, "students": stuList, "groupid": groupid, 'tags': json.dumps(tags), 'datalist': json.dumps(datalist), 'namesforit': names, 'names': json.dumps(names), 'colors': json.dumps(color), 'allcount': json.dumps(allcount), } return render(request, 'VisualData/groupdata.html', context)