Skip to content

Commit b78304a

Browse files
committed
Add DispatchContestXp functionality and button to issue contest XP in ground control
1 parent ba4b33b commit b78304a

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

src/commons/sagas/RequestsSaga.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,6 +1273,24 @@ export const calculateContestScore = async (
12731273
return resp;
12741274
};
12751275

1276+
/**
1277+
* POST /courses/{courseId}/admin/assessments/{assessmentId}/dispatchContestXp
1278+
*/
1279+
export const dispatchContestXp = async (
1280+
assessmentId: number,
1281+
tokens: Tokens
1282+
): Promise<Response | null> => {
1283+
const resp = await request(
1284+
`${courseId()}/admin/assessments/${assessmentId}/dispatchContestXp`,
1285+
'POST',
1286+
{
1287+
...tokens
1288+
}
1289+
);
1290+
1291+
return resp;
1292+
};
1293+
12761294
/**
12771295
* GET /courses/{courseId}/admin/assessments/{assessmentId}/{visibleEntries}/scoreLeaderboard
12781296
*/
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { IconNames } from '@blueprintjs/icons';
2+
import ControlButton from 'src/commons/ControlButton';
3+
import { dispatchContestXp } from 'src/commons/sagas/RequestsSaga';
4+
import { useTokens } from 'src/commons/utils/Hooks';
5+
6+
type Props = {
7+
assessmentId: number;
8+
};
9+
10+
const CalculateContestScoreButton: React.FC<Props> = ({ assessmentId }) => {
11+
const tokens = useTokens();
12+
13+
return (
14+
<div className="control-button-container">
15+
<ControlButton
16+
icon={IconNames.AddRowTop}
17+
onClick={async () => {
18+
dispatchContestXp(assessmentId, tokens);
19+
}}
20+
label="Dispatch Contest XP"
21+
/>
22+
</div>
23+
);
24+
};
25+
26+
export default CalculateContestScoreButton;

src/pages/academy/groundControl/subcomponents/GroundControlConfigureCell.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import CalculateContestScoreButton from '../configureControls/CalculateContestSc
1818
import ExportScoreLeaderboardButton from '../configureControls/ExportScoreLeaderboardButton';
1919
import ExportVoteLeaderboardButton from '../configureControls/ExportVoteLeaderboardButton';
2020
import AssignEntriesButton from './configureControls/AssignEntriesButton';
21+
import DispatchContestXpButton from '../configureControls/DispatchContestXpButton';
2122

2223
type Props = {
2324
handleConfigureAssessment: (
@@ -119,6 +120,7 @@ const ConfigureCell: React.FC<Props> = ({
119120
<Collapse isOpen={hasVotingFeatures}>
120121
<div className="voting-related-controls">
121122
<CalculateContestScoreButton assessmentId={data.id} />
123+
<DispatchContestXpButton assessmentId={data.id} />
122124
<ExportScoreLeaderboardButton assessmentId={data.id} />
123125
<ExportVoteLeaderboardButton assessmentId={data.id} />
124126
<AssignEntriesButton

0 commit comments

Comments
 (0)