Spaces:
Sleeping
Sleeping
File size: 4,820 Bytes
53f9c43 8db2db5 53f9c43 2b130d1 53f9c43 2b130d1 |
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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
import streamlit as st
from settings import TECHNOLOGIES_LIST
class Layout:
@staticmethod
def render_header():
"""
Renders the header of the application with a logo and title.
"""
st.markdown(
"""
<style>
.header {
text-align: center;
font-size: 28px; /* Reduced size */
font-weight: 600; /* Slightly lighter font weight */
color: #034732; /* Darker green for a more professional look */
margin-top: 15px;
margin-bottom: 5px;
}
.sub-header {
text-align: center;
font-size: 14px; /* Subtle and smaller font */
color: #5E6472; /* Muted grayish-blue for contrast */
margin-bottom: 20px;
}
.logo {
display: block;
margin: 0 auto;
max-width: 60px; /* Smaller logo size */
height: auto;
margin-bottom: 10px;
filter: drop-shadow(0px 4px 4px rgba(0, 0, 0, 0.25)); /* Added subtle shadow */
}
.divider {
height: 1px;
margin: 20px 0;
background-color: #D0D0D0; /* Light gray for a clean divider */
border: none;
}
</style>
<div>
<img src="https://framerusercontent.com/images/QNgS2NOAyBozR6eFdgzSFhJRbY.png?scale-down-to=512" class="logo" />
<div class="header">NonStop Assessments</div>
<div class="sub-header">Empowering talent, one question at a time.</div>
<hr class="divider">
</div>
""",
unsafe_allow_html=True
)
@staticmethod
def render_signup_form():
"""
Renders the signup form for candidate details.
:return: Tuple containing name, email, experience, and selected technology.
"""
with st.form("signup_form"):
st.header("Sign Up")
name = st.text_input("Full Name", help="Please enter your full name")
email = st.text_input("Email", help="Please enter your email")
experience = st.slider("Total Years of Experience", 0, 20, 0, help="Select your years of experience")
technology = st.selectbox("Technology", TECHNOLOGIES_LIST, help="Select your primary technology")
submit = st.form_submit_button("Start Test")
if submit:
if not name or not email:
st.error("Name and Email are required! Please fill both fields.")
return None, None, None, None, None
return name, email, experience, technology, submit
return None, None, None, None, None
@staticmethod
def render_instructions():
"""
Renders test instructions for the candidates.
"""
st.header("Instructions")
st.info(
"""
1. Each question is multiple-choice.
"""
)
@staticmethod
def render_progress_bar(current, total):
"""
Renders a progress bar for the test.
:param current: Current progress (integer).
:param total: Total progress (integer).
"""
st.progress(current / total)
@staticmethod
def render_test_question(question, idx):
"""
Renders a single test question with multiple-choice options.
:param question: Dictionary containing question details.
:param idx: Index of the question for unique Streamlit keys.
:return: Selected option from the user.
"""
st.markdown(f"""
<div class="question-card">
<b>Question {idx + 1}:</b> {question['question']}
</div>
""",
unsafe_allow_html=True,
)
selected_option = st.radio(
"",
[question['option1'], question['option2'], question['option3'], question['option4']],
key=f"q{idx}",
label_visibility="collapsed",
help="Choose the correct answer",
index=None
)
st.markdown("---")
return selected_option
@staticmethod
def render_completion_message(score, total):
"""
Displays a completion message after the test is submitted.
:param score: Total score obtained by the candidate.
:param total: Total questions in the test.
"""
st.success("Test completed successfully! Great job on completing it. Thank you for your effort and dedication.")
|