Spaces:
Sleeping
Sleeping
burtenshaw
commited on
Commit
·
95114d7
1
Parent(s):
e4143a6
add question level feedback
Browse files
app.py
CHANGED
|
@@ -61,16 +61,20 @@ def check_code(user_code, solution, challenge):
|
|
| 61 |
# Extract the verdict from the response
|
| 62 |
is_correct = response.upper().startswith("CORRECT")
|
| 63 |
|
| 64 |
-
# Add the explanation to the status text
|
| 65 |
explanation = response.split("\n", 1)[1] if "\n" in response else ""
|
| 66 |
-
|
|
|
|
| 67 |
|
| 68 |
return is_correct
|
| 69 |
|
| 70 |
except Exception as e:
|
| 71 |
gr.Warning(f"Error checking code: {str(e)}")
|
| 72 |
# Fall back to simple string comparison if LLM fails
|
| 73 |
-
|
|
|
|
|
|
|
|
|
|
| 74 |
|
| 75 |
|
| 76 |
def on_user_logged_in(token: gr.OAuthToken | None):
|
|
|
|
| 61 |
# Extract the verdict from the response
|
| 62 |
is_correct = response.upper().startswith("CORRECT")
|
| 63 |
|
| 64 |
+
# Add the explanation to the status text with emoji
|
| 65 |
explanation = response.split("\n", 1)[1] if "\n" in response else ""
|
| 66 |
+
status = "✅ Correct!" if is_correct else "❌ Incorrect!"
|
| 67 |
+
gr.Info(f"{status}\n\n{explanation}")
|
| 68 |
|
| 69 |
return is_correct
|
| 70 |
|
| 71 |
except Exception as e:
|
| 72 |
gr.Warning(f"Error checking code: {str(e)}")
|
| 73 |
# Fall back to simple string comparison if LLM fails
|
| 74 |
+
is_correct = user_code.strip() == solution.strip()
|
| 75 |
+
status = "✅ Correct!" if is_correct else "❌ Incorrect!"
|
| 76 |
+
gr.Info(f"{status} (Fallback comparison)")
|
| 77 |
+
return is_correct
|
| 78 |
|
| 79 |
|
| 80 |
def on_user_logged_in(token: gr.OAuthToken | None):
|