Spaces:
Sleeping
Sleeping
burtenshaw
commited on
Commit
·
9350e9c
1
Parent(s):
8adf41a
style response message
Browse files- app.py +15 -1
- criteria.py +5 -5
app.py
CHANGED
|
@@ -13,6 +13,7 @@ from org import join_finishers_org
|
|
| 13 |
|
| 14 |
CERTIFYING_ORG_LINKEDIN_ID = os.getenv("CERTIFYING_ORG_LINKEDIN_ID", "000000")
|
| 15 |
|
|
|
|
| 16 |
def download_profile_picture(profile_url: str):
|
| 17 |
"""Download profile picture from URL."""
|
| 18 |
response = requests.get(profile_url)
|
|
@@ -94,12 +95,24 @@ def create_linkedin_button(username: str, cert_url: str | None) -> str:
|
|
| 94 |
)
|
| 95 |
button_url = base_url + params
|
| 96 |
|
| 97 |
-
|
| 98 |
<a href="{button_url}" target="_blank" style="display: block; margin-top: 20px; text-align: center;">
|
| 99 |
<img src="https://download.linkedin.com/desktop/add2profile/buttons/en_US.png"
|
| 100 |
alt="LinkedIn Add to Profile button">
|
| 101 |
</a>
|
| 102 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
|
| 104 |
|
| 105 |
def upload_certificate_to_hub(username: str, certificate_img) -> str:
|
|
@@ -151,6 +164,7 @@ def check_certification(token: gr.OAuthToken | None):
|
|
| 151 |
)
|
| 152 |
|
| 153 |
# Check certification criteria
|
|
|
|
| 154 |
result = check_certification_criteria(username)
|
| 155 |
|
| 156 |
# Generate certificate if passed
|
|
|
|
| 13 |
|
| 14 |
CERTIFYING_ORG_LINKEDIN_ID = os.getenv("CERTIFYING_ORG_LINKEDIN_ID", "000000")
|
| 15 |
|
| 16 |
+
|
| 17 |
def download_profile_picture(profile_url: str):
|
| 18 |
"""Download profile picture from URL."""
|
| 19 |
response = requests.get(profile_url)
|
|
|
|
| 95 |
)
|
| 96 |
button_url = base_url + params
|
| 97 |
|
| 98 |
+
message = f"""
|
| 99 |
<a href="{button_url}" target="_blank" style="display: block; margin-top: 20px; text-align: center;">
|
| 100 |
<img src="https://download.linkedin.com/desktop/add2profile/buttons/en_US.png"
|
| 101 |
alt="LinkedIn Add to Profile button">
|
| 102 |
</a>
|
| 103 |
"""
|
| 104 |
+
message += """
|
| 105 |
+
<a href="https://huggingface.co/agents-course-finishers" target="_blank"
|
| 106 |
+
style="display: inline-block; background-color: #fff7e0; border: 2px solid #ffa500;
|
| 107 |
+
border-radius: 10px; padding: 10px 20px; margin: 20px auto; text-align: center;
|
| 108 |
+
text-decoration: none; color: #000; white-space: nowrap;">
|
| 109 |
+
<img src="https://agents-course-unit1-certification-app.hf.space/gradio_api/file=/usr/local/lib/python3.10/site-packages/gradio/icons/huggingface-logo.svg"
|
| 110 |
+
style="display: inline-block; height: 20px; vertical-align: middle; margin-right: 10px;">
|
| 111 |
+
<span style="display: inline-block; vertical-align: middle; color: #000;">You are now an Agents Course Finisher</span>
|
| 112 |
+
</a>
|
| 113 |
+
"""
|
| 114 |
+
|
| 115 |
+
return message
|
| 116 |
|
| 117 |
|
| 118 |
def upload_certificate_to_hub(username: str, certificate_img) -> str:
|
|
|
|
| 164 |
)
|
| 165 |
|
| 166 |
# Check certification criteria
|
| 167 |
+
gr.Info("Collecting data from your course progress...")
|
| 168 |
result = check_certification_criteria(username)
|
| 169 |
|
| 170 |
# Generate certificate if passed
|
criteria.py
CHANGED
|
@@ -137,12 +137,12 @@ def get_certificate_result(
|
|
| 137 |
passed = has_passed(pass_percentage, num_questions)
|
| 138 |
|
| 139 |
if passed:
|
| 140 |
-
|
| 141 |
-
message="""
|
| 142 |
Congratulations, you successfully completed the course! 🎉 \n
|
| 143 |
-
You can download your certificate below ⬇️
|
| 144 |
-
|
| 145 |
-
|
|
|
|
| 146 |
certificate_path=CERTIFICATE_PATH,
|
| 147 |
pass_percentage=pass_percentage,
|
| 148 |
passed=True,
|
|
|
|
| 137 |
passed = has_passed(pass_percentage, num_questions)
|
| 138 |
|
| 139 |
if passed:
|
| 140 |
+
message = """
|
|
|
|
| 141 |
Congratulations, you successfully completed the course! 🎉 \n
|
| 142 |
+
You can download your certificate below ⬇️
|
| 143 |
+
"""
|
| 144 |
+
return CertificateResult(
|
| 145 |
+
message=message,
|
| 146 |
certificate_path=CERTIFICATE_PATH,
|
| 147 |
pass_percentage=pass_percentage,
|
| 148 |
passed=True,
|