def edit_own_review(): if session["csrf_token"] != request.form["csrf_token"]: abort(403) review_id = request.form["review_id"] work_id = request.form["work_id"] page = "/work/" + str(work_id) if request.form["delete"] == "3": db.delete_report(review_id, "review") if request.form["delete"] == "1": db.delete_review(review_id) return redirect(page) review = request.form["review"] if review: db.update_review(review_id, review) score = request.form["score"] db.update_score(review_id, score) return redirect(page)
def update_score(self, away_score, home_score, time_left): db.update_score(self.game_id, away_score, home_score, time_left)
def RunSubmission(id): # Base info from DB # Already filled in the main loop -- Vimal lang = langs[id].lower() ext = extensions[lang].lower() problem = probNames[id] user = users[id] sourceFile = "%s/submissions/%s/%s/%s.%s" % (BASE, user, id, problem, ext) # Compile exeFile = "%s/submissions/%s/%s/%s.exe" % (BASE, user, id, problem) if lang in needCompile: compileLog = "%s/submissions/%s/%s/%s.compile" % (BASE, user, id, problem) compileCmd = CompileCommand(sourceFile, exeFile, compileLog, lang) (out, ret) = Execute(compileCmd) compileSuccess = False if ret == None: compileSuccess = True if not compileSuccess: print "Error compiling %s" % id U(user, int(problem), "CE ") compileOutput = "" if os.path.exists(compileLog): c = open(compileLog, 'r') compileOutput = c.read() #update in db # Added by Vimal # Update in db that the submisssion compilation failed db.set_status(id, 'CE', '-', compileOutput) return #Execute with stdin testInput = "%s/problems/%s/INP" % (BASE, problem) Output = "%s/submissions/%s/%s/%s.out" % (BASE, user, id, problem) Error = "%s/submissions/%s/%s/%s.err" % (BASE, user, id, problem) exeCmd = ExecuteCommand(exeFile, testInput, Output, Error, lang, problem) (out, ret) = Execute(exeCmd) executionSuccess = False status = ParseZSimpleOutput(Error) # print id, status if ret != None: print "Error executing %s" % id if status['return'] == "tle": U(user,int(problem),"TLE") else: U(user,int(problem),"XE") #update db about error # Updating, -- Vimal stat = '' if status['return'] == 'tle': stat = 'TLE' else: stat = 'XE' # Dont set any error/score information db.set_status(id, stat) return if "return" in status: if status['return'] == 'ok': # update db about time executionSuccess = True # Update DB -- Vimal time = status['time'] db.update_time(id, time) else: # update in db about error U(user,int(problem),"XE ") print status['return'] else: # internal error, put blame on user # update db about error U(user,int(problem),"IE ") print "Internal error %s" % id # Update DB -- Vimal db.set_status(id, 'IE') #db.revert_last_submit(id) return if not executionSuccess: print "Error executing %s" % id U(user,int(problem),"XE ") #update db about error # Update DB -- Vimal db.set_status(id, 'XE') return # Check out with answer correctOutput = "%s/problems/%s/OUT" % (BASE, problem) if problem !=7: checkCmd = "diff -w -bB %s %s 1>/dev/null 2>&1" % (Output, correctOutput) (out, ret) = Execute(checkCmd) if ret == None: # accepted # update db print "Accepted %s" % id # Update DB -- Vimal # AC points = db.get_problem_points(problem) db.set_status(id, 'AC', points) db.update_score(problem, id, points) # update the score, in the logs U(user,int(problem),"AC ") else: # wrong answer # update db print "Wrong answer %s" % id # Update DB -- Vimal # WA db.set_status(id, 'WA') U(user,int(problem),"WA ") else: ######################################## # This section is for the NP-Complete contest # # WE NEED TO GET THIS DONE :) # ######################################## # Do we need the correct output for this problem? -- No! checkCmd = "%s/problems/%s/checker %s %s"\ % (BASE, problem, correctOutput, Output) (out, ret) = Execute(checkCmd) if ret == None: out = string.strip(out) # out is score # update db # update-score iff the previous score < current-score # but increase the number of submissions anyway if out == "WA": # Put Wrong Answer print "Wrong answer %s" % id # Update DB -- Vimal # WA db.set_status(id, 'WA') U(user,int(problem),"WA ") else: points = db.get_problem_points(problem) db.set_status(id, 'AC', points) db.update_score(problem, id, points) # update the score, in the logs U(user,int(problem),"AC ") else: #internal error #update db print "Internal Error %s" % id U(user,int(problem),"IE ") # Update DB -- Vimal db.set_status(id, 'IE')