File size: 959 Bytes
7989b0a
 
 
 
 
 
f5c9fb8
7989b0a
 
 
f5c9fb8
7989b0a
 
 
f5c9fb8
 
 
 
 
7989b0a
 
f5c9fb8
7989b0a
 
f5c9fb8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import streamlit as st
from components.feedback import get_ai_feedback

def show_coding_challenges():
    st.title("Solve Coding Challenges")

    # Display the coding challenge problem
    problem = "Implement a linear regression model from scratch."
    st.write(f"Problem: {problem}")

    # Input area for user to write the solution
    user_code = st.text_area("Write your solution here:", height=300)

    if st.button("Submit Solution"):
        # Simple validation of the code structure (replace with more advanced logic if needed)
        if "def" in user_code and "return" in user_code:
            st.success("Great! Your code structure seems correct.")
        else:
            st.error("It looks like there's an issue with your code. Make sure to define a function and return a result.")

    if st.button("Get AI Feedback"):
        # Get AI feedback on the user's code
        feedback = get_ai_feedback(user_code)
        st.write(feedback)