Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
if node.test.func.attr == "value":
|
| 32 |
button_used = True
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
|
|
|
| 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).")
|