Skip to content

Commit

Permalink
Assessment Configurability in Ground Control (#2863)
Browse files Browse the repository at this point in the history
* Change hasTokenCounter to hasVotingAttributes in Assessment Config. Enable tokencounter depending on assessment hasTokenCounter, not assessmentConfig

* Rename hasVotingAttributes to hasVotingFeatures

* Create dialog box for configuration in ground control

* Create dialog box for configurations with voting config toggles

* Combine toggleHasTokenCounter and toggleVotingFeatures into configureAssessment

* Create backend request for updating configurations

* Add message for updating assessment configurations

* Isolate hastokencounter as its own field

* Add non-functional voting controls

* Fix tests

* Add new column for token counter in admin panel

* Fix bugs relating to tokencounter switch

* Remove unnecessary maxwidth property on tokencounter switch

* Fix bug where toggling tokencounter would request voting features to be true to backend

* Create footer text to clarify usage of hastokencounter and hasVotingFeatures

* Align text on configure dialogbox

* Fix tests post-merge

The stronger type checking had been causing compile errors.

* Fix imports

* Add close dialog upon saving

* Uncapitalise letters in config dialog

* Change label from has token counter to enable token counter

* Code quality improvements

* Create new section for team-related configurations

* Fix code quality per suggestion

* Fix errors post-merge

* Fix lint errors

---------

Co-authored-by: Richard Dominick <[email protected]>
  • Loading branch information
2 people authored and izruff committed Mar 30, 2024
1 parent 37f1b4c commit 7694ad4
Show file tree
Hide file tree
Showing 20 changed files with 343 additions and 31 deletions.
3 changes: 2 additions & 1 deletion src/commons/XMLParser/XMLParserHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ const makeAssessmentOverview = (result: any, maxXpVal: number): AssessmentOvervi
story: rawOverview.story,
xp: 0,
gradingStatus: 'none' as GradingStatuses,
maxTeamSize: 1
maxTeamSize: 1,
hasVotingFeatures: false
};
};

Expand Down
12 changes: 11 additions & 1 deletion src/commons/application/actions/__tests__/SessionActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ test('setAssessmentConfigurations generates correct action object', () => {
isManuallyGraded: true,
displayInDashboard: true,
hasTokenCounter: false,
hasVotingFeatures: false,
hoursBeforeEarlyXpDecay: 48,
earlySubmissionXp: 200
},
Expand All @@ -344,6 +345,7 @@ test('setAssessmentConfigurations generates correct action object', () => {
isManuallyGraded: true,
displayInDashboard: true,
hasTokenCounter: false,
hasVotingFeatures: false,
hoursBeforeEarlyXpDecay: 48,
earlySubmissionXp: 200
},
Expand All @@ -353,6 +355,7 @@ test('setAssessmentConfigurations generates correct action object', () => {
isManuallyGraded: true,
displayInDashboard: true,
hasTokenCounter: false,
hasVotingFeatures: false,
hoursBeforeEarlyXpDecay: 48,
earlySubmissionXp: 200
}
Expand Down Expand Up @@ -541,7 +544,8 @@ test('updateAssessmentOverviews generates correct action object', () => {
story: null,
xp: 0,
gradingStatus: 'none',
maxTeamSize: 1
maxTeamSize: 1,
hasVotingFeatures: false
}
];
const action = updateAssessmentOverviews(overviews);
Expand Down Expand Up @@ -769,6 +773,7 @@ test('updateAssessmentTypes generates correct action object', () => {
isManuallyGraded: true,
displayInDashboard: true,
hasTokenCounter: false,
hasVotingFeatures: false,
hoursBeforeEarlyXpDecay: 48,
earlySubmissionXp: 200
},
Expand All @@ -778,6 +783,7 @@ test('updateAssessmentTypes generates correct action object', () => {
isManuallyGraded: true,
displayInDashboard: true,
hasTokenCounter: false,
hasVotingFeatures: false,
hoursBeforeEarlyXpDecay: 48,
earlySubmissionXp: 200
},
Expand All @@ -787,6 +793,7 @@ test('updateAssessmentTypes generates correct action object', () => {
isManuallyGraded: true,
displayInDashboard: true,
hasTokenCounter: false,
hasVotingFeatures: false,
hoursBeforeEarlyXpDecay: 48,
earlySubmissionXp: 200
},
Expand All @@ -796,6 +803,7 @@ test('updateAssessmentTypes generates correct action object', () => {
isManuallyGraded: true,
displayInDashboard: true,
hasTokenCounter: false,
hasVotingFeatures: false,
hoursBeforeEarlyXpDecay: 48,
earlySubmissionXp: 200
},
Expand All @@ -805,6 +813,7 @@ test('updateAssessmentTypes generates correct action object', () => {
isManuallyGraded: true,
displayInDashboard: true,
hasTokenCounter: false,
hasVotingFeatures: false,
hoursBeforeEarlyXpDecay: 48,
earlySubmissionXp: 200
}
Expand All @@ -823,6 +832,7 @@ test('deleteAssessmentConfig generates correct action object', () => {
isManuallyGraded: true,
displayInDashboard: true,
hasTokenCounter: false,
hasVotingFeatures: false,
hoursBeforeEarlyXpDecay: 48,
earlySubmissionXp: 200
};
Expand Down
15 changes: 10 additions & 5 deletions src/commons/application/reducers/__tests__/SessionReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ test('SET_ASSESSMENT_CONFIGURATIONS works correctly', () => {
earlySubmissionXp: 200,
isManuallyGraded: false,
displayInDashboard: true,
hasTokenCounter: false
hasTokenCounter: false,
hasVotingFeatures: false
},
{
assessmentConfigId: 1,
Expand All @@ -171,7 +172,8 @@ test('SET_ASSESSMENT_CONFIGURATIONS works correctly', () => {
earlySubmissionXp: 200,
isManuallyGraded: false,
displayInDashboard: true,
hasTokenCounter: false
hasTokenCounter: false,
hasVotingFeatures: false
},
{
assessmentConfigId: 1,
Expand All @@ -183,7 +185,8 @@ test('SET_ASSESSMENT_CONFIGURATIONS works correctly', () => {
earlySubmissionXp: 200,
isManuallyGraded: false,
displayInDashboard: true,
hasTokenCounter: false
hasTokenCounter: false,
hasVotingFeatures: false
}
];

Expand Down Expand Up @@ -339,7 +342,8 @@ const assessmentOverviewsTest1: AssessmentOverview[] = [
story: null,
xp: 0,
gradingStatus: GradingStatuses.none,
maxTeamSize: 5
maxTeamSize: 5,
hasVotingFeatures: false
}
];

Expand All @@ -359,7 +363,8 @@ const assessmentOverviewsTest2: AssessmentOverview[] = [
story: null,
xp: 1,
gradingStatus: GradingStatuses.grading,
maxTeamSize: 1
maxTeamSize: 1,
hasVotingFeatures: false
}
];

Expand Down
6 changes: 5 additions & 1 deletion src/commons/assessment/AssessmentTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ export type AssessmentOverview = {
gradingStatus: GradingStatus;
id: number;
isPublished?: boolean;
hasVotingFeatures: boolean;
hasTokenCounter?: boolean;
maxXp: number;
number?: string; // For mission control
openAt: string;
Expand Down Expand Up @@ -98,6 +100,7 @@ export type AssessmentConfiguration = {
hoursBeforeEarlyXpDecay: number;
earlySubmissionXp: number;
hasTokenCounter: boolean;
hasVotingFeatures: boolean;
};

export interface IProgrammingQuestion extends BaseQuestion {
Expand Down Expand Up @@ -246,7 +249,8 @@ export const overviewTemplate = (): AssessmentOverview => {
story: 'mission',
xp: 0,
gradingStatus: 'none',
maxTeamSize: 1
maxTeamSize: 1,
hasVotingFeatures: false
};
};

Expand Down
1 change: 1 addition & 0 deletions src/commons/assessment/__tests__/Assessment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const mockAssessmentProps = assertType<AssessmentProps>()({
isManuallyGraded: true,
displayInDashboard: true,
hasTokenCounter: false,
hasVotingFeatures: false,
hoursBeforeEarlyXpDecay: 48,
earlySubmissionXp: 200
}
Expand Down
8 changes: 2 additions & 6 deletions src/commons/assessmentWorkspace/AssessmentWorkspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -274,16 +274,12 @@ const AssessmentWorkspace: React.FC<AssessmentWorkspaceProps> = props => {
* Handles toggling enabling and disabling token counter depending on assessment properties
*/
useEffect(() => {
if (props.assessmentConfiguration.hasTokenCounter) {
if (assessment?.hasTokenCounter) {
handleEnableTokenCounter();
} else {
handleDisableTokenCounter();
}
}, [
props.assessmentConfiguration.hasTokenCounter,
handleEnableTokenCounter,
handleDisableTokenCounter
]);
}, [assessment?.hasTokenCounter, handleEnableTokenCounter, handleDisableTokenCounter]);

/**
* Handles toggling of relevant SideContentTabs when mobile breakpoint it hit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const defaultProps = assertType<AssessmentWorkspaceProps>()({
isManuallyGraded: true,
displayInDashboard: true,
hasTokenCounter: false,
hasVotingFeatures: false,
hoursBeforeEarlyXpDecay: 48,
earlySubmissionXp: 200
},
Expand Down
40 changes: 29 additions & 11 deletions src/commons/mocks/AssessmentMocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const mockAssessmentConfigurations: AssessmentConfiguration[][] = [
displayInDashboard: true,
hoursBeforeEarlyXpDecay: 48,
hasTokenCounter: false,
hasVotingFeatures: false,
earlySubmissionXp: 200
},
{
Expand All @@ -32,6 +33,7 @@ export const mockAssessmentConfigurations: AssessmentConfiguration[][] = [
displayInDashboard: true,
hoursBeforeEarlyXpDecay: 48,
hasTokenCounter: false,
hasVotingFeatures: false,
earlySubmissionXp: 200
},
{
Expand All @@ -41,6 +43,7 @@ export const mockAssessmentConfigurations: AssessmentConfiguration[][] = [
displayInDashboard: true,
hoursBeforeEarlyXpDecay: 48,
hasTokenCounter: false,
hasVotingFeatures: false,
earlySubmissionXp: 200
},
{
Expand All @@ -49,7 +52,8 @@ export const mockAssessmentConfigurations: AssessmentConfiguration[][] = [
isManuallyGraded: true,
displayInDashboard: true,
hoursBeforeEarlyXpDecay: 48,
hasTokenCounter: true,
hasTokenCounter: false,
hasVotingFeatures: true,
earlySubmissionXp: 200
},
{
Expand All @@ -59,6 +63,7 @@ export const mockAssessmentConfigurations: AssessmentConfiguration[][] = [
displayInDashboard: true,
hoursBeforeEarlyXpDecay: 48,
hasTokenCounter: false,
hasVotingFeatures: false,
earlySubmissionXp: 200
}
],
Expand All @@ -70,6 +75,7 @@ export const mockAssessmentConfigurations: AssessmentConfiguration[][] = [
displayInDashboard: true,
hoursBeforeEarlyXpDecay: 48,
hasTokenCounter: false,
hasVotingFeatures: false,
earlySubmissionXp: 200
},
{
Expand All @@ -79,6 +85,7 @@ export const mockAssessmentConfigurations: AssessmentConfiguration[][] = [
displayInDashboard: true,
hoursBeforeEarlyXpDecay: 48,
hasTokenCounter: false,
hasVotingFeatures: false,
earlySubmissionXp: 200
},
{
Expand All @@ -88,6 +95,7 @@ export const mockAssessmentConfigurations: AssessmentConfiguration[][] = [
displayInDashboard: true,
hoursBeforeEarlyXpDecay: 48,
hasTokenCounter: false,
hasVotingFeatures: false,
earlySubmissionXp: 200
}
]
Expand All @@ -109,7 +117,8 @@ const mockUnopenedAssessmentsOverviews: AssessmentOverview[] = [
story: 'mission-1',
xp: 0,
gradingStatus: GradingStatuses.none,
maxTeamSize: 1
maxTeamSize: 1,
hasVotingFeatures: false
}
];

Expand Down Expand Up @@ -141,7 +150,8 @@ const mockOpenedAssessmentsOverviews: AssessmentOverview[] = [
story: 'mission-1',
xp: 1,
gradingStatus: GradingStatuses.none,
maxTeamSize: 4
maxTeamSize: 4,
hasVotingFeatures: false
},
{
type: 'Missions',
Expand All @@ -158,7 +168,8 @@ const mockOpenedAssessmentsOverviews: AssessmentOverview[] = [
story: 'mission-2',
xp: 2,
gradingStatus: GradingStatuses.none,
maxTeamSize: 1
maxTeamSize: 1,
hasVotingFeatures: false
},
{
type: 'Quests',
Expand All @@ -175,7 +186,8 @@ const mockOpenedAssessmentsOverviews: AssessmentOverview[] = [
story: 'sidequest-2.1',
xp: 3,
gradingStatus: GradingStatuses.none,
maxTeamSize: 2
maxTeamSize: 2,
hasVotingFeatures: false
},
{
type: 'Paths',
Expand All @@ -192,7 +204,8 @@ const mockOpenedAssessmentsOverviews: AssessmentOverview[] = [
story: null,
xp: 0,
gradingStatus: GradingStatuses.excluded,
maxTeamSize: 2
maxTeamSize: 2,
hasVotingFeatures: false
},
{
type: 'Others',
Expand All @@ -210,7 +223,8 @@ const mockOpenedAssessmentsOverviews: AssessmentOverview[] = [
xp: 3,
gradingStatus: GradingStatuses.none,
private: true,
maxTeamSize: 1
maxTeamSize: 1,
hasVotingFeatures: false
}
];

Expand All @@ -230,7 +244,8 @@ const mockClosedAssessmentOverviews: AssessmentOverview[] = [
story: 'mission-3',
xp: 800,
gradingStatus: GradingStatuses.grading,
maxTeamSize: 1
maxTeamSize: 1,
hasVotingFeatures: false
},
{
type: 'Quests',
Expand All @@ -247,7 +262,8 @@ const mockClosedAssessmentOverviews: AssessmentOverview[] = [
story: null,
xp: 500,
gradingStatus: GradingStatuses.none,
maxTeamSize: 1
maxTeamSize: 1,
hasVotingFeatures: false
},
{
type: 'Quests',
Expand All @@ -264,7 +280,8 @@ const mockClosedAssessmentOverviews: AssessmentOverview[] = [
story: null,
xp: 150,
gradingStatus: GradingStatuses.graded,
maxTeamSize: 1
maxTeamSize: 1,
hasVotingFeatures: false
},
{
type: 'Quests',
Expand All @@ -281,7 +298,8 @@ const mockClosedAssessmentOverviews: AssessmentOverview[] = [
story: null,
xp: 100,
gradingStatus: GradingStatuses.excluded,
maxTeamSize: 1
maxTeamSize: 1,
hasVotingFeatures: false
}
];

Expand Down
1 change: 1 addition & 0 deletions src/commons/profile/__tests__/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const assessmentConfigurations: AssessmentConfiguration[] = [
isManuallyGraded: false,
displayInDashboard: false,
hasTokenCounter: false,
hasVotingFeatures: false,
hoursBeforeEarlyXpDecay: 0,
earlySubmissionXp: 0
}));
Expand Down
Loading

0 comments on commit 7694ad4

Please sign in to comment.