-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgradeCalc.py
87 lines (72 loc) · 3.82 KB
/
gradeCalc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# Author: Cameron Kerley
# Date: 04/27/22
# Purpose: Calculate the final grade for a student
# Inputs: Number of tests taken, number of tests total, score in percent for test
# constants: TEST_POINT_WEIGHT, CLASS_WORK_WEIGHT, CHECKS_AND_SETS_WEIGHT,
# weight being % of final grade for work type
# Outputs: Final grade for student and the total points for each type of work
from calcLib import stringHandler, calcModule
CLASS_WORK_WEIGHT = 25.0
TEST_POINT_WEIGHT = 15.00
CHECKS_AND_SETS_WEIGHT = 15.0
def main(debug=None)->str:
# list of prompts for user input
dataToEnter = stringHandler.promptStrBuilder()
dataRecived = stringHandler.promptFunctions(dataToEnter, [])
# do not use last prompt in dataToEnter list
# unpack list
testsTotal, testTaken = dataRecived
# calculate weight factor or total points for class currently,
# scales from 0 to 100 based on weight val, ie 3/4 = 100% of class total calculated
maxScoreTotal = (TEST_POINT_WEIGHT * (testTaken + 1))
factor = (CHECKS_AND_SETS_WEIGHT + CLASS_WORK_WEIGHT) + maxScoreTotal
# print(factor)
#
# calculate the weight factors for each assignment type
EXAM_WEIGHT_FACTOR = TEST_POINT_WEIGHT / factor
CLASS_WORK_FACTOR = CLASS_WORK_WEIGHT / factor
CHECKS_AND_SETS_FACTOR = CHECKS_AND_SETS_WEIGHT / factor
# print(f'recived:- {testTaken}/{testsTotal} tests taken.')
completedTestScores, newTestPointTot = calcModule.getTestScores(testsTotal, testTaken, EXAM_WEIGHT_FACTOR, TEST_POINT_WEIGHT)
x1 = sum(completedTestScores) + newTestPointTot
x2 = calcModule.WeightCalc(CLASS_WORK_FACTOR, float(input(f'Enter % for class work: ')))
x3 = calcModule.WeightCalc(CHECKS_AND_SETS_FACTOR, float(input(f'Enter % for checks & set\'s work: ')))
f = round(x1 + x2 + x3,2)
calcArr = [f'current grade is:--- {f}%,',
f'test point total is:--- {x1}/{maxScoreTotal},',
f'class work total is:--- {x2}/{CLASS_WORK_WEIGHT},',
f'checks & sets total is:--- {x3}/{CHECKS_AND_SETS_WEIGHT},']
calcStr = '\n'.join(calcArr)
# return as string for printing purposes, perserves cmd line
# functionality of this and other files, not used in main
return calcStr
def uiVersion(gradeLst=list)->str:
dataRecived = gradeLst[0]
testsTotal, testTaken = dataRecived
maxScoreTotal = (TEST_POINT_WEIGHT * (testTaken + 1))
factor = (CHECKS_AND_SETS_WEIGHT + CLASS_WORK_WEIGHT) + maxScoreTotal
EXAM_WEIGHT_FACTOR = TEST_POINT_WEIGHT / factor
CLASS_WORK_FACTOR = CLASS_WORK_WEIGHT / factor
CHECKS_AND_SETS_FACTOR = CHECKS_AND_SETS_WEIGHT / factor
completedTestScores, newTestPointTot = gradeLst[1]
debugResult = []
for i in range(len(completedTestScores)):
score = calcModule.WeightCalc(EXAM_WEIGHT_FACTOR, completedTestScores[i])
debugResult.append(score)
newTestPointTot = calcModule.WeightCalc(EXAM_WEIGHT_FACTOR,newTestPointTot)
x1 = sum(debugResult) + newTestPointTot
x2 = calcModule.WeightCalc(CLASS_WORK_FACTOR, float(gradeLst[2]))
x3 = calcModule.WeightCalc(CHECKS_AND_SETS_FACTOR, float(gradeLst[3]))
f = round(x1 + x2 + x3,2)
calcArr = [f'current grade is:--- {f}%,',
f'test point total is:--- {x1} / {maxScoreTotal},',
f'class work total is:--- {x2} / {CLASS_WORK_WEIGHT},',
f'checks & sets total is:--- {x3} / {CHECKS_AND_SETS_WEIGHT},']
calcStr = '\n'.join(calcArr)
# return as string for printing purposes, perserves cmd line
# functionality of this and other files, not used in main
return calcStr
# if not imported as a module call the data prompt function & execute without saving to file
if __name__ == '__main__':
studentGrades = main()
print(studentGrades)