From 90f54026df490bb1ed40112a476e8fc0c0aa5d1a Mon Sep 17 00:00:00 2001
From: Joshua Randall <jranda10@emich.edu>
Date: Thu, 10 Oct 2024 16:22:42 -0400
Subject: [PATCH] converted the program to 2d arrays

---
 main.py | 85 +++++++++++++++++++++++++++++++++++++++++----------------
 1 file changed, 62 insertions(+), 23 deletions(-)

diff --git a/main.py b/main.py
index 58bfad1..edd7b0d 100644
--- a/main.py
+++ b/main.py
@@ -33,7 +33,12 @@ title = "Name of Assignment"
 
 # 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
 
@@ -158,40 +163,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("Run 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")
@@ -205,11 +244,11 @@ def adjustScore():
         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()
@@ -218,9 +257,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():
-- 
GitLab