feat: enhance project search for teachers

Extended the `projects_search` function and adjusted `category_page` logic to specifically cater to searches initiated by teachers. This update introduces a `teachers` flag that, when set to true, modifies the search criteria to include projects tagged for teachers, thereby streamlining the retrieval of educational content. This change aims to improve the user experience for educators by making relevant projects more accessible.

By distinguishing teacher-initiated searches with a dedicated filter, the platform can now offer more tailored content, thus enhancing its value as an educational resource.
This commit is contained in:
Kumi 2024-05-25 17:10:19 +02:00
parent 70e4b9ddee
commit b320099c44
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -306,9 +306,14 @@ def category_page(app, name, teachers=False):
):
channels.append(channel["channel"])
category_ibles, total = projects_search(
app, category=name, page=page, filter_by="featureFlag:=true"
)
if teachers:
category_ibles, total = projects_search(
app, teachers=True, page=page, filter_by="featureFlag:=true"
)
else:
category_ibles, total = projects_search(
app, category=name, page=page, filter_by="featureFlag:=true"
)
for ible in category_ibles:
link = f"/{ible['document']['urlString']}"
@ -352,6 +357,7 @@ def projects_search(
app,
query="*",
category="",
teachers=False,
channel="",
filter_by="",
page=1,
@ -371,6 +377,11 @@ def projects_search(
filter_by += " && "
filter_by += f"channel:={channel}"
if teachers:
if filter_by:
filter_by += " && "
filter_by += "teachers:=Teachers"
query = quote(query)
filter_by = quote(filter_by)