Example #1
0
def send_to_celery(memberIdIndex, problemIndex, submissionIndex,
                   usedLanguageName, usedLanguageVersion,
                   sumOfSubmittedFileSize, problemName, filePath, tempPath):
    if usedLanguageName == OtherResources().const.PYTHON:
        usedLanguageIndex = get_used_language_index(usedLanguageName,
                                                    usedLanguageVersion)
    else:
        usedLanguageIndex = get_used_language_index(usedLanguageName)
    submissionCount, solutionCheckCount = get_submission_info(
        memberIdIndex, problemIndex)
    insert_to_submissions(submissionIndex, submissionCount, solutionCheckCount,
                          usedLanguageIndex, sumOfSubmittedFileSize)
    problemPath, limitedTime, limitedMemory, solutionCheckType, numberOfTestCase = get_problem_info(
        problemIndex, problemName)

    if numberOfTestCase >= 2:
        numberOfTestCase -= 1

    Grade.delay(submissionIndex, submissionCount, int(problemIndex),
                str(filePath), str(problemPath), str(solutionCheckType),
                numberOfTestCase, limitedTime, limitedMemory,
                str(usedLanguageName), str(usedLanguageVersion),
                str(problemName))

    dao.commit()

    flash(LanguageResources().const.SubmissionSuccess[session[
        OtherResources().const.LANGUAGE]])
    os.system(OtherResources().const.DELETE_COMMAND % filePath)
    os.rename(tempPath, filePath)
def send_to_celery(memberId, courseId, problemId, usedLanguageName, sumOfSubmittedFileSize, problemName, filePath, tempPath):
    usedLanguageIndex = get_used_language_index(usedLanguageName)
    usedLanguageVersion = get_used_language_version(courseId, usedLanguageIndex)
    submissionCount, solutionCheckCount, viewCount = get_submission_info(memberId, courseId, problemId)
    insert_to_submissions(courseId, memberId, problemId, submissionCount, solutionCheckCount, viewCount, usedLanguageIndex, sumOfSubmittedFileSize)
    problemPath, limitedTime, limitedMemory, solutionCheckType, isAllInputCaseInOneFile, numberOfTestCase, problemCasesPath = get_problem_info(problemId, problemName)
    problemFullName = make_problem_full_name(problemId, problemName)
            
    Grade.delay(str(filePath),
                str(problemPath),
                str(memberId),
                str(problemId),
                str(solutionCheckType),
                numberOfTestCase,
                limitedTime,
                limitedMemory,
                str(usedLanguageName),
                str(usedLanguageVersion),
                str(courseId),
                submissionCount,
                str(problemFullName))

    dao.commit()
    
    flash(OtherResources.const.SUBMISSION_SUCCESS)
    os.system("rm -rf %s" % filePath)
    os.rename(tempPath, filePath)
def send_to_celery(memberIdIndex, problemIndex, submissionIndex, usedLanguageName, usedLanguageVersion, sumOfSubmittedFileSize, problemName, filePath, tempPath):
    if usedLanguageName == OtherResources().const.PYTHON:
        usedLanguageIndex = get_used_language_index(usedLanguageName, usedLanguageVersion)
    else:
        usedLanguageIndex = get_used_language_index(usedLanguageName)
    submissionCount, solutionCheckCount = get_submission_info(memberIdIndex, problemIndex)
    insert_to_submissions(submissionIndex, submissionCount, solutionCheckCount, usedLanguageIndex, sumOfSubmittedFileSize)
    problemPath, limitedTime, limitedMemory, solutionCheckType, numberOfTestCase = get_problem_info(problemIndex, problemName)
    
    if numberOfTestCase >= 2:
        numberOfTestCase -= 1
            
    Grade.delay(submissionIndex,
                submissionCount,
                int(problemIndex),
                str(filePath),
                str(problemPath),
                str(solutionCheckType),
                numberOfTestCase,
                limitedTime,
                limitedMemory,
                str(usedLanguageName),
                str(usedLanguageVersion),
                str(problemName))
    
    dao.commit()
    
    flash(LanguageResources().const.SubmissionSuccess[session[OtherResources().const.LANGUAGE]])
    os.system(OtherResources().const.DELETE_COMMAND % filePath)
    os.rename(tempPath, filePath)