Skip to content
This repository was archived by the owner on Nov 18, 2020. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from src.shareddata.shareddata import g_config
from src.worker.judgers.baseJudger import Judger
from src.worker.judgers.ProgrammingJudger.checkers import *


class ProgrammingJudger(Judger):

def __init__(self, t_tag, t_sandbox):
"""
@detail
Expand All @@ -10,37 +13,37 @@ def __init__(self, t_tag, t_sandbox):
"""
Judger.__init__(self, t_tag)
self.m_sandbox = t_sandbox
self.m_checkers = {0:compileChecker.CompileChecker("compile check", t_sandbox),\
1:staticChecker.StaticChecker("static check", t_sandbox)\
2:standardChecker.StandardChecker("standard tests", t_sandbox)\
3:randomChecker.RandomChecker("random tests", t_sandbox)\
4:memoryChecker.MemoryChecker("memory check", t_sandbox)\
self.m_checkers = {0: compileChecker.CompileChecker("compile check", t_sandbox),
1: staticChecker.StaticChecker("static check", t_sandbox),
2: standardChecker.StandardChecker("standard tests", t_sandbox),
3: randomChecker.RandomChecker("random tests", t_sandbox),
4: memoryChecker.MemoryChecker("memory check", t_sandbox)
}

def judger(self, submission):
"""
@param
submission is the detail of a student submission,
@structure is as:
{"submission_id":s_id, "submission_problem_id":p_id,
{"submission_id":s_id, "problem_id":p_id,
"problem_type":p_type, "submission_type":s_type,
"submission_problem_config":config}
@detail
submission_id : the id of current submission
submission_problem_id: the id of problem corresponding to current sub
problem_type: choice or programming
submission_type:student submission or teacher design a problem
submission_config: the config of submission
submission_problem_config: the config of submission
"""
submission_id = submission["submission_id"]
problem_id = submission["problem_id"]
config = submission["submission_config"]
#ret is used to store the judge result
config = submission["submission_problem_config"]
# ret is used to store the judge result
ret["total_grade"] = 0
ret["submission_id"] = submission_id

#if missing submission dependency, write the report and return
if not (checke_submission_legal(submission_id, problem_id)):
# if missing submission dependency, write the report and return
if not (check_submission_legal(submission_id, problem_id)):
ret["error"] = "missing submission dependency"
ret["write_grade"] = 1
self.write_result_to_database(submission_id, ret, True)
Expand All @@ -53,7 +56,7 @@ def judger(self, submission):
g_logger.info("[Judger Programming] start to check submission id = " + \
str(submission_id))
for index in xrange(0, 5):
#continue when this stage not in the config
# continue when this stage not in the config
if self.m_checkers[index].getTag() not in config["grading"]:
continue

Expand All @@ -71,7 +74,7 @@ def judger(self, submission):
self.write_result_to_database(submission_id, ret, True)

@staticmethod
def checke_submission_legal(submission_id, problem_id):
def check_submission_legal(submission_id, problem_id):
"""
checker submission and standard files exists or not,
if missing some of them, return False, else True
Expand Down