Skip to content

Commit 0777e25

Browse files
[Feature:Plagiarism] Add support for common/provided code (#31)
* Refactor: fix warnings in C++, make code more readable * Merge adjacent regions * Add Python Linting * attempt to fix path issue * Update pylint.yml * Update pylint.yml * Fix most linter issues * Nightly progress * Reimplement algorithm * Implement save matches * Fix bugs * Add rankings * Minor changes * Final touches * Add "common code" functionality * Create .flake8 * Ignore all existing Python files for now * More fixes * Finish linting of existing files * Fix one more issue * Debug output files * Fix merging * Fix bugs in writing the files * Initial draft for individual student ranking * Fix compiler errors * Update ranking directory structure * Minor fix to the directory path * Another minor fix * Fix merging code * Initial Draft * Fix compiler errors * Fix percentages? * Add concatenation for provided code * Change percentage calculations * Fix a few last things with provided code support Co-authored-by: sbelsk <[email protected]>
1 parent edb2ef1 commit 0777e25

File tree

2 files changed

+147
-113
lines changed

2 files changed

+147
-113
lines changed

bin/concatenate_all.py

+21
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,32 @@ def main():
9797
# Remove concat file if there no content...
9898
if total_concat == 0:
9999
os.remove(my_concatenated_file)
100+
# FIXME: is this the correct path?
100101
p2 = os.path.join(course_dir, "lichen", "tokenized", gradeable, user, version)
101102
if os.path.isdir(p2):
102103
shutil.rmtree(p2)
103104
os.rmdir(my_concatenated_dir)
104105

106+
# =========================================================================
107+
# concatenate any files in the provided_code directory
108+
provided_code_path = os.path.join(course_dir, "lichen", "provided_code", gradeable)
109+
output_dir = os.path.join(course_dir, "lichen", "concatenated",
110+
gradeable, "provided_code", "provided_code")
111+
output_file = os.path.join(output_dir, "submission.concatenated")
112+
113+
if os.path.isdir(provided_code_path) and len(os.listdir(provided_code_path)) != 0:
114+
# If the directory already exists, delete it and make a new one
115+
if os.path.isdir(output_dir):
116+
shutil.rmtree(output_dir)
117+
os.makedirs(output_dir)
118+
119+
with open(output_file, 'w') as of:
120+
# Loop over all of the provided files and concatenate them
121+
for file in sorted(os.listdir(provided_code_path)):
122+
with open(os.path.join(provided_code_path, file), encoding='ISO-8859-1') as tmp:
123+
# append the contents of the file
124+
of.write(tmp.read())
125+
105126
print("done")
106127

107128

0 commit comments

Comments
 (0)