Automatically set title if question creator does not
| Project: | Quiz |
| Version: | 6.x-4.x-dev |
| Component: | User interface |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
| Issue tags: | Usability |
Hi, and thanks for the great work on the quiz module!
I have been playing around with the 3.* and 4.*.dev versions and have noticed a few things I'd like to point to.
I noticed that you have to set a title manually when you create questions to be able to separate them from each other under "manage questions". This goes for all question types except multiple choice.
Being able to optionally set a title is nice, but I don't believe you should be forced to in order to get an overview of your question database. In many cases it will be sufficient to just use the first words (say 50-60 characters) of the question as a title. This as most of the time only the quiz / question creators / administrator sees them.
Consider the two screenshots, the fist from ATutors question database which uses the question text itself to identify the questions for admins:
http://skitch.com/vegardjo/biqj8/helsekompetanse.no-question-database
and the second showing the Drupal Quiz question database where you have to write a title:
http://skitch.com/vegardjo/bib1r/re-evalueringsquiz-6.12
(not that if you would have to write a title to identify the questions in the first example the title would pretty much be the same as the question, effectively making the question creator type the same thing two times).
This might not seem like a big thing, but in the day to day creating and managing of a question database having to type a title will annoy users :) Being able to create a title, but having a fallback will enjoy users!

#1
Couldn't that be achieved with a similar mechanism like Pathauto (http://drupal.org/project/pathauto) with the help of the Token module (http://drupal.org/project/token)? Just an idea.
Frank
#2
Hm, that seems a bit like overkill for me? I'm more thinking of adding a condition to the test question class (I'm just guessing such a thing exists) checking if there is a title, and if so use it, if not use X number of characters from the qestions field as the title.
This is how the comment module works. You can add a title to your comment, but if you don't one is generated for you..
#3
we need to use jQuery to populate title field with text from question field as the quiz author starts typing the question.
#4
#5
The current state of things is that the title is optional, and there is no default text for any module but Multichoice.
There are two options that I would be in favor of:
- Make title required
- Make title optional but auto-add a title if none is input
It sounds like most people are in favor of the second option, right?
I'm sorta tempted to make this a bug, since the screenshot that vegardjo included is clearly icky. Thoughts?
#6
I like to go with second option . you can Test it here (type some text in question field the same will be reflected in title field) and let me your thoughts.
feel free to open it again if you find any bugs.
#7
Just tested it very quickly, and I really like your solution - intuitive and elegant! Thanks, no more complaints from me :)
#8
http://drupal.org/project/auto_nodetitle may be used for automatic titles with tokens support. You can enable it on desired content types.
#9
The jquery solution actually has a bug, where it will give you an error message if the question (and thus title) is longer 128 characters. Then you manually have to delete characters from the title till you are below 128, or set a new title with under 128 characters. I guess it should just add up to 128 (or less) characters, then stop..
Also, the auto_nodetitle module nirvanajyothi mentioned looks really usable too! And as far as I see now thery're not in conflict with each other either!
#10
sivaji, what do you think of nirvanajyothi's suggestion to use auto_nodetitle. seems like it was designed for just this situation.
#11
I don't agree to use auto_nodetitle module. I don't like to do that evil. The code i used to achieve this task is as below (~10 lines)
/** Adds inline js to automatically set the question's node title.
*/
function quiz_set_auto_title() {
drupal_add_js('
$(document).ready(function () {
$("#edit-body").keyup(function () {
$("#edit-title").val($("#edit-body").val().substring(0, 128));
});
});
', 'inline');
}
10 lines of code or 11.8 K module which one you would like to have ?
#12
@vegardjo Thanks, i have changed
substring(0, 255)tosubstring(0, 128). Hope this will fix this bug.-$("#edit-title").val($("#edit-body").val().substring(0, 255));+$("#edit-title").val($("#edit-body").val().substring(0, 128));
#13
Automatically closed -- issue fixed for 2 weeks with no activity.
#14
Re-opening because this there is a bug in the implementation above. It writes to the title field on every keypress in the body field, regardless of whether the user wants the title edited.
I just loaded a question with a title I wanted to keep. When I pressed a key in the body field, the title was overwritten with part of the body.
I propose that the auto-titling Javascript only be activated if the form is loaded with an empty title. Otherwise maintain the title at load, unless of course the user edits it themselves.
#15
Attached is a patch trying to fix this issue. The patch has also been commited to 4.x-dev
#16
I just noticed that whenever I save my question node, the title is overwritten by the auto-titler. If we can't get this working correctly for 4.0, let's not include it.
Would it be easier if we had a checkbox for whether to auto-title? It could be all client-side. Checking it would disable the input field and keep it updated with the contents of the body. Unchecking it would stop the auto-titling and let the user modify it as they wish.
#17
After setting my titles using SQL, they're still reverted whenever there's an edit operation on the node, like setting a taxonomy term.
The server side shouldn't change the title unless it's blank, and maybe even not then. Should users be disallowed from having blank titles?
#18
It is fixed. It wasn't a bug but an amoeba. They can be hard to spot!
Client side only auto-titling would be good, but I don't think we will be able to make it work with all kinds of wysiwyg editors enabled. At least not with the current wysiwyg module.
And yes, I don't think we should allow questions that don't have a title. In a lot of quiz and drupal UI the title is the only thing used to recognize a node. That being said I don't think we should require a title using #required in the form definition array either because having to write titles on this type of content is a pain for users...
#19
#20
Good amoeba huntin.
Sorry if you've explained this before, but what problem does WYSIWYG pose for a client-side implementation? Does the id of the field change?
#21
I forgot to answer this it seems. I don't know exactly how the JS wysiwyg editors work, but I've heard that they replace the textareas with a div to be able to insert multimedia. Maybe they fill in a hidden field or something with the html onExit() or something.. I have never looked in to it, so this is just speculation.
TinyMCE provides functionality to get the content of the wysiwyg using JS, but I think you have to do some settings when attaching the wysiwyg to have this functionality available, and I don't know how other editors work. What we need is a API from the wysiwyg module, and the wysiwyg maintainers are working on it for their next version if I understood them correctly.
#22
Automatically closed -- issue fixed for 2 weeks with no activity.