bgaultier commited on
Commit
f3f6557
·
verified ·
1 Parent(s): 99442c4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -6
app.py CHANGED
@@ -23,17 +23,22 @@ def grade(student_code):
23
  pin_num = str(args[0].value)
24
  if pin_num in pin_setup:
25
  pin_setup[pin_num] = True
26
- elif isinstance(node.value, ast.NameConstant) and isinstance(node.targets[0], ast.Name):
27
  bool_variable_used = True
28
 
29
  if isinstance(node, ast.If):
30
- if isinstance(node.test, ast.Call) and isinstance(node.test.func, ast.Attribute):
 
 
 
 
31
  if node.test.func.attr == "value":
32
  button_used = True
33
- for stmt in node.body:
34
- if isinstance(stmt, ast.Assign):
35
- if isinstance(stmt.value, ast.UnaryOp) and isinstance(stmt.value.op, ast.Not):
36
- led_toggle_detected = True
 
37
 
38
  if not all(pin_setup.values()):
39
  feedback.append("⛔️ Pins 22 (LED) and 15 (button) must be correctly set up (-3 pts).")
 
23
  pin_num = str(args[0].value)
24
  if pin_num in pin_setup:
25
  pin_setup[pin_num] = True
26
+ elif isinstance(node.value, (ast.NameConstant, ast.Constant)) and isinstance(node.targets[0], ast.Name):
27
  bool_variable_used = True
28
 
29
  if isinstance(node, ast.If):
30
+ if isinstance(node.test, ast.UnaryOp) and isinstance(node.test.op, ast.Not):
31
+ if isinstance(node.test.operand, ast.Call) and isinstance(node.test.operand.func, ast.Attribute):
32
+ if node.test.operand.func.attr == "value":
33
+ button_used = True
34
+ elif isinstance(node.test, ast.Call) and isinstance(node.test.func, ast.Attribute):
35
  if node.test.func.attr == "value":
36
  button_used = True
37
+
38
+ for stmt in node.body:
39
+ if isinstance(stmt, ast.Assign):
40
+ if isinstance(stmt.value, ast.UnaryOp) and isinstance(stmt.value.op, ast.Not):
41
+ led_toggle_detected = True
42
 
43
  if not all(pin_setup.values()):
44
  feedback.append("⛔️ Pins 22 (LED) and 15 (button) must be correctly set up (-3 pts).")