UCL-INGI / LEPL1402

INGInious tasks for LEPL1402 at EPL ( UCLouvain )
4 stars 5 forks source link

Integrate plagiarism tool : JPlag #1

Closed jy95 closed 5 years ago

jy95 commented 5 years ago

Here is what you will need to do to integrate the plagiarism tool JPlag into our generic run script :

1) Creates a new function inside helper.py :

# Find all java files
def find_files_in_path(path):
    base_folder = Path(path)
    files = Path(path).rglob("*{}".format(FILE_EXTENSION)) if base_folder.exists() else []
    return { 
        relative_path(file)
        for file in files
    }

2) Modify these two lines of method run_command :

def run_command(cmd, cwd=None):
    proc = subprocess.Popen(cmd, cwd=cwd ,shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE)

To :

def run_command(cmd, cwd=None, universal_newlines=None):
    proc = subprocess.Popen(cmd, cwd=cwd ,shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE, universal_newlines=universal_newlines)

3) Add these lines of code at the end of runfile.py (after "Show and handle results") :

# Don't forget to add this import statment at the top of the file : 
#           from inginious import input
student_name = input.get_input("@username")

# The files filled by the student are all inside PATH_TEMPLATES
files_to_be_tested = helper.find_files_in_path(PATH_TEMPLATES)

# Creates the archive like expected by JPlag 
for student_file in files_to_be_tested:
   command = "archive -a {} -o {}".format(student_file, student_name)
   helper.run_command(command, universal_newlines=True)

Documentation :

Inginious - archive Inginious - JPlag