0

I'm trying to make gamification Q&A platform where users can earn xp and level up with doing some tasks given by system.

Requirements

  • When user level up, new tasks must given this user and user earns xp for completing each given task.
  • If user level up and has still some tasks from previous level, user can do prev tasks with new ones.

My Db Design

Tasks

id | xp | level

id : task id

xp : xp amount

level: lower limit to show this task

user_tasks

user_id | task_id | compeleted | created_at

From this design I can handle which tasks user have or will have.

Problem

How can I check task if completed or not ? Let's say one task is that " Ask 5 questions and earn 50 xp ". How can I check that ? This is only one example. I need a dynamic db design and I can't create it. How games specially MMORG games handle this stiuation ?

Thanks for any advice.

Abraam
  • 13
  • 1
  • 3

1 Answers1

0

Let's say

  • Every User has many tasks (completed/uncompleted).
  • A single task has Xp (amount).
  • A task has task_details

Now (e.g )

if xp_of_user > 10 then user_level = 1, 
if xp_of_user > 20 then user_level = 2, 

and so on

(or any criteria you decide.)

Ask 5 questions to earn 50 xp

You need to think in terms of tasks now. Assume that answering 5 questions is a single task worth 50 xp. You can define task_definition table which define your task specification for example 5 questions, watching 2 videos, running through survey forms or any.

How can I check task if completed or not ?

You already created a completed (boolean) field which will help you in this. If you are asking about how to know if the user has answered all the questions ? then that must be done by that specific form or place where you are conducting the questions. That form or process will be responsible for updating your task table.

Community
  • 1
  • 1
DivineCoder
  • 702
  • 5
  • 11
  • `task_definition` table is a interesting idea. Can you give some details inside of it ? What columns should it have ? – Abraam Jul 23 '16 at 01:49
  • Yes I create completed column but I need to check if user accomplish this task at each question added on database whatever user have given task or not. What do you mean "spesific form" ? – Abraam Jul 23 '16 at 01:51