I added fields to my quiz result at /admin/quiz/quiz-result-types/manage/quiz_result/form-display.

Now when I go to /quiz/1/take I see the fields instead of Question 1. This is great!

However, after filling out the fields and hitting the submit button, I'm redirected back to the form.
A new QuizResult entity was created with the form data saved, but no questions answered.

I'm thinking its the QuizController::take() function that is buggy.

if ($build_on_last || (is_a($field, FieldConfig::class) && $field->getThirdPartySetting('quiz', 'show_field'))) {
            // We found a field to be filled out.
            $redirect_url = Url::fromRoute('entity.quiz.take', ['quiz' => $quiz_result->getQuiz()->id()]);
            $form = \Drupal::service('entity.form_builder')->getForm($quiz_result, 'default', ['redirect' => $redirect_url]);
            return $form;
          }
CommentFileSizeAuthor
#4 3152601-4.patch1.04 KBdjdevin
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sagesolutions created an issue. See original summary.

djdevin’s picture

This works if you check off "Allow resume" on the quiz.

The result isn't getting correctly put into the session after the fields are submitted.

Should probably wait until #3093971: Update session management to fix

sagesolutions’s picture

@djdevin I checked the "Allow resume" box on the quiz, but that seemed to have no effect. I've added patch #18 from https://www.drupal.org/project/quiz/issues/3093971 successfully, but that still didn't continue with the questions after submitting the form.

Any other options need to be selected that I am missing?

djdevin’s picture

Status: Active » Needs review
FileSize
1.04 KB

This should fix the issue against the latest dev.

sagesolutions’s picture

Status: Needs review » Reviewed & tested by the community

@djdevin This patch now works in resuming the quiz.

Thanks for the patch!

  • djdevin committed 5aa5874 on 6.x
    Issue #3152601 by djdevin: Added fields to quiz result form. Now I cant...
djdevin’s picture

Status: Reviewed & tested by the community » Fixed

Fixed!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.