Skip to content

Commit

Permalink
Merge pull request #779 from Lunatic-Labs/SKIL-534-2
Browse files Browse the repository at this point in the history
SKIL 534-2
  • Loading branch information
aparriaran authored Nov 21, 2024
2 parents a2a3f3b + 1b0dad0 commit 1abb378
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
4 changes: 4 additions & 0 deletions BackEndFlask/controller/Routes/Completed_assessment_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ def get_all_completed_assessments():

get_assessment_task(assessment_task_id) # Trigger an error if not exists.
completed_assessments = get_completed_assessment_with_team_name(assessment_task_id)

if not completed_assessments:
completed_assessments = get_completed_assessment_with_user_name(assessment_task_id)

completed_count = get_completed_assessment_count(assessment_task_id)
result = [
{**completed_assessment_schema.dump(assessment), 'completed_count': completed_count}
Expand Down
17 changes: 12 additions & 5 deletions BackEndFlask/models/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -1082,9 +1082,6 @@ def get_course_name_by_at_id(at_id:int) -> str :

return course_name[0][0]




def get_completed_assessment_ratio(course_id: int, assessment_task_id: int) -> int:
"""
Description:
Expand All @@ -1096,9 +1093,19 @@ def get_completed_assessment_ratio(course_id: int, assessment_task_id: int) -> i
Return: int (Ratio of users who have completed an assessment task rounded to the nearest whole number)
"""
ratio = 0

all_usernames_for_completed_task = get_completed_assessment_with_user_name(assessment_task_id)
all_students_in_course = get_users_by_course_id_and_role_id(course_id, 5)
ratio = (len(all_usernames_for_completed_task) / len(all_students_in_course)) * 100

if all_usernames_for_completed_task:
all_students_in_course = get_users_by_course_id_and_role_id(course_id, 5)

ratio = len(all_usernames_for_completed_task) / len(all_students_in_course) * 100
else:
all_teams_in_course = get_team_members_in_course(course_id)
all_teams_for_completed_task = get_completed_assessment_with_team_name(assessment_task_id)

ratio = len(all_teams_for_completed_task) / len(all_teams_in_course) * 100

ratio_rounded = round(ratio)

Expand Down

0 comments on commit 1abb378

Please sign in to comment.