requisite_processor 0.2.6__tar.gz → 0.2.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {requisite_processor-0.2.6 → requisite_processor-0.2.7}/PKG-INFO +3 -2
- {requisite_processor-0.2.6 → requisite_processor-0.2.7}/pyproject.toml +1 -1
- {requisite_processor-0.2.6 → requisite_processor-0.2.7}/requisite_processor/requisite_processor.py +36 -12
- {requisite_processor-0.2.6 → requisite_processor-0.2.7}/README.md +0 -0
- {requisite_processor-0.2.6 → requisite_processor-0.2.7}/requisite_processor/__init__.py +0 -0
- {requisite_processor-0.2.6 → requisite_processor-0.2.7}/requisite_processor/requisite_check.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: requisite_processor
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.7
|
|
4
4
|
Summary: Module for working with course requisite data and checking requisite satisfaciton.
|
|
5
5
|
Author: Michael Hickman
|
|
6
6
|
Author-email: mhickman@unm.edu
|
|
@@ -10,6 +10,7 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
10
10
|
Classifier: Programming Language :: Python :: 3.11
|
|
11
11
|
Classifier: Programming Language :: Python :: 3.12
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.13
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
13
14
|
Description-Content-Type: text/markdown
|
|
14
15
|
|
|
15
16
|
# Requisite Processor
|
{requisite_processor-0.2.6 → requisite_processor-0.2.7}/requisite_processor/requisite_processor.py
RENAMED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import re
|
|
2
|
-
from typing import List
|
|
2
|
+
from typing import List, Union
|
|
3
3
|
from requisite_processor.requisite_check import RequisiteCheckResult
|
|
4
4
|
|
|
5
|
+
def somefunc(a):
|
|
6
|
+
return a
|
|
7
|
+
|
|
5
8
|
class RequisiteProcessor:
|
|
6
|
-
def __init__(self, prerequisites: dict):
|
|
9
|
+
def __init__(self, prerequisites: dict, course_equivalents: Union[dict, None] = None):
|
|
7
10
|
self.prerequisite_rules = prerequisites
|
|
11
|
+
self.course_equivalents = course_equivalents
|
|
8
12
|
|
|
9
13
|
@property
|
|
10
14
|
def availabile_academic_periods(self) -> list[str]:
|
|
@@ -31,7 +35,7 @@ class RequisiteProcessor:
|
|
|
31
35
|
def check_satisfaction(
|
|
32
36
|
self,
|
|
33
37
|
course_code: str,
|
|
34
|
-
courses_taken: list[dict] = None,
|
|
38
|
+
courses_taken: Union[list[dict], None] = None,
|
|
35
39
|
test_scores = None,
|
|
36
40
|
academic_period = None,
|
|
37
41
|
ignore_tests = False,
|
|
@@ -69,6 +73,12 @@ class RequisiteProcessor:
|
|
|
69
73
|
if courses_taken is None:
|
|
70
74
|
courses_taken = []
|
|
71
75
|
|
|
76
|
+
if self.course_equivalents is not None:
|
|
77
|
+
for ct in courses_taken:
|
|
78
|
+
if ct['code'] in self.course_equivalents:
|
|
79
|
+
ct['code'] = self.course_equivalents[ct['code']]['code']
|
|
80
|
+
|
|
81
|
+
|
|
72
82
|
if academic_period is None:
|
|
73
83
|
academic_period = self.latest_available_academic_period
|
|
74
84
|
|
|
@@ -89,7 +99,7 @@ class RequisiteProcessor:
|
|
|
89
99
|
return self.__traverse_prereqs(prereq_rule, academic_period, courses_taken, test_scores, ignore_grades)
|
|
90
100
|
|
|
91
101
|
|
|
92
|
-
def fast_check(self, course_code: str, courses_taken = None, academic_period = None) -> bool:
|
|
102
|
+
def fast_check(self, course_code: str, courses_taken = None, test_scores = None, academic_period = None) -> bool:
|
|
93
103
|
if academic_period is None:
|
|
94
104
|
academic_period = self.latest_available_academic_period
|
|
95
105
|
|
|
@@ -107,7 +117,10 @@ class RequisiteProcessor:
|
|
|
107
117
|
if courses_taken is None:
|
|
108
118
|
courses_taken = []
|
|
109
119
|
|
|
110
|
-
|
|
120
|
+
if test_scores is None:
|
|
121
|
+
test_scores = {}
|
|
122
|
+
|
|
123
|
+
return self.__fast_check(prereq_rule, courses_taken, test_scores)
|
|
111
124
|
|
|
112
125
|
|
|
113
126
|
|
|
@@ -127,9 +140,13 @@ class RequisiteProcessor:
|
|
|
127
140
|
|
|
128
141
|
def __traverse_prereqs(self, prereq_data: dict, academic_period, courses_taken, test_scores, ignore_grades):
|
|
129
142
|
if prereq_data['type'] == 'course':
|
|
143
|
+
prereq_code = prereq_data['course']['code']
|
|
144
|
+
if self.course_equivalents is not None and prereq_code in self.course_equivalents:
|
|
145
|
+
prereq_code = self.course_equivalents[prereq_code]['code']
|
|
146
|
+
|
|
130
147
|
selected_course = None
|
|
131
148
|
for course in courses_taken:
|
|
132
|
-
if course['code'] ==
|
|
149
|
+
if course['code'] == prereq_code and (ignore_grades is True or self.__grade_score(course['grade']) >= self.__grade_score(prereq_data['minimum_course_grade'])):
|
|
133
150
|
selected_course = course
|
|
134
151
|
break
|
|
135
152
|
|
|
@@ -180,8 +197,9 @@ class RequisiteProcessor:
|
|
|
180
197
|
prereq_operands = []
|
|
181
198
|
|
|
182
199
|
for sub_prereq_data in prereq_data['operands']:
|
|
183
|
-
|
|
184
|
-
|
|
200
|
+
# TODO : Consider how to handle concurrency
|
|
201
|
+
# if sub_prereq_data['type'] == 'course' and sub_prereq_data['concurrency_ind'] is True:
|
|
202
|
+
# continue
|
|
185
203
|
|
|
186
204
|
prereq_operands.append(sub_prereq_data)
|
|
187
205
|
|
|
@@ -210,10 +228,16 @@ class RequisiteProcessor:
|
|
|
210
228
|
return result
|
|
211
229
|
|
|
212
230
|
|
|
213
|
-
def __fast_check(self, prereq_data: dict, courses_taken: List[str]) -> bool:
|
|
231
|
+
def __fast_check(self, prereq_data: dict, courses_taken: List[str], test_scores: dict) -> bool:
|
|
214
232
|
if prereq_data['type'] == 'placement_test':
|
|
215
|
-
|
|
233
|
+
test_code = prereq_data['placement_test']['test_code']
|
|
234
|
+
if test_code not in test_scores:
|
|
235
|
+
return False
|
|
216
236
|
|
|
237
|
+
if test_scores[test_code] >= prereq_data['minimum_test_score']:
|
|
238
|
+
return True
|
|
239
|
+
else:
|
|
240
|
+
return False
|
|
217
241
|
|
|
218
242
|
if prereq_data['type'] == 'course':
|
|
219
243
|
for course in courses_taken:
|
|
@@ -225,7 +249,7 @@ class RequisiteProcessor:
|
|
|
225
249
|
|
|
226
250
|
if prereq_data['type'] == 'and':
|
|
227
251
|
for sub_prereq_data in prereq_data['operands']:
|
|
228
|
-
if self.__fast_check(sub_prereq_data, courses_taken) is False:
|
|
252
|
+
if self.__fast_check(sub_prereq_data, courses_taken, test_scores) is False:
|
|
229
253
|
return False
|
|
230
254
|
|
|
231
255
|
return True
|
|
@@ -233,7 +257,7 @@ class RequisiteProcessor:
|
|
|
233
257
|
|
|
234
258
|
if prereq_data['type'] == 'or':
|
|
235
259
|
for sub_prereq_data in prereq_data['operands']:
|
|
236
|
-
if self.__fast_check(sub_prereq_data, courses_taken) is True:
|
|
260
|
+
if self.__fast_check(sub_prereq_data, courses_taken, test_scores) is True:
|
|
237
261
|
return True
|
|
238
262
|
|
|
239
263
|
return False
|
|
File without changes
|
|
File without changes
|
{requisite_processor-0.2.6 → requisite_processor-0.2.7}/requisite_processor/requisite_check.py
RENAMED
|
File without changes
|