Any tips on how to create a button that indicates whether a task has been completed? For example: a member finishes reading a text and he marks the completion of the task. That way, when you log in you already know that you performed that task.
Hi Jr,
There are a number of ways you can accomplish this. You can create a collection that stores the data of the task that the current user that is logged in completes.
To get the information regarding the user who is logged in, take a look at the wix-users API here .
To store the task that has been completed, you will want to run a query using the wix-data API here to add the task information and user to a data collection.
You can also create a query that checks what tasks have been completed by the user and indicate that on the page so the user knows they have completed the task.
This is just one suggestion on how to do this with Corvid but I encourage you to explore different way that may work best with you after taking a look at the Corvid API Reference.
Best Regards,
Edward
Hello,
This is exactly what I was looking for. Thank you so much.
I’m way over my head with writing code for this and would really appreciate any help. To be honest, as you can probably tell by seeing my coding attempt below, I don’t really what I’m doing hehe. I’ve read several posts in the past couple of hours on this but still don’t have a clear direction.
My objective:
- Upon completion of a task, a user check marks the associated task checkbox
- This information gets updated to the database in the form of – “logged in user” has completed tasks 1,2,3,4,5,6,7 … out of 100
- This information then gets displayed in the form of a progress bar for the user to see
What I’ve done so far…
I’ve created a collection called ‘TaskCompletionStatus’ and have added the following fields:
Member Email:
Task Status: for taking in the user input from checkbox
Task Number: this is for the progress bar. Each checkbox will have a number associated with it. So if user has completed 15 out of 40 tasks, the progress bar will show this.
For getting the user information and inserting into the database, I have the following code which I know I’m messing up and would appreciate any help with this.
import wixUsers from ‘wix-users’ ;
import wixData from ‘wix-data’ ;
$w.onReady( function () {
let user = wixUsers.currentUser;
user.getEmail()
.then((email) => {
let userEmail = email;
});
});
export function day01task01_change(event) {
// when user clicks checkbox
let toInsert = {
“memberEmail” : “email” ,
“taskCompletionStatus” : “taskstatus” ,
“taskCompletionNumber” : “tasknumber” ,
};
wixData.insert( "TaskCompletionStatus" , toInsert)
.then((results) => {
let item = results;
})
. catch ((err) => {
let errorMsg = err;
});
}
Right now I can’t even get the database to populate, so I haven’t even began implementing the other steps for actually displaying updated information to the user.
Appreciate any help.
Thank you.