Questions, tags and GIFT

Questions, tags and GIFT

napisao/la Cris Fuhrman -
Broj odgovora: 9

Hi all - I was on sabbatical for a year so didn't touch Moodle in more than a year. Now I'm prepping my sites for fall, and eager to jump in again. I see that tags are available now for questions in the bank, which is a very cool feature.

Edit: it appears to be 3.7 Sorry I don't know exactly what version of Moodle, as https://tracker.moodle.org/browse/MDL-29467 seems still not to be resolved.

Anyway, I added a few tags two two questions using the GUI in the bank. It seems easy enough, but not as easy as it would be for me to do in a GIFT version (text editor) where I can search for keywords, etc.

I exported my bank, but don't find any of the tags I added (in the GUI) in the GIFT version that is exported. 

Is there GIFT support for the (non hierarchical) tagging of questions? If so, what is the format?

Odgovor na Cris Fuhrman

Re: Questions, tags and GIFT

napisao/la Simon Küpfer -

Hi all

Because there was no answer to this question yet and becaus I'm very interested in this, too: Is there GIFT support for the (non hierarchical) tagging of questions? If so, what is the format? 

Thanks for any hint!

Odgovor na Simon Küpfer

Re: Questions, tags and GIFT

napisao/la Tim Hunt -
Slika Core developers Slika Documentation writers Slika Particularly helpful Moodlers Slika Peer reviewers Slika Plugin developers

Tags are not currently spported in GIFT. Just to give the history, GIFT has been in Moodle for years. Tags for questions are a relatively recent addition. At the time, GIFT format was not exteded to include tag support.

Could we add it now?  The main consideration for if we can do that is to keep both backwards and forwards compatitibility. That is, if you have a GIFT format file that works in the current version of Moodle, then it should still import into tomorrow's Moodle and give the same questions. And, if you create a GIFT file with tags to import into tomorrow's Moodle, then it is nice if it can be imported into current (or old) Moodle without causing errors (although the tags will be ignored.)

Also, as well as tags, I would like to be able to set the question ID number. We should be able to do both at the same time.

Let us look at Current GIFT format, and see how we could change it, here is a simple example:

// Here is a question.
::Addition question:: What is 2 + 2? {#4}

My first thought was to change the ::Addition question:: bit which gives the question name, one could imaging ::Addition question::tag:add::tag:basic::id:four::. However, if we did this, then when importing into old Moodle, the extra "tag:add::tag:basic::id:four::" bit would be treated as part of the question text.

So, I think the way we have to do this by putting the tags in the comments:

// Here is a question.
// [tag:add] [tag:basic] [id:four]
::Addition question:: What is 2 + 2? {#4}

That looks quite nice and clear to me. Easy to type, easy to process in code. Can anyone think of somthing better?

(Note, there would be no limit on where the tags and idnumber appeared in the comment. The following would produce exactly the same question, but I would not recommend it.

// [tag:  basic] Here is a [id:   four   ] que[tag:add   ]stion.
::Addition question:: What is 2 + 2? {#4}

Odgovor na Tim Hunt

Re: Questions, tags and GIFT

napisao/la Cris Fuhrman -
Another perspective: question banks with tags are new, so if old versions of Moodle use them, they should not break. But importing them may not be ideal. Your first example is not the end of the world for old Moodle implementations - if it's a major problem for them, they need to upgrade - chances are if they want to use tags, they should anyway. I think it's more reasonable to have a clean solution for longer-term support.

Using comments for tags works, but it's an ugly design long term. Moodle already has a lot of these, including the XML for questions which cannot be validated because tags are overloaded. As much as I admire Moodle support for the community (it's perhaps the best things about Moodle), saying one has to support all old versions of a software at any cost is simply not sustainable.

I've reverse-engineered a PEG grammar for GIFT that has some use (it's not pretty, but is working in JavaScript/NodeJS). It has lots of tests. It would be easy to play around with ideas there if anyone is interested. 
Odgovor na Cris Fuhrman

Re: Questions, tags and GIFT

napisao/la Tim Hunt -
Slika Core developers Slika Documentation writers Slika Particularly helpful Moodlers Slika Peer reviewers Slika Plugin developers
I think it must be a matter of opinion, because I thing the comments option is the one that makes the GIFT file more human-readable and easy to type, which I think is the primary design consideration, and it is no problem to parse it. At least I just wrote some proof-of-concept PHP code.

I am slighly worried that 'id' and 'tag' are anglo-centric, but I can't think of anything better. Also, GIFT already uses [html], [moodle], [plain] and [markdown] in the syntax, so I don't think this is a big deal.
Odgovor na Tim Hunt

Re: Questions, tags and GIFT

napisao/la Cris Fuhrman -
My point was mostly about overloading a comment. Parsers see the // and ignore the rest - that is what is meant by a comment.

How about on the stem, using another token to specify a list of non-hierarchical keywords (aka tags):

Extending it along these lines:

::title:: Question title (optional)
@@tag1 tag2 tag3@@ Question tags (optional)

So, you put the tags somewhere on the question's first line:

::Question about design::@@grammar parser consistency@@What ways can I implement tags in GIFT? {}

Edit: Even the $ can be used on a separate line, like $CATEGORY: tom/dick/harry - it could be $TAGS: tag1 tag2 tag3 -- this would allow defining multiple questions for the same set of tags. Again, it is not overloading the comment line. Arguing "something can be easily coded" is good for short-term solutions, but "technical debt" is real and it has a cost for projects that last a long time.
Odgovor na Cris Fuhrman

Re: Questions, tags and GIFT

napisao/la Cris Fuhrman -
Just to show what it would look like using a grammar, I made a branch on the repo to allow support for non-hierarchical categories (tags) using @@ tags @@, as with :: Title :: -- You can see the code changes are smaller than the changes to the tests (which are not complete, but in the end there will be test file changes than grammar changes). With a grammar, the parser code is generated (those diffs are actually big).

https://github.com/fuhrmanator/GIFT-grammar-PEG.js/commit/55aad0c2b03f3234e4ef06aee9fa5d046efa26a2

I realize changing Moodle is not as easy (as far as I know PEGjs can't generate a parser in PHP). However, the parsing code of a ::Title:: in PHP could be modified easily to parse @@tags@@, right? Hope this is helpful!
Odgovor na Cris Fuhrman

Re: Questions, tags and GIFT

napisao/la Tim Hunt -
Slika Core developers Slika Documentation writers Slika Particularly helpful Moodlers Slika Peer reviewers Slika Plugin developers
Every day, doing Moodle development, I use an IDE which parses useful information out of comments and uses.

The Moodle GIFT importer is a paser. It parses this information just fine.

Your premise is just false.

Also, this was implemented weeks ago. You are too late to try to reopen this debate.
Odgovor na Cris Fuhrman

Re: Questions, tags and GIFT

napisao/la Simon Küpfer -
Hi guys
Thanks for advice and your ideas for the future of GIFT. So, tags for GIFT aren't realized yet.