Hello guys!
I need to create a condition to check if the Question is correct or not, comparing the Answer given by the student and the correct answer defined by the Adm when the Question option was created.
I mean I have to create a condition to check if both attributes sides are exaclty, is that possible or do I have to create a SQL Query ? I am attaching a screen of my preparation, I hope it helps to explain what I need.
Thanks in advance
Thiago
Hi guys! Following the explanation from my colleagues above, I have created this attribute which says when the student answer is the same as the correct answer. So in this new attribute, a Question is only Correct when all the rows are TRUE.
1 - Here's the New Attribute (AnswerByOptionCorrect), as Gabriel have suggested me
2 - I had to create a bit of logic, because new answers (AnswerId = NULL) starts with Answer.OptionId NULL and I noticed that the new attribute was working only for existing Answers with assigned OptionId , which is created on the very first time CheckBox OnChange.
So I had to create a For Each after the Prep to check if it is a new Answer, and if yes, to create it with the respective OptionId, before starts the CheckBox OnChange logic.
Then I created this logic on the CheckBox OnChange action to verify if have a False inside the new attribute
It works for me, now my next step is to register it in a new Entity to create the Score logic!
Feel free to comment and suggest another solutions or to point something I did wrongly here. I am newbie and all the advices and learning are welcome for me!
Cheers
Hi Thiago, if I understood you will need to JOIN, between over the same Table, and then you will able to add a filter on Option1 or/and Option_2 table.
Best Regards
Paulo Ricardo
PAULO RICARDO FAGUNDES JUNIOR wrote:
Hi Paulo, thanks for your reply!
I already have this done. My question is how to create a condition or logic to check if the answer side is exaclty the same as the options correct answer side, if yes, the question is registered as Correct, otherwise Incorrect.
Cheers !
Thiago Da Rocha wrote:
That's good, I'm glad you can done it. Could you mark the answer like a solution?
Thanks
Hi Paulo!
I meant that I already have the JOIN done. What I am trying to figure out is how can I create a condition to ask Outsystem to check two attributes in a Entity exactly in another with the same Id and Data Type
In this example, Answer. OptionId and Answer.IsAnswer with Option.Id and Option.IsCorrect.
To my question be correct all the answers.optionId should be exactly as the right side
You can add a new attribute to compare both Option.IsCorrect and Answer.IsAnswer and work with it to figure it out if everything matches. You can do it by adding a filter for NewAttribute = false, if the list is empty this means everything is correct, or , in case you are using the table records, you can use ListAny action instead.
Gabriel Cardoso wrote:
Hi Gabriel, thanks for your advice. Following what you said, I am now able to get the information I wanted .
Thanks for your idea.
Now do you think I can create a condition to compare the new attribute with the OptionIsCorrect, to check if the question is correct ?
Thanks a lot
This solution actually doesnt workin for me, because when I compare the Answer True, with Option Correct False, it returns False, which comparing with the Option Correct column, will say its True, when it isnt.
EDITED: Sorry I was doing the NewAttribute wrongly. I have now specified it as IsCorrect = IsAnswer
Hello Thiago,
What exactly is your goal?
It seems to me that depending on what is the real goal you have (the final one, I mean), you can do this in an easier way...
Cheers.
Eduardo Jauch wrote:
Hi Eduardo, how are you ? Thanks for you reply!
I have a Question with multiples option, which one with a True or False value for Correct or not, which you decide when you created the options. Also I have another Entity Answer, which collect the Student answer when he check the box, onchange action.
The question will be only considered correct when all the student answer are the same as the option correct attribute. Otherwise it will be incorrect.
Its just one lil part of the project that I am doing as Outsystems trainee, which is an Exam Generator and Manager, and now I am working in the Exam form, to collect the answers and calculate the right questions, to give the total score and status.
I dunno if I was clear, please let me know and I can print some screens !
If you create a condition by your new attribute, AnswersByCorrect=True, you'll achieve that.
Still not working for me.
I cant figure out how to make it works, terrible newbie here lol
Hi Thiago,
You can't just have a query that will retrieve, filtered by question, options where Answer.IsAnswer = True and Option.IsCorrect = False and after that check if list is empty ? If list is empty the question is correct, if not retrieved list are all wrong options ?
But as Eduardo Jauch asked you need to check what is your real goal, e.g. if you want only a query that say by question if it is correct or not i think you will need an advance query.
Plácido Miranda wrote:
Thanks for the answer Placido! Appreciate ! What I need is check if the Question is correct, comparing the Student answers from the options with the options correct answer. If both values are the same, then its a Correct question !
You have 2 cases:
1st: Student answers correctly
|---------------------|------------------|--------------------| | IsAnswer | IsCorrect | IsCorrect=IsAnswer | |---------------------|------------------|--------------------| | True | True | True | |---------------------|------------------|--------------------| | False | False | True | |---------------------|------------------|--------------------| | False | False | True | |---------------------|------------------|--------------------|
--------------------|
True |
| False | False | True | |---------------------|------------------|--------------------| | False | False | True | |---------------------|------------------|--------------------|
| False | False | True | |---------------------|------------------|--------------------|
2nd: Student answer is INcorrect
|---------------------|------------------|--------------------| | IsAnswer | IsCorrect | IsCorrect=IsAnswer | |---------------------|------------------|--------------------| | True | False | False | |---------------------|------------------|--------------------| | False | True | False | |---------------------|------------------|--------------------| | False | False | True | |---------------------|------------------|--------------------|
False |
| False | True | False | |---------------------|------------------|--------------------| | False | False | True | |---------------------|------------------|--------------------|
NewAttribute = IsCorrect=IsAnswer
IsCorrect=IsAnswer
What you have to do is to, for example, add a filter on your aggregate NewAttribute=False and if the query returns empty, it means the answer is correct, 1st case, otherwise it's the 2nd.
Thanks for the help Gabriel! Really appreciate it
Hi Thiago.
So, what you want to do is to calculate the user score.
One more question. The user can check MORE than one option in an answer, or just one?If he can check only ONE option and you want to calculate the score, assuming the score is "divided" between the number of questions (all have the same value), you can do something very simple. I'll put here as SQL and you can convert to Aggregate (good exercise, han? ;) rs)
SELECT Count(*) FROM Question INNER JOIN Option ON Option.QuestionID = Question.ID AND Option.IsCorrect = 1 INNER JOIN Answer ON Answer.OptionID = Option.ID AND Answer.IsAnswer = 1
This will give you the number of question the user got correct.Would this help?Cheers.
One more question. The user can check MORE than one option in an answer, or just one?If he can check only ONE option and you want to calculate the score, assuming the score is "divided" between the number of questions (all have the same value), you can do something very simple. All put here as SQL and you can convert to Aggregate (good exercise, han? ;) rs)
Hello Eduardo, thanks for the Query, really appreciate it!
Yes 1 question can have one or multiple correct answers, thats why I am struggling to create this logic. Thats why I need to check if the Answers are exactly the Options Correct, because if one register is different, the question is wrong!
Gonna try your query and give you a feedback soon! Cheers
Ok,
So, if you CAN have more than one option correct and the user must mark ALL the correct answers and NOT mark ANY of the wrong answers, it is a little bit trickier.
I would do something like this:
SELECT Question.ID FROM Question INNER JOIN Option ON Option.QuestionID = Question.ID LEFT JOIN Answer ON Answer.OptionID = Option.ID AND Answer.IsAnswer = Option.IsCorrect GROUP BY Question.ID HAVING count(*) = count(Answer.ID)
This will not give you the count of correct questions, but the list of correct answers.This is possible to achieve with an Aggregate.But you are luck, as you can use the Count property of the aggregate to know how many questions are correct.Hope this helps:)P.S.: I didn't tested it... :P lol xD
Thanks a lot Eduardo, gonna try both and give you a feedback! Cheers
Here is an example of an aggregate:
CountOfOptions is the count of Options ID, while CountOfCorrectAnswerOptions is the count of the Answer ID
Here the filter:
Than you just see the Count of the aggregate to know how many answers are completely correct.
Hi Eduardo, how are you doing ??
Unfortunately I am not very familiar with Advanced SQL yet, and I couldnt make it works :( But I am pretty sure I doing something wrong and your Query and solution is work! As I have a bit of hurry, I have found a solution that I explain below !
When I have a free time (maybe weekend, I said maybe lol) I gonna try to check what I doing wrong with the Query and try to make it work with my project.
Anyway thanks for your attention and help !
Hello Thiago.
What I thing you are doing wrong (not much, just a little bit), is to use logic to compute something you can get with only the query/aggregate.
I did a small example of a very simple (without validations, etc) app that you can create questions with options, can create exams and associate questions, and can create exam instances and associate to a user, and than the user can do the exam.
There is a routine to compute the grade, using the approach I explained before.
Feel free to take a look. (It's in version 11)
Cheers Eduardo, I will have a look for sure and feedback you ! Now I having problem to register the question result in a Entity, to use it in the future when the Exam is done. But it will be for a new thread thought !
Thanks for your help