Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QuizAttempt check if question is answered correctly #28

Closed
alex1897 opened this issue Aug 15, 2022 · 7 comments · Fixed by #29
Closed

QuizAttempt check if question is answered correctly #28

alex1897 opened this issue Aug 15, 2022 · 7 comments · Fixed by #29
Labels
enhancement New feature or request

Comments

@alex1897
Copy link
Contributor

Is it currently not possible to check after a question is answered if it's correct, right?

The leering effect is a lot better if the user knows on which question they made a mistake, instead of just telling them the points they made at the end.

I built myself a validation which seems to work (for single/multiple choice) but I guess there would a better way. Since the model already has the validation, could it provide a function to validate it?

Something like:
$quizAttempt->validate($quiz_question->id)

@harishdurga
Copy link
Owner

Yeah, it's possible. Something like the following?

{
  "result": [
    {
      "question_id": 1,
      "is_correct": false,
      "score": -1,
      "given_answer": 20,
      "correct_answer": 10.5
    },
    {
      "question_id": 2,
      "is_correct": true,
      "score": 5,
      "given_answer": "123456",
      "correct_answer": "123456"
    }
  ]
}

@harishdurga harishdurga added the enhancement New feature or request label Aug 16, 2022
@alex1897
Copy link
Contributor Author

Yes, even better with more information. I just thought about true/false. However, the given/correct will be difficult for the multiple choice.

@harishdurga
Copy link
Owner

correct_answer may also contain other types of data. The above JSON snippet is just for ref.

@alex1897
Copy link
Contributor Author

@harishdurga: Sorry for checking so late, I was busy on other projects.

I think this works in general, but noticed two things:

  1. If you allow multiple attempts, this does not work. In the user_answer is a list of all given answers of all attempts and the is_correct is also wrong
  2. Why is there an array around when calling quiz_attempt->validate($quiz_question_id). To get the value of is_correct I would need to call it like quiz_attempt->validate($quiz_question_id)[$quiz_question_id][is_correct] and the [$quiz_question_id] is redundant

Bildschirm­foto 2022-11-16 um 17 04 05

Bildschirm­foto 2022-11-16 um 16 54 23

@harishdurga
Copy link
Owner

Hey @alex1897 , If you have some spare time can you please raise a PR fixing the mentioned problem?

@alex1897
Copy link
Contributor Author

alex1897 commented Dec 5, 2022

Hi @harishdurga, I already looked at the code and to be honest I can't solve the problem.

@harishdurga
Copy link
Owner

Understood. No problem, I will try to solve this in sometime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants