Skip to content

Commit 7b4a1af

Browse files
authored
Merge pull request #206 from PROCOLLAB-github/dev
Изменена система начисления баллов
2 parents 3d9d1b9 + e317f17 commit 7b4a1af

6 files changed

Lines changed: 32 additions & 21 deletions

File tree

apps/progress/mapping.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@
1717

1818

1919
class AdditionalPoints(Enum):
20-
MONTH = 10
21-
SKILL = 50
20+
MONTH = 0
21+
SKILL = 20

apps/questions/mapping.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77

88
class TypeQuestionPoints(Enum):
9-
INFO_SLIDE: int = 5
10-
QUESTION_SINGLE_ANSWER: int = 5
11-
QUESTION_WRITE: int = 5
12-
QUESTION_CONNECT: int = 5
13-
QUESTION_EXCLUDE: int = 5
9+
INFO_SLIDE: int = 20
10+
QUESTION_SINGLE_ANSWER: int = 20
11+
QUESTION_WRITE: int = 20
12+
QUESTION_CONNECT: int = 20
13+
QUESTION_EXCLUDE: int = 20
1414
QUESTION_WO_POINTS: int = 0
1515

1616

apps/questions/services/check_questions_answers.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,18 +137,23 @@ def _create_tast_obj_result(
137137
correct_answer: bool = True,
138138
):
139139
"""
140-
Формирование результата.
141-
Если навык Task бесплатный, то без поинтов.
140+
Формирование результата выполнения задачи:
141+
- 80 / количество задач в навыке
142+
- 0 баллов, если задача бесплатная
142143
"""
143144
if self.request_task_object.task.free_access:
144-
point_type = TypeQuestionPoints.QUESTION_WO_POINTS
145+
points = 0
146+
else:
147+
skill = self.request_task_object.task.skill
148+
tasks_count = skill.tasks.count() or 1 # защита от деления на 0
149+
points = round(80 / tasks_count)
145150

146-
TaskObjUserResult.objects.create_user_result(
147-
self.request_task_object.id,
148-
self.request_profile_id,
149-
point_type,
151+
TaskObjUserResult.objects.create(
152+
task_object=self.request_task_object,
153+
user_profile_id=self.request_profile_id,
150154
text=text,
151155
correct_answer=correct_answer,
156+
points_gained=points,
152157
)
153158

154159
def _delete_self_counter(self):

apps/tests/courses_tests/test_courses_response.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ class TestTaskResultPathResponse:
285285
OLD_SUB_NEXT_TASK_ID: int = 2
286286
NEW_SUB_PERCENT_PROGRESS: int = 50
287287
OLD_SUB_PERCENT_PROGRESS: int = 13
288-
POINTS_GAINED: int = 5
288+
POINTS_GAINED: int = 20
289289
DONE_CORRECT: int = 1
290290

291291
@pytest.mark.usefixtures("full_filled_published_skill")
@@ -540,7 +540,9 @@ def test_task_of_skill_new_sub_full_done(self, api_auth_with_sub_client: APIClie
540540
assert response_dct["stats_of_weeks"][0]["is_done"] is True, (
541541
"Засчитало неделю неверно."
542542
)
543-
assert response_dct["stats_of_weeks"][0]["done_on_time"] is True, (
543+
# Значение изменено на False:
544+
# система больше не учитывает бонусные баллы за месяц.
545+
assert response_dct["stats_of_weeks"][0]["done_on_time"] is False, (
544546
"Засчитало неделю неверно."
545547
)
546548
assert response_dct["tasks"][0]["status"] is True, "Засчитало задачу неверно."

apps/tests/fixtures/skill_answers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,19 @@ def skill_three_users_answers(
2929
TaskObjUserResult.objects.create(
3030
task_object_id=task_obj_idx,
3131
user_profile=user_admin_with_trial_sub.profiles,
32-
points_gained=5
32+
points_gained=20
3333
)
3434
for task_obj_idx in range(1, 3):
3535
TaskObjUserResult.objects.create(
3636
task_object_id=task_obj_idx,
3737
user_profile=user_staff_with_trial_sub.profiles,
38-
points_gained=5
38+
points_gained=20
3939
)
4040

4141
TaskObjUserResult.objects.create(
4242
task_object_id=1,
4343
user_profile=user_with_trial_sub.profiles,
44-
points_gained=5
44+
points_gained=20
4545
)
4646

4747

apps/tests/progress_tests/test_progress_response.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class TestProgressProfileResponse:
4848
Тесты пути: `/progress/profile/`
4949
"""
5050

51-
POINTS_IN_PROFILE: int = 5
51+
POINTS_IN_PROFILE: int = 20
5252
SKILL_PERCENT_DONE: int = 13
5353

5454
def test_progress_profile_new_sub_full_data(self, api_auth_with_sub_client: APIClient):
@@ -131,7 +131,7 @@ class TestUserScoreRating:
131131
Тесты пути: `/progress/user-rating/?time_frame=...`
132132
"""
133133

134-
SINGLE_SCORE_COUNT = 5
134+
SINGLE_SCORE_COUNT = 20
135135

136136
@pytest.mark.parametrize("time_frame", ("last_day", "last_month", "last_year"))
137137
def test_empty_data_without_answers(self, time_frame: str, api_auth_with_sub_client: APIClient):
@@ -169,7 +169,11 @@ def test_free_single_answer_by_new_sub(self, time_frame: str, api_auth_with_sub_
169169
def test_user_rating_with_different_roles(self, time_frame: str, api_auth_with_sub_client: APIClient):
170170
"""Все ответы даны в 1 время, таймлайн не решает, рейтинг по дате должен быть одинаковым."""
171171
response = api_auth_with_sub_client.get(constants.USER_SCORE_RATING_PATH + f"?time_frame={time_frame}")
172+
print("1"*100)
173+
print(response)
172174
response_dct = response.json()
175+
print("1"*100)
176+
print(response_dct)
173177
assert (
174178
response_dct["count"] == 1
175179
), "В рейтинге должeн быть 1 пользователь (Стафф и админ не должны отображаться)"

0 commit comments

Comments
 (0)