RoleBasedMultipliers - IEEE-Team-3/map GitHub Wiki

Overview

Role-based multipliers allow users with specific roles to earn more points than others. For example, team leaders or admins may earn double points for tasks or achievements due to their increased responsibility.

Role-Based Point Multiplier System

  • Admin: 2x points for task completion and achievements.
  • Team Leader: 1.5x points for task completion and achievements.
  • Regular User: Standard points, no multiplier.
  • Contributor: 1.2x points for submitting extra tasks.

Example Scenarios

  1. An Admin completes a task worth 10 points → Admin gets 20 points.
  2. A Team Leader completes a task worth 10 points → Team Leader gets 15 points.
  3. A Regular User completes a task worth 10 points → User gets 10 points.

Example Backend Logic

function getMultiplierForRole(role) {
  switch (role) {
    case 'admin':
      return 2;
    case 'team-leader':
      return 1.5;
    case 'contributor':
      return 1.2;
    default:
      return 1;
  }
}

function assignRoleBasedPoints(user, taskPoints) {
  const multiplier = getMultiplierForRole(user.role);
  const pointsToAward = taskPoints * multiplier;
  assignPoints(user._id, pointsToAward, 'task', 'Completed task');
}
⚠️ **GitHub.com Fallback** ⚠️