chg: [app:scores] Added completion timestamp
This commit is contained in:
parent
96d5b6d89e
commit
6814294e77
2 changed files with 26 additions and 11 deletions
17
exercise.py
17
exercise.py
|
@ -247,8 +247,9 @@ def get_completion_for_users():
|
|||
for task in exercise_status['tasks'].values():
|
||||
for user_id in completion_per_user.keys():
|
||||
completion_per_user[int(user_id)][exercise_status['uuid']][task['uuid']] = False
|
||||
for user_id in task['completed_by_user']:
|
||||
completion_per_user[int(user_id)][exercise_status['uuid']][task['uuid']] = True
|
||||
for entry in task['completed_by_user']:
|
||||
user_id = entry['user_id']
|
||||
completion_per_user[int(user_id)][exercise_status['uuid']][task['uuid']] = entry
|
||||
|
||||
return completion_per_user
|
||||
|
||||
|
@ -268,13 +269,17 @@ def get_score_for_task_completion(tasks_completion: dict) -> int:
|
|||
|
||||
|
||||
def mark_task_completed(user_id: int, exercise_uuid: str , task_uuid: str):
|
||||
if user_id not in db.EXERCISES_STATUS[exercise_uuid]['tasks'][task_uuid]['completed_by_user']:
|
||||
db.EXERCISES_STATUS[exercise_uuid]['tasks'][task_uuid]['completed_by_user'].append(user_id)
|
||||
is_completed = any(filter(lambda x: x['user_id'] == user_id, db.EXERCISES_STATUS[exercise_uuid]['tasks'][task_uuid]['completed_by_user']))
|
||||
if not is_completed:
|
||||
db.EXERCISES_STATUS[exercise_uuid]['tasks'][task_uuid]['completed_by_user'].append({
|
||||
'user_id': user_id,
|
||||
'time': time.time(),
|
||||
})
|
||||
|
||||
|
||||
def mark_task_incomplete(user_id: int, exercise_uuid: str , task_uuid: str):
|
||||
if user_id in db.EXERCISES_STATUS[exercise_uuid]['tasks'][task_uuid]['completed_by_user']:
|
||||
db.EXERCISES_STATUS[exercise_uuid]['tasks'][task_uuid]['completed_by_user'].remove(user_id)
|
||||
completed_without_user = list(filter(lambda x: x['user_id'] != user_id, db.EXERCISES_STATUS[exercise_uuid]['tasks'][task_uuid]['completed_by_user']))
|
||||
db.EXERCISES_STATUS[exercise_uuid]['tasks'][task_uuid]['completed_by_user'] = completed_without_user
|
||||
|
||||
|
||||
def get_progress():
|
||||
|
|
|
@ -99,11 +99,21 @@
|
|||
class="select-none cursor-pointer text-nowrap"
|
||||
@click="toggleCompleted(progress.exercises[exercise.uuid].tasks_completion[task.uuid], user_id, exercise.uuid, task.uuid)"
|
||||
>
|
||||
<FontAwesomeIcon
|
||||
:icon="progress.exercises[exercise.uuid].tasks_completion[task.uuid] ? faCheck : faTimes"
|
||||
:class="`text-xl ${progress.exercises[exercise.uuid].tasks_completion[task.uuid] ? 'dark:text-green-400 text-green-600' : 'dark:text-slate-500 text-slate-400'}`"
|
||||
/>
|
||||
<small :class="progress.exercises[exercise.uuid].tasks_completion[task.uuid] ? 'dark:text-green-400 text-green-600' : 'dark:text-slate-500 text-slate-400'"> (+{{ task.score }})</small>
|
||||
<span class="flex flex-col">
|
||||
<span>
|
||||
<FontAwesomeIcon
|
||||
:icon="progress.exercises[exercise.uuid].tasks_completion[task.uuid] ? faCheck : faTimes"
|
||||
:class="`text-xl ${progress.exercises[exercise.uuid].tasks_completion[task.uuid] ? 'dark:text-green-400 text-green-600' : 'dark:text-slate-500 text-slate-400'}`"
|
||||
/>
|
||||
<small :class="progress.exercises[exercise.uuid].tasks_completion[task.uuid] ? 'dark:text-green-400 text-green-600' : 'dark:text-slate-500 text-slate-400'"> (+{{ task.score }})</small>
|
||||
</span>
|
||||
<span class="text-sm leading-3">
|
||||
<span v-if="progress.exercises[exercise.uuid].tasks_completion[task.uuid].time">
|
||||
{{ (new Date(progress.exercises[exercise.uuid].tasks_completion[task.uuid].time * 1000)).toTimeString().split(' ', 1)[0] }}
|
||||
</span>
|
||||
<span v-else></span>
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
</td>
|
||||
<td class="border-b border-slate-100 dark:border-slate-700 text-slate-500 dark:text-slate-400 p-3">
|
||||
|
|
Loading…
Reference in a new issue