Quiz

ID numbers for questions and question categories?

 
Tim at Lone Pine Koala Sanctuary
ID numbers for questions and question categories?
Core developersDocumentation writersParticularly helpful MoodlersPlugin developers

This is a rather technical question, but I thought I would ask anyway.

In Moodle, lots of things (for example users, courses, course categories, activities, groups, ... have a filed called 'ID number' which is mostly not used by Moodle. It is there to give things a unique identity, to help refer to them, particuarly when linking with external systems. For examle user.idnumber is often used to link to the student ID in a student record system, for example when using database authentication; and that, in combination with course and group idnumbers can be used by enrolment plugins to automatically put users in the right courses, groups and cohorts.

(There are a few exceptions to the 'not used in Moodle' bit. For example activity/grade_item idnumbers are used when you are setting up gradebook calculations.)

Until now, questions and question_categories have not had idnumbers, but for a project we are working on, we think the best option is to add them, so we have created MDL-62708.

The plus side is that it gives you another way to uniquely identify questions, that is otherwise normally hidden from students. The only negative I can see is that this would then be an additional field on the Edit question form which people would have to ignore if they did not want to use it. (Which is more of a problem for activities like StudentQuiz than for the Question bank, I think.)

So, what do people think about this proposed change? Thanks in advance if you can gives your opinion.


 
Average of ratings: Useful (1)
Picture of Marcus Green
Re: ID numbers for questions and question categories?
Core developersParticularly helpful MoodlersPlugin developersTesters

How about a new settings field for the quiz that determines if that field is shown in the editing form?

 
Average of ratings: -
Tim at Lone Pine Koala Sanctuary
Re: ID numbers for questions and question categories?
Core developersDocumentation writersParticularly helpful MoodlersPlugin developers

Because this is not about quizzes. Questions live in the question bank.

The project we are working on is our own equivalent of https://moodle.org/plugins/filter_simplequestion. (And, for various reasons, we are pretty sure we need to build our own version of that plugin, rather than build on the existing one.) The issues we are trying to address are: how to uniquely identify the question you want to embed (in a way that will still work after you have made a copy of the course by backing it up and restoring it), and how can you restrict which questions can be embedded (by only making it possible to embed questions where both the question and the category have had an idnumber added).

 
Average of ratings: -
Picture of Marcus Green
Re: ID numbers for questions and question categories?
Core developersParticularly helpful MoodlersPlugin developersTesters

OOh I downloaded that recently, I must now try it out. The downside seems minimal to negligible and the upside is you get to create an interesting nw plugin. 

 
Average of ratings: -
Picture of Richard Jones
Re: ID numbers for questions and question categories?
Particularly helpful MoodlersPlugin developersTesters
Your proposal will also help the Simple lesson activity (awaiting approval now) to backup and restore its questions, so it gets my vote.


Look forward to an improved version of Simple question.   It does appear to fill a need that was out there despite its limitations.  Also I was thinking about re-doing it, so saves me the trouble.

Simple lesson: https://github.com/richardjonesnz/moodle_mod_simplelesson.


 
Average of ratings: -
Picture of Daniel Thies
Re: ID numbers for questions and question categories?
Core developersParticularly helpful MoodlersPlugin developersTesters

In this case wouldn't the requirement be that idnumber is unique in a given course context rather than system? When the course is restored, the idnumber should belong to a restored question in the course question bank.

 
Average of ratings: -
Tim at Lone Pine Koala Sanctuary
Re: ID numbers for questions and question categories?
Core developersDocumentation writersParticularly helpful MoodlersPlugin developers

That is the proposal: the idnumber would be unique within one context.

 
Average of ratings: -
Picture of Daniel Thies
Re: ID numbers for questions and question categories?
Core developersParticularly helpful MoodlersPlugin developersTesters

By context I assume that means course in this case. Then I think that adding a field to the question bank is not necessarily the right way to approach the problem. The difficulty is that defining question sets is normally done in a activity rather than a filter. An activity has the backup machinery to store the question information, but filters do not so you are trying to build it into the question bank.

A current workaround for embedding a question would be to create a one question ungraded quiz or qpractice which is set to stealth mode, enable the activity autolinking filter, and include thie quiz name in another activity. This will backup and restore properly.

That process could be improved by modifying the filter to embedded of popup the quiz and display alternate text, create simplified quiz activity that can define question by aliases.

This may not be as simple for the teachers to set up, but allows them to control other parameters like question behaviour.

 
Average of ratings: -
Tim at Lone Pine Koala Sanctuary
Re: ID numbers for questions and question categories?
Core developersDocumentation writersParticularly helpful MoodlersPlugin developers

I don't think you have understood our goal.

Our goal is to present students with an experience like this http://www.open.ac.uk/openmarkexamples/text-response/structured-response, which could be used anywhere, for example in a Page or Book resource, or even in a label on the course page.

I link to a quiz is not the same thing at all.

 
Average of ratings: -
Picture of Daniel Thies
Re: ID numbers for questions and question categories?
Core developersParticularly helpful MoodlersPlugin developersTesters

No that is what i was thinking about. Yes quiz module is overkill I know. In this case start attempt, submissions, etc. are not really desired. Rather than linking to the quiz the filter code be made to embedded the questions directly into page (and update possibly with AJAX).

My suggestion is that you define the questions that are accessible to the filter in a quiz (or qpractice), and then use the filter to embed them as you like. That could be done without changing the question bank. Every thing gets backed up and restored nicely.

I was not suggesting the current quiz and activity are experiencially the same, but more topologically homeomorphic.

 
Average of ratings: -
Tim at Lone Pine Koala Sanctuary
Re: ID numbers for questions and question categories?
Core developersDocumentation writersParticularly helpful MoodlersPlugin developers

That is a much more complex design, and it does not even solve the backup and restore issue: you can make a backup that includes one activity but not another. Also, how you going to identify which question from the quiz is being embedded in each place?

Sorry, but I think your suggestion creates more problems then it solves.

 
Average of ratings: -
Picture of Daniel Thies
Re: ID numbers for questions and question categories?
Core developersParticularly helpful MoodlersPlugin developersTesters

I know it sounds little complex, but I do not think it would be in practice. With full course backup activities and filter settings are saved and restored together already.. Individual questions could be identified as Embeded Quiz#7 meaning 7th question of quiz named Embeded Quiz.

Last night I made a filter to embed H5P questions just to test the idea. It is available at https://github.com/dthies/moodle-filter_hvp.

I do not think idnumber is bad, but I am just not convinced it will be that easy.

 
Average of ratings: -
Tim at Lone Pine Koala Sanctuary
Re: ID numbers for questions and question categories?
Core developersDocumentation writersParticularly helpful MoodlersPlugin developers

Well, we are the ones implementing this, and we still think that using idnumber will be the easiest thing for our teachers to use (most important) and also makes it easy to implement the filter. Implementing question and question_category idnumber in Moodle core is not entirely simple because there are some tricky things to get right (e.g. what happens if you restore a backup adding to an existing course?) but my colleagues John is working on that, and has got most of these issues addressed already (see the tracker issue if you are interested.)

 
Average of ratings: Useful (1)
Picture of Emma Richardson
Re: ID numbers for questions and question categories?
Documentation writersParticularly helpful MoodlersPlugin developers

Database wise it totally makes sense to have unique identifiers.  In the question part, can this not come from the question name though?  I thought that field was already unique?  That would save an additional field and people are already using that field to create question identifiers that are understandable to them.

 
Average of ratings: -
Tim at Lone Pine Koala Sanctuary
Re: ID numbers for questions and question categories?
Core developersDocumentation writersParticularly helpful MoodlersPlugin developers

I think using question names that clearly and uniquely identify the question is good practice, but they are not required to be unique in the database schema, nor in the code, and there is not an index on that column.

Therefore, I think a separate field for a machine-readable seems to add some additional value.

 
Average of ratings: -
Picture of Mike Churchward
Re: ID numbers for questions and question categories?
Core developersParticularly helpful MoodlersPlugin developersPlugins guardiansTesters

I still like the idea of adding a general metadata system to Moodle, that allows a variety of contexts to have metadata and values added to them. ID numbers would simply be an instance of metadata.

I played with a POC for this type of system with a local metadata plugin, based loosely off of the custom user field system. For the question ID number proposal, questions and question categories simply need to be added as context subplugins.

I think a general system would be better than adding specific metadata to various pieces in Moodle. We have tags now, but metadata adds the extra ability to have specific values for each datum.

Mike

 
Average of ratings: -
Tim at Lone Pine Koala Sanctuary
Re: ID numbers for questions and question categories?
Core developersDocumentation writersParticularly helpful MoodlersPlugin developers
A complete metadata system for Moodle has been being talked about for about a decade and has still not happened. It is a really big thing and I am not going to wait for it. In the mean time, I want to make one specific thing happen. Please can we keep this thread on-topic.
 
Average of ratings: -
Picture of Mike Churchward
Re: ID numbers for questions and question categories?
Core developersParticularly helpful MoodlersPlugin developersPlugins guardiansTesters

Okay. Then no, I don't think you should do that.

 
Average of ratings: -
Dominique Bauer
Re: ID numbers for questions and question categories?
Documentation writersParticularly helpful Moodlers

When previewing a question from the 'Editing quiz: Question name' page, the address shows an id number, for example '456' in "http​s​:​​/​​/​de​mo.​mo​o​d​le.​n​et​​/question​/​prev​i​e​w.ph​p?​id​=456&​cm​id=600". Isn't this a question id number, unique and automatically generated by Moodle, that you could use?

 
Average of ratings: -
Tim at Lone Pine Koala Sanctuary
Re: ID numbers for questions and question categories?
Core developersDocumentation writersParticularly helpful MoodlersPlugin developers

Of course, all entities in Moodle have an automatically genereated id like that. It is a unique identifier, but it is limited:

  • It is an automatically generated integer. You have no control over it which is a difficulty if you want the identifier to be meaningful in some way.
  • When you do something like backup and restore a course, in the restored course, the id will change, which would break any links that depend on it.
These limitations are why many things in Moodle have both an automatically generated id (integer), and also an (optional) assigned 'idnumber' (string).
 
Average of ratings: -
Picture of Richard Jones
Re: ID numbers for questions and question categories?
Particularly helpful MoodlersPlugin developersTesters

Also, as Tim explained in the first post, an id number of this kind doesn't have to be numeric, this is potentially very useful for classification schemes.

 
Average of ratings: -
Tim at Lone Pine Koala Sanctuary
Re: ID numbers for questions and question categories?
Core developersDocumentation writersParticularly helpful MoodlersPlugin developers

Is this a fair summary of the opinions expressed so far in this thread:


Supports the idea

  • Tim Hunt
  • Marcus Green
  • Richard Jones


Partial support

  • Emma Richardson - wonders if Question name is sufficient.


Neutral

  • Daniel Thies - tried to suggest an alternative approach
  • Dominique Bauer - wonders why we can't just use id


Against

  • Mike Churchward - since he wants a completely general metadata system



 
Average of ratings: -
Tim at Lone Pine Koala Sanctuary
Re: ID numbers for questions and question categories?
Core developersDocumentation writersParticularly helpful MoodlersPlugin developers

So, the balance of opinion was slighly positive, and of the reasons given to not do this, I have not yet read anything that convinces me not to continue with this.

Therefore, I am planning to submit the code (written by my colleague John in MDL-62708) for integration next week (unless someone comes up with a convincing last-minute objection). Thanks.

 
Average of ratings: -
Picture of Shamim Rezaie
Re: ID numbers for questions and question categories?
Core developersMoodle HQParticularly helpful MoodlersPlugin developersTestersTranslators

Having an idnumber field is useful for integration, so I like the proposal.

Regarding the concern you mentioned about activities such as StudentQuiz, I'd say such activities should not display the idnumber field at all.

 
Average of ratings: -
Picture of Simey Lameze
Re: ID numbers for questions and question categories?
Core developersDocumentation writersMoodle HQPlugin developersTesters

Hi all, I've read the discussion and it's awesome to see so many great ideas!

I really liked Mike's metadata idea, but that's something that should be done in the whole core, not just question. Daniel suggestions is also really good, something like we did for tags where you can have different tags for different contexts. But again, it would take more time and resources to implement.

Honestly, I'm leaning towards Tim's idea for starters, but in my honest opinion it should NOT be unique.
AFAIK users and others accepts  an non-unique id number, so for consistency sake I'd suggest follow same behaviour on question. (actually just noticed groups require an unique id number)
Like mentioned above, this is mostly used to connect with external systems (like users for instance), so adding uniqueness to that field will help in some cases but pretty sure it can be a stress for others.

An idea would be adding a confirmation message when adding a new question, something like "There are other questions using same id number, do you want to add this question anyway? "

That would prevent duplicated id numbers on questions and would also be flexible enough to let users use that field accordingly to their needs.

Thanks!

 
Average of ratings: -
Tim at Lone Pine Koala Sanctuary
Re: ID numbers for questions and question categories?
Core developersDocumentation writersParticularly helpful MoodlersPlugin developers

Thanks for your comments.

Groups require a unique idnumber within one courseid.

Grade items and course_modules (which are sometimes the same thing, e.g. assignment and quiz) .

I never knew that user.idnumber was not forced to be unique. Since it is often used for data integration, I imagine non-unique user idnumbers woudl be really bad. Certainly they woudl cause havoc at the Open University. In practice, at the OU, we don't have any dupicate idnumbers, even though we have 998,191 rows in our user table.

So, anyway, uniqueness makes more sense to me, and is done for several other idnumbers already, so I favour keeping uniqueness.


 
Average of ratings: -