山东大学-VirtualJudge-总结8

在最近的几天,主要是改正在以往contest的实现中存在的一些问题,主要是:
1 无法从contestoverview中进入题目的详细说明页面
2 用户在submit中提交的代码无法正常在Status中显示评测状态
3 Contest的时区设置错误,没有设置为东八区时间
4 实现了Contest 的中的倒计时功能

修改过后的contest_get_problem方法####

def contest_get_problem(req, cid):
    if req.is_ajax():
        contest = Contest.objects.get(id=cid)
        pid = req.GET.get('pid')
        t = loader.get_template('contest/contest_problem.html')
        problem = Problem.objects.get(proid=pid)
        if contest.private:
            if req.user.is_superuser==False and req.user.info not in contest.accounts.all() :
                problem = []
        #content_html = t.render(Context({'problem': problem, 'user' : req.user}))
        # return HttpResponse(content_html)
        return render(req,'contest/contest_problem.html',{'problem': problem, 'user' : req.user})

修改过后的submit方法####

def contest_submit(req, cid):
    contest = Contest.objects.get(id=cid)
    #time = datetime.datetime.now(pytz.timezone(pytz.country_timezones('cn')[0]))
    # time1=time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))
    time=timezone.now()
    # print(contest.start_time + contest.duration_time)
    if time > contest.start_time + contest.duration_time:
        finish = True
    else:
        finish = False

    if contest.private:
        if req.user.is_superuser==False and req.user.info not in contest.accounts.all() :
            return HttpResponseRedirect("/contest/" + cid + "/")

    if req.method == 'GET':
        return ren2res("contest/contest_submit.html", req, {'contest': contest, 'problems': contest.get_problem_list()})
    elif req.method == 'POST':
        pid = req.POST.get('pid')
        #need change start
        # sub = Status(pro=Problem.objects.get(proid=pid), user=req.user, lang=req.POST.get('lang'))
        sub = Status(user=req.user, pro=Problem.objects.get(proid=pid), lang=req.POST.get('lang'), result='Waiting', 
            time=time)

        if not finish:
            sub.cid = contest.id
        else:
            sub.cid = -1
        sub.save()
        if req.POST.get('code'):
            content_file = ContentFile(req.POST.get('code'))
        elif req.FILES:
            content_file = ContentFile(req.FILES['file'].read())
        else:
            return ren2res("contest/contest_submit.html", req,
                           {'contest': contest, 'problems': contest.get_problem_list(), 'err': 'No Submit!'})
        #sub.source_code.save(name=str(sub.runid), content=content_file)
        sub.save()
        #judger.Judger(sub)
        #result=judge_delay.delay(sub)
    if not finish:
        return HttpResponseRedirect("/contest/" + cid + "/")
    else:
        return HttpResponseRedirect("/contest/"+cid+"/status?pid=" + pid)
        #need change end

山东大学-VirtualJudge-总结8_第1张图片
overview
山东大学-VirtualJudge-总结8_第2张图片
从overview进入问题描述界面
山东大学-VirtualJudge-总结8_第3张图片
修正时区

contest实现正确的计时:

山东大学-VirtualJudge-总结8_第4张图片
Contest开始时间还未到
山东大学-VirtualJudge-总结8_第5张图片
contest开始之后正确计时

接下来主要集中在开发contestclarification功能,以及整个virtualJudgeRank功能

你可能感兴趣的:(山东大学-VirtualJudge-总结8)