RFC: New Question Type: matrix

RFC: New Question Type: matrix

by Penny Leach -
Number of replies: 28
Hello quiz forum!

I'm about to start working on this new question type for a client and I bugged Tim for feedback and he (rightfully so) suggested I should discuss it here instead... so here we go.

The idea is that it's for the teacher to define a matrix, with either checkboxes or radio buttons in each cell, and the student puts checks in the boxes.

Grading works one of a few ways:

- Get all of the defined boxes checked for 100%, else 0%
- Get at least one of the defined boxes checked for 100%, else 0%
- Some sort of weighting which I'm trying to finish defining.

I made a very brief spec to follow what I'm doing over here: http://docs.moodle.org/en/Development:Matrix_Question_Type_Specification which is mostly technical.

Ideas/feedback welcome!
Average of ratings: -
In reply to Penny Leach

Re: RFC: New Question Type: matrix

by Neil Spurgeon -

Looks very interesting. In a different focus and for a s;ightly different purpose we have used the Moodle database (which is really more like a flat file table) for a similar purpose and that met our needs without needing to develop anything as swish as what you are planning - but then of course it didn't feed into the Gradebook - which at the time wasn't a key issue for us - will be very interested in this if it pans out OK

good luck

Neil

In reply to Penny Leach

Re: RFC: New Question Type: matrix

by Stefan Eberhard -
Very very very useful!

The question type will solve a lot of my problems. Please go ahead!

I offer to test it with my students in our (not proctive) testing site.
In reply to Penny Leach

Re: RFC: New Question Type: matrix

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Hi Penny,
Could you please provide a few concrete examples of how this new question type might be used? I always find it difficult to understand this kind of stuff if I don't have concrete, real-world examples under my eyes! Thanks,
Joseph
In reply to Joseph Rézeau

Re: RFC: New Question Type: matrix

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I just added some examples to that proposal page.
In reply to Penny Leach

Re: RFC: New Question Type: matrix

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Thanks Penny. It's great to have you working on the quiz.

And just to make you feel really welcome, here are some comments on the database design wink
  1. Remember that the coding guidelines say that foreign key columns should have names like questionid, not question. A lot of the question database tables are so old, they predate that change in the guidelines, so there is plenty of inconsistency - oh joy! - but new tables should do the right thing.
  2. I think that the row and column options are fundamentally different, so I would have separate question_matrix_subquestions and question_matrix_answers tables and lose the xory column - even though that is one extra table, and at the moment they will have identical columns.
  3. I think it is better to change the foreign key matrix refrerences question_matrix to foreign key questionid refrerences question. If you want just one practical example of why that is better, think about the code required in the delete_question($questionid) method, but really I think linking to the question table is just better design.
  4. In a similar vein, is it worth adding a redundant questionid column to the question_matrix_weight table? (I don't know)
  5. If you replace the question_matrix_option table as above, then the natural column names to use in question_matrix_weight change.
  6. Another bit of the coding guidelines: The table names should be question_matrix_options and question_matrix_weights - but, I think, not question_matrices. Although that would be strictly consistent with the coding guidelines, it would be inconsistent with all the other question types.
  7. The roundzero = false option will be inconsistent with adaptive mode. See MDL-1647 and duplicates for the equivalent wrangling about multichoice.

More, about the grading. Presumably you will grade each sub-question separately, and they add/average the scores to get the overall grade. So, if you have
  • a question with three sub-questoins,
  • the total mark for the question is 6, and
  • the student gets two of three sub-questions right,
then they will get 4 marks.
In reply to Tim Hunt

Re: RFC: New Question Type: matrix

by Stefan Eberhard -
I suggest to support Penny!

Here my ideas for using this type

***********
Ein Kunde zahlt durch Bank unter Abzug von Skonto. Wie ist zu buchen?


Konto
Soll
Haben
Bank
[x]
[]
Forderungen
[ ] [x]
Mehrwersteuer
[x] [ ]
Vorsteuer
[ ] [ ]
Kundenskonto
[x] [ ]

*********************


Penny:
Pierre Pichet modified the Cloze-Question to a special-type "Newmultianswer" that can be used similar. Perhaps you can use his ideas.

In reply to Stefan Eberhard

Re: RFC: New Question Type: matrix

by Penny Leach -
Hi Stefan,

I couldn't find that in the modules & plugins db - do you have a link?
In reply to Tim Hunt

Re: RFC: New Question Type: matrix

by Penny Leach -
Thanks everyone for your replies

You're right about the db schema, I was really just trying to get it out of my head rather than follow rules, but yup. I'll change it.

About the other points

2. xory... yes, I didn't like that either. Happy to change it, no argument on this one smile

3. referencing referencing question instead of matrix.. I thought about that but then wrote some delete code: http://paste.dollyfish.net.nz/138693?filetype=php (UNTESTED!!!) and didn't think it was too hard. I'm not sure I agree with you that it's better design, but that's probably a tangental conversation we can have elsewhere smile

4. I'm not sure about that either... generally I don't think this schema is complicated enough to warrant it...

5. sure

6. ha, ok.

7. I need to read about that more after I've had coffee I think - are you saying that that should just be forced all the time? Or forced during adaptive mode?

Grading - yes.

Cheers for feedback!
P
In reply to Penny Leach

Re: RFC: New Question Type: matrix

by Penny Leach -
By the way, if anyone has any good suggestions for how the teacher-editing UI for this should work, that would be very helpful smile
In reply to Penny Leach

Re: RFC: New Question Type: matrix

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Oh, just noticed, you defined a question_matrix_answers table. That won't work. The entire student's reponse has to be magled into a string and stored in the question_states.answer column. At least for now.


In terms of editing UI, the image target question type has a refresh button you click after choosing of changing the image.

Calculated makes use of some infrastructure that lets you have a multi-page form, but Pierre and I are not sure that is a good idea - that might go away eventually.

I would go with a refesh button to set up the weights matrix when you set up the rows and columns and grading options. Later, you could try ajaxifying it to save page loads.
In reply to Tim Hunt

Re: RFC: New Question Type: matrix

by Penny Leach -
Arg - so the docs lied:

http://docs.moodle.org/en/Development:Quiz_database_structure#quiz_states

Says:

answer
text NOT NULL,
This field is deleted during runtime and replaced with the responses field. For legacy reasons it is still called answer in the database. Questiontypes can store students' responses (usually in a serialized format) in this field using the method save_session_and_responses. Questiontypes are allowed to deviate from this and handle their response storage in any desired way. Some questiontypes do not use this field but instead store the student response in their own table extending this table.
In reply to Penny Leach

Re: RFC: New Question Type: matrix

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
That is a lie.

I have been meaning to update the remainder of that page, after my diagram, for years. Sorry.
In reply to Tim Hunt

Re: RFC: New Question Type: matrix

by Penny Leach -
Maybe someone can help with something ...

I've looked at the image target qtype and I see it's adding extra submit buttons that send particular values (addcropper etc), but I can't see where the submit gets hijacked not to do the normal save and redirect.

I wondered if it might be in validation, but it doesn't seem to be , and I can't find any moodledocs about it.

Anyone have any ideas? Tim?
In reply to Penny Leach

Re: RFC: New Question Type: matrix

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

Re: RFC: New Question Type: matrix

by Penny Leach -
As discussed on jabber (here for anyone else who stumbles across this):

Imagetarget uses optional_param directly and then does some magic I haven't been able to figure out.

The *correct* way to do it, is as Tim has pointed out above.

Still - this has piqued my curiosity and if anyone can figure out what the imagetarget magic is, I would be interested to know wink
In reply to Penny Leach

Re: RFC: New Question Type: matrix

by Penny Leach -
One thing that would be really cool is the ability to use images, or embedded media in the matrix definition - eg, embed a little video for each row and then the columns are keywords that match, or similar.

I'm a little wary of just giving users the html editor because they could theoretically generate totally whack looking pages. What do people think about this?
In reply to Penny Leach

Re: RFC: New Question Type: matrix

by Dale Quattrin -
I was just about to make the same suggestion about images, etc. That would dramatically increase the utility of this type of question.
In reply to Penny Leach

Re: RFC: New Question Type: matrix

by Matt Campbell -
Some of us generate totally whack looking pages already....

Seriously, it would be nice to be able to add images, audio, video, etc. Putting HTML code into the question and answer fields that don't have the HTML editor seems to work fairly well and would be consistent with how quiz questions with 1.9, and I don't see in the docs that question creation is going to drastically change with the new quiz UI for 2.0.

Depending on the question type, the main question has an HTML editor. Sub-questions (think matching) and answers do not. If you think of the matrix definition rows as being sub-questions and columns being answers, then I would think that to keep the question type consistent with the rest, you wouldn't have the HTML editor available, but that it would support the use of HTML in the fields.

Thanks,
Matt
In reply to Penny Leach

Re: RFC: New Question Type: matrix

by Tieku Bortei-Doku -

Hello Penny,

I know this is a different topic, but Tim mentioned that you are good at back porting stuff from 2.0 to 1.9. Could you incorporate the new quiz navigation in 2.0 with the ability to flag questions and a summary page at the end for answered and unanswered questions from 2.0 to 1.9 for me? It is a feature we really need now and the wait for 2.0 might be a little too long for us.

Many thanks

Tieku

http://moodle.org/mod/forum/discuss.php?d=115424#p506445

In reply to Tieku Bortei-Doku

Re: RFC: New Question Type: matrix

by Penny Leach -
Hi Tieku

I did backport the roles ui work from 2.0 to 1.9, but I did it as part of my job and it was funded by a client who wanted it.

If you'd like to discuss a potential project with me, please email me directly using the address on my profile page smile

Cheers
Penny
In reply to Penny Leach

Re: RFC: New Question Type: matrix

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
But those changes are BIIIIG, so it would probably be a lot of work.
In reply to Penny Leach

Re: RFC: New Question Type: matrix

by Tieku Bortei-Doku -

Hello Penny,

I know this is a different topic, but Tim mentioned that you are good at back porting stuff from 2.0 to 1.9. Could you incorporate the new quiz navigation in 2.0 with the ability to flag questions and a summary page at the end for answered and unanswered questions from 2.0 to 1.9 for me? It is a feature we really need now and the wait for 2.0 might be a little too long for us.

Many thanks

Tieku

http://moodle.org/mod/forum/discuss.php?d=115424#p506445

In reply to Penny Leach

Re: RFC: New Question Type: matrix

by Pierre Pichet -
Creating these boxes are similar to using Horizontal Multichoice in Cloze question.

The actual cloze code can handle the storage of student different answers.

The problem is how to set and store the rules to grade this multiple multichoice question.
We could create a new questiontype that will use much of the actual Cloze code with new fields in the question_multianswer table or a similar table.
Tim has a better knowledge than me on how to store things in a database.


Pierre
P.S. The sequence field question_multianswer table already store the subquestions id.



In reply to Penny Leach

Re: RFC: New Question Type: matrix

by Stefan Eberhard -
Here a question using Pierre Pichets Newmultianswer. It would be no problem to change the fieldwidth

The question:

1answering correct

2
scored

3
answering (one wrong)


S4scored

5

In reply to Stefan Eberhard

Re: RFC: New Question Type: matrix

by Pierre Pichet -
I think you are putting me back on this NEWMULTIANSWER projectwink

Pierre
In reply to Stefan Eberhard

Re: RFC: New Question Type: matrix

by Eric Constantin -
Hi, this Newmultianswer question-type looks exactly like what I need! where can I get it?

Thanks,
Eric
In reply to Eric Constantin

Re: RFC: New Question Type: matrix

by Pierre Pichet -
I have to recode the initial project to the last 1.9. (it was build on 1.92).
Put this up on my to-do list
Pierre
In reply to Penny Leach

Re: RFC: New Question Type: matrix

by Penny Leach -
Hello again

After much bashing my head against the rather formidable wall that is formslib (making a matrix of checkboxes or any other form elements is not recommended!) I have a basic, somewhat working, implementation.

I put it in contrib just now (the 1.9 branch only) but it does include two patches as well as just the question type. Both formslib related (documented in the README)

I would be extremely grateful if people could have a play with this and see how it goes - I really didn't know that much about question types or the quiz module or anything before starting this (and in fact there are still some unimplemented functions that I didn't seem to need to implement and I guess should remove).

Thanks!

http://cvs.moodle.org/contrib/plugins/question/type/matrix/?pathrev=MOODLE_19_STABLE