PMatch N Choose K

PMatch N Choose K

by Caleb Waddell -
Number of replies: 2

Is there a way to write pmatch questions to account for a user inputting a few answers from a short list of possibilities (like a combination problem where there are N total possible answers and they need to input K of them)?

For a very simplified example question:

"what are any 4 of the first 8 letters of the alphabet?"

A, B, C, D, E, F, G, H are all possibilities, but I'm unsure how (if even possible) to make an answer that will check for at least any 4 of them.


As more of a closer to useful example, I have been doing this to help account for partial credit (although it isn't doing the same thing my question was about, I felt it was kind of related):

"Atoms are composed of three subatomic particles, each with a different net electric charge: one positive, one negative, and one with no net charge. These particles are called __30x1__ , respectively. 

(Please enter your answers as a comma separated list: e.g.     green, purple, yellow)


match_mw (proton? electron? neutron?) - 100%

match_mw (proton? neutron? electron?) - 66.666%

match_mw (* * neutron?) - 33.3333%

.....etc. for all possibilities"


Thanks for any advice!



Average of ratings: -
In reply to Caleb Waddell

Re: PMatch N Choose K

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
This can be done, and there is an example here: https://www.open.edu/openlearncreate/mod/oucontent/view.php?id=52747&section=2.2.1, the bit near "2.24 A response match"
Average of ratings: Useful (1)
In reply to Tim Hunt

Re: PMatch N Choose K

by Caleb Waddell -
Ah, okay. I just need to separate all the options with a pipe operator and list them all multiple times (for the number of responses I'm looking for).
match_mow (A|B|C|D|E|F|G|H A|B|C|D|E|F|G|H A|B|C|D|E|F|G|H A|B|C|D|E|F|G|H )

I had previously tried nested match_any:
match_all(
match_any (A|B|C|D|E|F|G|H)
match_any (A|B|C|D|E|F|G|H)
match_any (A|B|C|D|E|F|G|H)
)
But just a single answer of A would match for all 3 and give full credit. I guess when it is in the single match_mow statement, the A option is "used up" for each consecutive check of answers?

Anyway, will give it a try. Thanks for pointing me exactly where I needed to be!