Skip to content

Badge System-Feature #426

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

Open
janareddyc7 opened this issue Jan 17, 2025 · 33 comments
Open

Badge System-Feature #426

janareddyc7 opened this issue Jan 17, 2025 · 33 comments
Assignees
Labels
App This feature is related to the app enhancement New feature or request large this feature is a large feature up next User suggestion user This ticket is related to a user within the application

Comments

@janareddyc7
Copy link

  1. Milestone Badges and Achievements:
    Answer 50 Questions Badge: A badge that users receive after answering 50 questions, showcasing their commitment and engagement. You can create different badges for different milestones (e.g., 100, 500, 1000 questions answered).
    Streak Badges: Users earn badges for consistent activity, such as answering questions for 7 days straight, completing challenges daily for a week, etc.
    Speciality Badges: Based on the type of questions answered, such as “Algorithms Pro,” “Frontend Specialist,” or “Python Enthusiast.” These would be unlocked by answering a certain number of questions in a specific category.
    Challenge Completion Badges: For completing specific coding challenges, users could earn badges that recognize their success, e.g., “Algorithm Master” or “Full Stack Guru” for completing a particular challenge type.
  2. Tiered Reward System:
    Bronze, Silver, Gold Tiers: Reward users with tier-based achievements. For example:
    Bronze: Answer 50 questions, complete 5 challenges.
    Silver: Answer 200 questions, achieve a 10-day streak.
    Gold: Answer 500 questions, win a monthly competition, or complete 50 challenges.

I can implement this

@Logannford
Copy link
Collaborator

@janareddyc7 these are great ideas! We have thought about implementing this here: #260

Is this something you'd like to see in the near future? I can start developing this very soon if that's the case? I would need to scope out schema changes, different levels etc so I am happy to have some conversations with you on what you feel would be the best way to do this 😄

@Logannford Logannford added enhancement New feature or request App This feature is related to the app user This ticket is related to a user within the application large this feature is a large feature labels Jan 17, 2025
@janareddyc7
Copy link
Author

i wanted to add it in the schema then create a model badge and then pass it out and then creating a seed.js for it and then creating a api endpoint followed by frontend logic

@janareddyc7
Copy link
Author

model Badge {
id Int @id @default(autoincrement())
name String
description String
type String // e.g., "Milestone", "Streak",
iconUrl String
}
this could be possible

@janareddyc7
Copy link
Author

do you want to add schema changes

@Logannford
Copy link
Collaborator

@janareddyc7 that's a good shout - maybe we could use server actions over API endpoints?

also that schema looks great - maybe we could change it slightly to match the current style guide:

model Badge {
    uid             String   @id @default(uuid())
    createdAt       DateTime @default(now())
    updatedAt       DateTime @updatedAt
    name String
    description String
    type String // e.g., "Milestone", "Streak",
    iconUrl String
}

I suppose we should also be adding relations to the user? this way if we ever need to filter the leaderboard page by badge in the future it would be really simple? 🤔

@Logannford
Copy link
Collaborator

do you want to add schema changes

yeah sure thing, let me change those and I will let you know once they've been done!

@janareddyc7
Copy link
Author

sure

@janareddyc7
Copy link
Author

model Achievement {
id Int @id @default(autoincrement())
userId Int
badgeId Int
unlockedAt DateTime @default(now())

user User @relation(fields: [userId], references: [id])
badge Badge @relation(fields: [badgeId], references: [id])
} so this could be backbone for achivement and for the bade

const badges = [
{ name: 'Answer 50 Questions', description: 'Milestone badge for answering 50 questions', type: 'Milestone', iconUrl: '/icons/50-questions.png' },
{ name: '7-Day Streak', description: 'Answer questions 7 days in a row', type: 'Streak', iconUrl: '/icons/7-day-streak.png' },
{ name: 'Algorithms Pro', description: 'Answer 50 algorithm-related questions', type: 'Specialty', iconUrl: '/icons/algorithms-pro.png' },
// Add more badges here
]; i think this good be good in a seed.js

@Logannford
Copy link
Collaborator

what do you think of this?

enum BadgeType {
    STREAK
    QUESTION_ANSWERED
    QUESTION_CORRECT
    TIME_TAKEN
    LEADERBOARD_POSITION
}

model Badge {
    uid String @id @default(uuid())
    createdAt DateTime @default(now())
    updatedAt DateTime @updatedAt

    name String
    description String

    imageUrl String

    type BadgeType

    // what the user needs to do to earn the badge
    requirements String

    // the achievements that have been earned for this badge
    achievements Achievement[]
}

model Achievement {
    uid String @id @default(uuid())
    createdAt DateTime @default(now())
    updatedAt DateTime @updatedAt

    badgeUid String
    badge Badge @relation(fields: [badgeUid], references: [uid], onDelete: Cascade, onUpdate: Cascade)

    // the user who earned the badge
    userUid String
    user Users @relation(fields: [userUid], references: [uid], onDelete: Cascade, onUpdate: Cascade)

   unlockedAt DateTime
}

model Users {
  // existing fields 

  // the user's achievements
  achievements Achievement[]
}

@janareddyc7
Copy link
Author

umm LEADERBOARD_POSITION could be tied to specific times or dynamic data. probably

enum BadgeType {
STREAK
QUESTION_ANSWERED
QUESTION_CORRECT
TIME_TAKEN
LEADERBOARD_POSITION
}

model Badge {
uid String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt

name String
description String
imageUrl String
type BadgeType

requirements Json // store as json

achievements Achievement[]
}

model Achievement {
uid String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt

badgeUid String
badge Badge @relation(fields: [badgeUid], references: [uid], onDelete: Cascade, onUpdate: Cascade)

userUid String
user Users @relation(fields: [userUid], references: [uid], onDelete: Cascade, onUpdate: Cascade)

unlockedAt DateTime
status String // Example: 'active', 'completed'
progress Int // Track progress towards completion
}

model Users {
uid String @id @default(uuid())
name String
email String @unique
password String

achievements Achievement[] // User's earned achievements
}
this

@Logannford
Copy link
Collaborator

that looks perfect @janareddyc7 . Let me get that in, run a migration on it and get it merged!

@janareddyc7
Copy link
Author

sure

@janareddyc7 janareddyc7 changed the title Badge System-Feature Came up twith these Badge System-Feature Jan 18, 2025
@Logannford
Copy link
Collaborator

pr here for the schema #427

@janareddyc7
Copy link
Author

ok

@janareddyc7
Copy link
Author

logic in application backend to track users' progress towards badges and unlock them next right

@janareddyc7
Copy link
Author

if i can can i add more badge types to the schema a lot more for users to exprience

@Logannford
Copy link
Collaborator

@janareddyc7 yeah that's right - we will have to ensure when a user answers a question we update their achievement appropriately

@Logannford
Copy link
Collaborator

if i can can i add more badge types to the schema a lot more for users to exprience

yep go for it! I was thinking it would also be great to have a 'misc' badge type - we can have badges such as 'open-source contributing' and more along those lines

@janareddyc7
Copy link
Author

sure im in a class right now i will get the code to later

@Logannford
Copy link
Collaborator

@janareddyc7 not a problem! No rush, if you can't pick it up for any reason, just let me know and I can finish it off 😄

@janareddyc7
Copy link
Author

janareddyc7 commented Jan 18, 2025

Spent some time herer

`enum BadgeCategory {
LOGIN // Login-related badges
STREAK // Streak-based achievements
QUESTION // Questions answered or correctness-based badges
TIME_BASED // Speed achievements (time-limited completions)
LEADERBOARD // Leaderboard and ranking-related badges
CATEGORY // Expertise in specific categories or topics
DIVERSITY // Cross-skill or multi-category achievements
MILESTONE // Major platform milestones
ENGAGEMENT // Participation in events or community interactions
CONTRIBUTION // Code contributions, reviews, or open-source
SPECIAL // Special or rare achievements
EVENT // Event-based badges
COMMUNITY // Contributions to forums, mentoring, or team collaborations
TEAM // Team-based achievements
CHALLENGE // Completion of specific challenges or tasks
SOCIAL // Social interaction-based badges
LEARNING // Knowledge acquisition badges
CREATIVE // Creative content or innovative contributions
SUPPORT // Helping or support-based achievements
BUG_HUNTER // Reporting or resolving bugs
SUSTAINABILITY // Achievements tied to green initiatives
DISCOVERY // Finding or uncovering hidden aspects of the platform
EXPLORATION // Exploring new topics, categories, or features
EXPERTISE // Mastery in specialized skills or domains
GAMIFICATION // Game-based achievements (e.g., quests, levels)
COLLABORATION // Working with teams, communities, or co-authors
INNOVATION // Inventing or contributing new ideas
ADVENTURE // Achievements tied to gamified exploration or quests
LIFETIME // Lifetime achievements and legacy awards
HISTORICAL // Achievements tied to past events or milestones
VETERAN // Long-term user or loyalty-based badges
}

enum BadgeSubType {
FIRST // First-time achievements
STREAK_SHORT // Short-term streaks (e.g., 7 days)
STREAK_MEDIUM // Medium-term streaks (e.g., 30 days)
STREAK_LONG // Long-term streaks (e.g., 90 days)
STREAK_ULTRA // Ultra-long streaks (e.g., 365 days)
QUANTITY_SMALL // Small milestones (e.g., 10 questions)
QUANTITY_MEDIUM // Medium milestones (e.g., 100 questions)
QUANTITY_LARGE // Large milestones (e.g., 500 questions)
QUANTITY_ULTRA // Massive milestones (e.g., 1,000+ questions)
QUALITY // Performance or accuracy-based achievements
QUALITY_PERFECT // Perfect performance or flawless achievements
SPEED_SHORT // Tasks completed within a short timeframe
SPEED_LONG // Long-duration tasks or challenges
RANK_GLOBAL // Achievements for global rankings
RANK_LOCAL // Achievements for local/community rankings
RANK_SPECIAL // Achievements tied to special ranking scenarios
VARIETY_BASIC // Basic diversity achievements (e.g., 3 categories)
VARIETY_INTERMEDIATE // Intermediate diversity achievements (e.g., 5 categories)
VARIETY_ADVANCED // Advanced diversity (e.g., 10+ categories)
PARTICIPATION_BASIC // Basic participation milestones
PARTICIPATION_ADVANCED // Advanced participation milestones
CONTRIBUTION_CODE // Achievements for coding-related contributions
CONTRIBUTION_DOCS // Achievements for documentation writing
CONTRIBUTION_MENTORING // Mentorship and reviews
CONTRIBUTION_REVIEW // For peer-review or code reviews
CONTRIBUTION_TESTS // For test case contributions
SOCIAL_LIKES // Gaining likes or positive feedback
SOCIAL_SHARES // Sharing content or achievements
SOCIAL_COMMENTS // Engagement through comments or interactions
BUG_REPORTING // Reporting issues or bugs
BUG_FIXING // Resolving bugs or issues
BUG_HUNTER_MASTER // Resolving 100+ critical issues
LEARNING_BEGINNER // Completing beginner-level tutorials
LEARNING_INTERMEDIATE // Completing intermediate-level tutorials
LEARNING_ADVANCED // Completing advanced-level tutorials
LEARNING_MASTER // Mastering a course or subject
CREATIVE_PROJECT // Submitting creative projects or innovations
CREATIVE_MASTERPIECE // Recognized as outstanding creative content
EVENT_ATTENDANCE // Attending events or sessions
EVENT_ORGANIZATION // Organizing events or workshops
EVENT_HOSTING // Hosting major events
TEAMWORK_BASIC // Basic team collaborations
TEAMWORK_ADVANCED // Advanced team contributions
TEAM_LEADERSHIP // Leading a team or project
EXPLORATION_BASIC // Exploring basic platform features
EXPLORATION_ADVANCED // Discovering advanced features or tools
DISCOVERY_HIDDEN // Uncovering hidden platform features
GAMIFICATION_LEVELS // Reaching levels in gamified systems
GAMIFICATION_QUESTS // Completing special quests or challenges
MISC // Miscellaneous or rare achievements
}

enum CompletionStatus {
INCOMPLETE
COMPLETED
}

model Badge {
uid String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
name String // Name of the badge
description String // Description of what the badge represents
imageUrl String // URL of the badge icon/image
category BadgeCategory // High-level category of the badge
subType BadgeSubType // Subtype or variation of the badge
requirements Json // JSON for badge criteria (e.g., milestones, streaks, etc.)
achievements Achievement[] // Links to achievements for users
}

model Achievement {
uid String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
badgeUid String
badge Badge @relation(fields: [badgeUid], references: [uid], onDelete: Cascade, onUpdate: Cascade)
userUid String
user Users @relation(fields: [userUid], references: [uid], onDelete: Cascade, onUpdate: Cascade)
unlockedAt DateTime? // Date the badge was unlocked
status CompletionStatus @default(INCOMPLETE) // Current completion status
progress Int @default(0) // Tracks user progress (e.g., 40/100 questions answered)
}`

@janareddyc7
Copy link
Author

let me know about it

@Logannford
Copy link
Collaborator

@janareddyc7 I love all of these. You've thought of some really good ones there. I like it! 🙌

@Logannford
Copy link
Collaborator

I see there is a lot there (which is not a bad thing), I reckon we start off by adding these enums, but only implementing the logic for some? Otherwise we'll be here for weeks!

What do you think of some of the first ones we could add in, @janareddyc7 ?

@janareddyc7
Copy link
Author

we could do open source misc and the question types like 10 questions abadge and the speed contribution and first time login ive acually added a bit uncessary given the feature is not avalable like teams i think we can go ahead with those ive mentioned

@Logannford
Copy link
Collaborator

Yeah, i'm happy with that, i'll just sum them up below:

  • number of question badges
  • login badges
  • question type
  • speed contribution
  • misc badges

🚀

@janareddyc7
Copy link
Author

enum BadgeCategory {
LOGIN // Login-related badges
STREAK // Streak-based achievements
MILESTONE // Major platform milestones
ENGAGEMENT // Participation in events or community interactions
CONTRIBUTION // Code contributions, reviews, or open-source
}

enum BadgeSubType {
// LOGIN
FIRST // First-time login or account activation
STREAK_SHORT // Short-term login streak (e.g., 7 days)
STREAK_MEDIUM // Medium-term login streak (e.g., 30 days)
STREAK_LONG // Long-term login streak (e.g., 90 days)

// STREAK
STREAK_SHORT // Short-term streaks (e.g., 7 days)
STREAK_MEDIUM // Medium-term streaks (e.g., 30 days)
STREAK_LONG // Long-term streaks (e.g., 90 days)
STREAK_ULTRA // Ultra-long streaks (e.g., 365 days)

// MILESTONE
QUANTITY_SMALL // Small milestones (e.g., 10 tasks)
QUANTITY_MEDIUM // Medium milestones (e.g., 100 tasks)
QUANTITY_LARGE // Large milestones (e.g., 500 tasks)
MILESTONE_VETERAN // Long-term engagement (e.g., 1 year)

// ENGAGEMENT
PARTICIPATION_BASIC // Basic participation (e.g., 1 event)
PARTICIPATION_ADVANCED // Advanced participation (e.g., 5 events)

// CONTRIBUTION
CONTRIBUTION_CODE // Code contributions
CONTRIBUTION_DOCS // Documentation contributions
CONTRIBUTION_MENTORING // Providing mentorship
CONTRIBUTION_REVIEW // Reviewing or peer reviewing code or content
BUG_REPORTING // Reporting bugs
BUG_FIXING // Fixing bugs

// EXPERTISE
QUALITY
QUALITY_PERFECT
EXPERTISE_CATEGORY

}

model Badge {
uid String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
name String // Name of the badge
description String // Badge description
imageUrl String // URL of the badge icon/image
category BadgeCategory // High-level category of the badge
subType BadgeSubType // Subtype or variation (e.g., Streak, Milestone)
requirements Json // Criteria (e.g., milestones, streaks, etc.)
}

model Achievement {
uid String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
badgeUid String
badge Badge @relation(fields: [badgeUid], references: [uid], onDelete: Cascade, onUpdate: Cascade)
userUid String
user Users @relation(fields: [userUid], references: [uid], onDelete: Cascade, onUpdate: Cascade)
unlockedAt DateTime? // Date the badge was unlocked
status CompletionStatus @default(INCOMPLETE)
progress Int @default(0) // Tracks progress, e.g., 50/100 tasks
}

enum CompletionStatus {
INCOMPLETE
COMPLETED
}
i think this is better

@janareddyc7
Copy link
Author

try to adjust to your needs

@Logannford
Copy link
Collaborator

@janareddyc7 love it, definitely feels like the right amount of badge for this to initially go in 🙌

@janareddyc7
Copy link
Author

sure

@janareddyc7
Copy link
Author

what about the images of the badges

@Logannford
Copy link
Collaborator

@janareddyc7 yeah good thought - maybe we can not add them in for MVP and add them later on? feels like some icons will need to be designed which could take a while

@janareddyc7
Copy link
Author

ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
App This feature is related to the app enhancement New feature or request large this feature is a large feature up next User suggestion user This ticket is related to a user within the application
Projects
None yet
Development

No branches or pull requests

2 participants