mirror of
https://github.com/JonasunderscoreJones/epr_grader.git
synced 2025-10-24 08:59:17 +02:00
Bugfix with folders without python file and lower deduction for module and class docstrings
This commit is contained in:
parent
27a13dacf2
commit
995a0586be
2 changed files with 9 additions and 3 deletions
|
|
@ -290,7 +290,8 @@ def begin_grading(folder: pathlib.Path, ratings_file: pathlib.Path, check_style:
|
|||
if len(violations_checkers) != 0:
|
||||
student_name = f.name.split('_')[0]
|
||||
file_path = os.path.join(f, target_name)
|
||||
update_style_deduction(file_path, violations_checkers[student_name], student_name)
|
||||
if student_name in violations_checkers:
|
||||
update_style_deduction(file_path, violations_checkers[student_name], student_name)
|
||||
print(f'({count}/{len(target_folders)}) Copy in {f.name}')
|
||||
print("Done!")
|
||||
|
||||
|
|
|
|||
|
|
@ -21,8 +21,10 @@ class ViolationChecker:
|
|||
__violations = None
|
||||
_style_check = ''
|
||||
__deduction = None
|
||||
__module_and_class_docstrings = None
|
||||
|
||||
def __init__(self, style_check: str, no_deduction: bool):
|
||||
self.__module_and_class_docstrings = 0
|
||||
self._style_check = style_check
|
||||
self.__deduction = no_deduction
|
||||
self.__violations = {'W0104': [0, 'Pointless statement', 0],
|
||||
|
|
@ -86,6 +88,8 @@ class ViolationChecker:
|
|||
"""Method to search for all violations"""
|
||||
for violation_name, _ in self.__violations.items():
|
||||
all_violations = re.findall(rf',*{violation_name}.*', self._style_check)
|
||||
if violation_name == 'C0114' or violation_name == 'C0115':
|
||||
self.__module_and_class_docstrings += len(all_violations)
|
||||
self.__violations[violation_name][0] = len(all_violations)
|
||||
|
||||
def list_violation(self):
|
||||
|
|
@ -123,7 +127,7 @@ class ViolationChecker:
|
|||
all_violations += value[0]
|
||||
else:
|
||||
for _, value in self.__violations.items():
|
||||
if value[2] == violation_group:
|
||||
if value[2] == violation_group or (value[2] == 10 and violation_group == 5):
|
||||
all_violations += value[0]
|
||||
return all_violations
|
||||
|
||||
|
|
@ -143,7 +147,8 @@ class ViolationChecker:
|
|||
return 0
|
||||
elif violation_group == 5:
|
||||
# Violation for docstrings with a max deduction
|
||||
return min(violation_amount*0.5, 2)
|
||||
# Module and class docstring gets the half amount of deduction
|
||||
return min(violation_amount*0.5 - self.__module_and_class_docstrings*0.25, 2)
|
||||
else:
|
||||
if violation_amount > 9:
|
||||
return 0.5
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue