GithubHelp home page GithubHelp logo

Comments (10)

drgrice1 avatar drgrice1 commented on July 20, 2024

Unfortunately, I don't think that this can be fixed without a rather hefty re-implementation of the way that MathObject matrix array answer rules work.

When the matrix answer array rule is called it sets several hash key values on the original object. Most notable for this particular issue is the key ans_name which is set to ${answerPrefix}_${name} where $answerPrefix = 'MaTrIx' and $name is the given or generated name for the first input for the (1,1) entry of the matrix. This is needed so that when the answer checker is called and subsequently ans_collect is called it can get the correct values from the form inputs. That is the problem here. The second time the array answer rule is called for the object it changes the value ans_name to be the derived name for the first input of the second matrix answer. So when the checker is called later for the first matrix answer it gets the values for all but the first input from the second matrix answer.

from pg.

somiaj avatar somiaj commented on July 20, 2024

I have also noticed this issue with MultiAnswer, and the fix I use is to create a copy of the MathObject before assigning it to the answer rule.

Would it be possible for PGML and parserMultiAnswer to detect if a MathObject has been used in another answer rule, and then create a copy of it to use/assign to the answer rule in this case?

from pg.

drgrice1 avatar drgrice1 commented on July 20, 2024

I don't think that is possible. I don't think that an object can clone itself at that point, and it wouldn't be able to update other references to itself.

from pg.

somiaj avatar somiaj commented on July 20, 2024

What about a warning that only professors can se then, so at least problem authors know that there might be a problem? Maybe something along the lines of "The MathObject in the Nth answer rule is being used in another answer rule. This can cause unexpected results. You should copy the MathObject, and assign the copy to the new answer rule."

from pg.

dpvc avatar dpvc commented on July 20, 2024

I don't think that an object can clone itself at that point,

PGML could use $mo->copy to make a duplicate, so it probably is possible.

Before I spend time looking into solutions, however, can someone tell me the use case for asking for the same matrix twice? I'm at a loss as to why someone would do that.

I know this has come up before, and I can't find the previous discussion. Sorry!

from pg.

dpvc avatar dpvc commented on July 20, 2024

PS, one should be able to do

DOCUMENT();
loadMacros(qw(PGstandard.pl PGML.pl));
Context("Matrix");
$A = Matrix([-1,0],[0,-1]);

BEGIN_PGML
[`[$A]={}`][_]*{$A}{5}

[`[$A]={}`][_]*{$A->copy}{5}
END_PGML

ENDDOCUMENT();

in this case, so I'm not sure how high a priority solving this is.

from pg.

somiaj avatar somiaj commented on July 20, 2024

@dpvc I ran across this in the case of a DE course, where I have a heavily scaffold problem, first students need to find the eigenvalues and eigenvectors (a 2x1 matrix) of a matrix. Then they need to use those in a formula to find fundamental solutions, (which I've setup in some multiAnswer setup), in such a way they have to enter in the same eigenvector twice.

The $A->copy works great, and once I knew about the issue, just making a copy fixed the problem. The issue was it was hard to debug as the problem just behaved weirdly, and it wasn't clear to me that a copy of the MathObject was needed, leading to lots of confusion as to what is going on and why the problem didn't work. Also the fact that what I typed into an answer box didn't translate to the correct answer in the answer table added to the confusion.

So I do agree that there is probably very limited use cases for this, but if for some reason an author does use the same MathObject matrix in two different answer boxes, the confusion about why things don't work and that a copy of the MathObject would fix the problem isn't clear. Hence my suggestion of at least a warning to point authors in the right direction to making it work.

from pg.

Alex-Jordan avatar Alex-Jordan commented on July 20, 2024

can someone tell me the use case for asking for the same matrix twice?

I had a three-part question where the pedagogical point was for students to see that all three answers were the same. All in the context of R^2, it was like:

a. What is the standard matrix for rotation about the origin by 180 degrees?

b. What is the standard matrix for negation of vectors?

c. What is the standard matrix for reflecting vectors over the x-axis and then reflecting over the y-axis?

All three answers are [[-1,0],[0,-1]] so at first I just had that stored as $A and reused it. Then discovering the issue, I just have $B and $C redundantly storing the same matrix. So it was easy to work around, but that was why a person might reuse something.

I suppose if the answer in question had a complicated custom answer checker, it would be a little more valuable to directly reuse it rather than store redundant copies.

from pg.

Alex-Jordan avatar Alex-Jordan commented on July 20, 2024

I am interested in the idea of automating the ->copy method when PGML is used. I think we have had other issue arise from things getting set when an answer checker is applied, and it sounds like this would be a way to address more than just this current issue.

from pg.

dpvc avatar dpvc commented on July 20, 2024

Thanks for the use cases @Alex-Jordan and @somiaj. Those make sense.

I will look into some possible approaches to working around this. I'd like to make a solution that is not PGML dependent, but certainly using $mo->copy is one way that could be used in PGML.

from pg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.