Sample (Question Type?) Module to Add Question Field(s)

Sample (Question Type?) Module to Add Question Field(s)

by Travis Bennett -
Number of replies: 3
Hey Devs,

I'm new to Moodle development, and have succeeded in making one module so far to export from Moodle to VISION (from Focus Learning Corporation). It is pending my company's approval to publish. It was faily easy to do, given similar modules already in existance.

However, I now could really use an additional field for my questions, with the field displayed on certain pages (e.g. edit, quiz, feedback, etc.). I read on the forums about many others in the same boat, and it is often debated on whether or not they should modify the core tables and code (which we know is not ideal).

Anyway, a sample plugin that just adds a field to each question (in a proper way) would go a long way to helping out everyone, including myself, who has additional question info (e.g. some sort of metadata) that needs extra field(s).

If anyone can help, or help point me in the right direction, I'd really appreciate it.


Average of ratings: -
In reply to Travis Bennett

Re: Sample (Question Type?) Module to Add Question Field(s)

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

What sort of metadata do you want to store? The one thing that already exists is tags, but whether that is suitable for your needs, I don't know.

In reply to Tim Hunt

Re: Sample (Question Type?) Module to Add Question Field(s)

by Travis Bennett -
Sadly tags wouldn't do it. I need to store a series of codes, in a certain order, that come from a catalog of question topics. It needs to be maintained as the same exact string, with intermittent commas, semicolons, etc. So tags will not work.

I'm already using the category field for a separate but related thing,
In reply to Travis Bennett

Re: Sample (Question Type?) Module to Add Question Field(s)

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

The safe way to do this is to make your own database table local_myquestionmetadata, which includes a column questionid that is a foreign key pointing to question.id. The only issue with that is loading that data without damaging performance too much.