山东大学-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

overview
从overview进入问题描述界面
修正时区

contest实现正确的计时:

Contest开始时间还未到
contest开始之后正确计时

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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 175,378评论 25 709
  • 最近的几天时间内,主要是进一步开发SDUVJ的contest的其他功能中,并在最终完成了contest的基本的开发...
    LJCgeorge阅读 3,838评论 0 0
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,399评论 19 139
  • 22年12月更新:个人网站关停,如果仍旧对旧教程有兴趣参考 Github 的markdown内容[https://...
    tangyefei阅读 35,295评论 22 257
  • 考试对于我们每个人来说再熟悉不过了。“考考考,老师的法宝;分分分,学生的命根”精确地概括了我们所受的长达十二年之久...
    幸福_娟阅读 2,915评论 4 6