maths / moodle-qtype_stack

Stack question type for Moodle
GNU General Public License v3.0
142 stars 149 forks source link

Multinomial coefficient #931

Closed KZerva closed 7 months ago

KZerva commented 1 year ago

Is there a way to calculate/format the multinomial coefficient? The maxima command multinomial(n,[k,l,...]); doesn't work.

If I use the command binomial(n,[k,l,...]), with simp:false I take the formatting I want, but I just force the formatting.

image

sangwinc commented 1 year ago

If you just want the formatting, what about {@binomial(36,sequence(12,12,12))@}?

I've reviewed Maxima's multinomial command. For some reason this spits out a compile message which disrupts the PHP/Maxima connection, so sadly I think this needs to remain forbidden for now.

aharjula commented 1 year ago

Chris, this seems to be yet another of those commands that compile during the first execution. If we had a list of these, then we could take care of that first execution during image generation or otherwise outside the normal execution. If I remember correctly there are plenty of probability-distribution related functions with this same behaviour. That project related to the refactoring of our CAS side code could be made to handle this on the side and produce various side products enabling us to pre-seed the CAS session or, preferably, the image with all functions in ready-to-use condition.

The compiling is not a problem for session2, the output coming from the compile goes to a different channel and should be ignored. The real problem often tends to be the paths and rights of the executing user when loading extra files into the runtime session.

In any case, I do believe that this has been seen before, maybe not for multinomial but for other such ones, and I think that back then, the user really wanted things to work and modified their own maximalocal.mac to do that first execution outside the session.

KZerva commented 1 year ago

I don't want only the formatting.

  1. I'd like to be able to evaluate it so that I can compare the student's answer with the teachers answer (mainly for feedback). I could just accept the minimal auto-feedback, if it wasn't for the next issue.
  2. If the students write the lower terms in a different order than the one I defined as correct answer, their answer counts as wrong. So aa: binomial(58,[9,15,20,14]); and aa: binomial(58,[15,9,20,14]); do not count as equal...
sangwinc commented 1 year ago

I think I'll add this issue to the list to work on together with @muhsala as this is relatively simple to add, and it will be a good opportunity to work through these parts of the codebase.