Skip to content

Commit

Permalink
filter ability screen id with 4229
Browse files Browse the repository at this point in the history
  • Loading branch information
usamabinnadeem-10 committed Aug 4, 2024
1 parent d4cffd8 commit c2e73cb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export async function getExamResults(
state: string | null = "",
onSuccess: any
) {
let URL = `/credentials/api/exam-results?page=${page}&ability_screen_id=4229`;
let URL = `/credentials/api/exam-results?page=${page}&ability_screen_id[]=4229`;
if (state) {
URL += `&state=${state}`;
}
Expand Down
7 changes: 6 additions & 1 deletion webapp/shop/api/trueability/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,17 @@ def get_assessment_redirect(self, id: str):
return None

def get_results(
self, page: int = 1, per_page: int = 50, state: str = None
self,
page: int = 1,
per_page: int = 50,
state: str = None,
ability_screen_id: list = None,
):
params = {
"state": state,
"page": page,
"per_page": per_page,
"ability_screen_id[]": ability_screen_id,
}
filtered_params = {k: v for k, v in params.items() if v is not None}
uri = "/api/v1/results?" + urlencode(filtered_params)
Expand Down
10 changes: 8 additions & 2 deletions webapp/shop/cred/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1254,12 +1254,18 @@ def cred_dashboard_exam_results(trueability_api, **_):
per_page = 50
page = int(flask.request.args.get("page", 1)) - 1
exam_state = flask.request.args.get("state", None)
ability_screen_id = flask.request.args.get("ability_screen_id[]", None)
first_results = trueability_api.get_results(
per_page=per_page, state=exam_state
per_page=per_page,
state=exam_state,
ability_screen_id=ability_screen_id,
)
last_page = first_results["meta"]["total_pages"]
latest_results = trueability_api.get_results(
page=last_page - page, per_page=per_page, state=exam_state
page=last_page - page,
per_page=per_page,
state=exam_state,
ability_screen_id=ability_screen_id,
)
return flask.jsonify(latest_results)
except Exception:
Expand Down

0 comments on commit c2e73cb

Please sign in to comment.