diff --git a/main.py b/main.py index df7cb0980f27ae956e22c5c5a510ce29a78a99fe..bc62e72478276cccc18330572026aa75ed56a563 100644 --- a/main.py +++ b/main.py @@ -2,10 +2,10 @@ from pyfiglet import Figlet from os import system from colored import Fore, Style #Documentation: https://dslackw.gitlab.io/colored/user_guide/user_guide/#user-guide from time import sleep -from dotenv import load_dotenv + import os -load_dotenv("./.env") + """ These are global variables, some can be changed. """ @@ -43,11 +43,16 @@ defaults = os.getenv("POINTS_FOR_RUNS", default=[10,20,0]) # Default points stored for each run. Each list entry is a run. A default run score of 0 allows extra credit. -# defaults = [10,15,20,0] +defaultLabels = ["Name", "Steps", "Extra Credit"] + +defaults = [ + [10], + [15,20], + [0]] # Late penalty if submission is late. 0 for no penalty -# latePenalty = scoreDefault * 0.1 # 10% of score default +latePenalty = 8 # 10% of score default """ ! NON CHANGEABLE @@ -151,7 +156,7 @@ def adjustLate(): global late global score global latePenalty - onTime = validateInput(input("Did the student turn in the assignment within 48 hours? [Y/n]: ")) + onTime = validateInput(input("Did the student turn in the assignment within 5 days? [Y/n]: ")) if onTime: points = latePenalty else: @@ -168,40 +173,74 @@ def boolResult(boolean): -def assignScore(default, points): +def assignScore(default, points, arrayPos): global score global pointsForRun - pointsForRun.append(points) + if len(pointsForRun) < (arrayPos + 1): + pointsForRun.append([]) + pointsForRun[arrayPos].append(points) invertPoints = default - points score = score - invertPoints def runScore(): - run = 1 - while(run <= len(defaults)): - # Insert default point conditions here - default = defaults[run - 1] - - points = input("Run " + str(run) + ": How many points should be assigned? [Default " + str(default) + "]: ") - if points == "": - points = default - else: - points = int(points) - assignScore(default, points) - run = run + 1 + catRun = 0 #category/default labels run + while(catRun < len(defaultLabels)): + run = 1 + while(run <= len(defaults[catRun])): + # Insert default point conditions here + default = defaults[catRun][run - 1] + + points = input(defaultLabels[catRun] + " " + str(run) + ": How many points should be assigned? [Default " + str(default) + "]: ") + if points == "": + points = default + else: + points = int(points) + assignScore(default, points, catRun) + run = run + 1 + catRun = catRun + 1 def printRuns(): global pointsForRun - count = 1 - for point in pointsForRun: - print("Run " + str(count) + ": " + f'{Fore.yellow}' + str(point) + f'{Style.reset}') - count = count + 1 + index = 0 + for i in defaultLabels: + print(i) + print("====================") + count = 1 + for point in pointsForRun[index]: + print("Run " + str(count) + ": " + f'{Fore.yellow}' + str(point) + f'{Style.reset}') + count = count + 1 + index = index + 1 + print() def adjustScore(): global score global pointsForRun global defaults + # Print out each category of run + count = 1 + print() + for i in defaultLabels: + print("[" + str(count) + "]: " + i) + count = count + 1 + print() + + # Get input + arrayPos = input("Which category of runs?: ") + if arrayPos == "": + print("Please enter an actual number") + sleep(1) + return + else: + arrayPos = int(arrayPos) + if arrayPos < 1 or arrayPos > len(defaultLabels): + print("Category out of range") + sleep(1) + return + + arrayPos = int(arrayPos) - 1 + run = input("Adjust score for which run?: ") if run == "": print("Please enter an actual number") @@ -209,17 +248,17 @@ def adjustScore(): return else: run = int(run) - if run < 1 or run > len(defaults): + if run < 1 or run > len(defaults[arrayPos]): print("Run out of range") sleep(1) return index = run - 1 print() - print("Run " + str(run) + ": " + f'{Fore.yellow}' + str(pointsForRun[index]) + f'{Style.reset}') + print("Run " + str(run) + ": " + f'{Fore.yellow}' + str(pointsForRun[arrayPos][index]) + f'{Style.reset}') # Insert default point conditions here - default = defaults[index] + default = defaults[arrayPos][index] print("Default: " + str(default)) print() @@ -228,9 +267,9 @@ def adjustScore(): newScore = default else: newScore = int(newScore) - oldScore = pointsForRun[index] + oldScore = pointsForRun[arrayPos][index] score = score - (oldScore - newScore) - pointsForRun[index] = newScore + pointsForRun[arrayPos][index] = newScore # Main function def main(): @@ -247,7 +286,7 @@ def main(): print(titleText.renderText(title)) print() name = input("Student name?: ") - late = not validateInput(input("Did the student turn in the assignment within 48 hours? [Y/n]: ")) + late = not validateInput(input("Did the student turn in the assignment within 5 days? [Y/n]: ")) if(late): score = score - latePenalty @@ -281,5 +320,15 @@ def main(): pointsForRun = [] late = False +def dimensionCheck(): + global defaults + global defaultLabels + if (len(defaults) == len(defaultLabels)): + return True + else: + return False; -main() +if(dimensionCheck()): + main() +else: + print("Dimensions for default and defaultLabels do not match. Please correct it before running the script again.") \ No newline at end of file