From d73d6fe970ed56b25e9b1f96fa5b64c1610a2ff0 Mon Sep 17 00:00:00 2001 From: Ihsan Ullah Date: Tue, 20 Jun 2023 06:32:58 +0500 Subject: [PATCH 1/3] Detailed results displayed for each task on leaderboard --- src/apps/api/serializers/submissions.py | 3 +- src/apps/api/views/competitions.py | 16 +++++++++++ .../riot/competitions/detail/leaderboards.tag | 28 +++++++++++++++---- 3 files changed, 41 insertions(+), 6 deletions(-) diff --git a/src/apps/api/serializers/submissions.py b/src/apps/api/serializers/submissions.py index a8d8ed071..db4b91e91 100644 --- a/src/apps/api/serializers/submissions.py +++ b/src/apps/api/serializers/submissions.py @@ -98,7 +98,8 @@ class Meta: 'scores', 'display_name', 'slug_url', - 'organization' + 'organization', + 'detailed_result' ) extra_kwargs = { "scores": {"read_only": True}, diff --git a/src/apps/api/views/competitions.py b/src/apps/api/views/competitions.py index d27a3fe5e..55ffc0836 100644 --- a/src/apps/api/views/competitions.py +++ b/src/apps/api/views/competitions.py @@ -517,6 +517,7 @@ def get_leaderboard(self, request, pk): } columns = [col for col in query['columns']] submissions_keys = {} + submission_detailed_results = {} for submission in query['submissions']: # count number of entries/number of submissions for the owner of this submission for this phase @@ -529,12 +530,22 @@ def get_leaderboard(self, request, pk): .strftime('%Y-%m-%d') submission_key = f"{submission['owner']}{submission['parent'] or submission['id']}" + + # gather detailed result from submissions for each task + # detailed_results are gathered based on submission key + submission_detailed_results.setdefault(submission_key, []).append({ + 'detailed_result': submission['detailed_result'], + 'task': submission['task'], + 'id': submission['id'] + }) + if submission_key not in submissions_keys: submissions_keys[submission_key] = len(response['submissions']) response['submissions'].append({ 'id': submission['id'], 'owner': submission['display_name'] or submission['owner'], 'scores': [], + 'detailed_results': [], 'fact_sheet_answers': submission['fact_sheet_answers'], 'slug_url': submission['slug_url'], 'organization': submission['organization'], @@ -559,6 +570,11 @@ def get_leaderboard(self, request, pk): tempScore['score'] = str(round(float(tempScore["score"]), precision)) response['submissions'][submissions_keys[submission_key]]['scores'].append(tempScore) + # put detailed results in its submission + for k, v in submissions_keys.items(): + response['submissions'][v]['detailed_results'] = submission_detailed_results[k] + print(f"\n{response['submissions']}\n") + for task in query['tasks']: # This can be used to rendered variable columns on each task tempTask = { diff --git a/src/static/riot/competitions/detail/leaderboards.tag b/src/static/riot/competitions/detail/leaderboards.tag index d289060ef..3b8724f84 100644 --- a/src/static/riot/competitions/detail/leaderboards.tag +++ b/src/static/riot/competitions/detail/leaderboards.tag @@ -29,8 +29,7 @@ Task: - { task.name } - + { task.name } # @@ -38,7 +37,7 @@ Entries Date of last entry {column.title} - Detailed Results + @@ -60,8 +59,12 @@ {submission.num_entries} {submission.last_entry_date} { submission.organization.name } - { get_score(column, submission) } - Show detailed results + + Show detailed results + {get_score(column, submission)} + + + @@ -147,6 +150,12 @@ column.task_id = task.id self.columns.push(column) } + if(self.enable_detailed_results){ + self.columns.push({ + task_id: task.id, + title: "Detailed Results" + }) + } } self.filter_columns() $('#leaderboardTable').tablesort() @@ -154,6 +163,15 @@ }) } + self.get_detailed_result_submisison_id = function(column, submisison){ + for (index in submisison.detailed_results) { + if(column.task_id == submisison.detailed_results[index].task){ + return submisison.detailed_results[index].id + } + } + } + + CODALAB.events.on('phase_selected', data => { self.phase_id = data.id self.update_leaderboard() From 0b4664dfcbd6a317c4df02cbb96415c71b2b1b07 Mon Sep 17 00:00:00 2001 From: Ihsan Ullah Date: Tue, 20 Jun 2023 06:55:31 +0500 Subject: [PATCH 2/3] more explanation added to detailed result fetching. url commented --- src/apps/api/views/competitions.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/apps/api/views/competitions.py b/src/apps/api/views/competitions.py index 55ffc0836..3a2b9c897 100644 --- a/src/apps/api/views/competitions.py +++ b/src/apps/api/views/competitions.py @@ -533,8 +533,10 @@ def get_leaderboard(self, request, pk): # gather detailed result from submissions for each task # detailed_results are gathered based on submission key + # `id` is used to fetch the right detailed result in detailed results page + # `detailed_result` url is not needed submission_detailed_results.setdefault(submission_key, []).append({ - 'detailed_result': submission['detailed_result'], + # 'detailed_result': submission['detailed_result'], 'task': submission['task'], 'id': submission['id'] }) From 8dfd944b6cac036fb4d493691feec01082e60612 Mon Sep 17 00:00:00 2001 From: Ihsan Ullah Date: Fri, 21 Jul 2023 18:29:02 +0500 Subject: [PATCH 3/3] detailed results removed from factsheets --- src/static/riot/competitions/detail/leaderboards.tag | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/static/riot/competitions/detail/leaderboards.tag b/src/static/riot/competitions/detail/leaderboards.tag index 3b8724f84..8ac68917a 100644 --- a/src/static/riot/competitions/detail/leaderboards.tag +++ b/src/static/riot/competitions/detail/leaderboards.tag @@ -29,7 +29,7 @@ Task: - { task.name } + { task.name } # @@ -104,6 +104,7 @@ self.filter_columns = () => { let search_key = self.refs.leaderboardFilter.value.toLowerCase() self.filtered_tasks = JSON.parse(JSON.stringify(self.selected_leaderboard.tasks)) + console.log(self.filtered_tasks) if(search_key){ self.filtered_columns = [] for (const column of self.columns){ @@ -146,16 +147,20 @@ self.selected_leaderboard.tasks.unshift(fake_metadata_task) } for(task of self.selected_leaderboard.tasks){ + for(column of task.columns){ column.task_id = task.id self.columns.push(column) } - if(self.enable_detailed_results){ + // -1 id is used for fact sheet answers + if(self.enable_detailed_results & task.id != -1){ self.columns.push({ task_id: task.id, title: "Detailed Results" }) + task.colWidth += 1 } + console.log(task) } self.filter_columns() $('#leaderboardTable').tablesort()