Closed shiyingwucl closed 2 weeks ago
[0: Excellent, 1:Satisfactory, 2:Unsatisfactory, etc.]
Flip this.
0: Unsatisfactory, 1: Moderate, 2: Satisfactory, 3: Excellent.
I had a look at your progress on this and have an idea of how we can simplify the logic. Currently, you handle additional key presses inside of the method that processes the first key press. One of the reasons is because we want to dynamically create options, and then also know inside of the handler method which of the several options they selected.
We can, I think, make this cleaner by (1) setting options
inside of the handling function and (2) changing the signature of the key handler methods so we can pass the actual key pressed by the user. Here is a toy example:
class MyController:
def __init__(self):
self.options = None
self.step1_options = { "a": self.step2_a, "b": self.step2_b } # we can have same options used in different places
def step1(self, k=None): # Note new argument "k" to accept the pressed keystroke (if any - defaults to None)
print("Start")
self.options = self.step1_options
def step2_a(self, k=None):
print("You selected A. Select more...")
self.options = {
"0": self.step3,
"1": self.step3,
"2": self.step3
}
def step2_b(self, k=None):
print(f"You selected B. Back to start...")
self.options = self.step1_options
def step3(self, k=None):
print(f"You selected {k}. Back to start...")
self.options = self.step1_options
def run(self):
self.step1()
while True:
k = readkey()
if k == "?":
print(" ".join(self.options.keys()))
else:
output = self.options.get(k)
if output is not None:
output(k=k) # Here, we pass the keystroke to the key handler
Hope that makes sense...?
I got the general idea of this. This method replaces the current_view too so I can also get rid of the long elif statements blocks for options in run()
Edit: realised that I misunderstood this, I just need to break down edit_applicant_score into smaller parts
It's both. You can break existing function into little parts, and remove the long elif in run()
Definition of Done / Acceptance Criteria
From applicant screen, add shortcut key to switch to see all the criteria, and from there you can enter a number (0-9) to select the criteria:
[0: Cover letter, 1:Phd, 2:Work experience, etc.]
and again enter a number to select the grade:
[0: Excellent, 1:Satisfactory, 2:Unsatisfactory, etc.]