Update Test.vue
-front works - fix bonus points
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
<!-- Карточка текущего пользователя и лучшего в группе -->
|
||||
<div class="max-w-5xl mx-auto grid grid-cols-1 lg:grid-cols-2 gap-6 mb-8">
|
||||
<!-- Карточка текущего пользователя -->
|
||||
<div class="bg-white rounded-xl shadow-lg p-6 border-l-4 border-teal-800">
|
||||
<div class="bg-white rounded-xl shadow-lg p-6 border-l-4 border-teal-600">
|
||||
<h3 class="text-lg font-semibold text-gray-800 mb-4">Ваша позиция</h3>
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="flex items-center space-x-4">
|
||||
@@ -110,6 +110,10 @@
|
||||
<h2 class="text-xl font-bold text-white">
|
||||
{{ activeGroupLabel }} - Топ {{ currentLeaderboard.length }}
|
||||
</h2>
|
||||
<!-- Примечание о бонусах только для школьников -->
|
||||
<p v-if="activeGroup === 'LMS Schoolchild'" class="text-white text-opacity-90 text-sm mt-1">
|
||||
* Бонусные баллы рассчитываются как 1 балл за каждые 100 очков активности (максимум 10)
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- Список участников -->
|
||||
@@ -154,22 +158,22 @@
|
||||
</div>
|
||||
|
||||
<!-- Очки и бонусы -->
|
||||
<div class="flex items-center space-x-6">
|
||||
<!-- Бонусы -->
|
||||
<div class="text-center">
|
||||
<div class="text-xs text-gray-500 mb-1">Бонус</div>
|
||||
<div class="flex items-center space-x-1">
|
||||
<span class="text-lg font-bold text-orange-500">{{ user.bonus }}</span>
|
||||
<span class="text-orange-400">⭐</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center space-x-6">
|
||||
<!-- Бонусы (только для школьников) -->
|
||||
<div v-if="user.isSchoolchild && user.bonus > 0" class="text-center">
|
||||
<div class="text-xs text-gray-500 mb-1">Бонус</div>
|
||||
<div class="flex items-center space-x-1">
|
||||
<span class="text-lg font-bold text-orange-500">{{ user.bonus }}</span>
|
||||
<span class="text-orange-400">⭐</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Очки -->
|
||||
<div class="text-center">
|
||||
<div class="text-xs text-gray-500 mb-1">Очки</div>
|
||||
<div class="text-xl font-bold text-gray-800">{{ user.points }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Очки -->
|
||||
<div class="text-center">
|
||||
<div class="text-xs text-gray-500 mb-1">Очки</div>
|
||||
<div class="text-xl font-bold text-gray-800">{{ user.points }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -345,9 +349,9 @@ function getGroupButtonClass(role) {
|
||||
|
||||
function getGroupGradientClass(role) {
|
||||
const classes = {
|
||||
'LMS Student': 'from-teal-300 to-teal-400',
|
||||
'Course Creator': 'from-teal-500 to-teal-600',
|
||||
'LMS Schoolchild': 'from-teal-100 to-teal-200'
|
||||
'LMS Student': 'from-teal-400 to-teal-500',
|
||||
'Course Creator': 'from-teal-600 to-teal-700',
|
||||
'LMS Schoolchild': 'from-teal-200 to-teal-300'
|
||||
}
|
||||
return classes[role] || 'from-blue-500 to-blue-600'
|
||||
}
|
||||
@@ -370,6 +374,17 @@ function getGroupStats(role) {
|
||||
}
|
||||
}
|
||||
|
||||
function calculateLeaderboard() {
|
||||
if (!logsResource.data) return
|
||||
|
||||
const pointsMap = {}
|
||||
|
||||
// Считаем сумму очков для каждого пользователя
|
||||
logsResource.data.forEach(log => {
|
||||
if (!pointsMap[log.user]) pointsMap[log.user] = 0
|
||||
pointsMap[log.user] += log.points
|
||||
})
|
||||
|
||||
function calculateLeaderboard() {
|
||||
if (!logsResource.data) return
|
||||
|
||||
@@ -396,13 +411,23 @@ function calculateLeaderboard() {
|
||||
|
||||
if (!hasValidRole) return null
|
||||
|
||||
// Пропускаем пользователей с отрицательными или нулевыми баллами
|
||||
if (pointsMap[user] < 0) return null
|
||||
|
||||
// Определяем является ли пользователь школьником
|
||||
const isSchoolchild = u.roles.includes('LMS Schoolchild')
|
||||
|
||||
// Вычисляем бонус только для школьников
|
||||
const bonus = isSchoolchild ? Math.min(Math.floor(pointsMap[user] / 100), 10) : 0
|
||||
|
||||
return {
|
||||
user,
|
||||
points: pointsMap[user],
|
||||
full_name: u.full_name,
|
||||
username: u.email?.split('@')[0] || user.split('@')[0],
|
||||
roles: u.roles || [],
|
||||
bonus: Math.min(Math.floor(pointsMap[user] / 100), 10)
|
||||
bonus: bonus,
|
||||
isSchoolchild: isSchoolchild // Добавляем флаг для удобства
|
||||
}
|
||||
})
|
||||
.filter(user => user !== null)
|
||||
|
||||
Reference in New Issue
Block a user