Skip to content

Display popular votes leaderboard #2785

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
d30e0ec
Create new tab for popular votes leaderboard
jayjay19630 Feb 13, 2024
ca2abec
Merge branch 'source-academy:master' into DisplayPopularVotesLeaderboard
jayjay19630 Feb 13, 2024
4230612
Rename popular votes to popular vote leaderboard
jayjay19630 Feb 14, 2024
d3a29d1
Edit assessment mocks and assessment types to include popular vote
jayjay19630 Feb 14, 2024
43e1e01
Modify tests
jayjay19630 Feb 14, 2024
1c93b0e
Merge branch 'DisplayPopularVotesLeaderboard' of github.com:jayjay196…
jayjay19630 Feb 14, 2024
e6b5b08
Rename score property to calculated score and add popularity score
jayjay19630 Feb 14, 2024
1ac975f
Conditionally render different kinds of score depending on leaderboar…
jayjay19630 Feb 14, 2024
ae59bbb
Revert "Conditionally render different kinds of score depending on le…
jayjay19630 Feb 15, 2024
53b9e74
Revert "Rename score property to calculated score and add popularity …
jayjay19630 Feb 15, 2024
4908f07
Edit snapshots
jayjay19630 Feb 15, 2024
3df696c
Merge branch 'source-academy:master' into DisplayPopularVotesLeaderboard
jayjay19630 Feb 15, 2024
8d1b47e
Merge branch 'master' into DisplayPopularVotesLeaderboard
RichDom2185 Feb 18, 2024
f71d078
Move from switch case to ternary ladder
jayjay19630 Feb 18, 2024
a719fe7
Merge branch 'DisplayPopularVotesLeaderboard' of github.com:jayjay196…
jayjay19630 Feb 18, 2024
edd37ab
Fix bug with snapshot
jayjay19630 Feb 19, 2024
ac4943c
Merge branch 'master' into DisplayPopularVotesLeaderboard
sayomaki Feb 21, 2024
40051e6
Merge branch 'master' into DisplayPopularVotesLeaderboard
RichDom2185 Feb 23, 2024
6735b70
Merge branch 'master' into DisplayPopularVotesLeaderboard
RichDom2185 Feb 23, 2024
8db4d6e
Merge branch 'master' into DisplayPopularVotesLeaderboard
RichDom2185 Feb 23, 2024
c982fdc
Merge branch 'master' of https://github.com/source-academy/frontend i…
RichDom2185 Feb 23, 2024
16a4a03
Merge branch 'master' into DisplayPopularVotesLeaderboard
RichDom2185 Feb 23, 2024
04c0117
Fix import post-merge
RichDom2185 Feb 23, 2024
b4df4c2
Update test snapshots
RichDom2185 Feb 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/commons/assessment/AssessmentTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export interface IContestVotingQuestion extends BaseQuestion {
postpend: string;
contestEntries: ContestEntry[];
scoreLeaderboard: ContestEntry[];
popularVoteLeaderboard: ContestEntry[];
type: 'voting';
}

Expand Down
15 changes: 15 additions & 0 deletions src/commons/assessmentWorkspace/AssessmentWorkspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -475,9 +475,24 @@ const AssessmentWorkspace: React.FC<AssessmentWorkspaceProps> = props => {
<SideContentContestLeaderboard
handleContestEntryClick={handleContestEntryClick}
orderedContestEntries={(question as IContestVotingQuestion)?.scoreLeaderboard ?? []}
leaderboardType={SideContentType.scoreLeaderboard}
/>
),
id: SideContentType.scoreLeaderboard
},
{
label: 'Popular Vote Leaderboard',
iconName: IconNames.PEOPLE,
body: (
<SideContentContestLeaderboard
handleContestEntryClick={handleContestEntryClick}
orderedContestEntries={
(question as IContestVotingQuestion)?.popularVoteLeaderboard ?? []
}
leaderboardType={SideContentType.popularVoteLeaderboard}
/>
),
id: SideContentType.popularVoteLeaderboard
}
);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,33 @@ exports[`AssessmentWorkspace AssessmentWorkspace page with ContestVoting questio
</div>
</span>
</div>
<div
aria-controls="bp5-tab-panel_side-content-tabs_popular_vote_leaderboard"
aria-disabled="false"
aria-expanded="false"
aria-selected="false"
class="bp5-tab side-content-tab"
data-tab-id="popular_vote_leaderboard"
id="bp5-tab-title_side-content-tabs_popular_vote_leaderboard"
role="tab"
tabindex="-1"
>
<span
class="bp5-popover-target"
>
<div
aria-expanded="false"
class="side-content-tooltip"
tabindex="0"
>
<span
aria-hidden="true"
class="bp5-icon bp5-icon-large bp5-icon-people"
data-icon="people"
/>
</div>
</span>
</div>
</div>
<div
aria-hidden="false"
Expand Down Expand Up @@ -854,7 +881,204 @@ exports[`AssessmentWorkspace AssessmentWorkspace page with ContestVoting questio
<div
class="header-score"
>
Score
Calculated Score
<span
aria-hidden="true"
class="bp5-icon bp5-icon-caret-down"
>
<svg
data-icon="caret-down"
height="16"
role="img"
viewBox="0 0 16 16"
width="16"
>
<path
d="M12 6.5c0-.28-.22-.5-.5-.5h-7a.495.495 0 00-.37.83l3.5 4c.09.1.22.17.37.17s.28-.07.37-.17l3.5-4c.08-.09.13-.2.13-.33z"
fill-rule="evenodd"
/>
</svg>
</span>
</div>
</div>
<div
class="LeaderboardCard"
>
<div
class="bp5-interactive bp5-card bp5-elevation-1"
data-testid="SideContentLeaderboardCard"
>
<pre
class="bp5-code-block contestentry-entryid"
>
student_1
</pre>
<pre
class="bp5-code-block contestentry-rank"
>
1
</pre>
<pre
class="bp5-code-block contestentry-score"
data-testid="contestentry-score"
/>
</div>
</div>
<div
class="LeaderboardCard"
>
<div
class="bp5-interactive bp5-card bp5-elevation-1"
data-testid="SideContentLeaderboardCard"
>
<pre
class="bp5-code-block contestentry-entryid"
>
student_2
</pre>
<pre
class="bp5-code-block contestentry-rank"
>
2
</pre>
<pre
class="bp5-code-block contestentry-score"
data-testid="contestentry-score"
/>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div
aria-hidden="true"
aria-labelledby="bp5-tab-title_side-content-tabs_popular_vote_leaderboard"
class="bp5-tab-panel side-content-tab"
id="bp5-tab-panel_side-content-tabs_popular_vote_leaderboard"
role="tabpanel"
>
<div
class="side-content-text"
>
<div
class="ContestLeaderboard"
>
<button
class="bp5-button bp5-minimal collapse-button"
type="button"
>
<span
aria-hidden="true"
class="bp5-icon bp5-icon-caret-down"
>
<svg
data-icon="caret-down"
height="16"
role="img"
viewBox="0 0 16 16"
width="16"
>
<path
d="M12 6.5c0-.28-.22-.5-.5-.5h-7a.495.495 0 00-.37.83l3.5 4c.09.1.22.17.37.17s.28-.07.37-.17l3.5-4c.08-.09.13-.2.13-.33z"
fill-rule="evenodd"
/>
</svg>
</span>
<span
class="bp5-button-text"
>
<span>
Popular Vote Leaderboard
</span>
<span
class="bp5-popover-target"
>
<span
aria-expanded="false"
aria-hidden="true"
class="bp5-icon bp5-icon-help"
tabindex="0"
>
<svg
data-icon="help"
height="16"
role="img"
viewBox="0 0 16 16"
width="16"
>
<path
d="M8 0C3.58 0 0 3.58 0 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm1 13H7v-2h2v2zm1.93-6.52c-.14.32-.35.64-.62.97L9.25 8.83c-.12.15-.24.29-.28.42-.04.13-.09.3-.09.52V10H7.12V8.88s.05-.51.21-.71L8.4 6.73c.22-.26.35-.49.44-.68.09-.19.12-.38.12-.58 0-.3-.1-.55-.28-.75-.18-.19-.44-.28-.76-.28-.33 0-.59.1-.78.29-.19.19-.33.46-.4.81-.03.11-.1.15-.2.14l-1.7-.25c-.12-.01-.16-.08-.14-.19.12-.82.46-1.47 1.03-1.94.57-.48 1.32-.72 2.25-.72.47 0 .9.07 1.29.22s.72.34 1 .59c.28.25.49.55.65.89.15.35.22.72.22 1.12s-.07.75-.21 1.08z"
fill-rule="evenodd"
/>
</svg>
</span>
</span>
</span>
</button>
<div
class="bp5-collapse"
style="height: auto; overflow-y: visible; transition: none;"
>
<div
aria-hidden="false"
class="bp5-collapse-body"
style="transform: translateY(0); transition: none;"
>
<div>
<div
class="leaderboard-header"
>
<div
class="header-entryid"
>
Student Name
<span
aria-hidden="true"
class="bp5-icon bp5-icon-caret-down"
>
<svg
data-icon="caret-down"
height="16"
role="img"
viewBox="0 0 16 16"
width="16"
>
<path
d="M12 6.5c0-.28-.22-.5-.5-.5h-7a.495.495 0 00-.37.83l3.5 4c.09.1.22.17.37.17s.28-.07.37-.17l3.5-4c.08-.09.13-.2.13-.33z"
fill-rule="evenodd"
/>
</svg>
</span>
</div>
<div
class="header-entryrank"
>
Rank
<span
aria-hidden="true"
class="bp5-icon bp5-icon-caret-down"
>
<svg
data-icon="caret-down"
height="16"
role="img"
viewBox="0 0 16 16"
width="16"
>
<path
d="M12 6.5c0-.28-.22-.5-.5-.5h-7a.495.495 0 00-.37.83l3.5 4c.09.1.22.17.37.17s.28-.07.37-.17l3.5-4c.08-.09.13-.2.13-.33z"
fill-rule="evenodd"
/>
</svg>
</span>
</div>
<div
class="header-score"
>
Popularity Score
<span
aria-hidden="true"
class="bp5-icon bp5-icon-caret-down"
Expand Down
16 changes: 14 additions & 2 deletions src/commons/mocks/AssessmentMocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -874,12 +874,24 @@ const mockContestEntryQuestion: Array<IContestVotingQuestion> = [
{
submission_id: 1,
student_name: 'student_1',
answer: { code: "display('leaderboard test')" }
answer: { code: "display('score_leaderboard test')" }
},
{
submission_id: 2,
student_name: 'student_2',
answer: { code: 'function leaderboard_test() { return true; }' }
answer: { code: 'function score_leaderboard_test() { return true; }' }
}
],
popularVoteLeaderboard: [
{
submission_id: 1,
student_name: 'student_1',
answer: { code: "display('popular_vote_leaderboard test')" }
},
{
submission_id: 2,
student_name: 'student_2',
answer: { code: 'function popular_vote_leaderboard_test() { return true; }' }
}
],
library: mockLibrary,
Expand Down
3 changes: 2 additions & 1 deletion src/commons/sideContent/SideContentTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export enum SideContentType {
autograder = 'autograder',
briefing = 'briefing',
contestVoting = 'contest_voting',
scoreLeaderboard = 'score_leaderboard',
dataVisualizer = 'data_visualizer',
editorGrading = 'editor_grading',
editorAutograder = 'editor_autograder',
Expand All @@ -31,8 +30,10 @@ export enum SideContentType {
grading = 'grading',
introduction = 'introduction',
module = 'module',
popularVoteLeaderboard = 'popular_vote_leaderboard',
questionOverview = 'question_overview',
remoteExecution = 'remote_execution',
scoreLeaderboard = 'score_leaderboard',
missionMetadata = 'mission_metadata',
mobileEditor = 'mobile_editor',
mobileEditorRun = 'mobile_editor_run',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import userEvent from '@testing-library/user-event';
import { shallowRender } from 'src/commons/utils/TestUtils';

import SideContentContestLeaderboard from '../content/SideContentContestLeaderboard';
import { SideContentType } from '../SideContentTypes';

const mockLeaderboardEntries = [
{
Expand All @@ -27,7 +28,8 @@ const mockLeaderboardEntries = [

const mockProps = {
handleContestEntryClick: () => {},
orderedContestEntries: mockLeaderboardEntries
orderedContestEntries: mockLeaderboardEntries,
leaderboardType: SideContentType.scoreLeaderboard
};

// Basic snapshot testing to catch unexpected changes
Expand All @@ -54,13 +56,14 @@ test('SideContentContestLeaderboard orders entry in the same order as orderedCon
expect(scores).toEqual(['100', '90', '80']);
});

test('Clicking the contest entry updates the editor for contest leaderboard.', async () => {
test('Clicking the contest entry updates the editor for score leaderboard.', async () => {
const user = userEvent.setup();
const mockedHandleContestEntryClick = jest.fn();

const mockProps = {
handleContestEntryClick: mockedHandleContestEntryClick,
orderedContestEntries: mockLeaderboardEntries
orderedContestEntries: mockLeaderboardEntries,
leaderboardType: SideContentType.scoreLeaderboard
};

const contestVotingContainer = <SideContentContestLeaderboard {...mockProps} />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ exports[`SideContentContestLeaderboard matches snapshot 1`] = `
</span>
<Blueprint5.Tooltip
compact={false}
content="View the top-rated contest entries!"
content="View the highest scoring contest entries!"
hoverCloseDelay={0}
hoverOpenDelay={100}
interactionKind="hover-target"
Expand Down Expand Up @@ -62,7 +62,7 @@ exports[`SideContentContestLeaderboard matches snapshot 1`] = `
<div
className="header-score"
>
Score
Calculated Score
<Blueprint5.Icon
autoLoad={true}
icon="caret-down"
Expand Down
Loading