diff --git a/code/web/services/Community/CampaignTable.php b/code/web/services/Community/CampaignTable.php index da4efbd124..cfdb790cc9 100644 --- a/code/web/services/Community/CampaignTable.php +++ b/code/web/services/Community/CampaignTable.php @@ -45,7 +45,7 @@ function launch() { foreach ($milestones as $milestone) { $milestoneComplete = $milestoneCompletionStatus[$milestone->id] ?? false; - $userProgress = MilestoneUsersProgress::getProgressByMilestoneId($milestone->id, $user->id); + $userProgress = MilestoneUsersProgress::getProgressByMilestoneId($milestone->id, $campaignId, $user->id); $totalGoals = CampaignMilestone::getMilestoneGoalCountByCampaign($campaignId, $milestone->id); $milestoneRewardGiven = MilestoneUsersProgress::getRewardGivenForMilestone($milestone->id, $user->id); diff --git a/code/web/services/Community/Dashboard.php b/code/web/services/Community/Dashboard.php index d14f3794cc..5b7c6a9e72 100644 --- a/code/web/services/Community/Dashboard.php +++ b/code/web/services/Community/Dashboard.php @@ -60,7 +60,7 @@ function launch() { $milestoneCompletionStatus = $userCampaign->checkMilestoneCompletionStatus(); foreach ($milestones as $milestone) { $milestoneComplete = $milestoneCompletionStatus[$milestone->id] ?? false; - $userProgress = CampaignMilestoneUsersProgress::getProgressByMilestoneId($milestone->id, $user->id); + $userProgress = CampaignMilestoneUsersProgress::getProgressByMilestoneId($milestone->id, $campaignId, $user->id); $totalGoals = CampaignMilestone::getMilestoneGoalCountByCampaign($campaign->id, $milestone->id); $milestoneRewardGiven = CampaignMilestoneUsersProgress::getRewardGivenForMilestone($milestone->id, $user->id); $userCampaigns[$campaign->id][$user->id]['milestones'][$milestone->id] = [ diff --git a/code/web/sys/Community/Campaign.php b/code/web/sys/Community/Campaign.php index 819ee7633b..cf260e6dcc 100644 --- a/code/web/sys/Community/Campaign.php +++ b/code/web/sys/Community/Campaign.php @@ -297,7 +297,7 @@ public static function getMilestoneRewards(int $campaignId, int $userId): array $userCampaign->campaignId = $campaignId; if ($userCampaign->find(true)) { - $milestoneProgress = CampaignMilestoneUsersProgress::getProgressByMilestoneId($milestone->id, $userId); + $milestoneProgress = CampaignMilestoneUsersProgress::getProgressByMilestoneId($milestone->id, $campaignId, $userId); $rewardGiven = (int)$milestoneProgress->rewardGiven; } @@ -455,7 +455,7 @@ public function getPastCampaigns(int $userId): array { // Update milestone details based on user progress foreach ($pastCampaignList[$campaign->id]->milestones as $milestone) { $milestoneProgress = CampaignMilestone::getMilestoneProgress($campaign->id, $userId, $milestone->id); - $milestone->userProgress = CampaignMilestoneUsersProgress::getProgressByMilestoneId($milestone->id, $userId); + $milestone->userProgress = CampaignMilestoneUsersProgress::getProgressByMilestoneId($milestone->id, $campaign->id, $userId); $milestone->isComplete = $milestoneCompletionStatus[$milestone->id] ?? false; $milestone->rewardGiven = CampaignMilestoneUsersProgress::getRewardGivenForMilestone($milestone->id, $userId); $milestone->progress = $milestoneProgress['progress']; diff --git a/code/web/sys/Community/CampaignMilestone.php b/code/web/sys/Community/CampaignMilestone.php index 79ef337254..4d3a4a802a 100644 --- a/code/web/sys/Community/CampaignMilestone.php +++ b/code/web/sys/Community/CampaignMilestone.php @@ -123,7 +123,7 @@ public static function getMilestoneProgress($campaignId, $userId, $milestoneId) $goal = $campaignMilestone->getMilestoneGoalCountByCampaign($campaignId, $milestoneId); //Number of completed goals for this milestone - $userCompletedGoalCount = $campaignMilestoneUsersProgress->getProgressByMilestoneId($milestoneId, $userId); + $userCompletedGoalCount = $campaignMilestoneUsersProgress->getProgressByMilestoneId($milestoneId, $campaignId, $userId); if ($goal > 0) { $progress = ($userCompletedGoalCount / $goal ) * 100; diff --git a/code/web/sys/Community/CampaignMilestoneUsersProgress.php b/code/web/sys/Community/CampaignMilestoneUsersProgress.php index 4c112a669d..d9b109ff82 100644 --- a/code/web/sys/Community/CampaignMilestoneUsersProgress.php +++ b/code/web/sys/Community/CampaignMilestoneUsersProgress.php @@ -4,14 +4,16 @@ class CampaignMilestoneUsersProgress extends DataObject public $__table = 'ce_campaign_milestone_users_progress'; public $id; public $userId; + public $ce_campaign_id; public $ce_milestone_id; public $progress; public $rewardGiven; - public static function getProgressByMilestoneId($milestoneId, $userId) { + public static function getProgressByMilestoneId($milestoneId, $campaignId, $userId) { $milestoneProgress = new Self(); $milestoneProgress->whereAdd('ce_milestone_id = ' . intval($milestoneId)); + $milestoneProgress->whereAdd('ce_campaign_id = ' . intval($campaignId)); $milestoneProgress->whereAdd('userId = ' . intval($userId)); $milestoneProgress->find(true); diff --git a/code/web/sys/Community/UserCampaign.php b/code/web/sys/Community/UserCampaign.php index 7ad400a4b8..10f19d382f 100644 --- a/code/web/sys/Community/UserCampaign.php +++ b/code/web/sys/Community/UserCampaign.php @@ -68,7 +68,7 @@ public function checkCompletionStatus() { $isComplete = true; foreach ($milestones as $milestone) { - $userProgress = CampaignMilestoneUsersProgress::getProgressByMilestoneId($milestone->id, $this->userId); + $userProgress = CampaignMilestoneUsersProgress::getProgressByMilestoneId($milestone->id, $this->campaignId, $this->userId); $goal = CampaignMilestone::getMilestoneGoalCountByCampaign($this->campaignId, $milestone->id); if ($userProgress < $goal) { @@ -85,7 +85,7 @@ public function checkMilestoneCompletionStatus() { foreach ($milestones as $milestone) { //User's progress for this milestone - $userProgress = CampaignMilestoneUsersProgress::getProgressByMilestoneId($milestone->id, $this->userId); + $userProgress = CampaignMilestoneUsersProgress::getProgressByMilestoneId($milestone->id, $this->campaignId, $this->userId); //Goal for this milestone $goal = CampaignMilestone::getMilestoneGoalCountByCampaign($this->campaignId, $milestone->id);