added some new features. (Showing student's reviews and courses, Show course reviews, Show Top Courses with a tag or in a category, skipping optional fields when creating entity)

This commit is contained in:
Hosein
2026-01-08 10:13:25 +03:30
parent caac6c3a08
commit 45138bb234
10 changed files with 314 additions and 37 deletions
+1 -1
View File
@@ -6,6 +6,6 @@ def create_entity_markup(entity_name, enitity_id, is_auth_needed=False):
markup.add(types.InlineKeyboardButton(
f"✏️ Edit {entity_name} " + ("🔒" if is_auth_needed else ""), callback_data=f"edit_{entity_name}_{enitity_id}"))
markup.add(types.InlineKeyboardButton(
f"🗑️ Delete {entity_name}" + ("🔒" if is_auth_needed else ""), callback_data=f"delete_{entity_name}_{enitity_id}"))
f"🗑️ Delete {entity_name} " + ("🔒" if is_auth_needed else ""), callback_data=f"delete_{entity_name}_{enitity_id}"))
return markup
+30 -2
View File
@@ -115,11 +115,11 @@ def format_teacher_info(teacher):
def format_course_info(course):
"""
Format course data into a nice message
course is a tuple: (id, name, created_at, teacher_id, updated_at, description, difficulty, language)
course is a tuple: (id, name, created_at, teacher_id, updated_at, description, difficulty, language, avgerage_rate)
"""
# print(course)
id, name, created_at, teacher_id, updated_at, description, difficulty, language = course
id, name, created_at, teacher_id, updated_at, description, difficulty, language, avgerage_rate = course
# Format dates nicely
created_date = format_date(created_at)
@@ -129,6 +129,7 @@ def format_course_info(course):
<b>📚 Course Profile</b>
<b>Name:</b> {name}
<b>⭐️ Average Rating:</b> {avgerage_rate}
<b>Description:</b>
{description}
@@ -141,3 +142,30 @@ def format_course_info(course):
<b>ID:</b> <code>{id}</code>
"""
return details.strip()
def format_course_review(review):
"""
Formate course review into a nice message
:param review: tuple(body: str, rate: int, student_name: str, course_name: str, created_at: date, updated_at: date)
"""
reviewBody, rate, student_name, course_name, created_at, updated_at = review
created_date = format_date(created_at)
updated_at = format_date(updated_at)
details = f"""
<b>✉️ Review</b>
<b>rate:</b> {'⭐️' * rate}
<b>Body:</b>\n{reviewBody}
<b>Course name:</b> {course_name}
<b>Student name:</b> {student_name}
<b>📅 Review Info</b>
<b>Created At:</b> {created_date}
<b>Last Updated At:</b> {updated_at}
"""
return details.strip()