Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
104 changes: 88 additions & 16 deletions src/components/assessment/__tests__/__snapshots__/index.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,18 @@ exports[`Assessment page does not show attempt Button for upcoming assessments f
</Blueprint2.Popover>
</div>
</div>
<div className=\\"row listing-order\\">
<div className=\\"row listing-grade\\">
<h6>

Max Grade: 3000

</h6>
</div>
<div className=\\"row listing-xp\\">
<h6>

Max XP: 3000

</h6>
</div>
<div className=\\"row listing-description\\">
Expand All @@ -135,7 +144,7 @@ exports[`Assessment page does not show attempt Button for upcoming assessments f
<path d=\\"M8 0C3.58 0 0 3.58 0 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm0 14c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.69 6-6 6zm1-6.41V4c0-.55-.45-1-1-1s-1 .45-1 1v4c0 .28.11.53.29.71l2 2a1.003 1.003 0 0 0 1.42-1.42L9 7.59z\\" fillRule=\\"evenodd\\" />
</svg>
</Blueprint2.Icon>
Due: 18th June, 13:24
Opens at: 18th June, 13:24
</div>
</Text>
</div>
Expand Down Expand Up @@ -207,9 +216,18 @@ exports[`Assessment page does not show attempt Button for upcoming assessments f
</Blueprint2.Popover>
</div>
</div>
<div className=\\"row listing-order\\">
<div className=\\"row listing-grade\\">
<h6>
Max Grade: 3000

Grade: 2 / 3000

</h6>
</div>
<div className=\\"row listing-xp\\">
<h6>

XP: 1 / 1000

</h6>
</div>
<div className=\\"row listing-description\\">
Expand Down Expand Up @@ -302,9 +320,18 @@ exports[`Assessment page does not show attempt Button for upcoming assessments f
</Blueprint2.Popover>
</div>
</div>
<div className=\\"row listing-order\\">
<div className=\\"row listing-grade\\">
<h6>
Max Grade: 3000

Grade: 3 / 3000

</h6>
</div>
<div className=\\"row listing-xp\\">
<h6>

XP: 2 / 1000

</h6>
</div>
<div className=\\"row listing-description\\">
Expand Down Expand Up @@ -397,9 +424,18 @@ exports[`Assessment page does not show attempt Button for upcoming assessments f
</Blueprint2.Popover>
</div>
</div>
<div className=\\"row listing-order\\">
<div className=\\"row listing-grade\\">
<h6>
Max Grade: 3000

Grade: 4 / 3000

</h6>
</div>
<div className=\\"row listing-xp\\">
<h6>

XP: 3 / 1000

</h6>
</div>
<div className=\\"row listing-description\\">
Expand Down Expand Up @@ -600,9 +636,18 @@ exports[`Assessment page with multiple loaded missions renders correctly 1`] = `
</Blueprint2.Popover>
</div>
</div>
<div className=\\"row listing-order\\">
<div className=\\"row listing-grade\\">
<h6>

Max Grade: 3000

</h6>
</div>
<div className=\\"row listing-xp\\">
<h6>

Max XP: 3000

</h6>
</div>
<div className=\\"row listing-description\\">
Expand All @@ -621,7 +666,7 @@ exports[`Assessment page with multiple loaded missions renders correctly 1`] = `
<path d=\\"M8 0C3.58 0 0 3.58 0 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm0 14c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.69 6-6 6zm1-6.41V4c0-.55-.45-1-1-1s-1 .45-1 1v4c0 .28.11.53.29.71l2 2a1.003 1.003 0 0 0 1.42-1.42L9 7.59z\\" fillRule=\\"evenodd\\" />
</svg>
</Blueprint2.Icon>
Due: 18th June, 13:24
Opens at: 18th June, 13:24
</div>
</Text>
<NavLink to=\\"/academy/missions/0/0\\" activeClassName=\\"active\\" ariaCurrent=\\"true\\">
Expand Down Expand Up @@ -717,9 +762,18 @@ exports[`Assessment page with multiple loaded missions renders correctly 1`] = `
</Blueprint2.Popover>
</div>
</div>
<div className=\\"row listing-order\\">
<div className=\\"row listing-grade\\">
<h6>
Max Grade: 3000

Grade: 2 / 3000

</h6>
</div>
<div className=\\"row listing-xp\\">
<h6>

XP: 1 / 1000

</h6>
</div>
<div className=\\"row listing-description\\">
Expand Down Expand Up @@ -812,9 +866,18 @@ exports[`Assessment page with multiple loaded missions renders correctly 1`] = `
</Blueprint2.Popover>
</div>
</div>
<div className=\\"row listing-order\\">
<div className=\\"row listing-grade\\">
<h6>
Max Grade: 3000

Grade: 3 / 3000

</h6>
</div>
<div className=\\"row listing-xp\\">
<h6>

XP: 2 / 1000

</h6>
</div>
<div className=\\"row listing-description\\">
Expand Down Expand Up @@ -907,9 +970,18 @@ exports[`Assessment page with multiple loaded missions renders correctly 1`] = `
</Blueprint2.Popover>
</div>
</div>
<div className=\\"row listing-order\\">
<div className=\\"row listing-grade\\">
<h6>
Max Grade: 3000

Grade: 4 / 3000

</h6>
</div>
<div className=\\"row listing-xp\\">
<h6>

XP: 3 / 1000

</h6>
</div>
<div className=\\"row listing-description\\">
Expand Down
5 changes: 4 additions & 1 deletion src/components/assessment/assessmentShape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ export interface IAssessmentOverview {
category: AssessmentCategory
closeAt: string
coverImage: string
grade: number
id: number
maximumGrade: number
maxGrade: number
maxXp: number
openAt: string
title: string
shortSummary: string
status: AssessmentStatus
story: string | null
xp: number
}

export enum AssessmentStatuses {
Expand Down
21 changes: 18 additions & 3 deletions src/components/assessment/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -287,16 +287,31 @@ const makeOverviewCard = (
</div>
<div className="col-xs-9 listing-text">
{makeOverviewCardTitle(overview, index, setBetchaAssessment)}
<div className="row listing-order">
<h6>{`Max Grade: ${overview.maximumGrade}`}</h6>
<div className="row listing-grade">
<h6>
{' '}
{beforeNow(overview.openAt)
? `Grade: ${overview.grade} / ${overview.maxGrade}`
: `Max Grade: ${overview.maxGrade}`}{' '}
</h6>
</div>
<div className="row listing-xp">
<h6>
{' '}
{beforeNow(overview.openAt)
? `XP: ${overview.xp} / ${overview.maxXp}`
: `Max XP: ${overview.maxGrade}`}{' '}
</h6>
</div>
<div className="row listing-description">
<Markdown content={overview.shortSummary} />
</div>
<div className="listing-controls">
<Text className="listing-due-date">
<Icon className="listing-due-icon" iconSize={12} icon={IconNames.TIME} />
{`Due: ${getPrettyDate(overview.closeAt)}`}
{beforeNow(overview.openAt)
? `Due: ${getPrettyDate(overview.closeAt)}`
: `Opens at: ${getPrettyDate(overview.openAt)}`}
</Text>
{renderAttemptButton ? makeOverviewCardButton(overview) : null}
</div>
Expand Down
42 changes: 30 additions & 12 deletions src/mocks/assessmentAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@ const mockUnopenedAssessmentsOverviews: IAssessmentOverview[] = [
category: AssessmentCategories.Mission,
closeAt: '2048-06-18T05:24:26.026Z',
coverImage: 'https://fakeimg.pl/300/',
grade: 1,
id: 0,
maximumGrade: 3000,
maxGrade: 3000,
maxXp: 1000,
openAt: '2038-06-18T05:24:26.026Z',
title: 'An Odessey to Runes (Duplicate)',
shortSummary:
'This is a test for the UI of the unopened assessment overview. It links to the mock Mission 0',
status: AssessmentStatuses.not_attempted,
story: 'mission-1'
story: 'mission-1',
xp: 0
}
]

Expand All @@ -31,8 +34,10 @@ const mockOpenedAssessmentsOverviews: IAssessmentOverview[] = [
category: AssessmentCategories.Mission,
closeAt: '2048-06-18T05:24:26.026Z',
coverImage: 'https://fakeimg.pl/300/',
grade: 2,
id: 0,
maximumGrade: 3000,
maxGrade: 3000,
maxXp: 1000,
openAt: '2018-06-18T05:24:26.026Z',
title: 'An Odessey to Runes',
shortSummary: `
Expand All @@ -50,33 +55,40 @@ _doloremque laudantium_, totam rem aperiam, eaque ipsa quae ab illo inventore

`,
status: AssessmentStatuses.attempted,
story: 'mission-1'
story: 'mission-1',
xp: 1
},
{
category: AssessmentCategories.Mission,
closeAt: '2048-06-18T05:24:26.026Z',
coverImage: 'https://fakeimg.pl/350x200/?text=World&font=lobster',
grade: 3,
id: 1,
maximumGrade: 3000,
maxGrade: 3000,
maxXp: 1000,
openAt: '2018-07-18T05:24:26.026Z',
title: 'The Secret to Streams',
shortSummary:
'Once upon a time, Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin nec vulputate sapien. Fusce vel lacus fermentum, efficitur ipsum.',
status: AssessmentStatuses.attempting,
story: 'mission-2'
story: 'mission-2',
xp: 2
},
{
category: AssessmentCategories.Sidequest,
closeAt: '2048-06-18T05:24:26.026Z',
coverImage: 'https://fakeimg.pl/350x200/?text=Hello',
grade: 4,
id: 2,
maximumGrade: 3000,
maxGrade: 3000,
maxXp: 1000,
openAt: '2018-07-18T05:24:26.026Z',
title: 'A sample Sidequest',
shortSummary:
'Once upon a time, Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin nec vulputate sapien. Fusce vel lacus fermentum, efficitur ipsum.',
status: AssessmentStatuses.not_attempted,
story: 'sidequest-2.1'
story: 'sidequest-2.1',
xp: 3
}
]

Expand All @@ -85,27 +97,33 @@ const mockClosedAssessmentOverviews: IAssessmentOverview[] = [
category: AssessmentCategories.Mission,
closeAt: '2008-06-18T05:24:26.026Z',
coverImage: 'https://fakeimg.pl/350x200/ff0000/000',
grade: 5,
id: 3,
maximumGrade: 3000,
maxGrade: 3000,
maxXp: 1000,
openAt: '2007-07-18T05:24:26.026Z',
title: 'A closed Mission',
shortSummary:
'Once upon a time, Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin nec vulputate sapien. Fusce vel lacus fermentum, efficitur ipsum.',
status: AssessmentStatuses.submitted,
story: 'mission-3'
story: 'mission-3',
xp: 4
},
{
category: AssessmentCategories.Sidequest,
closeAt: '2008-06-18T05:24:26.026Z',
coverImage: 'https://fakeimg.pl/350x200/ff0000,128/000,255',
grade: 6,
id: 4,
maximumGrade: 3000,
maxGrade: 3000,
maxXp: 1000,
openAt: '2007-07-18T05:24:26.026Z',
title: 'A closed sidequest',
shortSummary:
'Once upon a time, Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin nec vulputate sapien. Fusce vel lacus fermentum, efficitur ipsum.',
status: AssessmentStatuses.submitted,
story: null
story: null,
xp: 5
}
]

Expand Down
8 changes: 0 additions & 8 deletions src/sagas/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,17 +316,9 @@ async function getAssessmentOverviews(tokens: Tokens): Promise<IAssessmentOvervi
* backend has property -> type: 'mission' | 'sidequest' | 'path' | 'contest'
* we have -> category: 'Mission' | 'Sidequest' | 'Path' | 'Contest'
*/

overview.category = capitalise(overview.type)
delete overview.type

/**
* backend has property maxGrade, we have property maximumGrade
*/

overview.maximumGrade = overview.maxGrade
delete overview.maxGrade

return overview as IAssessmentOverview
})
} else {
Expand Down