Problem/Motivation

In order to make a Quiz, it is necessary to have questions. In order to make a question, it is necessary to have a Question Type. I am unable to add a Question Type as the form does not include any submit button or link to add a Question Type. I am thus unable follow even the initial step to create a Quiz.

Steps to reproduce

Install Quiz. Go to /admin/quiz/quiz-question-types/add.

Note that it is not possible to add a Question Type.

See screenshot.

Issue fork quiz-3211287

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

brooke_heaton created an issue. See original summary.

djdevin’s picture

Sorry, this screen isn't supposed to appear. Question types can only be created in code.

Are you trying to add questions to a quiz? Do you have any of the question type modules enabled (quiz_truefalse, quiz_multichoice)?

hmendes’s picture

Hello!
I was trying to reproduce the error, and this page is showing when trying to access /admin/quiz/quiz-question-types/add, but I think the only way to get to this page would be writing the url manually. The path /admin/quiz/quiz-question-types is working and doesn't have any redirect to the /add page.
But is the /admin/quiz/quiz-question-types/add supposed to exist if "Question types can only be created in code."?
Tested on Drupal 8.9.16 and Quiz 6.x-dev

oily’s picture

'n order to make a Quiz, it is necessary to have questions. In order to make a question, it is necessary to have a Question Type'

Hi, The only way to create a question type is to create it in code. There are question types that come 'ready-made' and that you can use. But you have to enable the modules for them. Go to /admin/modules and filter on 'quiz'. Then enable the quiz_multichoice and/ or the quiz_truefalse module.

Then you will be able to create questions and so create quizzes.

If the existing question types are not what you require you will have to code yourself your own.

brooke_heaton’s picture

I think the lesson is that the /admin/quiz/quiz-question-types/add route should not exist. Why does it exist if questions types can not be added via the UI?

hmendes’s picture

Status: Active » Needs review
StatusFileSize
new942 bytes

Hello!
Adding a patch to remove the quiz-question-types/add route from the module, as it is not being used. Please review.

oily’s picture

The title of the issue 'Unable to add a question type' seems to have been answered for you in previous comments: you can, but you have to do it in code. It is not a problem, that is an intentional decision that was made by the module maintainer at some point.

If you want to remove the 'add' route then why not remove the 'delete', 'edit' etc routes too? But perhaps it should be dealt with under a new issue.

By removing the routes the root problem is not removed since those who choose to type in the 'add' etc route will be met with a 404. Would be better to retain the routes and print an informational message stating e.g. 'Question types can only be created in code.'

hmendes’s picture

Hello @andrew.farquharson,

The edit and delete routes do exist within the module ( although i didn't understand what happened under the delete route ), that's why i just removed the 'add' route, but about "Would be better to retain the routes and print an informational message stating..." I don't think this should be a problem for the module to solve... for every module you can change things with code, but that doesn't mean we should have to create a route for every content type used specifying that it should be created/edited/deleted only with code, if a certain route doesn't exist, than the user knows it is not possible to create the content via UI.

I think for this issue specifically we could also change the README of the repository to give the users a clearer tutorial on how to use it, some of the module I saw they have in the README a 'Usage' subject for this. And maybe we can create another issue for the patch or just change this one to include the unused routes problem.

djdevin’s picture

Version: 6.x-5.x-dev » 6.x-dev

Thanks, the routes were just there because they are part of boilerplate Drupal Entity classes.

Even if you could add new question types in the UI there would be no way to implement any sort of grading behavior. So it makes sense to remove them.

oily’s picture

Hi @hmendes,

I agree with @djdevin that it will do not harm to remove the entries for 'add' in the entity annotations since as he says they are only 'bolierplate.'

djdevin’s picture

The routes are provided by AdminHtmlRouteProvider, so removing the entries in links means they will go away too.

oily’s picture

@hmendes Your patch makes sense

oily’s picture

I created an issue fork pulled it to local, applied @hmendes patch. The /admin/quiz/quiz-question-types/add path now shows 'page not found'.

The patch seems fine. i created a merge request.

djdevin’s picture

djdevin’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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