Skip to content

Update Value/AnswerChecker diagnostics output.#1384

Open
somiaj wants to merge 1 commit intoopenwebwork:developfrom
somiaj:diag-to-plots
Open

Update Value/AnswerChecker diagnostics output.#1384
somiaj wants to merge 1 commit intoopenwebwork:developfrom
somiaj:diag-to-plots

Conversation

@somiaj
Copy link
Contributor

@somiaj somiaj commented Mar 11, 2026

Use plots.pl to create the graphs instead of the old graphmacros.

Remove use of tables for formatting. Using bordered divs instead. Only use of a table is for the table of test points, which now uses row headers properly and padding and no longer uses blank cells for spacing. The test point table puts each variable in its own row for multivariable functions.

Here are some test problems, one using an adaptive parameter, and one with multivariables to show each variable test points are put in their own row.

DOCUMENT();
loadMacros('PGstandard.pl', 'PGML.pl');
$ans = Compute('(3 x^4 + 4)/x');
BEGIN_PGML
Enter [``[$ans]``]: [_]{$ans->cmp(diagnostics => 1)}
END_PGML
ENDDOCUMENT();
DOCUMENT();
loadMacros('PGstandard.pl', 'PGML.pl', 'PGcourse.pl');
Context()->variables->are(t => 'Real', C0 => 'Parameter');
$aSoln = Compute('C0 * e^t - 1')->cmp(diagnostics => 1);
BEGIN_PGML
Find one solution to the differential equation.

    [`\frac{dy}{dt} = y + 1`]

[`y =`] [_]{$aSoln}
END_PGML
ENDDOCUMENT();
DOCUMENT();
loadMacros('PGstandard.pl', 'PGML.pl');
Context()->variables->are(x => 'Real', y => 'Real', z => 'Real');
$ans = Compute('(4x - 3y)/z');
BEGIN_PGML
Enter [``[$ans]``]: [_]{$ans->cmp(diagnostics => 1)}
END_PGML
ENDDOCUMENT();

I don't think stating the domain, range, and aspect ratio of the graphs is useful. I left that there, but suggest removing it.

@drgrice1 for some reason the mathjax for the graph labels only renders when clicking on the graph, but not the original graph output. I didn't debug as to why.

@somiaj somiaj force-pushed the diag-to-plots branch 2 times, most recently from 97c7015 to 3baf230 Compare March 11, 2026 14:55
@somiaj
Copy link
Contributor Author

somiaj commented Mar 11, 2026

In testing this I ran across a bug where test points were not being graphed correctly when using adaptive parameters, and that was because the adaptive parameters are included in the list of variable names, but don't have test points assigned to them, so the test points being used were either nonexistent or assigned to a different variable depending on the random order of the keys from the variables hash.

So I updated this to remove adaptive parameters from the list of variable names.

I also updated it so that the list of test points only shows the values of variable test points used in either the student or correct answer. This does make the table more useful to me when there are additional variables in the context not used.

@somiaj somiaj force-pushed the diag-to-plots branch 2 times, most recently from 9ba9108 to d3b0f5f Compare March 11, 2026 15:11
@somiaj
Copy link
Contributor Author

somiaj commented Mar 11, 2026

There is another possible issue where alias variables aren't correctly dealt with in determining what the test points are for the graph. I think this is similar to the parameter issue where these variables aren't given test points so the wrong list of test points is chosen to be graphed.

@drgrice1
Copy link
Member

@drgrice1 for some reason the mathjax for the graph labels only renders when clicking on the graph, but not the original graph output. I didn't debug as to why.

This is not happening for me. The MathJax renders on initial page load for me.

@somiaj
Copy link
Contributor Author

somiaj commented Mar 11, 2026

@drgrice1 wonder if it is a race condition where mathjax isn't fully loaded by the time the graph loads, I think I've had this happen before.

@somiaj somiaj force-pushed the diag-to-plots branch 2 times, most recently from c2dc9fc to c691d32 Compare March 11, 2026 23:25
@somiaj
Copy link
Contributor Author

somiaj commented Mar 11, 2026

Okay, I think I got the variables vs parameters vs aliases figured out. Aliases didn't need to be dealt with as the formula already does the substitution, parameters just need to be filtered otherwise they make the count of which list of test points to use incorrect. @dpvc Care to let me know if I'm missing something, the main bit of code I have is here:

		# Get the test points. This requires first determining what variables are in use and ignore parameters.
		my $points    = [];
		my @params    = $self->{context}->variables->parameters;
		my %pnames    = map { $_ => 1 } @params;
		my @names     = $self->{context}->variables->variables;
		my @variables = grep { !$pnames{$_} } keys %{ $self->{variables} };

		# If a single variable is found, use its test points for the graph.
		# Functions with more than one variable are not graphed so test points are not needed.
		if (scalar(@variables) == 1) {
			my $vi = 0;
			while ($names[$vi] ne $variables[0]) { $vi++ }
			$points = [ map { $_->[$vi] } @{ $self->{test_points} } ];
		}

Use plots.pl to create the graphs instead of the old graphmacros.

Remove use of tables for formatting. Use bordered divs instead.
Cleanup some of the HTML use with this as well. Space the graphs
vertically, to work better on smaller screens or in the problem
editor.

When finding test points, remove adaptive parameters from
the list of variable names, as these can make it so the
test points shown on the graphs are incorrect.

Only use of a table is for the table of test points, which now
uses row headers, padding, and no longer uses blank cells for
spacing. Multivariable functions have the test points for each
variable in their own row instead of showing them as a point.
Only variables used in correct or student answers are shown.
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