Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create parseStuansAsMatrix() #401

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

rpruim
Copy link
Contributor

@rpruim rpruim commented Jul 14, 2023

As per the discussion in this forum, I've created a function that takes a student-supplied calculated matrix and returns it as a matrix rather than as an array.

I have not updated the documentation. Is that done by manually updating the HTML? If so, we could put something like this in there:

<h3><a name="parseStuansAsMatrix">parseStuansAsMatrix</a></h3>
<p>parseStuansAsMatrix(student answer, eval)</p>
<p>Converts a students matrix answer into a matrix</p>
<p>student answer can come from <code>$stuanswers[$thisq]</code> for single-part
questions, or <code>getstuans($stuanswers, $thisq, (part index))</code> for
multi-part.  If <code>eval</code> is true (the default), expressions in a calculated matrix are evaluated before creating the matrix.</p>

@rpruim
Copy link
Contributor Author

rpruim commented Jul 14, 2023

I've added an additional argument to control whether symbolic expressions are evaluated.

@drlippman
Copy link
Owner

Thanks for this. However since the evaluated values for the matrix are already present in $stuanswersval, I'm hesitant to have this function do the work of evaluating the expressions a second time, as that's pretty inefficient.

I'm thinking a more efficient pattern would be to have the optional second argument be the $stuanswersval entry. If provided, the function could still use $stuanswers from the first argument to determine the dimension, then use the second entry for the values.

It probably should also be noted that the function only works for matrix questions without $answersize set. That definitely has the potential to be confusing. Perhaps it would be better to have the function inputs be parseStuansAsMatrix(student answer, [answersize, student answer val]), where answersize would be null if answersize wasn't set on the question.

Repository owner deleted a comment from sonarcloud bot Sep 7, 2023
@rpruim
Copy link
Contributor Author

rpruim commented Sep 8, 2023

This snuck past me in July. Sorry for that.

I'm basically in support of some good way to get a matrix and know it's shape without the question writer needing to do hacky things each time this happens. It is a bit confusing that parseStuAnsAsMatrix() doesn't parse as a matrix but only provides an array.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants