Skip to content

Commit b365da2

Browse files
committed
feat(app/quiz): go to related challenge
fixed #214
1 parent bba7458 commit b365da2

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/domain/quiz/widgets/quiz-limiter/QuizLimiter.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ const limitTypeMap = {
4141
[LimitType.Enrolled]: 'Please enroll a specific course or challenge first.',
4242
};
4343

44+
// FIXME: use a more precise way to judge instead
45+
function resolveCollectionName(linkedId) {
46+
const stringified = linkedId.toString();
47+
48+
return stringified.length > 3 && stringified.startsWith('2') ? 'challenges' : 'courses';
49+
}
50+
4451
function QuizLimiterWidget({
4552
id,
4653
limit = {},
@@ -86,7 +93,7 @@ function QuizLimiterWidget({
8693

8794
const handleConfirm = () => {
8895
if (type === LimitType.Enrolled) {
89-
router.push(`/learn/courses/${extra}`);
96+
router.push(`/learn/${resolveCollectionName(extra)}/${extra}`);
9097
} else if (type === LimitType.Wallet) {
9198
bindWallet(closeDialog);
9299
} else {

0 commit comments

Comments
 (0)