def __init__(self, id=None):
        if id != None:
            details = getKey(f"/submissions/{id}/submission.json")
            self.id = details["id"]
            self.user = User.get(details["user"]) or User.getByName(details["user"])    # Ensures backward compatibility with older db's
            self.problem = Problem.get(details["problem"])
            self.timestamp = int(details["timestamp"])
            self.language = details["language"]
            self.code = details["code"]
            self.type = details["type"]
            self.results = details["results"]
            self.result = details["result"]
            self.status = details.get("status", None)
            self.checkout = None  # On server restart, all judges lose their checkouts
            self.version = 0
        else:
            self.id = None
            self.user = None     # Instance of User
            self.problem = None     # Instance of Problem
            self.timestamp = 0        # Time of submission (in milliseconds from time.time() * 1000)
            self.language = None
            self.code = None     # Source code
            self.type = None
            self.results = []      # One result for each test case
            self.result = None     # Overall result
            self.status = None     # One of Submission.STATUS_REVIEW, Submission.STATUS_JUDGED
            self.checkout = None     # id of judge that has submission checked out
            self.version = 1        # Version number for judge changes to this record

        self.inputs = []      # For display only
        self.outputs = []     # For display only
        self.errors = []      # For display only
        self.answers = []     # For display only
        self.compile = None   # Compile error
示例#2
0
    def __init__(self, id=None):
        if id != None:
            details = getKey(f"/contests/{id}/contest.json")
            self.id = details["id"]
            self.name = details["name"]
            self.start = int(details["start"])
            self.end = int(details["end"])
            self.scoreboardOff = int(details.get("scoreboardOff", self.end))
            self.showProblInfoBlocks = details.get("showProblInfoBlocks",
                                                   "Off")
            self.problems = [Problem.get(id) for id in details["problems"]]
            self.tieBreaker = str(details.get(
                "tieBreaker",
                "")).lower() == "true"  # True = sample correct breaks ties
            self.displayFullname = str(details.get(
                "displayFullname", "")).lower(
                ) == "true"  # True = full names displayed in reports

        else:
            self.id = None
            self.name = None
            self.start = None  # timestamp in milliseconds from time.time() * 1000
            self.end = None
            self.scoreboardOff = None
            self.showProblInfoBlocks = None
            self.problems = None
            self.tieBreaker = False
            self.displayFullname = False
示例#3
0
 def __init__(self, id=None):
     if id != None:
         details = getKey(f"/problems/{id}/problem.json")
         self.id = details["id"]
         self.title = details["title"]
         self.description = details["description"]
         self.statement = details["statement"]
         self.input = details["input"]
         self.output = details["output"]
         self.constraints = details["constraints"]
         self.samples = int(
             details["samples"])  # Number of sample test cases
         self.tests = int(details["tests"])  # Total number of test cases
         self.sampleData = [Datum.get(id, i) for i in range(self.samples)]
         self.testData = [Datum.get(id, i) for i in range(self.tests)]
         self.timelimit = details.get(
             "timelimit",
             str(Problem.default_timelimit))  # Time limit in seconds
     else:
         self.id = None
         self.title = None
         self.description = None
         self.statement = None
         self.input = None
         self.output = None
         self.constraints = None
         self.samples = 0
         self.tests = 0
         self.sampleData = []
         self.testData = []
         self.timelimit = str(Problem.default_timelimit)
示例#4
0
 def __init__(self, id=None):
     if id != None:
         details = getKey(f"/messages/{id}/message.json")
         self.id = details["id"]
         self.fromUser = User.get(details["from"])
         self.toUser = User.get(details["to"])
         self.isGeneral = bool(details["general"])  # General announcement
         self.isAdmin = bool(details["admin"])  # Message sent to admin
         self.message = details["message"]
         self.timestamp = float(details["timestamp"])
         self.replyTo = details.get("replyTo")
     else:
         self.id = None
         self.fromUser = None
         self.toUser = None
         self.isGeneral = False
         self.isAdmin = False
         self.message = ""
         self.timestamp = 0
         self.replyTo = None
示例#5
0
 def get(id: str, num: int):
     input = getKey(f"/problems/{id}/input/in{num}.txt")
     output = getKey(f"/problems/{id}/output/out{num}.txt")
     return Datum(input, output)
示例#6
0
            "fullname": self.fullname,
            "password": self.password,
            "type": self.type
        }

    @staticmethod
    def allJSON():
        return [users[id].toJSON() for id in users]
    
    def delete(self):
        del users[self.id]
        del userNames[self.username]
        self.save(False)
    
    def isAdmin(self) -> bool:
        return self.type == "admin"

    @staticmethod
    def all():
        return [users[id] for id in users]


usrs = getKey("/users.json") or []
for usr in usrs:
    user = User(usr["username"], usr.get('fullname', usr["username"]), usr["password"], usr["type"], usr["id"])

    # Fill data structures with id and username from class
    # in case JSON data was overrided
    users[user.id] = user
    userNames[user.username] = user